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"));
+};
this.canvas_.getContext('2d').clearRect(0, 0, this.canvas_.width,
this.canvas_.height);
- if (is_initial_draw) {
- // Generate a static legend before any particular point is selected.
- this.setLegendHTML_();
- } else {
+ // Generate a static legend before any particular point is selected.
+ this.setLegendHTML_();
+
+ if (!is_initial_draw) {
if (clearSelection) {
if (typeof(this.selPoints_) !== 'undefined' && this.selPoints_.length) {
// We should select the point nearest the page x/y here, but it's easier