Added an option to plot random points instead of just a sine wave.
authorAnthony Robledo <antrob@google.com>
Tue, 28 Jun 2011 19:45:53 +0000 (15:45 -0400)
committerDan Vanderkam <danvk@google.com>
Thu, 7 Jul 2011 21:03:50 +0000 (17:03 -0400)
tests/dygraph-many-points-benchmark.html

index b4f7471..3899552 100644 (file)
@@ -16,6 +16,9 @@
   <body>
     <p>Plot which can be easily generated with different numbers of points for
        benchmarking/profiling and improving performance of dygraphs.</p>    
+    <p>Data to plot:
+      <input type="radio" name="plot_group1" value="sine" onclick="clickedRadioButton(this);" checked> sinusoid function
+      <input type="radio" name="plot_group1" value="rand" onclick="clickedRadioButton(this);"> random points <br></p>
     <p>Number of points:
        <input type="text" id="num_points_input" size="20"></p>
     <p>Number of series:
@@ -35,6 +38,7 @@
 
     <script type="text/javascript">
       var plot;
+      var dataType = "sine";
 
       var durations = [];
       updatePlot = function() {
           var x = xmin + delta * i;
           var elem = [ x ];
           for (var j = 0; j < numSeries; j++) {
-            var y = Math.sin(x + (j * adj));
+            var y;
+            if (dataType == "rand") {
+              y = Math.random() * 2 - 1;
+            } else {
+              y = Math.sin(x + (j * adj));
+            }
             elem.push(y);
           }
           data[i] = elem;
               "completed in " + (end2 - start2) + " milliseconds.";
         }
       };
+      
+      clickedRadioButton = function(radiobutton) {
+        dataType = radiobutton.value;
+      };
+        
 
       document.getElementById('num_points_input').value = '100';
       document.getElementById('num_series_input').value = '1';