SriG
March 7, 2022, 11:14am
1
Need help in increasing space above the graph to add chart title using Aspose.Cells for Java API.
Used following link for changing position & size of chart.
Class Libraries & REST APIs for the developers to manipulate & process Files from Word, Excel, PowerPoint, Visio, PDF, CAD & several other categories in Web, Desktop or Mobile apps. Develop & deploy on Windows, Linux, MacOS &...
Attached sample excel with chart for your reference.
SampleChart.zip (6.9 KB)
Thanks in advance
@SriG ,
You do not need to increase space above. You may simply set chart’s title visible for your needs. See the following lines of code:
e.g.
Sample code:
.....
Chart chart = worksheet.getCharts().get(0);
chart.getCharts().get(0).getTitle().setVisible(true);
.......
Moreover, you may decrease the width of the plot area of chart so your title should be shown above the plot area.
SriG
March 7, 2022, 3:46pm
3
Thanks for the response.
Updated the Chart title to visible. And title is getting placed over the chart instead of top.
Also tried updating the plot area as follows, but it is not taking the given values.
Could you please take a look and suggest the required changes to plot area.
Chart chart = worksheet.getCharts().get(0);
chart.getTitle().setVisible(true);
chart.getChartObject().setWidth(400);
chart.getChartObject().setHeight(300);
chart.getChartObject().setX(250);
chart.getChartObject().setY(150);
chart.getPlotArea().setX(50);
chart.getPlotArea().setY(100);
@SriG ,
See and try the following sample code for your reference:
e.g.
Sample code:
......
chart.getTitle().setVisible(true);
chart.getTitle().setText("Test Title1");
chart.calculate();
int height = chart.getPlotArea().getHeight();
int width = chart.getPlotArea().getWidth();
chart.getPlotArea().setY(500);
chart.getPlotArea().setHeight(height);
chart.getPlotArea().setHeight(width);
.....
Hope, this helps a bit.