Hi All,
Hi Jitendra,
Hi Adnan,
Alternatively i am looking for combination of line and bar chart in java with aspose.slides
Hi Jitendra,
I have observed your requirements and like to share that Aspose.Slides support MSO charts. Unfortunately, it does not support Grids as they are not part of MSO charts or tables inside PowerPoint. Aspose.Slides does support working with PowerPoint tables. For more details, please visit this documentation section for your kind reference.
For more about charts and their respective code samples, I suggest you to please visit this documentation section for your reference. You will find number of samples related to chart creation, updation and formatting in this. I have also created a sample code for your reference that is adding a Bar chart and Line chart together. The Bar chart has 2 series inside it where as there is one series for Line chart. You can extend the chart series as per your requirements.
public static void TestLineBar()
{
Presentation pres = new Presentation();ISlide slide = pres.getSlides().get_Item(0);
// Creating the default chart
IChart chart = slide.getShapes().addChart(ChartType.ClusteredBar, 0, 0, 500, 400);// Getting the default chart data worksheet index
int defaultWorksheetIndex = 0;// Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();// Delete demo series
chart.getChartData().getSeries().clear();// Add new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 1, “Series 1”), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 2, “Series 2”), chart.getType());// Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, “Cat 1”));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, “Cat 2”));// Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 50));
// Setting fill color for series
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.RED);// Take second chart series
series = chart.getChartData().getSeries().get_Item(1);
// Now populating series data
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 30));
series.getDataPoints().addDataPointForBarSeries(fact.getCell(defaultWorksheetIndex, 2, 2, 10));
series.getFormat().getFill().setFillType(FillType.Solid);
series.getFormat().getFill().getSolidFillColor().setColor(Color.GREEN);chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 0, 3, “Line Series”), ChartType.Line);
series = chart.getChartData().getSeries().get_Item(2);series.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 1, 3, 5));
series.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 12));
series.getDataPoints().addDataPointForLineSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 9));pres.save(“C:\Aspose Data\AsposeScatterChart.pptx”, SaveFormat.Pptx);
}
The above code sample answers your questions related to Bar charts, Line charts, Bar chart with 2 series and combination of Bar and line chart. For more about Pie charts, I suggest you to please visit this documentation link. I hope the shared information will be helpful to you.
Many Thanks,