From 1eb2feb3ea1d2e6d87e15529b66283474f1458d8 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sat, 19 Mar 2011 12:46:52 -0400 Subject: [PATCH] fix error when no series are visible --- dygraph.js | 14 ++++++++++++++ tests/no-visibility.html | 31 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/no-visibility.html diff --git a/dygraph.js b/dygraph.js index 5030123..64f4c18 100644 --- a/dygraph.js +++ b/dygraph.js @@ -2635,6 +2635,20 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { seriesForAxis[idx].push(series); } + // If no series are defined or visible then fill in some reasonable defaults. + if (seriesForAxis.length == 0) { + var axis = this.axes_[0]; + axis.computedValueRange = [0, 1]; + var ret = + Dygraph.numericTicks(axis.computedValueRange[0], + axis.computedValueRange[1], + this, + axis); + axis.ticks = ret.ticks; + this.numYDigits_ = ret.numDigits; + return; + } + // Compute extreme values, a span and tick marks for each axis. for (var i = 0; i < this.axes_.length; i++) { var axis = this.axes_[i]; diff --git a/tests/no-visibility.html b/tests/no-visibility.html new file mode 100644 index 0000000..5fcfd5b --- /dev/null +++ b/tests/no-visibility.html @@ -0,0 +1,31 @@ + + + no-visibility + + + + + + + + +

No visible series

+

This test verifies that a chart will still draw without any JS errors + when no series are visible.

+
+ + + + + -- 2.7.4