google / google-visualization-issues

288 stars 35 forks source link

Bug: curveType : function should not have impact on scale #1180

Open orwant opened 9 years ago

orwant commented 9 years ago
What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.
1. create a chart with three values from high to low then high again
2.all value must be positive, the middle one is zero
3.then 'function' actually smooth values below zero to draw the curve, and the scale
goes negative

What component is this issue related to (PieChart, LineChart, DataTable,
Query, etc)?
LineChart

Are you using the test environment (version 1.1)?
NO

What operating system and browser are you using?
Safari on Mac OS X

*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

Original issue reported on code.google.com by ybizeul on 2013-03-29 15:32:32

orwant commented 9 years ago
Is this what you were talking about? Because this seems working just fine to me.

cheers

http://jsfiddle.net/rokakoma/vjUjp/

Original issue reported on code.google.com by rokakomma on 2013-05-05 20:39:04

orwant commented 9 years ago
Yes, but in your example, there is no reason to interpolate a negative value since the
minimum is given already.
Change the values in your sample to :
          data.addRow([1, 10]);
          data.addRow([2, 1]);
          data.addRow([3, 1]);
          data.addRow([4, 10]);

And you'll see what I mean. In that situation, I'd rather the minimum scale given to
be respected

Original issue reported on code.google.com by ybizeul on 2013-05-06 03:13:45

orwant commented 9 years ago
You can even slightly change your sample to that :
          data.addRow([1, 10]);
          data.addRow([2, 0]);
          data.addRow([2.9, 10]);

And what I describe happens as well

Original issue reported on code.google.com by ybizeul on 2013-05-06 03:16:09

orwant commented 9 years ago
It still seems okay for me
Spline Interpolation is working like this

If you try http://www.akiti.ca/CubicSpline.html and you enter:
1 10
2 1
3 1
4 10

and you ask for the value at 2.5 it will result -0.125

Also with the other values
1 10
2 0
3 2.9

and you ask for 2.5 it will result -0.16  (which is different from google chart's result
actually, but still negative)

There are many kinds of interpolation, the most commonly used is cubic spline, but
there are more simpler versions, just take a look at this: http://www.math.uiowa.edu/ftp/atkinson/ENA_Materials/Overheads/sec_4-3.pdf

Also here is a 3 point example at WIKI, where the results k1..k3 are the first derivatives
of the curve, since k2 is negative and the middle point is (0.0) it clearly shows that
the lowest point of the curve will be right and lower from (0,0).

All-in-all I think this is just working fine actually.

Original issue reported on code.google.com by rokakomma on 2013-05-06 09:38:26

orwant commented 9 years ago
Ohh, I forgot the WIKI link: http://en.wikipedia.org/wiki/Spline_interpolation

Original issue reported on code.google.com by rokakomma on 2013-05-06 09:41:14

orwant commented 9 years ago
I do not discuss the result of the interpolation itself. But if I say my graph has a
lower limit of 0, it should respect that and "crop" the curve and not change the scale
to fit the graph

Original issue reported on code.google.com by ybizeul on 2013-05-06 10:35:35

orwant commented 9 years ago
It's also documented that the graph changes scale if the values exceed the defined interval.
That's also a normal function, and it has nothing to do with the curveType itself.

Forcing the graph to "crop" the curve is a legitim need though, and should work the
same way as rangefilter "crop" haxis. I suggest post it as a feature request, since
it seems rather a feature to me, than a bugfix.

cheers

Original issue reported on code.google.com by rokakomma on 2013-05-06 11:23:47

orwant commented 9 years ago
It has to do with the curveType in a sense that without it, scale stays at 0, and with
"function" it widens to minus something.
Thanks for your inputs, I'll fill a feature request right away ! Charts looks really
nice when smoothed, I'd like to use that in my situation :-)

Original issue reported on code.google.com by ybizeul on 2013-05-06 12:51:13

mikila85 commented 7 years ago

what about this?

dlaliberte commented 7 years ago

Yes, we need some new options for how to smooth the curve. In some cases, you might want the curve to go through each point parallel to the domain axis, and stay between adjacent points on the range axis. This probably ought to be the default for 'function', since it would behave more like a function. Other times, you might want minimum curvature change through a point and between the adjacent two points (e.g. when drawing a circle). Controlling the curve before the first and after the last point is another interesting problem.