Bug 136963 - chart upper Y bound is 1.2 when real range upper bound is 1
Summary: chart upper Y bound is 1.2 when real range upper bound is 1
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Chart (show other bugs)
Version:
(earliest affected)
6.2.8.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-23 01:52 UTC by Mark
Modified: 2021-01-09 02:18 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
The maximum on the chart isn't the true maximum value. (109.09 KB, image/jpeg)
2020-10-18 00:12 UTC, Mark
Details
Percent-stacked chart, max is correct at 100% (107.94 KB, image/jpeg)
2021-01-07 01:37 UTC, Mark
Details
3D look, chart max is 1 which is correct (112.91 KB, image/jpeg)
2021-01-07 01:38 UTC, Mark
Details
Percent-stacked, 3D look, max is 1 which is correct, also looks very similar to previous attachment (122.06 KB, image/jpeg)
2021-01-07 01:40 UTC, Mark
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark 2020-09-23 01:52:43 UTC
Description:
I'm plotting a series of values, scaled against their maximum. For example, the cell D2 contains "=B2/MAX($B$2:$B$27)", and the same repeated through D3:D27. The adjusted cell reference is B2, changed to B3-B27.

The important point is that no cell value in column D is greater than 1.

But if I try to plot column D on a chart, the upper bound of the chart is 1.2. No value in column D is greater than 1.

Why is the chart-bounding algorithm adding that extra space?

Steps to Reproduce:
1. Start a new spreadsheet.
2. In A1, enter "0", and in A2, enter "1". Select these two cells.
3. From the menu: "Insert"/"Chart..."
4. A dialog opens up, pertaining to the chart that's already added to the spreadsheet. It's a column chart. Move the dialog out of the way, so you can see the chart.

Actual Results:
The chart's maximum Y-value is 1.2, even though the actual maximum value in the data range is 1.

Expected Results:
The maximum Y-value on the chart should be 1, not something larger.


Reproducible: Always


User Profile Reset: No



Additional Info:
Slackware-current. I can confirm this on both 6.2.8.2 and 7.0.1 versions of LibreOffice.
Comment 1 Mark 2020-10-18 00:12:32 UTC
Created attachment 166476 [details]
The maximum on the chart isn't the true maximum value.

This screenshot was done following the "steps to reproduce" I outlined above.

LibreOffice version: 7.0.2.2
Comment 2 Leyan 2021-01-06 08:45:38 UTC
This is as designed. The automated axis configuration leaves a buffer around the value so that it is not too close to the boundaries of the chart. If you want to remove this buffer, you have to manually configure the axis minimum and maximum.
Comment 3 Mark 2021-01-07 01:35:16 UTC
I would be very interested to read the design document, or the online discussion, about such a visual buffer. And as a counterpoint, the same two values (in the instructions to reproduce) can be plotted as a "percent stacked" chart, with no visual buffer, and it's just as effective. It's the 3rd type of vertical bar chart, in the same dialog.

And, checking the "3D Look" box, with the regular vertical bar chart style, renders a 3D chart, with the chart maximum at 1, not 1.2. In fact, the 3D vertical bar and 3D stacked percentage charts look nearly identical, the only difference being the vertical axis values ("1" vs. "100%") and chart rendering adjustments related to the same text.

I will attach screenshots to demonstrate all these.
Comment 4 Mark 2021-01-07 01:37:16 UTC
Created attachment 168731 [details]
Percent-stacked chart, max is correct at 100%
Comment 5 Mark 2021-01-07 01:38:34 UTC
Created attachment 168732 [details]
3D look, chart max is 1 which is correct
Comment 6 Mark 2021-01-07 01:40:09 UTC
Created attachment 168733 [details]
Percent-stacked, 3D look, max is 1 which is correct, also looks very similar to previous attachment
Comment 7 Leyan 2021-01-07 22:13:37 UTC
The best way if you want to understand better what is going on is to look at the code: https://github.com/LibreOffice/core/blob/90cc24d4728dc94a30865d3b3af9409d5967b45a/chart2/source/view/axes/ScaleAutomatism.cxx#L923

You can see that the additional space is mentioned in the comment, it is explicitly calculated and not a side effect or a bug. When starting from 0, if the max value is more that the largest tick * 20/21 (so "too close" to the top), another gradation is added. In your example, if the largest value is more than 20/21=0.9539095... then the maximum will be 1.2 and not 1.

It has been like this since at least 2007 (code history is more difficult to get before that).
Comment 8 Mark 2021-01-09 02:18:37 UTC
Thanks for your quick reply.

So this behavior is at least 13 years old. I've explored further with miscellaneous small values in A1 and B1. I'm guessing that I've never created a chart with sufficiently small values to expose it.

As much as I'd like to consider some enhancement(s) for calculating the default min/max chart ranges, the user can already override the defaults with explicitly stated ranges, as you said. Therefore, I'm marking as WONTFIX since it's nothing that needs to be fixed.