创建成交量高低收(VHLC)股票图表
Contents
[
Hide
]
可能的使用场景
我们将讨论的第三种股票图表是成交量高低收图。再次重申,必须确保数据顺序正确。如果需要重新排列数据表,应在设置图表之前进行。 此图表包括一个立即在第一个(类别)列之后的成交量列,并且图表在主轴上显示此成交量的柱形图,而价格则移至次要轴。
成交量高低收(VHLC)股票图表
示例代码
以下示例代码加载了 样本Excel文件 并生成了 输出Excel文件。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |