Chart toImage is giving different view than original for PIE Chart

Hi,

I wanted to embed an excel (that has both data sheet and chart sheet) into a presentation slide. I did that so. I also wanted to add the chart snapshot as image for the slide. That too is fine.

But, the snapshot chart image does has some variations between the original chart. I have attached the ppt file for your reference.

The snapshot image actually collapses the data values of the chart, that gives us a different behavior. I have the below properties, does this can be a cause to this issue

chart.setElevation(25)
chart.setFirstSliceAngle(90)

Can you please help me here, to add the actual snapshot of the image without any difference.

REgards
Sundhar
Aspose OEM Licence Holder

Hi Sundhar,


Thanks for your interest in Aspose.Slides.

Please visit methods of Chart class and this documentation link to create chart and embed it in presentation. It would be great, if you can share your code for investigation purpose.

Hi,

I don’t have any issues in creating the chart and embedding, but my problem is the variation bwt the snapshot image and the original chart.

When we open the PPT file, the slide has a snapshot image of the chart, which has all the data label values overlapped with one another, when we double click the image and view the original chart, it is rendered properly, where all values are visible correctly.

Below is the code that I was using
------------------------------------

Presentation presentation = new Presentation();
Slide slide = presentation.getSlideByPosition(1);

Workbook workbook = new Workbook();
Worksheets worksheets = workbook.getWorksheets();
worksheets.removeSheet(0);
Worksheet dataSheet = worksheets.addSheet(SheetType.WORKSHEET,
“Data”);
Worksheet chartSheet = worksheets
.addSheet(SheetType.CHART, “Chart”);
worksheets.setActiveSheet(chartSheet);

Chart chart = chartSheet.getCharts().addChart(ChartType.PIE_3D, 0,
0, 0, 0, 50, 50);

Cells cells = dataSheet.getCells();

cells.getCell(“A1”).setValue("");
cells.getCell(“B1”).setValue("");
cells.getCell(“A2”).setValue(“Russia Segment 3”);
cells.getCell(“B2”).setValue(83323936);
cells.getCell(“A3”).setValue(“EQUANT”);
cells.getCell(“B3”).setValue(5245881344d);
cells.getCell(“A4”).setValue(“A”);
cells.getCell(“B4”).setValue(28827);
cells.getCell(“A5”).setValue(“FT”);
cells.getCell(“B5”).setValue(122892288);
cells.getCell(“A6”).setValue(“OBS”);
cells.getCell(“B6”).setValue(2949744);
cells.getCell(“A7”).setValue(“Russia Segment 2”);
cells.getCell(“B7”).setValue(22530148);
cells.getCell(“A8”).setValue(“C”);
cells.getCell(“B8”).setValue(404449504);
cells.getCell(“A9”).setValue(“B”);
cells.getCell(“B9”).setValue(1914391040);
cells.getCell(“A10”).setValue(“Russia Segment 1”);
cells.getCell(“B10”).setValue(155947952);

int index = chart.getNSeries()
.add("=Data!A1:B10", true, true, true);
chart.getNSeries().get(index).setName("=Data!" + “B1”);

dataSheet.autoFitColumns();

chart.setSizeWithWindow(false);
chart.setLegendShown(true);
chart.getLegend().setPosition(LegendPositionType.BOTTOM);
chart.setElevation(25);
chart.setFirstSliceAngle(90);

NSeries nSeries = chart.getNSeries();
int numSeries = nSeries.size();
for (int i = 0; i < numSeries; i++) {
ASeries aSeries = nSeries.get(i);
DataLabels dataLabels = aSeries.getDataLabels();
dataLabels.setValueShown(true);
dataLabels.setLegendKeyShown(true);
}

ImageOptions imageOptions = new ImageOptions();
imageOptions.setImageFormat(ImageFormat.JPEG);
imageOptions.setFashion(FileFormatType.EXCEL97TO2003);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
chart.toImage(outputStream, imageOptions);
byte[] imageBytes = outputStream.toByteArray();
outputStream.close();

ByteArrayInputStream inputStream = new ByteArrayInputStream(
imageBytes);
Picture picture = new Picture(presentation, inputStream);
inputStream.close();

outputStream = new ByteArrayOutputStream();
workbook.setOleSize(0, 50, 0, 50);
workbook.save(outputStream);
byte[] oleBytes = outputStream.toByteArray();
outputStream.close();

OleObjectFrame oleObjectFrame = slide.getShapes()
.addOleObjectFrame(0, 0,
(int) presentation.getSlideSize().getX(),
(int) presentation.getSlideSize().getY(),
“Excel.Sheet.8”, oleBytes);
oleObjectFrame
.setPictureId(presentation.getPictures().add(picture));

presentation.save(“aspose_slides.ppt”, SaveFormat.PPT);
System.out.println(“done…”);

I have also attached the java code along with the ppt that was generated out of it.

Kindly suggest us what could be the problem.

Your quick suggestion will help us a lot.

Hi Sundhar,


I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as SLIDESJAVA-30129. Our team will look into this issue and you will be updated via this forum thread once it is resolved.

We apologize for your inconvenience.

Hi Sundhar,


Our development team has investigated the issue on their end. Actually, the issue lies in Aspose.Cells when generating the chart image. I have attached the generated Aspose.Cells generated chart in the form of file along with excel file. Aspose.Slides displays the same in Ole frame. You may please need to consult Aspose.Cells forum for further resolution.

Many Thanks,

The issues you have found earlier (filed as SLIDESJAVA-30129) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.