jiezawsze / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

drawSeriesLines.plotLine interpolates linearly despite possible non-linear transforms #524

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The function plotLine in drawSeriesLines interpolates the intersection point of 
a line between a datapoint inside the visible graph area and outside with the 
edge of the frame linearly.

This is wrong, as the datapoints are at that stage already transformed. The 
interpolation must be done on the untransformed data, as the calculated 
intersection point is always wrong if the transform on one of the axes is 
non-linear.

This for example breaks power-law curves with just a handful of data points in 
a log-log plot. Those curves should be lines (and thus require only two 
datapoints, but the intersections are calculated completely wrong.

Original issue reported on code.google.com by dan...@schwen.de on 28 Apr 2011 at 10:10

GoogleCodeExporter commented 8 years ago
Hm, I may be wrong about the cause, I'm still trying to follow the code flow. 
However here is a minimal testcase:

http://schwen.de/wikisource/bugs/flot/flotbug.html

the red and green line should be exactly on top of each other. The red line is 
deviating up. This is wrong. Bot datasets contain a simple x^2 series, which 
should appear linear in a log-log plot.

Original comment by dan...@schwen.de on 28 Apr 2011 at 10:49

GoogleCodeExporter commented 8 years ago
Ha! It is just the opposite, you are linearly interpolating the non-linear 
original data, which in a log-log plot looks way worse than interpolating the 
transformed data!

Original comment by dan...@schwen.de on 28 Apr 2011 at 10:59

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This patch removes the manual clipping in plotLine and replaces it with a 
canvas clip path. This of course breaks excanvas for old Internet Explorer 
versions. 

The alternative is to convert the manual clipping to transformed coordinates. 
Not too hard either. I may try that too. 

Demo of the patch:
http://schwen.de/wikisource/bugs/flot/flotclip.html

Original comment by dan...@schwen.de on 29 Apr 2011 at 1:36

Attachments:

GoogleCodeExporter commented 8 years ago
Hi!

Okay, to sum up: the problem is that the clipping code is operating on the 
non-transformed data.

I'm afraid breaking excanvas compatibility is a not an option for Flot at this 
point.

There's another route I've been thinking about that I know other plot packages 
are doing, which is using the edge of the canvas to clip. This requires adding 
an extra canvas for the inside of the chart, but could potentially enable 
clipping of even harder stuff, like text.

Original comment by olau%iol...@gtempaccount.com on 9 May 2011 at 3:52

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 4 Jun 2012 at 9:36