Commit f8594bd2 authored by olau@iola.dk's avatar olau@iola.dk

Allow null values in coordinates to have an affect on axis scaling

git-svn-id: https://flot.googlecode.com/svn/trunk@81 1e0a6537-2640-0410-bfb7-f154510ff394
parent da9023c1
......@@ -7,12 +7,12 @@ Consider a call to the plot function:
The placeholder is a jQuery object that the plot will be put into.
This placeholder needs to have its width and height set as explained
in the README. The plot will modify some properties of the placeholder
so it's recommended you simply pass in a div that you don't use for
anything else.
in the README (go read that now if you haven't, it's short). The plot
will modify some properties of the placeholder so it's recommended you
simply pass in a div that you don't use for anything else.
The format of the data is documented below, as is the available
options. The "plot" object returned has some members you can call.
options. The "plot" object returned has some methods you can call.
These are documented separately below.
Note that in general Flot gives no guarantees if you change any of the
......@@ -38,14 +38,14 @@ E.g.
Note that to simplify the internal logic in Flot both the x and y
values must be numbers, even if specifying time series (see below for
how to do this). This is a common problem because you might
accidentally retrieve data from the database and serialize them
directly to JSON without noticing the wrong type.
how to do this). This is a common problem because you might retrieve
data from the database and serialize them directly to JSON without
noticing the wrong type.
If a null is specified as a point or if one of the coordinates is null
or NaN or couldn't be converted to a number, the point is ignored. As
a special case, a null value for lines is interpreted as a line
segment end, i.e. the two points before and after the null value are
or couldn't be converted to a number, the point is ignored when
drawing. As a special case, a null value for lines is interpreted as a
line segment end, i.e. the point before and after the null value are
not connected.
The format of a single series object is as follows:
......
......@@ -241,11 +241,11 @@
}
function processData() {
var top_sentry = Number.POSITIVE_INFINITY,
bottom_sentry = Number.NEGATIVE_INFINITY;
var topSentry = Number.POSITIVE_INFINITY,
bottomSentry = Number.NEGATIVE_INFINITY;
xaxis.datamin = yaxis.datamin = x2axis.datamin = y2axis.datamin = top_sentry;
xaxis.datamax = yaxis.datamax = x2axis.datamax = y2axis.datamax = bottom_sentry;
xaxis.datamin = yaxis.datamin = x2axis.datamin = y2axis.datamin = topSentry;
xaxis.datamax = yaxis.datamax = x2axis.datamax = y2axis.datamax = bottomSentry;
xaxis.used = yaxis.used = x2axis.used = y2axis.used = false;
for (var i = 0; i < series.length; ++i) {
......@@ -253,6 +253,7 @@
axisx = series[i].xaxis,
axisy = series[i].yaxis;
axisx.used = axisy.used = true;
for (var j = 0; j < data.length; ++j) {
if (data[j] == null)
continue;
......@@ -260,27 +261,29 @@
var x = data[j][0], y = data[j][1];
// convert to number
if (x == null || y == null || isNaN(x = +x) || isNaN(y = +y)) {
data[j] = null; // mark this point as invalid
continue;
if (x != null && !isNaN(x = +x)) {
if (x < axisx.datamin)
axisx.datamin = x;
if (x > axisx.datamax)
axisx.datamax = x;
}
if (x < axisx.datamin)
axisx.datamin = x;
if (x > axisx.datamax)
axisx.datamax = x;
if (y < axisy.datamin)
axisy.datamin = y;
if (y > axisy.datamax)
axisy.datamax = y;
axisx.used = axisy.used = true;
if (y != null && !isNaN(y = +y)) {
if (y < axisy.datamin)
axisy.datamin = y;
if (y > axisy.datamax)
axisy.datamax = y;
}
if (x == null || y == null || isNaN(x) || isNaN(y))
data[j] = null; // mark this point as invalid
}
}
function setDefaultMinMax(axis) {
if (axis.datamin == top_sentry)
if (axis.datamin == topSentry)
axis.datamin = 0;
if (axis.datamax == bottom_sentry)
if (axis.datamax == bottomSentry)
axis.datamax = 1;
}
......
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