Commit 6e99181b authored by olau@iola.dk's avatar olau@iola.dk

Simplify transformation helper function slightly and fix issue 263

that prevented inverse transforms from working correctly.


git-svn-id: https://flot.googlecode.com/svn/trunk@303 1e0a6537-2640-0410-bfb7-f154510ff394
parent 47821c71
...@@ -136,6 +136,8 @@ Bug fixes: ...@@ -136,6 +136,8 @@ Bug fixes:
- Fix bug with backwards compatibility for shadowSize = 0 (report and - Fix bug with backwards compatibility for shadowSize = 0 (report and
suggested fix by aspinak). suggested fix by aspinak).
- Adapt examples to skip loading excanvas (fix by Ryley Breiddal). - Adapt examples to skip loading excanvas (fix by Ryley Breiddal).
- Fix bug that prevent a simple f(x) = -x transform from working
correctly (fix by Mike, issue 263).
Flot 0.6 Flot 0.6
......
...@@ -771,11 +771,17 @@ ...@@ -771,11 +771,17 @@
var s, m, t = axis.options.transform || identity, var s, m, t = axis.options.transform || identity,
it = axis.options.inverseTransform; it = axis.options.inverseTransform;
if (axis.direction == "x") {
// precompute how much the axis is scaling a point // precompute how much the axis is scaling a point
// in canvas space // in canvas space
s = axis.scale = plotWidth / (t(axis.max) - t(axis.min)); if (axis.direction == "x") {
m = t(axis.min); s = axis.scale = plotWidth / Math.abs(t(axis.max) - t(axis.min));
m = Math.min(t(axis.max), t(axis.min));
}
else {
s = axis.scale = plotHeight / Math.abs(t(axis.max) - t(axis.min));
s = -s;
m = Math.max(t(axis.max), t(axis.min));
}
// data point to canvas coordinate // data point to canvas coordinate
if (t == identity) // slight optimization if (t == identity) // slight optimization
...@@ -788,20 +794,6 @@ ...@@ -788,20 +794,6 @@
else else
axis.c2p = function (c) { return it(m + c / s); }; axis.c2p = function (c) { return it(m + c / s); };
} }
else {
s = axis.scale = plotHeight / (t(axis.max) - t(axis.min));
m = t(axis.max);
if (t == identity)
axis.p2c = function (p) { return (m - p) * s; };
else
axis.p2c = function (p) { return (m - t(p)) * s; };
if (!it)
axis.c2p = function (c) { return m - c / s; };
else
axis.c2p = function (c) { return it(m - c / s); };
}
}
function measureTickLabels(axis) { function measureTickLabels(axis) {
var opts = axis.options, i, ticks = axis.ticks || [], labels = [], var opts = axis.options, i, ticks = axis.ticks || [], labels = [],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment