From: Dan Vanderkam Date: Sat, 11 Sep 2010 16:44:33 +0000 (-0700) Subject: attach divs to points; respect clipping area X-Git-Tag: v1.0.0~670 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e6d5314821c8972d803e8600171d5733e01e669a;p=dygraphs.git attach divs to points; respect clipping area --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 1947ccd..b71044a 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -520,6 +520,10 @@ DygraphCanvasRenderer.prototype._renderAnnotations = function() { var points = this.layout.annotated_points; for (var i = 0; i < points.length; i++) { var p = points[i]; + if (p.canvasx < this.area.x || p.canvasx > this.area.x + this.area.w) { + continue; + } + var a = p.annotation; var tick_height = 6; if (a.hasOwnProperty("tickHeight")) { @@ -557,6 +561,7 @@ DygraphCanvasRenderer.prototype._renderAnnotations = function() { div.title = p.annotation.text; div.style.color = this.colors[p.name]; div.style.borderColor = this.colors[p.name]; + a.div = div; Dygraph.addEvent(div, 'click', bindEvt('clickHandler', 'annotationClickHandler', p, this)); diff --git a/tests/annotation.html b/tests/annotation.html index 2cecb9a..b87c291 100644 --- a/tests/annotation.html +++ b/tests/annotation.html @@ -16,22 +16,27 @@
-
-
+
+