Adding a Stock Chart
Spread WinRT 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.Xaml.SpreadSheet.Data.SpreadOpenHighLowCloseSeries ds = new GrapeCity.Xaml.SpreadSheet.Data.SpreadOpenHighLowCloseSeries();
GrapeCity.Xaml.SpreadSheet.Data.DoubleSeriesCollection dcx = new GrapeCity.Xaml.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.Xaml.SpreadSheet.Data.SpreadChart sc = gcSpreadSheet1.ActiveSheet.AddChart("chart", GrapeCity.Xaml.SpreadSheet.Data.SpreadChartType.StockHighLowOpenClose, 50, 50, 500, 400);
sc.DataSeries.Add(ds);
VB
Copy Code
Dim ds As New GrapeCity.Xaml.SpreadSheet.Data.SpreadOpenHighLowCloseSeries()
Dim dcx As New GrapeCity.Xaml.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.Xaml.SpreadSheet.Data.SpreadChartType.StockHighLowOpenClose, 50, 50, 500, 400)
sc.DataSeries.Add(ds)
See Also