FlexSheet for WPF | ComponentOne
Customizing Appearance / Using Floating Objects / Inserting SparkLine
In This Topic
    Inserting SparkLine
    In This Topic

    The data in C1FlexSheet can be visualized using SparkLines. A sparkline is a small graph that fits inside a cell and uses data from a range of cells. To visualize the data in sparklines, you need to add data to a sheet in C1FlexSheet.
    Insert the following code directly below the InitializeComponent() method to add a sheet and data in it:

    flex.AddSheet("Sheet1", 10, 10)
    Dim sh = flex.Sheets("Sheet1")
    
    If sh IsNot Nothing Then
        For r As Integer = 0 To 4
            Dim datas As New List(Of Double)()
            For c As Integer = 0 To 5
                If c < 5 Then
                    Dim rnd As New Random(New Object().GetHashCode())
                    Dim num As Double = Rnd.[Next](10)
                    sh.Grid(r, c) = num
                    datas.Add(num)
                Else
                    'use namespace C1.WPF.FlexGrid for SparkLineType and CellRange
                    flex.InsertSparkLine(SparkLineType.Line, datas, sh, New CellRange(r, 5))
                End If
            Next
        Next
    End If
    
    flex.AddSheet("Sheet1", 10, 10);
    var sh = flex.Sheets["Sheet1"];
                
    if (sh != null)
    {
        for (int r = 0; r < 5; r++)
        {
            List<double> datas = new List<double>();
            for (int c = 0; c < 6; c++)
            {
                if (c < 5)
                {
                    Random rnd = new Random(new object().GetHashCode());
                    double num = rnd.Next(10);
                    sh.Grid[r, c] = num;
                    datas.Add(num);
                }
                else
                {
                    flex.InsertSparkLine(SparkLineType.Line, datas, sh, new CellRange(r, 5));
                    //use namespace C1.WPF.FlexGrid for SparkLineType and CellRange
                }
            }
        }
    }
    

    The above code will add sparkline to the C1FlexSheet control.