Commit db3a081d authored by Karl Quinsland's avatar Karl Quinsland

updated threshold plugin to work with 'above' operator

parent 355331fd
...@@ -7,7 +7,8 @@ The plugin supports these options: ...@@ -7,7 +7,8 @@ The plugin supports these options:
series: { series: {
threshold: { threshold: {
below: number below: number,
above: mumber,
color: colorspec color: colorspec
} }
} }
...@@ -22,10 +23,10 @@ It can also be applied to a single series, like this: ...@@ -22,10 +23,10 @@ It can also be applied to a single series, like this:
An array can be passed for multiple thresholding, like this: An array can be passed for multiple thresholding, like this:
threshold: [{ threshold: [{
below: number1 below: number1,
color: color1 color: color1
},{ },{
below: number2 above: number2,
color: color2 color: color2
}] }]
...@@ -48,7 +49,7 @@ You may need to check for this in hover events. ...@@ -48,7 +49,7 @@ You may need to check for this in hover events.
}; };
function init(plot) { function init(plot) {
function thresholdData(plot, s, datapoints, below, color) { function thresholdData(plot, s, datapoints, below, above, color) {
var ps = datapoints.pointsize, i, x, y, p, prevp, var ps = datapoints.pointsize, i, x, y, p, prevp,
thresholded = $.extend({}, s); // note: shallow copy thresholded = $.extend({}, s); // note: shallow copy
...@@ -71,7 +72,7 @@ You may need to check for this in hover events. ...@@ -71,7 +72,7 @@ You may need to check for this in hover events.
y = origpoints[i + 1]; y = origpoints[i + 1];
prevp = p; prevp = p;
if (y < below) if (y < below || y > above)
p = threspoints; p = threspoints;
else else
p = newpoints; p = newpoints;
...@@ -122,11 +123,11 @@ You may need to check for this in hover events. ...@@ -122,11 +123,11 @@ You may need to check for this in hover events.
}); });
$(s.threshold).each(function(i, th) { $(s.threshold).each(function(i, th) {
thresholdData(plot, s, datapoints, th.below, th.color); thresholdData(plot, s, datapoints, th.below, th.above, th.color);
}); });
} }
else { else {
thresholdData(plot, s, datapoints, s.threshold.below, s.threshold.color); thresholdData(plot, s, datapoints, s.threshold.below, s.threshold.above, s.threshold.color);
} }
} }
...@@ -137,6 +138,6 @@ You may need to check for this in hover events. ...@@ -137,6 +138,6 @@ You may need to check for this in hover events.
init: init, init: init,
options: options, options: options,
name: 'threshold', name: 'threshold',
version: '1.2' version: '1.3'
}); });
})(jQuery); })(jQuery);
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