Use CSS for tests, gallery and docs
[dygraphs.git] / tests / linear-regression.html
index 6ccc94e..873e7ca 100644 (file)
@@ -1,13 +1,14 @@
+<!DOCTYPE html>
 <html>
   <head>
+    <link rel="stylesheet" href="../css/dygraph.css">
     <title>Linear Regression</title>
-    <!--[if IE]>
-    <script type="text/javascript" src="../excanvas.js"></script>
-    <![endif]-->
-    <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">
     body { max-width: 640 px; }
     </style>
     <div id="demodiv" style="width: 480px; height: 320px;"></div>
 
     <script type="text/javascript">
-      var data = "X,Y1,Y2\n";
+      var data = [];
       for (var i = 0; i < 120; i++) {
-        // data.push([i,
-        //            i / 5.0 + 10.0 * Math.sin(i / 3.0),
-        //            30.0 - i / 5.0 - 10.0 * Math.sin(i / 3.0 + 1.0)]);
-        data += i + "," + i + "/120," + (i*(120-i)) + "/" + (60*60) + "\n";
+        data.push([i,
+                   i / 5.0 + 10.0 * Math.sin(i / 3.0),
+                   30.0 - i / 5.0 - 10.0 * Math.sin(i / 3.0 + 1.0)]);
       }
 
       g = new Dygraph(
               document.getElementById("demodiv"),
               data,
               {
+                labels: ['X', 'Y1', 'Y2'],
                 underlayCallback: drawLines,
                 drawPoints: true,
-                strokeWidth: 0.0,
-                fractions: true,
-                errorBars: true
+                strokeWidth: 0.0
               }
           );
 
         g.updateOptions({});
       }
 
+      function toHex(rgb) {
+        return 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
+      }
+
       function drawLines(ctx, area, layout) {
         if (typeof(g) == 'undefined') return;  // won't be set on the initial draw.
 
           var x2 = range[1];
           var y2 = a * x2 + b;
 
-          // Scale up to percentages, rather than fractions.
-          y1 *= 100;
-          y2 *= 100;
-
           var p1 = g.toDomCoords(x1, y1);
           var p2 = g.toDomCoords(x2, y2);
 
-          var c = new RGBColor(g.getColors()[i - 1]);
+          var c = Dygraph.toRGB_(g.getColors()[i - 1]);
           c.r = Math.floor(255 - 0.5 * (255 - c.r));
           c.g = Math.floor(255 - 0.5 * (255 - c.g));
           c.b = Math.floor(255 - 0.5 * (255 - c.b));
-          var color = c.toHex();
+          var color = toHex(c);
           ctx.save();
           ctx.strokeStyle = color;
           ctx.lineWidth = 1.0;