Spread WPF Documentation
Adding a Stock Chart
Spread WPF Documentation > Developer's Guide > Working with Charts > Creating Charts > Creating Chart Types > Adding a Stock Chart

You can create a stock type chart by setting the type to StockHighLowOpenClose. The following image displays a stock chart.

Using Code

The following code creates a stock chart.

  1. Create and add values with the SpreadOpenHighLowCloseSeries and DoubleSeriesCollection classes.  
  2. Add the chart and specify the chart type with the AddChart method.
CS
Copy Code
GrapeCity.Windows.SpreadSheet.Data.SpreadOpenHighLowCloseSeries ds = new GrapeCity.Windows.SpreadSheet.Data.SpreadOpenHighLowCloseSeries();
GrapeCity.Windows.SpreadSheet.Data.DoubleSeriesCollection dcx = new GrapeCity.Windows.SpreadSheet.Data.DoubleSeriesCollection();
dcx.Add(1);
dcx.Add(2);
dcx.Add(3);
dcx.Add(4);
ds.XValues = dcx;
ds.OpenSeries.Values.Add(30);
ds.OpenSeries.Values.Add(31);
ds.OpenSeries.Values.Add(32);
ds.OpenSeries.Values.Add(33);
ds.CloseSeries.Values.Add(25.45);
ds.CloseSeries.Values.Add(23.05);
ds.CloseSeries.Values.Add(17.32);
ds.CloseSeries.Values.Add(20.45);
ds.HighSeries.Values.Add(40);
ds.HighSeries.Values.Add(41);
ds.HighSeries.Values.Add(42);
ds.HighSeries.Values.Add(43);
ds.LowSeries.Values.Add(23.49);
ds.LowSeries.Values.Add(19.55);
ds.LowSeries.Values.Add(15.12);
ds.LowSeries.Values.Add(17.84);
GrapeCity.Windows.SpreadSheet.Data.SpreadChart sc = gcSpreadSheet1.ActiveSheet.AddChart("chart", GrapeCity.Windows.SpreadSheet.Data.SpreadChartType.StockHighLowOpenClose, 50, 50, 500, 400);
sc.DataSeries.Add(ds);
VB.NET
Copy Code
Dim ds As New GrapeCity.Windows.SpreadSheet.Data.SpreadOpenHighLowCloseSeries()
Dim dcx As New GrapeCity.Windows.SpreadSheet.Data.DoubleSeriesCollection()
dcx.Add(1)
dcx.Add(2)
dcx.Add(3)
dcx.Add(4)
ds.XValues = dcx
ds.OpenSeries.Values.Add(30)
ds.OpenSeries.Values.Add(31)
ds.OpenSeries.Values.Add(32)
ds.OpenSeries.Values.Add(33)
ds.CloseSeries.Values.Add(25.45)
ds.CloseSeries.Values.Add(23.05)
ds.CloseSeries.Values.Add(17.32)
ds.CloseSeries.Values.Add(20.45)
ds.HighSeries.Values.Add(40)
ds.HighSeries.Values.Add(41)
ds.HighSeries.Values.Add(42)
ds.HighSeries.Values.Add(43)
ds.LowSeries.Values.Add(23.49)
ds.LowSeries.Values.Add(19.55)
ds.LowSeries.Values.Add(15.12)
ds.LowSeries.Values.Add(17.84)
Dim sc = GcSpreadSheet1.ActiveSheet.AddChart("chart", GrapeCity.Windows.SpreadSheet.Data.SpreadChartType.StockHighLowOpenClose, 50, 50, 500, 400)
sc.DataSeries.Add(ds)
See Also