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

Free Support Forum - aspose.com

Category Axis Label Not Showing

Hi,

I have generated graph using aspose cell. Its generated graph, but not showing Category Axis label. It showing default value like 1, 2, etc…

It also not showing Legend on Top position, although I have set is.

My code like following…

Chart chart = charts.get(chartIndex);
SeriesCollection nSeries = chart.getNSeries();
CategorySeries= dataSheet+ “!C”+(rowStartPos+1)+":I"+(rowStartPos+1)+"";
String vSeries=“C”+ (rowStartPos+2) +":I"+(rowEndPos+1);
nSeries.add(vSeries,false);
nSeries.setCategoryData(CategorySeries);

chart.getValueAxis().setMaxValue(100);
chart.getValueAxis().setMinValue(90);

//Format Plot Area
ChartFrame plotArea = chart.getPlotArea();
Area area = plotArea.getArea();
area.setForegroundColor(Color.fromArgb(255,255,255));

//Format Title
Title title = chart.getTitle();
title.setText(gTitle);
com.aspose.cells.Font font = title.getFont();
font.setSize(9);
title.getTextFont().setName(“Arial”);

//Hide Legend
chart.setShowLegend(true);
Legend legend = chart.getLegend();
legend.setPosition(LegendPositionType.Top);

Please suggest, what I am missing
Thanks in advance…
Regards,
Sanjay Kumar Mishra

Hi Sanjay,


Thank you for contacting Aspose support.

I believe there could be a problem with your current version of the Aspose.Cells APIs which isn’t allowing to get correct/desired results. I would suggest you to give a try to the latest revision of the API, that is; Aspose.Cells for Java (Latest Version) at the moment. Please note, I have simply executed the following piece of code to show the legend of the Chart 1 on top and it seem to have fixed the problem related to the Category Axis labels as well.

In case the problem persists with latest revision, please provide us an executable sample application covering your complete scenario (generation of chart as well) along with your desired results that you may create manually in Excel application to show what you exactly require to achieve with Aspose.Cells APIs.

Java

Workbook book = new Workbook(dir + “KPI+Dashboard.xlsx”);
Worksheet sheet = book.getWorksheets().get(0);
ChartCollection charts = sheet.getCharts();
Chart chart = charts.get(“Chart 1”);
chart.calculate();
chart.setShowLegend(true);
chart.getLegend().setPosition(LegendPositionType.TOP);
chart.calculate();
book.save(dir + “output.xlsx”);

Hi Babar,

Thanks for your quick response. As per your instruction, I have updated my API with 8.7.1.

For my first problem, it works like charm, and it solve my first problem.

But for my second problem - Legend not showing on top, its not working. When I put chart.calculate(), its throws error like:

java.lang.NumberFormatException: Input string was not in a correct format: CEll Availability
at com.aspose.cells.b.a.ze.g(Unknown Source)
at com.aspose.cells.zbt.a(Unknown Source)
at com.aspose.cells.zim.a(Unknown Source)
at com.aspose.cells.zim.b(Unknown Source)
at com.aspose.cells.zis.an(Unknown Source)
at com.aspose.cells.zka.d(Unknown Source)
at com.aspose.cells.ziq.b(Unknown Source)
at com.aspose.cells.ziq.a(Unknown Source)
at com.aspose.cells.Chart.a(Unknown Source)
at com.aspose.cells.Chart.calculate(Unknown Source)

where is in legend, there is text.

Please suggest.
Regards
Sanjay Kumar Mishra

Hi Sanjay.


As per company policy, we have to replicate the issue with latest revision of the API before logging it in our database. As per my testing, I am not getting any exception on Chart.calculate method while using the latest revision, which is Aspose.Cells for Java (Latest Version) at the moment. You have upgraded to 8.7.1 therefore I would request to give the latest version (8.7.1.2) a try on your side. In case the problem persists, we need an executable copy of your application along with input spreadsheet, if different than already shared sample. Please also provide your environment details as follow for thorough investigation.

  • Operating system version & architecture
  • JDK vendor, version & architecture
  • JVM arguments, if any
  • Locale of your machine

Thank you for your understanding.