PlotArea size

aspose-cells 8.6.2.6

- create whatever chart in Excel and save
- load this file with aspose

chart.getPlotArea().getX() = 0
chart.getPlotArea().getY() = 0
chart.getPlotArea().getWidth() = 0
chart.getPlotArea().getHeight() = 0

The plot area seems not filled with its values.

Hi,


If you need to get X, Y, height and width of plot area/ chart area, you should try to use Chart.calculate() method before obtaining the values from these attributes.
e.g
Sample code:

chart.calculate();

Let us know if you still have any issue.

Thank you.

It works, thanks.

Wouldn’t it be good to have those values directly, without calling calculate (at least if no modification has been done to the chart since the loading) ?

Hi,


Good to know that your issue is sorted out now.

Well, Aspse.Cells does not calculate the custom position, height or width of plot area, legend or X/Y axis (if these objects are auto-assigned) when chart is loaded, so you got to call the Chart.calculate() method to obtain the values from these attributes at runtime.

Thank you.

What is the factor between chart height and inside heights (title, plotArea, legend) ?

On a bar chart, I retrieve values that do not match :
chart H: 242
title Y: 165
title H: 579
plot Y: 760
plot H: 2298
legend Y: 3455
legend H: 380

Hi Sébastien,


I believe you are already aware of the chart elements in general, however, I have attached a snapshot along with following details for your reference.

  1. The chart area of the chart.
  2. The plot area of the chart.
  3. The data points of the data series that are plotted in the chart.
  4. The horizontal (category) and vertical (value) axis along which the data is plotted in the chart.
  5. The legend of the chart.
  6. A chart and axis title that you can use in the chart.
  7. A data label that you can use to identify the details of a data point in a data series.
centile:
What is the factor between chart height and inside heights (title, plotArea, legend) ?

Regarding your original concerns as quoted above, I am afraid, I didn’t quite understand your question. If you have any ambiguity in reference to the chart’s element size or position, it would be appropriate that you should share the sample spreadsheet containing the chart in question along with code (preferably a standalone sample application) to retrieve the aforementioned values while using latest revision of the Aspose.Cells for Java 8.6.3.4. We will check it soon to provide the justification/assistance.

I know chart zones well.

Using the same numbers to identify the zones, here what is not coherent, with values taken from a unique ‘Chart’ object:

1) chart area height : 242
2) plot area height : 2298
plot area Y : 760

We can see that plot area height is way bigger than chart area height.

Attached example with two simple charts : column and bar
Here are the results obtained with my version : 8.6.2.6

COLUMN CHART: TITLE_1
height: 267
inner height: 2517
title height: 524
plot area height: 3101
legend height: 345

BAR CHART: TITLE_2
height: 266
inner height: 2211
title height: 526
plot area height: 2586
legend height: 346

Hi Sébastien,


Thank you for sharing the samples and problem description. Please spare us little time to work with them. We will shortly get back with updates in this regard.

Hi again,


Thank you for your patience.

I have checked your recently shared scenario while using the latest version of Aspose.Cells for Java 8.6.3.4 to get the same results as shown in your last post. Please note, the Shape.Height property returns the value in the unit of Pixels whereas all other properties such as PlotArea.InnerHeight, PlotArea.Height & ChartFrame.Height etc return the values in the units of 1/4000 of the chart area therefore these values are not comparable. If you could allow me some more time (till next working day) I can discuss the matter with concerned member of the product team to get more details on this topic.

Hi Sébastien,


Adding more to my previous response, the position of Chart object is represented by 4000 units and this offsets from the edge of the chart. By simple calculation, you can get the measurement/size information in the unit of Pixels. For instance, you may get the left-right corner of the chart point by the following code. In a similar manner, you can retrieve other information as well.

Java

int left = chartPoint.getShapeX() * chartWidthPx / 4000;
int top = chartPoint.getShapeY() * chartHeightPx / 4000;

Regarding your original concerns as stated in your last response, as the Shape.getHeight property returns the value in the unit of Pixels whereas other values are returned in the unit of 1/4000 of the chart area therefore you should first convert all other relative measurements in unit of Pixels for consistency while using the simple formula (value in units of 1/4000) * chartHeightPx (or chartWidthPx) / 4000.

