X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=f03defca54ee462e9d555ce556babe391c79ae35;hb=78e58af463c6b5a09d85d6014bbdba0b3d8a605a;hp=ff9fbfaa91694db51a2e446d629ee23078e72500;hpb=94ea5744c9541f9c91ee2d150d06024e430c967e;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index ff9fbfa..f03defc 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1655,10 +1655,12 @@ Dygraph.prototype.updateSelection_ = function() { if (!Dygraph.isOK(pt.canvasy)) continue; var circleSize = this.attr_('highlightCircleSize', pt.name); - ctx.beginPath(); - ctx.fillStyle = this.plotter_.colors[pt.name]; - ctx.arc(canvasx, pt.canvasy, circleSize, 0, 2 * Math.PI, false); - ctx.fill(); + var callback = this.attr_("drawHighlightCallback", pt.name); + if (!callback) { + callback = Dygraph.Circles.DEFAULT; + } + callback(this.g, pt.name, ctx, canvasx, pt.canvasy, + this.plotter_.colors[pt.name], circleSize); } ctx.restore(); @@ -2051,10 +2053,10 @@ Dygraph.prototype.renderGraph_ = function(is_initial_draw, clearSelection) { 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 @@ -2654,9 +2656,9 @@ Dygraph.prototype.parseCSV_ = function(data) { this.parseFloat_(vals[1], i, line), this.parseFloat_(vals[2], i, line) ]; } else { - this.warning('When using customBars, values must be either blank ' + - 'or "low;center;high" tuples (got "' + val + - '" on line ' + (1+i)); + this.warn('When using customBars, values must be either blank ' + + 'or "low;center;high" tuples (got "' + val + + '" on line ' + (1+i)); } } } @@ -2897,21 +2899,25 @@ Dygraph.prototype.parseDataTable_ = function(data) { * @private */ Dygraph.prototype.start_ = function() { - if (typeof this.file_ == 'function') { - // CSV string. Pretend we got it via XHR. - this.loadedEvent_(this.file_()); - } else if (Dygraph.isArrayLike(this.file_)) { - this.rawData_ = this.parseArray_(this.file_); + var data = this.file_; + + // Functions can return references of all other types. + if (typeof data == 'function') { + data = data(); + } + + if (Dygraph.isArrayLike(data)) { + this.rawData_ = this.parseArray_(data); this.predraw_(); - } else if (typeof this.file_ == 'object' && - typeof this.file_.getColumnRange == 'function') { + } else if (typeof data == 'object' && + typeof data.getColumnRange == 'function') { // must be a DataTable from gviz. - this.parseDataTable_(this.file_); + this.parseDataTable_(data); this.predraw_(); - } else if (typeof this.file_ == 'string') { + } else if (typeof data == 'string') { // Heuristic: a newline means it's CSV data. Otherwise it's an URL. - if (this.file_.indexOf('\n') >= 0) { - this.loadedEvent_(this.file_); + if (data.indexOf('\n') >= 0) { + this.loadedEvent_(data); } else { var req = new XMLHttpRequest(); var caller = this; @@ -2924,11 +2930,11 @@ Dygraph.prototype.start_ = function() { } }; - req.open("GET", this.file_, true); + req.open("GET", data, true); req.send(null); } } else { - this.error("Unknown data format: " + (typeof this.file_)); + this.error("Unknown data format: " + (typeof data)); } };