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,6 +211,43 @@ ...@@ -211,6 +211,43 @@
} }
} }
function setRange(axis, axisOptions) {
var min = axisOptions.min != null ? axisOptions.min : axis.datamin;
var max = axisOptions.max != null ? axisOptions.max : axis.datamax;
if (max - min == 0.0) {
// degenerate case
var widen;
if (max == 0.0)
widen = 1.0;
else
widen = 0.01;
min -= widen;
max += widen;
}
else {
// consider autoscaling
var margin = axisOptions.autoscaleMargin;
if (margin != null) {
if (axisOptions.min == null) {
min -= (max - min) * margin;
// make sure we don't go below zero if all values
// are positive
if (min < 0 && axis.datamin >= 0)
min = 0;
}
if (axisOptions.max == null) {
max += (max - min) * margin;
if (max > 0 && axis.datamax <= 0)
max = 0;
}
}
}
axis.min = min;
axis.max = max;
}
function setTickSize(axis, axisOptions) { function setTickSize(axis, axisOptions) {
var delta = (axis.max - axis.min) / axisOptions.noTicks; var delta = (axis.max - axis.min) / axisOptions.noTicks;
var maxDec = axisOptions.tickDecimals; var maxDec = axisOptions.tickDecimals;
...@@ -240,42 +277,6 @@ ...@@ -240,42 +277,6 @@
axis.tickDecimals = Math.max(0, (maxDec != null) ? maxDec : dec); 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) {
var widen;
if (max == 0.0)
widen = 1.0;
else
widen = 0.01;
min -= widen;
max += widen;
}
// consider autoscaling
var margin = axisOptions.autoscaleMargin;
if (margin != null) {
if (axisOptions.min == null) {
min -= (max - min) * margin;
// make sure we don't go below zero if all values
// are positive
if (min < 0 && axis.datamin >= 0)
min = 0;
}
if (axisOptions.max == null) {
max += (max - min) * margin;
if (max > 0 && axis.datamax <= 0)
max = 0;
}
}
axis.min = min;
axis.max = max;
}
function extendXRangeIfNeededByBar() { function extendXRangeIfNeededByBar() {
if (options.xaxis.max == null) { if (options.xaxis.max == null) {
// great, we're autoscaling, check if we might need a bump // 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