Create Volume-Open-High-Low-Close(VOHLC) Stock Chart
Possible Usage Scenarios
The fourth stock chart we will look at is the Volume Open High Low Close chart. Again it is important to repeat that you must have the data in the correct order. If you need to rearrange your data table, you should do it before you set up your chart. This chart include a column for volume immediately after the first (category) column, and the charts include a column chart on the primary axis showing this volume, while the prices are moved to the secondary axis.
Volume-Open-High-Low-Close (VHLC) stock chart
Sample Code
The following sample code loads the sample Excel file and generates the output Excel file.
// Create an instance of Workbook | |
Workbook workbook = new Workbook("Volume-Open-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.StockVolumeOpenHighLowClose, 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-Open-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:F9", 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"); |