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:
- Fix bug with backwards compatibility for shadowSize = 0 (report and
suggested fix by aspinak).
- 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
......
......@@ -771,11 +771,17 @@
var s, m, t = axis.options.transform || identity,
it = axis.options.inverseTransform;
if (axis.direction == "x") {
// precompute how much the axis is scaling a point
// in canvas space
s = axis.scale = plotWidth / (t(axis.max) - t(axis.min));
m = t(axis.min);
if (axis.direction == "x") {
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
if (t == identity) // slight optimization
......@@ -788,20 +794,6 @@
else
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) {
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