s/RGBColor/RGBColorParser in the tests directory.
[dygraphs.git] / tests / linear-regression-addseries.html
index 530cea3..5e79860 100644 (file)
@@ -1,13 +1,17 @@
+<!DOCTYPE html>
 <html>
   <head>
+    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
     <title>Linear Regression</title>
     <!--[if IE]>
-    <script type="text/javascript" src="excanvas.js"></script>
+    <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="../dygraph-dev.js"></script>
+
     <style type="text/css">
     body { max-width: 640 px; }
     </style>
 
           var y = data[i][series];
           if (y == null) continue;
+          if (y.length == 2) {
+            // using fractions
+            y = y[0] / y[1];
+          }
 
           num++;
           sum_x += x;
@@ -73,7 +81,7 @@
         var b = (sum_y - a * sum_x) / num;
 
         coeffs[series] = [b, a];
-        if (console) {
+        if (typeof(console) != 'undefined') {
           console.log("coeffs(" + series + "): [" + b + ", " + a + "]");
         }
 
         for (var i = 0; i < labels.length; i++) {
           new_labels.push(labels[i]);
           if (i) new_colors.push(orig_colors[i - 1]);
-          new_opts[new_colors.length] = null;
           if (coeffs[i]) {
             // Darken the series by 50% to generate its regression.
-            new_labels.push(labels[i] + " Regression");
-            var c = new RGBColor(orig_colors[i - 1]);
+            var label = labels[i] + " Regression";
+            new_labels.push(label);
+            var c = new RGBColorParser(orig_colors[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));
             new_colors.push(c.toHex());
-            new_opts[new_colors.length] = {
+            new_opts[label] = {
               drawPoints: false,
               strokeWidth: 1.0
             };