X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fannotation.html;h=31e00623eccc1665faed6eb9558f65aa3eeb1d35;hb=bf7d192b5aef6ea82e7e627d4cfcfca1cb978f23;hp=0e25fb75166d9f0d57a7bb68a55d94f061aa6947;hpb=20bb4e9d1e3da5bedaee7584a9e91aefd9e3a6d4;p=dygraphs.git
diff --git a/tests/annotation.html b/tests/annotation.html
index 0e25fb7..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',
@@ -99,7 +104,10 @@
shortText: 'P',
text: 'Parabola Annotation at same x-coord'
} );
- g.setAnnotations(annotations);
+
+ if (graph_initialized) {
+ g.setAnnotations(annotations);
+ }
function add() {
var x = last_ann + 2;