We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to add categories in ScatterWithSmoothLines type chart into java aspose.slides api?

HI I am trying to using first time aspose.slides for java api to create chart into pptx file. I need to some double values at Y Axis and some String value at X Axis. but i am able to doing this. because i am very confused to use this library. i have a lot study this library.

my code is -

Presentation pres = new Presentation();

ISlide slide = pres.getSlides().get_Item(0);

//Creating the default chart
IChart chart = slide.getShapes().addChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);

//Getting the default chart data worksheet index
int defaultWorksheetIndex = 0;

//Getting the chart data worksheet
IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();

//Delete demo series

//Add new series
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 1, “Series 1”), chart.getType());
chart.getChartData().getSeries().add(fact.getCell(defaultWorksheetIndex, 1, 3, “Series 2”), chart.getType());

//Adding new categories
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 1, 0, “Caetegoty 1”));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 2, 0, “Caetegoty 2”));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 3, 0, “Caetegoty 3”));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 4, 0, “Caetegoty 4”));
chart.getChartData().getCategories().add(fact.getCell(defaultWorksheetIndex, 5, 0, “Caetegoty 5”));

//Take first chart series
IChartSeries series = chart.getChartData().getSeries().get_Item(0);

//Add new point (1:3) there.
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 1), fact.getCell(defaultWorksheetIndex, 2, 2, 3));

//Add new point (2:10)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 2), fact.getCell(defaultWorksheetIndex, 3, 2, 10));

//Edit the type of series
series.setType (ChartType.ScatterWithStraightLinesAndMarkers);

//Changing the chart series marker

//Take second chart series
series = chart.getChartData().getSeries().get_Item(1);

//Add new point (5:2) there.
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 2, 3, 5), fact.getCell(defaultWorksheetIndex, 2, 4, 2));

//Add new point (3:1)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 3, 3, 3), fact.getCell(defaultWorksheetIndex, 3, 4, 1));

//Add new point (2:2)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 4, 3, 2), fact.getCell(defaultWorksheetIndex, 4, 4, 2));

//Add new point (5:1)
series.getDataPoints().addDataPointForScatterSeries(fact.getCell(defaultWorksheetIndex, 5, 3, 5), fact.getCell(defaultWorksheetIndex, 5, 4, 1));

//Changing the chart series marker

pres.save("/home/echasro/Desktop/TODAY/AsposeScatterChart.pptx", SaveFormat.Pptx);

I am creating this slide like -like =http://i.stack.imgur.com/IFfIQ.jpg

but i need to add categories like = 12/12/2014,12/13/2014,14/12/2014 etc at X Axis.

Please suggest me any idea do this complete.
Thank for reading

Hi Chandan,

Thanks for your interest in Aspose.Slides.

I have observed the requirement and image shared by you. I request you to please share the desired sample chart in the form of presentation. If it is possible in PowerPoint then I will try to create the similar one using Aspose.Slides. Actually, the line charts are plotted on X and Y axis. However, you are wishing to set the date along X axis, which seems not possible in my knowledge. Therefore, I request you to please share the desired chart in the form of PowerPoint presentation and I will try my best to help you further in this regard.

Many Thanks,

Hi Mudassir Fayyaz,
Thanks for response.

I want to share to you PowerPoint presentation as per discussion. But don’t how to share PowerPoint presentation file with this reply box. So i am sending a Google Drive Share Link:

please give suggestion to solve this issue.
please help me.

Hi Chandan,

Thank you for sharing the presentation file with us. I have tried opening the chart shared in presentation in PowerPoint 2010. Unfortunately, PowerPoint 2010 does not recognize this as chart and even I am not able to edit the chart data. I need to see the chart data. Can you please share, in which Office version you have created the chart. Is the Microsoft Office Chart or have been generated by some other way. Please share the chart data in the form of excel file as well so that I can have a view and develop understanding about it.

Many Thanks,