From e6d5314821c8972d803e8600171d5733e01e669a Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sat, 11 Sep 2010 09:44:33 -0700 Subject: [PATCH] attach divs to points; respect clipping area --- dygraph-canvas.js | 5 +++++ tests/annotation.html | 38 +++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) 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 @@
-
-
+
+
-- 2.7.4