My goal:
- take an existing chart
- resize its plot area inner height so that plotAreaInnerHeightInPixelsAfter = nbValues * plotAreaInnerHeightInPixelsBefore / 2
- resize char height so that plot area is the same distance from chart borders than before

I’ve provided a sample in which chart sizes are printed:
- before resizing
- after resizing
- after reloading the new chart

The values I’ve calculated for resizing and positioning seem correct.
But when we open the resized chart document, the Y positioning of the plot area is too big and the inner height is too low.

NB: Please note that the javadoc is full of copy/paste errors in ChartShape and PlotArea.
This part of the API is not self-evident and a valid documentation could help …
You could also add drawings and examples in it in order to simplify the support.

Hi Sébastien,

centile:
My goal:
- take an existing chart
- resize its plot area inner height so that plotAreaInnerHeightInPixelsAfter = nbValues * plotAreaInnerHeightInPixelsBefore / 2
- resize char height so that plot area is the same distance from chart borders than before

I've provided a sample in which chart sizes are printed:
- before resizing
- after resizing
- after reloading the new chart

The values I've calculated for resizing and positioning seem correct.
But when we open the resized chart document, the Y positioning of the plot area is too big and the inner height is too low.

I have executed your code against the sample and have received the following output. Could you please confirm if you are concerned about the difference in highlighted values before reloading the chart from file and afterwards?

8.6.3.6
1.8.0_66
>>> INITIAL <<<
chart height (pixel): 150
plot area inner height: 880
plot area inner height (pixel): 33
plot area Y: 1147
plot area Y (pixel): 43
>>> RESIZED <<<
chart height (pixel): 1470
plot area inner height: 3682
plot area inner height (pixel): 1353
plot area Y: 117
plot area Y (pixel): 43
>>> RELOADED <<<
chart height (pixel): 1470
plot area inner height: 2852
plot area inner height (pixel): 1048
plot area Y: 1146
plot area Y (pixel): 421


centile:

NB: Please note that the javadoc is full of copy/paste errors in ChartShape and PlotArea.
This part of the API is not self-evident and a valid documentation could help ...
You could also add drawings and examples in it in order to simplify the support.

Sure, we will plan a complete review of JavaDocs in order to address any errors and for possible improvements/enhancements. We will keep you posted with updates in this regard.
babar.raza:
I have executed your code against the sample and have received the following output. Could you please confirm if you are concerned about the difference in highlighted values before reloading the chart from file and afterwards?


Yes, indeed.
We can see that the plotAreaY in the reloaded chart is the same as the initial one despite the chart shape growth, which can be observed visually (there is a gap between the title and the plot area).

Also, the plot area inner height has been reduced (but this is certainly due to automatic resizing due to the fact that the plot area height could not fit in the remaining bottom room because of the Y wrong positioning).

Hi Sébastien,


Thank you for the confirmation.

Please replace the statement chart.getPlotArea().setY(plotAreaYAfter) in RESIZING block with chart.getPlotArea().setInnerY(plotAreaYAfter) and execute the code again. The result would be as follow.

>>> INITIAL <<<
chart height (pixel): 150
plot area inner height: 880
plot area inner height (pixel): 33
plot area Y: 1147
plot area Y (pixel): 43
>>> RESIZED <<<
chart height (pixel): 1470
plot area inner height: 3682
plot area inner height (pixel): 1353
plot area Y: 117
plot area Y (pixel): 43

>>> RELOADED <<<
chart height (pixel): 1470
plot area inner height: 3682
plot area inner height (pixel): 1353
plot area Y: 114
plot area Y (pixel): 42

You will notice that the values of PlotArea Inner Height now correspond to the values before reloading the chart from spreadsheet, however, the values for PlotArea Y are still different (117 as compared to 114 & 43 as compared to 42). We have logged an investigative ticket (CELLSJAVA-41701) in our database and have requested the concerned member of the product team to further investigate the matter. As soon as we receive any updates in this regard, we will post here for your kind reference.

Hi,

Thanks for using Aspose.Cells.

This is to inform you that we have fixed your issue CELLSJAVA-41701 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

The issues you have found earlier (filed as CELLSJAVA-41701) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.