We are seeing an issue where the labels on the a Chart’s horizontal axis (aka X-axis) are appearing vertically instead of diagonally. If you open the attached WaterfallChart.xlsx file in Excel, you should see that the X-axis labels have diagonal orientation. However, when Aspose Cells converts the Chart to an image, it shows the X-axis labels with a vertical orientation. Our expectation is that the the X-axis labels in the Aspose generated image appear diagonally (similar to Excel).
This behavior can be seen in the latest Aspose Cells for Java version 20.9, the attached WaterfallChart.xlsx workbook and the following Java code:
final String xlFile = [PATH] + "WaterfallChart.xlsx";
Workbook wb = new Workbook(xlFile);
Shape chart = wb.getWorksheets().get("Sheet1").getShapes().get("Chart 1);
// Convert the Chart to PNG Image
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageType(ImageType.PNG);
options.setDesiredSize(chart.getWidth(), chart.getHeight());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
chart.toImage(baos, options);
byte[] imgBytes = baos.toByteArray();
// Save the image file
Path imgFile = Paths.get(xlFile.replace(".xlsx", ".png"));
Files.deleteIfExists(imgFile);
Files.write(imgFile, imgBytes);
System.out.format("Saved image as: %s%n", imgFile.toString());
Running the above code should produce a new WaterfallChart.png file similar to the one attached. Rendering the PNG shows the X-axis labels with horizontal orientation. Additionally, notice how the chart area is much smaller (compared to Excel) - because the X-axis labels are taking up much more of the available vertical space.
Environment Details:
Aspose Cells for Java 20.9
Java version 1.8.0_211
Windows 10 OS (but also reproducible under Linux).
@oraspose,
We have logged the issue as “CELLSJAVA-43311” in our database for investigations. Once we will have some news for you, we will update you in this topic.
@oraspose,
This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.
The issues you have found earlier (filed as CELLSJAVA-43311) have been fixed in Aspose.Cells for Java 20.10. This message was posted using Bugs notification tool by ahsaniqbalsidiqui
Hello.
We are actively evaluating upgrade from current Cells library 21.03 which is over 2 years old to the latest Aspose Cells for Java library v23.06 or newer.
We noticed a possible regression with the subject issue “Chart X-Axis Labels are Vertical Instead of Diagonal when Converted to Image” when we used EMF image type.
You can reproduce this with the same input excel file “WaterfallChart.xlsx”, the same sample code as provided before, and set Image type to EMF: options.setImageType(ImageType.EMF)
Attached is the zip file containing the input excel file and output with generated EMF image, as well as HTML .
Please let us know if you need more information.
Thank you. WaterfallChart.7z (16.7 KB)
This is to inform you that your issue has been resolved. The solution will be added to the upcoming release of Aspose.Cells (v23.7) that we plan to release in 1-2 days. We will notify you once the next version is available.
Hello again.
While checking the new release of Aspose.Cells 24.1, we noticed this particular issue resurfaced again. While the solution release in 23.7 was fine and labels were diagonal in generated PNG and EMF images, the images generated with 24.1 again have labels in vertical orientation instead of diagonal. See attached zip file containing the output EMF charts generated with Aspose.Cells 24.1 and Aspose.Cells version 23.9 using the same input template WaterfallChart.xlsx and the same sample code.
Please let us know if you need anything else.
Thank you.
@oraspose
For cases where Axis labels have longer text, some users prefer to display the full text. Therefore, we have optimized the display by vertically showing Axis labels to accommodate the complete text content. Could you accept the current optimization results? If yes, we will consider the current display as final. If not, we will evaluate the possibility of further optimization. We apologize for any inconvenience caused.
No, we cannot accept this optimization.
Our goal is to attain an image that is as close as possible to the way a chart is rendered in Excel. We assume that workbook authors have formatted their chart in a way that is acceptable for their reporting purposes - as such, we need to match the charts to the extent possible.We realize that Aspose needs to programmatically render the chart from XML data. - so a 100% matching conversion to an image may not always be possible. However, in this case, the way that the image was generated under Cells v 23.7 and 23.9 was more desirable than the way it is now rendered under version 24.1. In the past, we have been provided with a "SaveOption " which allowed us to revert to the prior behavior (for example, the HtmlSaveOptions::setFormatDataIgnoreColumnWidth API was added in 23.11) per this thread). Would something like that be possible in this case?
Please note that we are trying to upgrade to the latest Aspose Cells version, however when we find differences in the output from previous versions (such as this case) - it prevents us from using the new version. The upgrade becomes even more difficult for us, when a new version fixes issues we’ve reported, but also introduces new differences.
We apologize that the new optimizations/changes are not suitable for your scenario. We will carefully evaluate your requirements and provide you with more options/updates. We apologize again for any inconvenience caused.
@oraspose
We will modify it again to achieve results similar to 23.7 and 23.9. We apologize for any inconvenience caused!
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSJAVA-45833
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.
Can you please provide timeline for when this issue is going to be resolved? Is it planned for upcoming release of Cells 24.02 ?
The reason we ask, there were issues in the past that kept preventing us from upgrading to the latest version.
@oraspose
Since your issue was logged two days ago, please allow us some time to evaluate and analyze it in detail. If it is not complex, we should be able to fix it soon, and the fix may be included in our upcoming release (Aspose.Cells v24.2 - planned for publication in the second week of February next month). If the issue is complex, it may take a few more weeks or even a month to resolve.
Additionally, if you purchase paid support, we will prioritize your issue so that it can be resolved earlier.