X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fannotation.html;h=31e00623eccc1665faed6eb9558f65aa3eeb1d35;hb=77a1405a7dea7e9de770583598a50e5907e6b1a1;hp=31d87232c2d864726876fc388ea7e166958e9d41;hpb=bbfb84f2a5e0fbb5259fab16f0785a5806c5bf8d;p=dygraphs.git diff --git a/tests/annotation.html b/tests/annotation.html index 31d8723..31e0062 100644 --- a/tests/annotation.html +++ b/tests/annotation.html @@ -1,11 +1,7 @@ - demo - @@ -35,6 +31,9 @@ return "(" + ann.series + ", " + ann.x + ")"; } + annotations = []; + var graph_initialized = false; + g = new Dygraph( document.getElementById("g_div"), function() { @@ -55,7 +54,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 +76,6 @@ ); var last_ann = 0; - annotations = []; for (var x = 10; x < 15; x += 2) { annotations.push( { series: 'sine wave', @@ -93,7 +98,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;