assertEquals(colors1, graph.getColors());
// extra colors are ignored until you add additional data series.
- var colors2 = [ "#aaa", "#bbb", "#ccc" ];
+ var colors2 = [ "#ddd", "#eee", "#fff" ];
graph.updateOptions({ colors: colors2 });
- assertEquals(colors1, graph.getColors());
+ assertEquals(["#ddd", "#eee"], graph.getColors());
graph.updateOptions({ file:
"X,Y1,Y2,Y3\n" +
graph.updateOptions({ colors: null, file: this.data });
assertEquals(defaultColors, graph.getColors());
}
+
+// Regression test for http://code.google.com/p/dygraphs/issues/detail?id=249
+// Verifies that setting 'legend: always' via update immediately shows the
+// legend.
+UpdateOptionsTestCase.prototype.testUpdateLegendAlways = function() {
+ var graphDiv = document.getElementById("graph");
+ var graph = new Dygraph(graphDiv, this.data, this.opts);
+
+ var legend = document.getElementsByClassName("dygraph-legend");
+ assertEquals(1, legend.length);
+ legend = legend[0];
+ assertEquals("", legend.innerHTML);
+
+ graph.updateOptions({legend: 'always'});
+
+ legend = document.getElementsByClassName("dygraph-legend");
+ assertEquals(1, legend.length);
+ legend = legend[0];
+ assertNotEquals(-1, legend.textContent.indexOf("Y1"));
+ assertNotEquals(-1, legend.textContent.indexOf("Y2"));
+};