Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Sparklines / Add Sparklines using Formulas / Spread Sparkline
In This Topic
    Spread Sparkline
    In This Topic

    Spread sparklines can be used to distribute data and compare them using different styles as shown in the image below.

    Spread Sparkline Basic Example

    When the sparkline is horizontal, the horizontal axis represents each point. The length of lines or the number of dots in the vertical axis represents the frequency of occurrence.

    The spread sparkline formula has the following syntax:

    =SPREADSPARKLINE(points, [showAverage, scaleStart, scaleEnd, style, colorScheme, vertical])

    The formula options are described below where only 'points' is the default parameter:

    Option Description
    points A reference that represents a range of cells that contains the values, such as "A1:A10".

    showAverage

    Optional

    A boolean that represents whether to show the average. 

    The default value is false.

    scaleStart

    Optional

    A number that represents the minimum boundary of the sparkline.

    The default value is the minimum of all values.

    scaleEnd

    Optional

    A number that represents the maximum boundary of the sparkline.

    The default value is the maximum of all values.

    style

    Optional

    A number that references the style of the Spread sparkline.

    The following six styles are supported:

    • Stacked = 1 - line from center to two sides
    • Spread = 2 - dot from center to two sides
    • Jitter = 3 - dot with a random location
    • Poles = 4 - line from one side to another
    • StackedDots = 5 - dot from one side to another
    • Stripe = 6 - line with an equal length

    The default value is 4 (poles).

    colorScheme

    Optional

    A string that represents the color of the sparkline.

    The default value is "#646464".

    vertical

    Optional

    A boolean that represents whether to display the sparkline vertically.

    The default value is false.

    Usage Scenario

    Consider a scenario where the disaster management department of a country wants to share the cost distribution and the fatalities suffered in different disasters that occurred through the years. A spread sparkline can help to display the various statistics involved with calamities, as shown in the image below.

    Spread Sparkline

    Spread Sparkline

    C#
    Copy Code
    // Get sheet
    var worksheet = fpSpread1_Sheet1.AsWorksheet();
                
    // Set data
    worksheet.SetValue(2, 0, new object[,]
    {
        { "Disaster type","No. of Events","Percent Frequency","Total Costs (Bil.)","Percent of Total Costs","Cost/Event (Bil.)","Deaths/Year" },
        {"Drought",28, 0.098, 258.9,0.138,9.2, 95 },
        {"Flooding",33, 0.116,151.09,0.081,4.6, 15},
        {"Freeze",9,0.032,31.07,0.016,3.4,4},
        {"Severe Storm",128,0.449, 286.3,0.153,2.2, 43},
        {"Tropical Cyclone",52, 0.182,997.3,0.531,19.2,161},
        {"Wildfire",18,0.063,102.3,0.055,5.7,10},
        {"Winter Storm",17,0.060,50.1,0.027,2.9, 26}
    });
                
    // Set SpreadSparkline formula
    worksheet.Cells["B2"].Formula = "SPREADSPARKLINE(B4:B10,TRUE,,,1,\"#00cccc\")";
    worksheet.Cells["C2"].Formula = "SPREADSPARKLINE(C4:C10,TRUE,,,2,\"#00cccc\")";
    worksheet.Cells["D2"].Formula = "SPREADSPARKLINE(D4:D10,TRUE,,,3,\"#00cccc\")";
    worksheet.Cells["E2"].Formula = "SPREADSPARKLINE(E4:E10,TRUE,,,4,\"#00cccc\")";
    worksheet.Cells["F2"].Formula = "SPREADSPARKLINE(F4:F10,TRUE,,,5,\"#00cccc\")";
    worksheet.Cells["G2"].Formula = "SPREADSPARKLINE(G4:G10,TRUE,,,6,\"#00cccc\")";
    
    Visual Basic
    Copy Code
    'Get sheet
    Dim worksheet = FpSpread1.Sheets(0).AsWorksheet()
            
    'Set data
    worksheet.SetValue(2, 0, New Object(,) {
        {"Disaster type", "No. of Events", "Percent Frequency", "Total Costs (Bil.)", "Percent of Total Costs", "Cost/Event (Bil.)", "Deaths/Year"},
        {"Drought", 28, 0.098, 258.9, 0.138, 9.2, 95},
        {"Flooding", 33, 0.116, 151.09, 0.081, 4.6, 15},
        {"Freeze", 9, 0.032, 31.07, 0.016, 3.4, 4},
        {"Severe Storm", 128, 0.449, 286.3, 0.153, 2.2, 43},
        {"Tropical Cyclone", 52, 0.182, 997.3, 0.531, 19.2, 161},
        {"Wildfire", 18, 0.063, 102.3, 0.055, 5.7, 10},
        {"Winter Storm", 17, 0.06, 50.1, 0.027, 2.9, 26}
    })
    
    'Set SpreadSparkline formula
    worksheet.Cells("B2").Formula = "SPREADSPARKLINE(B4:B10,TRUE,,,1,""#00cccc"")"
    worksheet.Cells("C2").Formula = "SPREADSPARKLINE(C4:C10,TRUE,,,2,""#00cccc"")"
    worksheet.Cells("D2").Formula = "SPREADSPARKLINE(D4:D10,TRUE,,,3,""#00cccc"")"
    worksheet.Cells("E2").Formula = "SPREADSPARKLINE(E4:E10,TRUE,,,4,""#00cccc"")"
    worksheet.Cells("F2").Formula = "SPREADSPARKLINE(F4:F10,TRUE,,,5,""#00cccc"")"
    worksheet.Cells("G2").Formula = "SPREADSPARKLINE(G4:G10,TRUE,,,6,""#00cccc"")"
    

    Using the Spread Designer

    1. Type data in a cell or a column or row of cells in the designer.
    2. Select a cell for the sparkline.
    3. Select the Insert menu.
    4. Select a sparkline type.
    5. Set the Data Range in the Create Sparklines dialog (such as =Sheet1!$E$1:$E$3).
      Alternatively, set the range by selecting the cells in the range using the pointer.

      You can also set additional sparkline settings in the dialog if available.

    6. Select OK.
    7. Select Apply and Exit from the File menu to save your changes and close the designer.