Y axis values missing

Hi,

I am using Aspose.Cells v8.5.2.4
On converting Chart 7 in attached excel to PDF the Y axis value 6 is missing

For reference the sample code:
private static void chartToPDF() throws Exception {
Workbook workbook = new Workbook(“D:\Excel.xlsx”);
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = workbook.getWorksheets().get(0).getCharts().get(“Chart 7”);
ChartShape cshape = chart.getChartObject();
int sheetIndex = ws.add();
com.aspose.cells.Worksheet worksheet = ws.get(sheetIndex);
chart.calculate();
double chartWidthInInches = chart.getChartObject().getWidthInch();
double chartHeightInInches = chart.getChartObject().getHeightInch();
boolean defaultApproach = true;
if (chartWidthInInches > 18 || chartHeightInInches > 5) {
// The approach being followed here is to iterate as many columns as colwidth in pixels & set each column width equal = 1 pixel.
// Similarly for chart height, iterate through as many rows as row height & set each row height = 1 pixel.
// This is being done to fit in large charts that have height & width beyond maximum row/col dimensions & white spaces around
// the chart.

double chartWidthInPixels = chart.getChartObject().getWidth();
double chartHeightInPixels = chart.getChartObject().getHeight();
// Deliberately including one more column because Aspose considers the last column adjacent to chart which leads to white space
// on right of chart
for (int i = 0; i <= chartWidthInPixels; i++) {
worksheet.getCells().setColumnWidthPixel(i, 1);
}

// Deliberately including one more row because Aspose considers the last row adjacent to chart which leads to white space
// below the chart.
for (int i = 0; i <= chartHeightInPixels; i++) {
worksheet.getCells().setRowHeightPixel(i, 1);
}
defaultApproach = false;
} else {
worksheet.getCells().setColumnWidthInch(0, chartWidthInInches);
worksheet.getCells().setRowHeightInch(0, chartHeightInInches);
}

//Setting the name of the newly added worksheet
String transientSheetName = “TransientWorksheet”;
worksheet.setName(transientSheetName);
//Copy the Chart to Second Worksheet
worksheet.getShapes().addCopy(cshape, 0, 0, 0, 0);
//Get the new chart and set its height and width accordingly
com.aspose.cells.Chart chart1 = worksheet.getCharts().get(0);
chart1.getChartObject().setHeightInch(chartHeightInInches);
chart1.getChartObject().setWidthInch(chartWidthInInches);
//Make remaining worksheets invisible so that they are not part of the output pdf
for (int i = 0; i < ws.getCount(); i++) {
String sheetName = ws.get(i).getName();
if(!transientSheetName.equalsIgnoreCase(sheetName)){
ws.get(i).setVisible(false);
}
}
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);
worksheet.getPageSetup().setTopMargin(0);
worksheet.getPageSetup().setBottomMargin(0);
worksheet.getPageSetup().setRightMargin(0);
worksheet.getPageSetup().setLeftMargin(0);
//Setting Print area to first cell only as the chart is contained in the first cell (A1:A1)
if (defaultApproach) {
worksheet.getPageSetup().setPrintArea(“A1:A1”);
}
// Save the workbook
workbook.save(“d:\temp\Chart 7.pdf”, pdfSaveOptions);
}


Can you please analyse this issue.

Thanks,
Jaspreet

Hi,


I have evaluated your scenario/ case using your sample code and template file a bit. I noticed that Chart.calculate() is not performing as expected, so you may comment the following line of code for now, it would work fine as I tested.
e.g
Sample code:

///chart.calculate();


Let us know if you still have any issue.

Thank you.

Hi,

I tried with commenting out chart.calculate() API & it worked. But removing chart.calculate() might make us lose some other important information required for rendering chart to PDF.

Can you please elaborate on chart.calculate() API more as I could not find anything more than this:
Calcuate the custom postion of plot area, axises if the postion of them are auto assigned.

Also, I would prefer not to remove this API from my code & would appreciate if you could resolve the chart.calculate() API bug.


Thanks,
Jaspreet

Hi,


Well, Chart.calculate() method calculates/re-calculates the plot area data and x and y axis values etc. As I already found the issue as you mentioned by using your sample code with your template file. I noticed that a Y-axis value is missing in the rendered chart image when converting to PDF file format, the Chart.calculate() is not performing as expected. I have logged a ticket with an id “CELLSJAVA-41504” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

Hello.

At IHS we also have Aspose.cells license and we have encountered this problem too.
Fixing it is important for us, because our users face it in everyday work.

Regards,
Tomek

Hi Tomek,

Please note, the ticket attached to this thread is currently in analysis phase therefore we cannot share an estimated time line for the fix at the moment. Regarding your scenario, we strongly suggest you to create a new thread with problem description and supporting documents so we could evaluate it separately and log separate ticket, if applicable.

Hi,

Thanks for using Aspose.Cells for Java.

Please download and try this fix: Aspose.Cells for Java v8.6.0.7 and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-41504) have been fixed in newer version of

Aspose.Cells for Java (Download | Maven).


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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan