google / google-visualization-issues

288 stars 35 forks source link

default rendering of set of small negative values inconsistent with set of small positive values #2859

Open rgguy opened 4 years ago

rgguy commented 4 years ago

When plotting a set of small positive values on the y-axis, the default behavior of LineChart appears to be to identify a mean, determine the maximum and minimum offsets from that mean, and then choose max/min y-axis values that provide a visual buffer above and below the extreme values. Basically, vaxis.viewWindowMode:'pretty' behavior, and a very plausible default behavior for most users.

But when plotting the negatives of that same set of values, the default behavior appears to forcibly set the baseline to 0, which often then "compresses" the plotted data to a very small portion of the available chart area. Manually setting vaxis.viewWindowMode:'maximized' achieves the expected behavior, but vaxis.viewWindowMode:'pretty' produces the baseline-set-to-0 behavior, which is inconsistent with what occurs with positive values of identical magnitude.

This behavior seems to violate two principles: that "positive vs negative" should be treated as mirror images of each other; and "the principle of least surprise" argues that the current positive values behavior is correct default behavior while the default negative behavior is an unpleasant surprise. LineChartNegativeValues.html.txt

LineChartNegativeValuesDisplay
dlaliberte commented 4 years ago

Hi rgguy,

Looks like you have found a bug. The logic about whether to include the baseline is not properly adjusting for when the values are negative. This has very likely been a problem for a couple of years now, and I'm not sure how soon I will be able to get around to fixing this.

One possible workaround is that, if you don't care where the baseline is, you can set the vAxis.baseline option to null, in which case it should not be included either for positive or negative values.

t-voet commented 2 years ago

Setting the vAxis.baseline option to null will not help, but a non-empty string like 'none' does.