Spread WPF 17
Spread WPF Documentation / Developer's Guide / Working with Charts / Creating Charts / Creating Chart Types / Adding a Line Chart
In This Topic
    Adding a Line Chart
    In This Topic

    You can create many different types of line charts such as Line, Line3D, LineSmoothed, LineStacked, LineStacked100pc, LineStacked100pcWithMarkers, LineStackedWithMarkers, LineWithMarkers, and LineWithMarkersSmoothed. The following image displays a line chart.

    An example of line chart

    Using Code

    The following code creates a line chart.

    1. Create and add values with the SpreadDataSeries class.  
    2. Add the chart and specify the chart type with the AddChart method.
    CS
    Copy Code
    GrapeCity.Windows.SpreadSheet.Data.SpreadDataSeries ds = new GrapeCity.Windows.SpreadSheet.Data.SpreadDataSeries();
    ds.Values.Add(3);
    ds.Values.Add(-2);
    ds.Values.Add(4);
    ds.Values.Add(7);
    GrapeCity.Windows.SpreadSheet.Data.SpreadDataSeries ds2 = new GrapeCity.Windows.SpreadSheet.Data.SpreadDataSeries();
    ds2.Values.Add(6);
    ds2.Values.Add(-7);
    ds2.Values.Add(8);
    ds2.Values.Add(10);
    GrapeCity.Windows.SpreadSheet.Data.SpreadChart chart = gcSpreadSheet1.ActiveSheet.AddChart("chart", GrapeCity.Windows.SpreadSheet.Data.SpreadChartType.Line, 50, 50, 500, 400);
    chart.DataSeries.Add(ds);
    chart.DataSeries.Add(ds2);
    VB.NET
    Copy Code
    Dim ds As New GrapeCity.Windows.SpreadSheet.Data.SpreadDataSeries()
    ds.Values.Add(3)
    ds.Values.Add(-2)
    ds.Values.Add(4)
    ds.Values.Add(7)
    Dim ds2 As New GrapeCity.Windows.SpreadSheet.Data.SpreadDataSeries()
    ds2.Values.Add(6)
    ds2.Values.Add(-7)
    ds2.Values.Add(8)
    ds2.Values.Add(10)
    Dim chart = GcSpreadSheet1.ActiveSheet.AddChart("chart", GrapeCity.Windows.SpreadSheet.Data.SpreadChartType.Line, 50, 50, 500, 400)
    chart.DataSeries.Add(ds)
    chart.DataSeries.Add(ds2)
    See Also