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

Free Support Forum - aspose.com

Axis Formatting For Small Multiples

Hello,

I'm creating a series of small charts which will have the exact same values on the x and y axis. However, I only want to display the values on the y axis in the chart farthest to the left. I can turn off the values just fine for the subsequent charts, but when I do the axis lines no longer match up. It seems to be because the labels on the first chart are displaying above the axis, pushing it down. Is there a way this can be fixed? I tried setting the TickLabelPositionType to low, but that didn't produce any noticable change.

Thanks,

Matt

Hi,

Well, I am not sure about your issue. Could you elaborate and explain it more. We appreciate if you could post your template excel file containing both charts; one with your desired results (you may manually create the chart in MS Excel) and also with Aspose.Cells APIs. Also, post your sample code here, we will look into it soon.

Thank you.

Actually, it seems to be a problem in Excel, also, but in Excel I can drag the interior chart area and change it to be the same size as the previous chart. Is there a width/height property I can set to emulate this in Aspose.Cells? I’ve attached an image to show you what I’m changing in Excel.

Hi,

Well, I think you may try to use the following for your need:

chart.ChartObject.Width/WidthCM/WidthInch/WidthPt attribute(s) to set the width

chart.ChartObject.Height/HeightCM/HeightInch/HeightPt attribute(s) to set the height

Thank you.

Hi Amjad,

I don't think that's the property that corresponds with what I was changing in the above screenshot. When I build the two aspose charts, those properties are already the same values. I need to be able to change the size of the box that is created by the chart axes, not the size of the entire chart area. This can be done in Excel by dragging the size of the box, so the property should exist somewhere.

Thanks,

Matt

Hi,

If you want to change the plot area size, you may try the following code for your need:

e.g..,

Chart.PlotArea.Width = .......

and

Chart.PlotArea.Height = --------

If you still could not figure it out, could you post your template file containing your charts (original and desired chart after re-sizing) with all the details here, we will check it soon.

Thank you.

Ok, I've attached a few documents. The first document is leading_chart.xls. This is the first chart in the series that I build, and Aspose builds this chart as it displays in the Excel file. After this chart is built with chart.toImage, I do the following:

areaWidth = chart.PlotArea.Width

areaHeight = chart.PlotArea.Height

The second chart is in trailing_chart.xls. Before building this chart with chart.toImage I do the following:

chart.PlotArea.Width = areaWidth

chart.PlotArea.Height = areaHeight

When aspose builds the second chart, it comes out looking like the attached jpg file and not how the chart appears in the trailing_chart.xls file.

There are two problems with this:

1) The plot area is overlapping with the chart title, which is obviously incorrect.

2) Assigning the width and height to the plot area does not seem to have any effect on the width and height of the plot area. If you line the two Excel files up side by side, you will see that the height of the y-axis in one file is not the same as the height of the y-axis in the second file.

Hi,

Please try the attached version. I have tested with it and I don't find the problems you have mentioned i.e.., plot area overlapping with the chart title and setting width and height to the plot area does not have any effect. The output chart image is OK.

Thank you.

Hi,

I am still getting the same errors as before, even with the new version of the DLL. Are you setting the plotArea.Width and plotArea.Height manually when you are building the chart? That is what is causing it to produce the errors.

chart.PlotArea.Width = areaWidth

chart.PlotArea.Height = areaHeight

areaWidth and areaHeight are numbers I got from another chart of the same proportions, so I know they are valid.

The errors do not appear in the Excel file, only when using chart.toImage.

Hi,

Following is my sample code using your template files and it works fine. Attached zip file contains the generated chart image and excel file.

Sample code:

Workbook workbook = new Workbook();
workbook.Open(@"F:\test\leading_chart.xls");
Chart chart = workbook.Worksheets[0].Charts[0];
int areaWidth = chart.PlotArea.Width;
int areaHeight = chart.PlotArea.Height;
int x = chart.PlotArea.X;
int y = chart.PlotArea.Y;

workbook.Open(@"F:\test\trailing_chart.xls");
chart = workbook.Worksheets[0].Charts[0];
chart.PlotArea.X = x;
chart.PlotArea.Y = y;
chart.PlotArea.Width = areaWidth;
chart.PlotArea.Height = areaHeight;
Bitmap bitmap = chart.ToImage();
bitmap.Save(@"F:\test\newtrailing1.jpg");

workbook.Save(@"F:\test\dest_trailing_chart.xls");

Thank you.