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

Free Support Forum - aspose.com

Resize a chart into

Hello,

I am trying to adjust the size of a chart in Excel with Aspose. Basically the size of the container chart is created base on my Excel file, so the ChartArea has the right dimension.
So I would like to ajust the size of the chart (PlotArea) to have exactly the same size as the container (ChartArea). And I am facing several problems.

First the dimension of the ChartArea seems not available (chart.ChartArea.Width = 0, even after havinf call the method chart.Calculate()).

Second, when I set:
chart.PlotArea.X = 0;
chart.PlotArea.Y = 0;
There is always a very small shift between the ChartArea and the PlotArea (

Third, can you confirm that the unit of Width and Heigth of ChartFrame are point, and not 1/4000 of the chart area (like for properties X and Y)
See documentation:
http://www.aspose.com/doctest/.net-components/aspose.cells-for-.net/aspose.cells.charts.chartframe.x.html
http://www.aspose.com/doctest/.net-components/aspose.cells-for-.net/aspose.cells.charts.chartframe.width.html

And finally, can you confirm that properties X and Y of ChartFrame are exactly 1/4000 (not approximatly)?

Thanks a lot,
Alexandre

Aspose version: 7.0.3
.NET version: 3.5

Hi,


Well, the Chart.ChartArea is actually represented by ChartFrame, so the X and Y attributes denote the x/y coordinate of the upper left corne in units of 1/4000 of the chart area. Moreover, the Width/Height properties are in the unit of points.

Could you give us your sample code with input and output Excel files here, we will check it soon. Also, could you attach a file having the charts with your desired dimensions regarding PlotArea manually created/adjusted in MS Excel, we will check it soon.

Thank you.

Hi,

Thanks for this quick response.

I attached 3 files. One sample of code, the result generated and the result expected.
Basically I generate two charts to show what I am talking about.

The first chart is created by the command:
sheet.Charts.Add(Aspose.Cells.Charts.ChartType.BarStacked, 2, 0, 20, 7);
The second is created by the command:
chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.BarStacked, 21, 0, 39, 10);

So the second chart is larger than the first one.
And then the configuration of the chart is simply:
chart.PlotArea.X = 0;
chart.PlotArea.Y = 0;
chart.PlotArea.Width = 3000;


You will notice, comparing both of my Excel file, that in the “result expected”, there is no margin between the PlotArea and the ChartArea.

Second, if the width’s unit is point, how do you explain that the size of the 2 charts are differents ?
It rather seems to be proportionnal to the size of the ChartArea.

Regards,
Alexandre

Hi,


Thanks for the sample code and template files.

We need more time to evaluate your issue, we will investigate it thoroughly. We have logged a ticket with an id: CELLSNET-40125. We will look into it next week and get back to you.

Thank you.

Hi,

Any news about the problem of resize? Also, as far as I make some test, I still really have the feeling that the width and height of the ChartFrame are in 1/4000 of the whole chart.

In all my test :

4000 < X + Width < 4020

4000 < Y + Height < 4020

Best,

Alexandre

Hi,


We will update you tomorrow.

Thanks,

Hi,

I actually opened another post for the specific problem of width and height since I believe this is a different issue. Feel free to close one of them if you think it is inappropriate.

<A href="https://forum.aspose.com/t/120422</A></P> <P> </P> <P>Regards,</P> <P> </P>

Hi,


The chart area is big enough as 4000 units for 2003 Excel. The value is dynamic, we need to calculate by the chart size. We created a test based on your codes. Please check the attached archive. Hope, it will help you to understand for your needs.


Thank you.

Hi,

Thanks. It helps a lot. I still have some issues but I cannot reproduce them on a test program.

There are some strange things even in your test code. For exemple, even in your output, the chart touch the top of the graph, but not the bottom. Also, for some reason, there are some small adjustment to perform when you hide the ValueAxis.

It still confirm that the width and height unit are 1/4000 of the chart area, and I also discovered the ChartObject that return the real dimension of the graph. Very useful.

I will get back to you if I face any other problem.

Thanks a lot.

Hi,

Thanks for your feedback.

I have logged your comment in our database. We will look into it further and then update you asap.

Hi,

Actually, the blank offset value (5 pixels) is not right for Excel 2003. If you could drag an object, eg. legend, chat title or plot area in Excel 2003, you will find that you cannot make it touch with the chart area frame completely, there would be some space for sure. We look over the Excel document but we don’t find the way on how much the space is there. Excel 2003 thinks a value not in the range i.e. 0 to 4000 will be valid. So, for your question/query, we cannot give a standard answer.

Thanks for your understanding!

Hi,

Thanks for your feedback. I think I will try to place my charts correctly by overlapping them.

Rgds,