Crear Gráfico de la bolsa de valores con Volumen Alto Bajo Cierre (VHLC)
Escenarios de uso posibles
El tercer gráfico de la bolsa de valores que veremos es el gráfico de Volumen Alto Bajo Cierre. Nuevamente es importante repetir que debe tener los datos en el orden correcto. Si necesita reorganizar su tabla de datos, debe hacerlo antes de configurar su gráfico. Este gráfico incluye una columna para el volumen inmediatamente después de la primera columna (categoría), y los gráficos incluyen un gráfico de columnas en el eje primario mostrando este volumen, mientras que los precios se mueven al eje secundario.
Gráfico de bolsa de valores Volumen-Alto-Bajo-Cierre (VHLC)
Código de muestra
El siguiente código de muestra carga el archivo Excel de muestra y genera el archivo Excel de salida.
// Create an instance of Workbook | |
Workbook workbook = new Workbook("Volume-High-Low-Close.xlsx"); | |
// Access the first worksheet. | |
Worksheet worksheet = workbook.Worksheets[0]; | |
//Create High-Low-Close-Stock Chart | |
int pieIdx = worksheet.Charts.Add(ChartType.StockVolumeHighLowClose, 5, 6, 20, 12); | |
// Retrieve the Chart object | |
Chart chart = worksheet.Charts[pieIdx]; | |
// Set the legend can be showed | |
chart.ShowLegend = true; | |
// Set the chart title name | |
chart.Title.Text = "Volume-High-Low-Close Stock"; | |
// Set the Legend at the bottom of the chart area | |
chart.Legend.Position = LegendPositionType.Bottom; | |
// Set data range | |
chart.SetChartDataRange("A1:E9", true); | |
// Set category data | |
chart.NSeries.CategoryData = "A2:A9"; | |
// Set Color for the first series(Volume) data | |
chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(79, 129,189); | |
// Fill the PlotArea area with nothing | |
chart.PlotArea.Area.FillFormat.FillType = FillType.None; | |
// Save the Excel file | |
workbook.Save("out.xlsx"); |