Format ChartArea and PlotArea using Aspose.Cells for .NET

I’m current trying to map the ActiveChart.PlotArea to the PlotArea for your component. I don’t see where the ActiveChart.PlotArea.InsideHeight and ActiveChart.PlotArea.InsideWidth maps to any property on the Apose.Cells.PlotArea.

Looking at the picture below, would this describe the chart and plot areas?
What does the PlotArea.X and PlotArea.Y represent?
Would PlotArea.X and PlotArea.Y be the upper left and top most corners of the PlotArea?
-----------------------------------------------
- ChartArea -
- ----------------------------- -
- - - -
- - PlotArea - -
- - - -
- ----------------------------- -
- -
-----------------------------------------------

Hi,


Well, you may use Chart.PlotArea.Width and Chart.PlotArea.Height to get/set the width and height of the chart plot area’s frame. Similarly you may use chart.ChartArea.Width/Height API to get/set the horizontal/vertical offset of the lower right row/column.

Also, Chart.PlotArea.X/Y APIs --> it Gets or sets the x/y coordinate of the upper left corner in units of 1/4000 of the
chart area.


Thank you.
hi,
i have signed some mark on this picture.Do I have an exact understanding?

thanks

Hi,


Thanks for the screen shot.

Yes, your understanding is correct.

Let us know if we can be of any further help.

Thank you.

Hi Pyntia,


The plot area in a chart refers to the area that graphically displays the data being charted. In a column chart or bar graph the plot area shows the vertical columns or bars with each column representing a single data series. Similarly, in a pie chart the plot area is the colored circle in the center of the chart that is subdivided into wedges. The plot area also includes the chart’s axes - such as the horizontal X axis and the vertical Y axis - the axis titles, gridlines, and data labels. On the other hand, the chart area is the bigger canvas where plot area along with the legend entries reside.

In order to get acquainted with ChartArea and PlotArea in reference the Aspose.Cells APIs, please go through the following article.
(http://www.aspose.com/docs/display/cellsnet/Setting+Chart+Appearance)

hi

the ChartObject Area,plotArea and the ChartArea i don’t understanding very much, exactly i was confuse about these property.

when open excel file, we catch the original property
original property
we find the plotArea size is much bigger than ChartObject’s size, why?

than i change plotArea property, set smaller width and height, the graphic is going so tiny.
change plotArea property
although the plotArea graphic is so small, but the width prop still bigger than ChartObject’s width

my aim is to control the plotArea to accurate position and size. i want to set L1,L2,L3,L4 values like below picture.
plotArea position & size

how can i do it?

the attachment is my test coding and original excel file.

thanks


the VBA code can work properly.

Sub ChangeScaleBarSize()
Set myDocument = ActiveSheet

For Each S In myDocument.ChartObjects
'MsgBox (S.Name)
With S.Chart
With .ChartArea
.Left = 0
.Width = 360
.Height = 260
End With
With .PlotArea
'设置绘图区在图表中的位置
.InsideLeft = 40
.InsideTop = 30
.InsideWidth = 300
.InsideHeight = 160
End With

End With
Next S
End Sub

i think there has some bug in aspose.cells

Hi,

Thanks for your posting and using Aspose.Cells.

Chart area will always be 0 because the entire chart is chart area. Chart area is itself divided as 4000 logical units. So if plot area is 2000 units wide, then it will be half of chart area and if plot area is 3000 units wide, then it will be 3/4 of the chart area.

If you want to get the height and width of the chart shape (not chart area), then use Chart.ChartObject X. Y, Width and Height properties. These properties have nothing to do with plot area.

The following code makes plot area cover the entire chart area.

C#


chart.PlotArea.X = 0;

chart.PlotArea.Y = 0;

chart.PlotArea.Width = 4000;

chart.PlotArea.Height = 4000;

hi, Faiz


thanks a lot.
hi, Faiz

can i control the L1,L2,L3,L4 distance like below picture?
<plotArea position & size

thanks

Hi,

Thanks for using Aspose.Cells.

I was not able to access your images from the links provided by you. They give me error. However, I found the image inside your rar archive which I have attached with this post for a reference.

L1 is actually Plot Area X property. If PlotArea.X is 100, then it means there is distance of 100 units from the left side of the chart area.

Similarly L4 is PlotArea.Y property. L3 is PlotArea.Height and L2 is PlotArea.Width properties.

hi, Faiz


i have test these prop,but i don’t think these prop can work property, you can use my attach code to test it.

or can you please show me some sample code to control the distance exactly.

thanks

Hi,

Thanks for your posting and using Aspose.Cells.

Please see the following sample code that makes use of Plot Area X, Y, Width and Height properties and takes images of them. Please also check the source excel file and output images generated with this code. These are 40 images and if you will see them in sequence you will see the X, Y, Width and Height property effects on the chart.

C#
Workbook workbook = new Workbook(“source.xlsx”);

Worksheet worksheet = workbook.Worksheets[0];

Chart chart = worksheet.Charts[0];
chart.Calculate();

int X = chart.PlotArea.X;
int Y = chart.PlotArea.Y;
int W = chart.PlotArea.Width;
int H = chart.PlotArea.Height;


//Now increasing X and taking images
for (int i = 0; i < 10; i++)
{
chart.PlotArea.X += 100;

ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.ImageFormat = ImageFormat.Png;

chart.ToImage(“chart-X” + i + “.png”, opts);
}

//Reset
chart.PlotArea.X = X;
chart.PlotArea.Y = Y;
chart.PlotArea.Width = W;
chart.PlotArea.Height = H;

//Now increasing Y and taking images
for (int i = 0; i < 10; i++)
{
chart.PlotArea.Y += 100;

ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.ImageFormat = ImageFormat.Png;

chart.ToImage(“chart-Y” + i + “.png”, opts);
}

//Reset
chart.PlotArea.X = X;
chart.PlotArea.Y = Y;
chart.PlotArea.Width = W;
chart.PlotArea.Height = H;

//Now increasing Width and taking images
for (int i = 0; i < 10; i++)
{
chart.PlotArea.Width += 100;

ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.ImageFormat = ImageFormat.Png;

chart.ToImage(“chart-Width” + i + “.png”, opts);
}

//Reset
chart.PlotArea.X = X;
chart.PlotArea.Y = Y;
chart.PlotArea.Width = W;
chart.PlotArea.Height = H;

//Now increasing Height and taking images
for (int i = 0; i < 10; i++)
{
chart.PlotArea.Height += 100;

ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.ImageFormat = ImageFormat.Png;

chart.ToImage(“chart-Height” + i + “.png”, opts);
}