Merge branch 'master' of git://github.com/danvk/dygraphs into highlight3
[dygraphs.git] / dygraph.js
index 735be8c..1d97bda 100644 (file)
@@ -461,14 +461,16 @@ Dygraph.prototype.attr_ = function(name, seriesName) {
 
   var sources = [];
   sources.push(this.attrs_);
-  if (this.user_attrs_) sources.push(this.user_attrs_);
-  if (this.user_attrs_ && seriesName) {
-    if (this.user_attrs_.hasOwnProperty(seriesName)) {
-      sources.push(this.user_attrs_[seriesName]);
-    }
-    if (seriesName === this.highlightSet_ &&
-        this.user_attrs_.hasOwnProperty('highlightSeriesOpts')) {
-      sources.push(this.user_attrs_['highlightSeriesOpts']);
+  if (this.user_attrs_) {
+    sources.push(this.user_attrs_);
+    if (seriesName) {
+      if (this.user_attrs_.hasOwnProperty(seriesName)) {
+        sources.push(this.user_attrs_[seriesName]);
+      }
+      if (seriesName === this.highlightSet_ &&
+          this.user_attrs_.hasOwnProperty('highlightSeriesOpts')) {
+        sources.push(this.user_attrs_['highlightSeriesOpts']);
+      }
     }
   }
 
@@ -1618,13 +1620,6 @@ Dygraph.prototype.mouseMove_ = function(event) {
   var canvasx = canvasCoords[0];
   var canvasy = canvasCoords[1];
 
-  var mouseoverCallback = this.attr_("mouseoverCallback");
-  if (mouseoverCallback) {
-    var highlightRow = this.idxToRow_(idx);
-    var ret = mouseoverCallback(this, event);
-    if (ret) return;
-  }
-
   var highlightSeriesOpts = this.attr_("highlightSeriesOpts");
   var selectionChanged = false;
   if (highlightSeriesOpts) {
@@ -1855,18 +1850,19 @@ Dygraph.prototype.animateSelection_ = function(direction) {
 
   var thisId = ++this.animateId;
   var that = this;
-  Dygraph.repeatAndCleanup(function(n) {
-        // ignore simultaneous animations
-        if (that.animateId != thisId) return;
-
-        that.fadeLevel += direction;
-        if (that.fadeLevel === 0) {
-          that.clearSelection();
-        } else {
-          that.updateSelection_(that.fadeLevel / totalSteps);
-        }
-      },
-      steps, millis, function() {});
+  Dygraph.repeatAndCleanup(
+    function(n) {
+      // ignore simultaneous animations
+      if (that.animateId != thisId) return;
+
+      that.fadeLevel += direction;
+      if (that.fadeLevel === 0) {
+        that.clearSelection();
+      } else {
+        that.updateSelection_(that.fadeLevel / totalSteps);
+      }
+    },
+    steps, millis, function() {});
 };
 
 /**
@@ -1894,8 +1890,6 @@ Dygraph.prototype.updateSelection_ = function(opt_animFraction) {
       ctx.fillRect(0, 0, this.width_, this.height_);
     }
     var setIdx = this.datasetIndexFromSetName_(this.highlightSet_);
-    var underlay = this.attr_('highlightUnderlay');
-    if (underlay) underlay(this, ctx, setIdx);
     this.plotter_._drawLine(ctx, setIdx);
   } else if (this.previousVerticalX_ >= 0) {
     // Determine the maximum highlight circle size.
@@ -1928,10 +1922,12 @@ Dygraph.prototype.updateSelection_ = function(opt_animFraction) {
       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_("drawHighlightPointCallback", 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();