From e0ff43a1c387a0ef9ee01ab52a61fbb698f413a5 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sat, 17 Mar 2012 14:09:39 -0400 Subject: [PATCH] Fix error when labelsDiv=null (was affecting unboxed-spark test) --- auto_tests/tests/pathological_cases.js | 13 +++++++++++++ dygraph.js | 2 ++ 2 files changed, 15 insertions(+) diff --git a/auto_tests/tests/pathological_cases.js b/auto_tests/tests/pathological_cases.js index c134b5f..21ff30a 100644 --- a/auto_tests/tests/pathological_cases.js +++ b/auto_tests/tests/pathological_cases.js @@ -35,3 +35,16 @@ pathologicalCasesTestCase.prototype.testOnePoint = function() { var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, opts); }; + +pathologicalCasesTestCase.prototype.testNullLegend = function() { + var opts = { + width: 480, + height: 320, + labelsDiv: null + }; + var data = "X,Y\n" + + "1,2\n"; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, data, opts); +}; diff --git a/dygraph.js b/dygraph.js index 79b53a9..045c394 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1842,6 +1842,8 @@ Dygraph.prototype.generateLegendHTML_ = function(x, sel_points, oneEmWidth) { */ Dygraph.prototype.setLegendHTML_ = function(x, sel_points) { var labelsDiv = this.attr_("labelsDiv"); + if (!labelsDiv) return; + var sizeSpan = document.createElement('span'); // Calculates the width of 1em in pixels for the legend. sizeSpan.setAttribute('style', 'margin: 0; padding: 0 0 0 1em; border: 0;'); -- 2.7.4