Crea Grafico Azionario Volume Alto Basso Chiusura (VHLC)
Possibili Scenari di Utilizzo
Il terzo grafico azionario che esamineremo è il grafico Volume Alto Basso Chiusura. È nuovamente importante ripetere che è necessario avere i dati nell’ordine corretto. Se è necessario riordinare la tabella dei dati, è necessario farlo prima di impostare il grafico. Questo grafico include una colonna per il volume immediatamente dopo la prima colonna (categoria), e i grafici includono un grafico a colonne sull’asse primario che mostra questo volume, mentre i prezzi sono spostati sull’asse secondario.
Grafico Azionario Volume-Alto-Basso-Chiusura (VHLC)
Codice di Esempio
Il codice di esempio seguente carica il file Excel di esempio e genera il file Excel di output.
// Create an instance of Workbook | |
Workbook workbook = new Workbook("Volume-High-Low-Close.xlsx"); | |
// Access the first worksheet. | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Create High-Low-Close-Stock Chart | |
int pieIdx = worksheet.getCharts().add(ChartType.STOCK_VOLUME_HIGH_LOW_CLOSE, 5, 6, 20, 12); | |
// Retrieve the Chart object | |
Chart chart = worksheet.getCharts().get(pieIdx); | |
// Set the legend can be showed | |
chart.setShowLegend(true); | |
// Set the chart title name | |
chart.getTitle().setText("Volume-High-Low-Close Stock"); | |
// Set the Legend at the bottom of the chart area | |
chart.getLegend().setPosition(LegendPositionType.BOTTOM); | |
// Set data range | |
chart.setChartDataRange("A1:E9", true); | |
// Set category data | |
chart.getNSeries().setCategoryData("A2:A9"); | |
// Set Color for the first series(Volume) data | |
chart.getNSeries().get(0).getArea().setForegroundColor(Color.fromArgb(79, 129,189)); | |
// Fill the PlotArea area with nothing | |
chart.getPlotArea().getArea().getFillFormat().setFillType(FillType.NONE); | |
// Save the Excel file | |
workbook.save("out.xlsx"); |