X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fannotation.html;h=6191436bb787b67792ee1523dd49c13e5b783e85;hb=d3b990da77ec190c27faf0fb5c7a6a4034880c2f;hp=31d87232c2d864726876fc388ea7e166958e9d41;hpb=bbfb84f2a5e0fbb5259fab16f0785a5806c5bf8d;p=dygraphs.git diff --git a/tests/annotation.html b/tests/annotation.html index 31d8723..6191436 100644 --- a/tests/annotation.html +++ b/tests/annotation.html @@ -35,6 +35,9 @@ return "(" + ann.series + ", " + ann.x + ")"; } + annotations = []; + var graph_initialized = false; + g = new Dygraph( document.getElementById("g_div"), function() { @@ -55,7 +58,14 @@ showRoller: true, width: 480, height: 320, - drawCallback: function(g) { + drawCallback: function(g, is_initial) { + if (is_initial) { + graph_initialized = true; + if (annotations.length > 0) { + g.setAnnotations(annotations); + } + } + var ann = g.annotations(); var html = ""; for (var i = 0; i < ann.length; i++) { @@ -70,7 +80,6 @@ ); var last_ann = 0; - annotations = []; for (var x = 10; x < 15; x += 2) { annotations.push( { series: 'sine wave', @@ -93,7 +102,16 @@ document.getElementById("events").innerHTML += "special handler
"; } } ); - g.setAnnotations(annotations); + annotations.push( { + series: 'parabola', + x: '20061012', + shortText: 'P', + text: 'Parabola Annotation at same x-coord' + } ); + + if (graph_initialized) { + g.setAnnotations(annotations); + } function add() { var x = last_ann + 2;