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

Open
dnschnur opened this Issue Sep 28, 2012 · 4 comments

Comments

Projects
None yet
1 participant
Owner

dnschnur commented Sep 28, 2012

Original author: dan...@schwen.de (April 28, 2011 22:10:14)

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: http://code.google.com/p/flot/issues/detail?id=524

Owner

dnschnur commented Sep 28, 2012

From dan...@schwen.de on April 28, 2011 22:49:32
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.

Owner

dnschnur commented Sep 28, 2012

From dan...@schwen.de on April 28, 2011 22:59:11
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!

Owner

dnschnur commented Sep 28, 2012

From dan...@schwen.de on April 29, 2011 01:36:17
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

Owner

dnschnur commented Sep 28, 2012

From olau%iol...@gtempaccount.com on May 09, 2011 15:52:07
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment