Free Support Forum -

Size and positioning of chart

How can I position the chart and control its height and width? e.g. if the data and the chart is on the same sheet, how can I place the chart after the data? Or, if they are on different sheets, how can I position the chart at a particular location within the chart sheet and control its height and width?

When you use the Charts.Add method, you can specify the chart size and position.

I already tried that. It does not seem to make any visible difference. I used the C# sample project from your Aspose.Cells download. It plots the chart on the second sheet with coordinates 0,0,0,0. I tried changing it to different values but it still looks the same.

The cost pareto demo create a new chart worksheet. In a chart worksheet, chart size and position cannot be adjust. To plot chart in a normal worksheet, please check sales by category demo. Or you can check .

To reference data in another worksheet, please try:

int chartIndex = excel.Worksheets[0].Charts.Add(ChartType.Column, 3, 3, 17, 10);
Chart chart = excel.Worksheets[0].Charts[chartIndex];
//Add chart data source
chart.NSeries.Add("Sheet2!A1:C3", true);

Thanks, Laurence. That worked.

Besides specifying the top-left and bottom-right coordinates in .Add method, is there any other way to control the “Height” and “Width” of the chart or the plot area?

You can try to use Chart.ChartArea and Chart.PlotArea to set them.

Thanks, Laurence.