Run tests on Travis-CI.
[dygraphs.git] / tests / annotation.html
index 8f6b51d..6d477e2 100644 (file)
@@ -1,16 +1,16 @@
+<!DOCTYPE html>
 <html>
   <head>
     <title>demo</title>
-    <!--[if IE]>
-    <script type="text/javascript" src="excanvas.js"></script>
-    <![endif]-->
     <!--
     <script type="text/javascript" src="dygraph-combined.js"></script>
     -->
-    <script type="text/javascript" src="../strftime/strftime-min.js"></script>
-    <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script>
-    <script type="text/javascript" src="../dygraph-canvas.js"></script>
-    <script type="text/javascript" src="../dygraph.js"></script>
+    <!--
+    For production (minified) code, use:
+    <script type="text/javascript" src="dygraph-combined.js"></script>
+    -->
+    <script type="text/javascript" src="../dist/dygraph.js"></script>
+
     <style type="text/css">
     .annotation {
     }
@@ -22,7 +22,7 @@
     <input type="button" value="Add Annotation" onclick="add()" />
     <input type="button" value="Shove to bottom" onclick="bottom(this)" />
     <div id="events"> </div>
-    <div style="position:absolute; left:200px; top: 200px;" id="g"></div>
+    <div style="position:absolute; left:200px; top: 200px;" id="g_div"></div>
     <div style="position:absolute; left:700px; top: 200px;" id="list"></div>
 
     <script type="text/javascript">
         return "(" + ann.series + ", " + ann.x + ")";
       }
 
-      g = new DateGraph(
-              document.getElementById("g"),
+      annotations = [];
+      var graph_initialized = false;
+
+      g = new Dygraph(
+              document.getElementById("g_div"),
               function() {
                 var zp = function(x) { if (x < 10) return "0"+x; else return x; };
                 var r = "date,parabola,line,another line,sine wave\n";
                 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++) {
                     var name = nameAnnotation(ann[i]);
                     html += "<span id='" + name + "'>"
-                    html += name + ": " + ann[i].shortText + " -> ";
-                    html += ann[i].text + "</span><br/>";
+                    html += name + ": " + (ann[i].shortText || '(icon)')
+                    html += " -> " + ann[i].text + "</span><br/>";
                   }
                   document.getElementById("list").innerHTML = html;
-                },
+                }
               }
           );
 
       var last_ann = 0;
-      annotations = [];
       for (var x = 10; x < 15; x += 2) {
         annotations.push( {
           series: 'sine wave',
@@ -80,8 +89,8 @@
         series: 'another line',
         x: "20061013",
         icon: 'dollar.png',
-        iconWidth: 18,
-        iconHeight: 23,
+        width: 18,
+        height: 23,
         tickHeight: 4,
         text: 'Another one',
         cssClass: 'annotation',
           document.getElementById("events").innerHTML += "special handler<br/>";
         }
       } );
-      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;