[]
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 Windows Forms 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#
// Enable enhanced shape and chart engines.
fpSpread1.Features.EnhancedShapeEngine = true;
fpSpread1.Features.EnhancedChartEngine = true;
// Stock chart data.
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++)
{
fpSpread1.AsWorkbook().ActiveSheet.Cells[i, j].Value = dataArray[i, j];
}
}
fpSpread1.AsWorkbook().ActiveSheet.Cells["A1:D16"].Select();
fpSpread1.AsWorkbook().ActiveSheet.Shapes.AddChart(
GrapeCity.Spreadsheet.Charts.ChartType.StockHLC,
100, 150, 400, 300, false
);VB
' Enable enhanced shape and chart engines.
fpSpread1.Features.EnhancedShapeEngine = True
fpSpread1.Features.EnhancedChartEngine = True
' Stock chart data.
Dim dataArray As Object(,) = {
{"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 i As Integer = 0 To dataArray.GetLength(0) - 1
For j As Integer = 0 To dataArray.GetLength(1) - 1
fpSpread1.AsWorkbook().ActiveSheet.Cells(i, j).Value = dataArray(i, j)
Next
Next
fpSpread1.AsWorkbook().ActiveSheet.Cells("A1:D16").Select()
fpSpread1.AsWorkbook().ActiveSheet.Shapes.AddChart(
GrapeCity.Spreadsheet.Charts.ChartType.StockHLC,
100, 150, 400, 300, False
)