X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=aea8830a3f02f10591f98b588acc2bd654d32e35;hb=f8540c66c5b87d5e88d31a800dc7af237bf01213;hp=99fdf3bba89df1f783242c4b8fb82eaa3bc3eab0;hpb=f417e3d384d1a03a38ce57a759c37b2de8eda937;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index 99fdf3b..aea8830 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1063,8 +1063,10 @@ Dygraph.prototype.createMouseEventElement_ = function() { * @private */ Dygraph.prototype.setColors_ = function() { - var num = this.attr_("labels").length - 1; + var labels = this.getLabels(); + var num = labels.length - 1; this.colors_ = []; + this.colorsMap_ = {}; var colors = this.attr_('colors'); var i; if (!colors) { @@ -1076,13 +1078,16 @@ Dygraph.prototype.setColors_ = function() { // alternate colors for high contrast. var idx = i % 2 ? Math.ceil(i / 2) : (half + i / 2); var hue = (1.0 * idx/ (1 + num)); - this.colors_.push(Dygraph.hsvToRGB(hue, sat, val)); + var colorStr = Dygraph.hsvToRGB(hue, sat, val); + this.colors_.push(colorStr); + this.colorsMap_[labels[i]] = colorStr; } } else { for (i = 0; i < num; i++) { if (!this.visibility()[i]) continue; var colorStr = colors[i % colors.length]; this.colors_.push(colorStr); + this.colorsMap_[labels[1 + i]] = colorStr; } } @@ -2103,7 +2108,7 @@ Dygraph.prototype.predraw_ = function() { // Create a new plotter. if (this.plotter_) { - this.cascadeEvents_('clear'); + this.cascadeEvents_('clearChart'); this.plotter_.clear(); } this.plotter_ = new DygraphCanvasRenderer(this, @@ -2333,7 +2338,7 @@ Dygraph.prototype.drawGraph_ = function() { * @private */ Dygraph.prototype.renderGraph_ = function(is_initial_draw) { - this.cascadeEvents_('clear'); + this.cascadeEvents_('clearChart'); this.plotter_.clear(); this.plotter_.render(); @@ -2349,7 +2354,10 @@ Dygraph.prototype.renderGraph_ = function(is_initial_draw) { this.rangeSelector_.renderInteractiveLayer(); } - this.cascadeEvents_('drawChart'); + this.cascadeEvents_('drawChart', { + canvas: this.hidden_, + drawingContext: this.hidden_ctx_, + }); if (this.attr_("drawCallback") !== null) { this.attr_("drawCallback")(this, is_initial_draw); } @@ -3496,6 +3504,7 @@ Dygraph.prototype.datasetIndexFromSetName_ = function(name) { * called once -- all calls after the first will return immediately. */ Dygraph.addAnnotationRule = function() { + // TODO(danvk): move this function into plugins/annotations.js? if (Dygraph.addedAnnotationCSS) return; var rule = "border: 1px solid black; " +