Hello,
Need help in creating a stock chart similar to that attached PPT using Aspose.Slides for Java API.
Attaching a sample PPT file with the manually created chart.
sample-stock-chart.zip (38.3 KB)
Thanks in Advance
Hello,
Need help in creating a stock chart similar to that attached PPT using Aspose.Slides for Java API.
Attaching a sample PPT file with the manually created chart.
sample-stock-chart.zip (38.3 KB)
Thanks in Advance
@SrideviG,
We have opened the following new ticket(s) in our internal issue tracking system and will consider your request according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESJAVA-39237
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@SrideviG,
I’ve requested plans for the issue from our development team. We will let you know as soon as possible.
@SrideviG,
Please try using the following code example:
Presentation pres = new Presentation();
try {
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.VolumeHighLowClose, 50, 50, 600, 400);
chart.getChartTitle().addTextFrameForOverriding("Chart Title");
chart.getChartTitle().setHeight(20);
chart.getChartTitle().setOverlay(false);
chart.setTitle(true);
chart.getLegend().setPosition(LegendPositionType.Bottom);
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(12);
chart.getAxes().getHorizontalAxis().getTextFormat().getPortionFormat().setFontHeight(12);
// chart.getAxes().SecondaryHorizontalAxis.TextFormat.PortionFormat.FontHeight = 12;
chart.getAxes().getVerticalAxis().setDisplayUnit(DisplayUnitType.Millions);
chart.getAxes().getVerticalAxis().setNumberFormat("$0\"M\"");
chart.getAxes().getVerticalAxis().setNumberFormatLinkedToSource(false);
chart.getAxes().getVerticalAxis().getTextFormat().getPortionFormat().setFontHeight(12);
chart.getAxes().getSecondaryVerticalAxis().setNumberFormat("$0.00");
chart.getAxes().getSecondaryVerticalAxis().setNumberFormatLinkedToSource(false);
chart.getAxes().getSecondaryVerticalAxis().getTextFormat().getPortionFormat().setFontHeight(12);
// Setting the index of the chart data sheet
final int defaultWorksheetIndex = 0;
// Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();
// Delete default generated series and categories
chart.getChartData().getSeries().clear();
chart.getChartData().getCategories().clear();
// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Jan"));
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Feb"));
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Mar"));
chart.getChartData().getCategories().add(fact.getCell(0, 4, 0, "Apr"));
chart.getChartData().getCategories().add(fact.getCell(0, 5, 0, "May"));
chart.getChartData().getCategories().add(fact.getCell(0, 6, 0, "Jun"));
chart.getChartData().getCategories().add(fact.getCell(0, 7, 0, "Jul"));
chart.getChartData().getCategories().add(fact.getCell(0, 8, 0, "Aug"));
chart.getChartData().getCategories().add(fact.getCell(0, 9, 0, "Sep"));
chart.getChartData().getCategories().add(fact.getCell(0, 10, 0, "Oct"));
chart.getChartData().getCategories().add(fact.getCell(0, 11, 0, "Now"));
// Adding new series
IChartSeries series = chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Total Revenue"), ChartType.ClusteredColumn);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 349268354.912));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 217780808.919));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 146016501.198));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 4, 1, 45908665.214));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 5, 1, 16198138.871));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 6, 1, 13983281.343));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 7, 1, 14121112.388));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 8, 1, 14338205.864));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 9, 1, 11174913.576));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 10, 1, 6506993.461));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 11, 1, 95.27));
// Adding new series
IChartSeries series1 = chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Price 2020"), ChartType.HighLowClose);
series1.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
series1.setSmooth(true);
series1.setPlotOnSecondAxis(true);
series1.getMarker().setSymbol(MarkerStyleType.Circle);
series1.getMarker().setSize(15);
series1.getMarker().getFormat().getFill().setFillType(FillType.Solid);
series1.getMarker().getFormat().getFill().getSolidFillColor().setColor(Color.ORANGE);
// Now populating series data
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 1, 2, 10.312));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 9.272));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 3, 2, 12.696));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 4, 2, 11.313));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 5, 2, 11.379));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 6, 2, 11.397));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 7, 2, 10.869));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 8, 2, 8.092));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 9, 2, 11.08));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 10, 2, 9.137));
series1.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 11, 2, 12.05));
// Adding new series
IChartSeries series2 = chart.getChartData().getSeries().add(fact.getCell(0, 0, 3, "Price 2021"), ChartType.HighLowClose);
series2.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
series2.setSmooth(true);
series2.setPlotOnSecondAxis(true);
series2.getMarker().setSymbol(MarkerStyleType.Dash);
series2.getMarker().setSize(15);
series2.getMarker().getFormat().getFill().setFillType(FillType.Solid);
series2.getMarker().getFormat().getFill().getSolidFillColor().setColor(Color.LIGHT_GRAY);
// Now populating series data
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 1, 3, 10.37));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 9.458));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 12.636));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 4, 3, 11.338));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 5, 3, 11.476));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 6, 3, 11.416));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 7, 3, 10.984));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 8, 3, 8.237));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 9, 3, 10.951));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 10, 3, 9.097));
series2.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 11, 3, 11.909));
// Adding new series
IChartSeries series3 = chart.getChartData().getSeries().add(fact.getCell(0, 0, 4, "Price 2022"), ChartType.HighLowClose);
series3.getFormat().getLine().getFillFormat().setFillType(FillType.NoFill);
series3.setSmooth(true);
series3.setPlotOnSecondAxis(true);
series3.getMarker().setSymbol(MarkerStyleType.Square);
series3.getMarker().setSize(15);
series3.getMarker().getFormat().getFill().setFillType(FillType.Solid);
series3.getMarker().getFormat().getFill().getSolidFillColor().setColor(new Color(128, 100, 162));
// Now populating series data
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 1, 4, 13.308));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 2, 4, 12.885));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 3, 4, 14.997));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 4, 4, 13.711));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 5, 4, 13.024));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 6, 4, 12.87));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 7, 4, 13.104));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 8, 4, 11.618));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 9, 4, 11.816));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 10, 4, 9.049));
series3.getDataPoints().addDataPointForStockSeries(fact.getCell(defaultWorksheetIndex, 11, 4, 10.2));
chart.getChartData().getSeriesGroups().get_Item(1).getHiLowLinesFormat().getLine().setWidth(0.75);
chart.getChartData().getSeriesGroups().get_Item(1).getHiLowLinesFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getChartData().getSeriesGroups().get_Item(1).getHiLowLinesFormat().getLine().getFillFormat().getSolidFillColor().setColor(new Color(64, 64, 64));
// Write the presentation to a disk
pres.save("stock_out.pptx", SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
Result: output.zip (33.9 KB)
Hi @andrey.potapov, Thanks for your response.
The above provided code example seems to have the logic as a combination of ClusteredColumn and HighLowClose.
Is it possible to have the VolumeHighLowClose added directly without a combination similar to the below stock chart example?
In Aspose cells API for excel, we have the direct implementation provided in the below ticket.
@SrideviG,
We have opened the following new ticket(s) in our internal issue tracking system and will consider your question according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESJAVA-39309
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi @andrey.potapov,
FYI, Used the below link as a reference and tried to generate the VolumeHighLowClose charttype.
But it is behaving as an OpenHighLowClose type.
As part of Issue ID(s): SLIDESJAVA-39309, will the issue with VolumeHighLowClose be triaged and checked on the feasible solution?
Or VolumeHighLowClose issue will be fixed and pushed in the next version release?
Could you please confirm?
Thanks in Advance
No, please note that the VolumeHighLowClose has the following structure in PowerPoint documents:
<c:plotArea>
<c:barChart>
...
</c:barChart>
<c:stockChart>
...
</c:stockChart>
</c:plotArea>
Without barChart, it will be the usual HighLowClose chart.
Aspose.Cells example just changes some styles of the filled diagram. If you create this chart from scratch without loading the data to Workbook
(sample-stock-excel.xlsx), the implementation will be the same (with ClusteredColumn and HighLowClose series).