Free Support Forum - aspose.com

About plotArea in the Chart

Hi again,

I create a chart with a legend in the corner (upper right) and a title in a textbox to placed it as i want.(upper left)
I want the plotArea to take all the width of the chart but he didn’t take the width below the legend …


Best regards.

Hi,

Please use following codes:

PlotArea plotArea = chart.getPlotArea();
plotArea.setWidth(4000 - plotArea.getX());

I have done it but it moves the legend … (which is set to LegendPositionType.CORNER). Must i place the legend myself ?

Best regards.

Hi,

The default position of legend of the chart is RIGHT . You should use Legend.setPosition() method to move the legend to other position.

In MS Excel ,if you move legend to the Corner, the plot area does not auto take the chart area's width below the legend. So you should set the size of the ploat area manually . See following codes:

Legend legend = chart.getLegend();
//Move legend to Corner
legend.setPosition(LegendPositionType.CORNER);
PlotArea plotArea = chart.getPlotArea();
//Set plot area width
plotArea.setWidth(4000 - plotArea.getX());

Hi,

It’s the codes i was using to obtain the previous result, moving the plotarea seems to replace the legend to the RIGHT position and it can’t be changed…

Hi,

This is our result.

Which do you open the file with? MS Excel or Excel Viewer. Could you try open the file with MS Excel?

Ok,
I open it with viewer and excel, same problem.
Maybe if i place the legend with setx and sety i can obtain the result i want…

Could you please post all your test code here? That will help us to figure out your need and check what may cause the problem. Thank you very much.

Hi,

The codes :
Charts charts = sheets.getCharts();
int index = charts.add(ChartType.COLUMN_CLUSTERED,ls+3,cols,ls+18,cols+3);
Chart chart = charts.getChart(index);

ValueAxis valueAxis2 = chart.getSecondValueAxis();
valueAxis2.setMinValue(-5.0);
valueAxis2.setMaxValue(5.0);

chart.getTextBoxes().addInChart(150,50,2500,350);
chart.getTextBoxes().get(0).setContent(“Parc roulant Renault VP+VU”);
chart.getTextBoxes().get(0).setHasLine(true);
Font f=new Font();
f.setBold(true);
f.setSize(12);
chart.getTextBoxes().get(0).setFont(f);

chart.getLegend().setPosition(LegendPositionType.CORNER);

PlotArea plotArea = chart.getPlotArea();
plotArea.setWidth(4000 - plotArea.getX() - 100);
plotArea.setY(500);
plotArea.setHeight(4000 - plotArea.getY() - 500);

NSeries serieses = chart.getNSeries();
serieses.add(“B5:B10”, true);
serieses.setCategoryData(“A5:A10”);
serieses.add(“C5:C10”, true);

ASeries as=serieses.get(0);
as.setName(“Parc roulant”);
as=serieses.get(1);
as.setName(“Evolution A/A-1”)


I join the result…

Hi,

May It is caused by old version .We will release new version recently . Please wait one or two days.