Add tests for new series option.
authorRobert Konigsberg <konigsberg@google.com>
Thu, 22 Nov 2012 17:02:24 +0000 (12:02 -0500)
committerRobert Konigsberg <konigsberg@google.com>
Thu, 22 Nov 2012 17:02:24 +0000 (12:02 -0500)
auto_tests/tests/per_series.js
tests/custom-circles.html
tests/isolated-points.html
tests/per-series.html
tests/two-axes-vr.html

index 4831ded..8f647cc 100644 (file)
@@ -1,9 +1,9 @@
 /**
- * @fileoverview FILL THIS IN
+ * @fileoverview Tests for per-series options.
  *
  * @author danvk@google.com (Dan Vanderkam)
  */
-var perSeriesTestCase = TestCase("per-series");
+var Tests for per-series options.
 
 perSeriesTestCase.prototype.setUp = function() {
   document.body.innerHTML = "<div id='graph'></div>";
@@ -48,3 +48,16 @@ perSeriesTestCase.prototype.testPerSeriesFill = function() {
   assertEquals([255,0,0,38], sampler.colorAtCoordinate(6.5, 0.5));
 };
 
+perSeriesTestCase.prototype.testOldStyleSeries = function() {
+  var opts = {
+    pointSize : 5
+    Y: { pointSize : 4 },
+  };
+  var data = "X,Y,Z\n1,0,0\n";
+  g = new Dygraph("Graph", data, opts);
+
+  assertEquals(5, g.getOption("pointSize"));
+  assertEquals(4, g.getOption("pointSize", "Y"));
+  assertEquals(5, g.getOption("pointSize", "Z"));
+};
+
index f2ef094..0e6d62f 100644 (file)
             drawPoints : true,
             pointSize : 5,
             highlightCircleSize: 8,
-            A : {
-              drawPointCallback : Dygraph.Circles.TRIANGLE,
-              drawHighlightPointCallback : Dygraph.Circles.TRIANGLE
-            },
-            B : {
-              drawPointCallback : Dygraph.Circles.HEXAGON,
-              drawHighlightPointCallback : Dygraph.Circles.HEXAGON
+            series : {
+              A : {
+                drawPointCallback : Dygraph.Circles.TRIANGLE,
+                drawHighlightPointCallback : Dygraph.Circles.TRIANGLE
+              },
+              B : {
+                drawPointCallback : Dygraph.Circles.HEXAGON,
+                drawHighlightPointCallback : Dygraph.Circles.HEXAGON
+              }
             }
         });
 
index f507fda..1c1da06 100644 (file)
       ],
       {
         labels: ["X", "S1", "S2" ],
-        S1: {
-          drawGapEdgePoints: true
+        series: {
+          S1: {
+            drawGapEdgePoints: true
+          }
         },
         pointSize: 4,
         showRoller: true
index 98501ac..84730b1 100644 (file)
@@ -18,6 +18,8 @@
     <div id="demodiv"></div>
     <h2>Chart with per-series properties with legend.</h2>
     <div id="demodiv2"></div>
+    <h2>First graph, using old-style series specification.</h2>
+    <div id="demodiv3"></div>
     <script type="text/javascript">
       data = function() {
         var zp = function(x) { if (x < 10) return "0"+x; else return x; };
               data,
               {
                 strokeWidth: 2,
+               series : {
+                  'parabola': {
+                    strokeWidth: 0.0,
+                    drawPoints: true,
+                    pointSize: 4,
+                    highlightCircleSize: 6
+                  },
+                  'line': {
+                    strokeWidth: 1.0,
+                    drawPoints: true,
+                    pointSize: 1.5
+                  },
+                  'sine wave': {
+                    strokeWidth: 3,
+                    highlightCircleSize: 10
+                  },
+                  'sine wave2': {
+                    strokePattern: [10, 2, 5, 2],
+                    strokeWidth: 2,
+                    highlightCircleSize: 3
+                  }
+                }
+              }
+          );
+      g2 = new Dygraph(
+              document.getElementById("demodiv2"),
+              data,
+              {
+                legend: 'always',
+                strokeWidth: 2,
                 'parabola': {
-                  strokeWidth: 0.0,
+                  strokePattern: null,
                   drawPoints: true,
                   pointSize: 4,
                   highlightCircleSize: 6
                 },
                 'line': {
+                  strokePattern: Dygraph.DASHED_LINE,
                   strokeWidth: 1.0,
                   drawPoints: true,
                   pointSize: 1.5
                 },
+                'another line': {
+                  strokePattern: [25, 5]
+                },
                 'sine wave': {
+                  strokePattern: Dygraph.DOTTED_LINE,
                   strokeWidth: 3,
                   highlightCircleSize: 10
                 },
                 'sine wave2': {
-                  strokePattern: [10, 2, 5, 2],
+                  strokePattern: Dygraph.DOT_DASH_LINE,
                   strokeWidth: 2,
                   highlightCircleSize: 3
                 }
               }
           );
-      g2 = new Dygraph(
-              document.getElementById("demodiv2"),
+      g3 = new Dygraph(
+              document.getElementById("demodiv3"),
               data,
               {
-                legend: 'always',
                 strokeWidth: 2,
                 'parabola': {
-                  strokePattern: null,
+                  strokeWidth: 0.0,
                   drawPoints: true,
                   pointSize: 4,
                   highlightCircleSize: 6
                 },
                 'line': {
-                  strokePattern: Dygraph.DASHED_LINE,
                   strokeWidth: 1.0,
                   drawPoints: true,
                   pointSize: 1.5
                 },
-                'another line': {
-                  strokePattern: [25, 5]
-                },
                 'sine wave': {
-                  strokePattern: Dygraph.DOTTED_LINE,
                   strokeWidth: 3,
                   highlightCircleSize: 10
                 },
                 'sine wave2': {
-                  strokePattern: Dygraph.DOT_DASH_LINE,
+                  strokePattern: [10, 2, 5, 2],
                   strokeWidth: 2,
                   highlightCircleSize: 3
                 }
index 5814435..0646b9a 100644 (file)
           data,
           {
             labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
-            'Y3': {
-              axis: {
+            series : {
+              'Y3': {
+                axis: {
+                }
+              },
+              'Y4': {
+                axis: 'Y3'  // use the same y-axis as series Y3
               }
             },
-            'Y4': {
-              axis: 'Y3'  // use the same y-axis as series Y3
-            },
             valueRange: [40, 70],
             axes: {
               y2: {
           data,
           {
             labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
-            'Y3': {
-              axis: {
+            series : {
+              'Y3': {
+                axis: {
+                }
+              },
+              'Y4': {
+                axis: 'Y3'  // use the same y-axis as series Y3
               }
             },
-            'Y4': {
-              axis: 'Y3'  // use the same y-axis as series Y3
-            },
             axes: {
               y: {
                 valueRange: [40, 80]
           data,
           {
             labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
-            'Y3': {
-              axis: {
+            series : {
+              'Y3': {
+                axis: {
+                }
+              },
+              'Y4': {
+                axis: 'Y3'  // use the same y-axis as series Y3
               }
             },
-            'Y4': {
-              axis: 'Y3'  // use the same y-axis as series Y3
-            },
             axes: {
               y: {
                 valueRange: [40, 80]