Setting chart shape top/left changing chart area position

Please see the attached workbook generated by the Cells component (latest version).


The only difference between the charts on sheet 1 and sheet 2 is a left/top position set for the chart shape on sheet 2:

chart.ChartObject.Top = topPosition
chart.ChartObject.Left = leftPosition

However, note that this has caused the chart area to shift down and to the right, causing the chart to overlap the legend.

Can you suggest a way to avoid this from happening? Setting the chart area x/y back to 0 appears to have no affect.

Thanks.

Shaun

Hi,

Please try the attached version. I have tested with it changing the top and left positions for your chart in the first sheet and it works fine.

e.g
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
workbook.Open(@“e:\test\xl.xls”);
Aspose.Cells.Chart chart = workbook.Worksheets[0].Charts[0];

chart.ChartObject.Top = 250;
chart.ChartObject.Left = 200;

workbook.Save(“e:\test\outxl2.xls”);


If you still find any issue, kindly paste your complete code here to show the issue, we will check it soon.

Thank you.

Amjad,


I tried to reproduce the result you describe above (same code) using new cells version, but I still get the same problem. Can you attach the workbook you produced so I can see it for myself?

Thanks.

Shaun

Hi Shaun,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the following sample code as I tested it and it works fine for setting both Chart Object and its Plot Area. I have also attached the resultant file for your reference:

Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();

workbook.Open(@"d:\test_temp\xl.xls");

Aspose.Cells.Chart chart = workbook.Worksheets[1].Charts[0];

chart.PlotArea.Y = 0;

chart.PlotArea.X = 0;

chart.ChartObject.Left = 0;

chart.ChartObject.Top = 0;

workbook.Save(@"d:\test_temp\outxl2.xls");

Thank You & Best Regards,

Nausherwan,


Thanks for your reply.

I want to be able to change the chart object top/left without it affecting the chart area. If you look at my original workbook, the charts are identical apart from in sheet 2 I set the top and left to be a non-zero value. The position of the shape is perfect, however the chart area has moved down and to the right and it overlaps the legend.

Do you understand the problem?

Thanks.

Shaun

To explain some more: I want to be able to set an x/y offset from the anchor row/column without it changing the chart.


Perhaps chart.ChartObject.Top and chart.ChartObject.Left are not the correct properties to use?

Shaun

Hi Shaun,

Thank you for considering Aspose.

We will get back to you soon regarding your issue.

Thank You & Best Regards,

Do you have an update? Appreciate your help as always.

Hi,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for the delayed response.

Our development team is currently on leave this week due to the Spring Festival Holidays. I will update you regarding your issue early next week.

Thank you for being patient,


Hi,

We are not completely sure about your issue. Please try the attached latest version/fix v4.8.2.6 and let us know if it work fine.

If you still find any issue, kindly create a sample project, zip it and post it here to show the issue with all the details, we will look into it soon.

Thank you.

Amjad,


Please see the attached project which demonstrates the problem. Note that the output chart is messed up.

If you comment out these 2 lines you get a perfect chart:

chart.ChartObject.Top = 100;
chart.ChartObject.Left = 100;

We need to position the charts at offsets from a row/column anchor point. The worksheet row/column heights are a variable which change in every worksheet.

Hi,

Well, I think the chart.ChartObject.Top/Left works as expected. I use the new fix v4.8.2.6 (that we attached in the previous post in this thread), attached is the output file using your code and template file.

I think you may give less values for chart.ChartObject.Top/Left to place the chart in your desired location in A1 cell.

Please check the attached file, Is it not what you want for your desired result. If not, kindly let us know where the chart should be placed. You should also post your expected file here.

Thank you.

Amjad,


In your output, the location of the chart is absolutely fine, that is not the problem here.

Please see the attached image. The first chart is the output if you leave top and left at 0. Note the chart is perfectly drawn.

The second chart in the image is the output when setting top and left both to 100 pixels. Note the interior of the chart has moved to the right and now the legend overlaps the plot area.

I want to know why the interior of the chart is moving. My expected result is that both charts look identical.

Thanks for your help.

Shaun

Hi,

Please see the attached image. The first chart is the output if you leave top and left at 0. Note the chart is perfectly drawn.

The second chart in the image is the output when setting top and left both
to 100 pixels. Note the interior of the chart has moved to the right
and now the legend overlaps the plot area.

I am still unable to find any issue here. I have the environment: VS.NET 2005, WinXp, Excel 2007.

Attached are my screen shots, check them, the are fine.

What is your environment, system details, MS Excel version etc.

Thank you.

Amjad,


It seems like the issue is related to the version of Excel.

Using the same workbook, when opened Excel 2002 (10.6856.6858 SP3) the chart looks fine. However, in Excel 2007 (12.0.6514.5000 SP2) the chart is messed up.

My environment is Vista, VS 2008, and the two Excel versions listed above.

Addition to my last post: some charts still show up wrong even in Excel 2002.

Hi,

Thanks for providing us further details.

We will further look into it and get back to you soon.

Thank you.

Hi,

We found your mentioned issue in Excel 2007 on Windows Vista. We will figure it out soon.

Your issue has been logged into our issue tracking system with an issue id: CELLSNET-14618.

Thank you.

Hi,

Please try the attached version, we have fixed your mentioned issue.

Thanks.

Looks great, thank you for your quick work.