From de7bf30ce92d287c2952011977c5911cda4eca46 Mon Sep 17 00:00:00 2001 From: Christian Theune Date: Fri, 3 Aug 2012 23:23:06 +0300 Subject: [PATCH] Synchronized auto-scaling w/ multiple charts You can pass "referenceSeries" as an option to a chart which causes this chart to use the referenced time series as the basis for its auto-scaling. --- smoothie.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/smoothie.js b/smoothie.js index 43f5739..e215652 100644 --- a/smoothie.js +++ b/smoothie.js @@ -44,6 +44,7 @@ function TimeSeries(options) { options.resetBounds = options.resetBounds || true; // Enable or disable the resetBounds timer this.options = options; this.data = []; + this.referenceSeries = options.referenceSeries || this; this.maxValue = Number.NaN; // The maximum value ever seen in this time series. this.minValue = Number.NaN; // The minimum value ever seen in this time series. @@ -56,6 +57,11 @@ function TimeSeries(options) { // Reset the min and max for this timeseries so the graph rescales itself TimeSeries.prototype.resetBounds = function() { + if (this.referenceSeries !== this) { + this.maxValue = this.referenceSeries.maxValue; + this.minValue = this.referenceSeries.minValue; + return + } this.maxValue = Number.NaN; this.minValue = Number.NaN; for (var i = 0; i < this.data.length; i++) {