[]
Stock charts are used to illustrate fluctuations in data over a time. It can represent fluctuations in stock, rainfall, or annual temperatures. The data arranged in columns or rows of a worksheet can be plotted in a stock chart.
Spread for WPF supports the following types of stock charts.
Sample Image | Description |
---|---|
ChartType.StockHLC Represents a stock high-low-close chart. A high-low-close chart displays the data values organized in the order: high, low, close with the close value lying in between the high and low values. | |
ChartType.StockOHLC Represents a stock open-high-low-close chart. An open-high-low-close chart displays the data values organized in the order: open, high, low and close. | |
ChartType.StockVHLC Represents a stock volume-high-low-close chart. A volume-high-low-close chart displays the data values organized in the order: volume, high, low and close. | |
ChartType.StockVOHLC Represents a stock volume-open-high-low-close chart. A volume-open-high-low-close chart displays the data values organized in the order: volume, open, high, low, and close. |
Refer to the following example code to add a stock chart.
C#
// Stock chart.
object[,] dataArray ={
{ "Date","High","Low","Close" },
{ new DateTime(DateTime.Now.Year,8,31),17592.76,17482.76,17577.94 },
{ new DateTime(DateTime.Now.Year,9,1),17538.76,17400.76,17518.94 },
{ new DateTime(DateTime.Now.Year,9,1),17584.76,17517.76,17554.94 },
{ new DateTime(DateTime.Now.Year,9,2),17698.76,17428.76,17618.94 },
{ new DateTime(DateTime.Now.Year,9,3),17786.76,17623.76,17718.94 },
{ new DateTime(DateTime.Now.Year,9,4),17754.71,17600.76,17718.94 },
{ new DateTime(DateTime.Now.Year,9,5),17797.76,17647.76,17718.94 },
{ new DateTime(DateTime.Now.Year,9,6),17867.76,17657.76,17818.94 },
{ new DateTime(DateTime.Now.Year,9,7),17832.76,17721.76,17778.94 },
{ new DateTime(DateTime.Now.Year,9,8),17795.76,17639.76,17688.94 },
{ new DateTime(DateTime.Now.Year,9,9),17768.76,17530.76,17638.94 },
{ new DateTime(DateTime.Now.Year,9,10),17798.76,17511.76,17518.94 },
{ new DateTime(DateTime.Now.Year,9,11),17722.76,17541.76,17598.94 },
{ new DateTime(DateTime.Now.Year,9,12),17788.76,17591.76,17668.94 },
{ new DateTime(DateTime.Now.Year,9,13),17662.76,17455.76,17566.94 }
};
for (int i = 0; i < dataArray.GetLength(0); i++)
for (int j = 0; j < dataArray.GetLength(1); j++)
spreadSheet1.Workbook.ActiveSheet.Cells[i, j].Value = dataArray[i, j];
spreadSheet1.Workbook.ActiveSheet.Cells["A1:D16"].Select();
spreadSheet1.Workbook.ActiveSheet.Shapes.AddChart(GrapeCity.Spreadsheet.Charts.ChartType.StockHLC, 100, 150, 400, 300, false);
VB
' Stock chart.
Dim dataArray As Object(,) = {
{"Date", "High", "Low", "Close"},
{New DateTime(Date.Now.Year, 8, 31), 17592.76, 17482.76, 17577.94},
{New DateTime(Date.Now.Year, 9, 1), 17538.76, 17400.76, 17518.94},
{New DateTime(Date.Now.Year, 9, 1), 17584.76, 17517.76, 17554.94},
{New DateTime(Date.Now.Year, 9, 2), 17698.76, 17428.76, 17618.94},
{New DateTime(Date.Now.Year, 9, 3), 17786.76, 17623.76, 17718.94},
{New DateTime(Date.Now.Year, 9, 4), 17754.71, 17600.76, 17718.94},
{New DateTime(Date.Now.Year, 9, 5), 17797.76, 17647.76, 17718.94},
{New DateTime(Date.Now.Year, 9, 6), 17867.76, 17657.76, 17818.94},
{New DateTime(Date.Now.Year, 9, 7), 17832.76, 17721.76, 17778.94},
{New DateTime(Date.Now.Year, 9, 8), 17795.76, 17639.76, 17688.94},
{New DateTime(Date.Now.Year, 9, 9), 17768.76, 17530.76, 17638.94},
{New DateTime(Date.Now.Year, 9, 10), 17798.76, 17511.76, 17518.94},
{New DateTime(Date.Now.Year, 9, 11), 17722.76, 17541.76, 17598.94},
{New DateTime(Date.Now.Year, 9, 12), 17788.76, 17591.76, 17668.94},
{New DateTime(Date.Now.Year, 9, 13), 17662.76, 17455.76, 17566.94}}
For i = 0 To dataArray.GetLength(0) - 1
For j = 0 To dataArray.GetLength(1) - 1
spreadSheet1.Workbook.ActiveSheet.Cells(i, j).Value = dataArray(i, j)
Next
Next
spreadSheet1.Workbook.ActiveSheet.Cells("A1:D16").[Select](gcdocsite__documentlink?toc-item-id=d8bada35-5477-4ada-bf48-acfdd406c714)
spreadSheet1.Workbook.ActiveSheet.Shapes.AddChart(GrapeCity.Spreadsheet.Charts.ChartType.StockHLC, 100, 150, 400, 300, False)