Added support for skipping points outside the specified range when autoscaling

git-svn-id: https://flot.googlecode.com/svn/trunk@110 1e0a6537-2640-0410-bfb7-f154510ff394
pull/1/head
olau@iola.dk 18 years ago
parent 919b9c7541
commit 22eb1489eb

@ -166,6 +166,7 @@ Customizing the axes
min: null or number
max: null or number
autoscaleMargin: null or number
autoscaleSkipPointsOutside: boolean
labelWidth: null or number
labelHeight: null or number
@ -192,6 +193,12 @@ specified, the plot will furthermore extend the axis end-point to the
nearest whole tick. The default value is "null" for the x axis and
0.02 for the y axis which seems appropriate for most cases.
If you set a range on an axis with min/max and then set
"autoscaleSkipPointsOutside" to true, the autoscale algorithm will
skip points that are outside this range when computing the scale for
the other axis. Otherwise all points input to Flot are always
considered.
"labelWidth" and "labelHeight" specifies the maximum size of the tick
labels in pixels. They're useful in case you need to align several
plots.

@ -6,6 +6,9 @@ New features:
- Added support for disabling interactivity for specific data series
(request from Ronald Schouten and Steve Upton).
- Added support for having the autoscale algorithm skip points outside
an axis range (autoscaleSkipPointsOutside on an axis).
Bug fixes:

@ -31,6 +31,7 @@
min: null, // min. value to show, null means set automatically
max: null, // max. value to show, null means set automatically
autoscaleMargin: null, // margin in % to add if auto-setting min/max
autoscaleSkipPointsOutside: null,
ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks
tickFormatter: null, // fn: number -> string
labelWidth: null, // size of tick labels in pixels
@ -266,6 +267,9 @@
for (axis in axes) {
axes[axis].datamin = topSentry;
axes[axis].datamax = bottomSentry;
axes[axis].min = options[axis].min;
axes[axis].max = options[axis].max;
axes[axis].skipoutside = options[axis].autoscaleSkipPointsOutside;
axes[axis].used = false;
}
@ -280,7 +284,7 @@
mindelta = series[i].bars.align == "left" ? 0 : -series[i].bars.barWidth/2;
maxdelta = mindelta + series[i].bars.barWidth;
}
axisx.used = axisy.used = true;
for (var j = 0; j < data.length; ++j) {
if (data[j] == null)
@ -290,6 +294,12 @@
// convert to number
if (x != null && !isNaN(x = +x)) {
if (axisx.skipoutside &&
((axisx.min != null && x + mindelta < axisx.min) ||
(axisx.max != null && x + maxdelta > axisx.max))) {
continue;
}
if (x + mindelta < axisx.datamin)
axisx.datamin = x + mindelta;
if (x + maxdelta > axisx.datamax)
@ -297,6 +307,11 @@
}
if (y != null && !isNaN(y = +y)) {
if (axisy.skipoutside &&
((axisy.min != null && y < axisy.min) ||
(axisy.max != null && y > axisy.max)))
continue;
if (y < axisy.datamin)
axisy.datamin = y;
if (y > axisy.datamax)

Loading…
Cancel
Save