From: Dan Vanderkam Date: Sat, 17 Mar 2012 18:09:39 +0000 (-0400) Subject: Fix error when labelsDiv=null (was affecting unboxed-spark test) X-Git-Tag: v1.0.0~309 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e0ff43a1c387a0ef9ee01ab52a61fbb698f413a5;p=dygraphs.git Fix error when labelsDiv=null (was affecting unboxed-spark test) --- 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;');