Commit 71a276d9 authored by olau@iola.dk's avatar olau@iola.dk

Fixed a newly introduced bug in dealing with data where min = max

git-svn-id: https://flot.googlecode.com/svn/trunk@40 1e0a6537-2640-0410-bfb7-f154510ff394
parent 8cf42618
......@@ -211,41 +211,12 @@
}
}
function setTickSize(axis, axisOptions) {
var delta = (axis.max - axis.min) / axisOptions.noTicks;
var maxDec = axisOptions.tickDecimals;
var dec = -Math.floor(Math.log(delta) / Math.LN10);
if (maxDec != null && dec > maxDec)
dec = maxDec;
var magn = Math.pow(10, -dec);
var norm = delta / magn; // norm is between 1.0 and 10.0
var tickSize = 1;
if (norm < 1.5)
tickSize = 1;
else if (norm < 3) {
tickSize = 2;
// special case for 2.5, requires an extra decimal
if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) {
tickSize = 2.5;
++dec;
}
}
else if (norm < 7.5)
tickSize = 5;
else
tickSize = 10;
axis.tickSize = tickSize * magn;
axis.tickDecimals = Math.max(0, (maxDec != null) ? maxDec : dec);
}
function setRange(axis, axisOptions) {
var min = axisOptions.min != null ? axisOptions.min : axis.datamin;
var max = axisOptions.max != null ? axisOptions.max : axis.datamax;
// check degenerate case
if (max - min == 0.0) {
// degenerate case
var widen;
if (max == 0.0)
widen = 1.0;
......@@ -255,7 +226,7 @@
min -= widen;
max += widen;
}
else {
// consider autoscaling
var margin = axisOptions.autoscaleMargin;
if (margin != null) {
......@@ -272,10 +243,40 @@
max = 0;
}
}
}
axis.min = min;
axis.max = max;
}
function setTickSize(axis, axisOptions) {
var delta = (axis.max - axis.min) / axisOptions.noTicks;
var maxDec = axisOptions.tickDecimals;
var dec = -Math.floor(Math.log(delta) / Math.LN10);
if (maxDec != null && dec > maxDec)
dec = maxDec;
var magn = Math.pow(10, -dec);
var norm = delta / magn; // norm is between 1.0 and 10.0
var tickSize = 1;
if (norm < 1.5)
tickSize = 1;
else if (norm < 3) {
tickSize = 2;
// special case for 2.5, requires an extra decimal
if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) {
tickSize = 2.5;
++dec;
}
}
else if (norm < 7.5)
tickSize = 5;
else
tickSize = 10;
axis.tickSize = tickSize * magn;
axis.tickDecimals = Math.max(0, (maxDec != null) ? maxDec : dec);
}
function extendXRangeIfNeededByBar() {
if (options.xaxis.max == null) {
// great, we're autoscaling, check if we might need a bump
......
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