X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fannotation.html;h=31e00623eccc1665faed6eb9558f65aa3eeb1d35;hb=c987f643c1a9c9af5ab0a7c05268dc9ca16ac00a;hp=31d87232c2d864726876fc388ea7e166958e9d41;hpb=7e5ddc9488079169a4311f870727043b5216a81e;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;