Créer un graphique boursier Volume Ouverture Haut Bas Fermeture (VOHLC)
Scénarios d’utilisation possibles
Le quatrième graphique boursier que nous étudierons est le graphique Volume Ouverture Haut Bas Fermeture. Encore une fois, il est important de souligner que vous devez avoir les données dans le bon ordre. Si vous devez réorganiser votre tableau de données, vous devriez le faire avant de configurer votre graphique. Ce graphique inclut une colonne pour le volume immédiatement après la première colonne (catégorie), et les graphiques incluent un graphique en colonnes sur l’axe primaire montrant ce volume, tandis que les prix sont déplacés vers l’axe secondaire.
Graphique boursier Volume-Ouverture-Haut-Bas-Fermeture (VHLC)
Code d’exemple
Le code d’exemple suivant charge le fichier Excel d’exemple et génère le fichier Excel de sortie.
// 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"); |