Merge pull request #457 from danvk/fix-log
authorDan Vanderkam <danvdk@gmail.com>
Wed, 5 Nov 2014 03:50:34 +0000 (22:50 -0500)
committerDan Vanderkam <danvdk@gmail.com>
Wed, 5 Nov 2014 03:50:34 +0000 (22:50 -0500)
Remove Dygraph.log and all its kin

plugins/range-selector.js
tests/range-selector.html

index 8842546..717f850 100644 (file)
@@ -594,6 +594,13 @@ rangeSelector.prototype.drawMiniPlot_ = function() {
     var dataPoint = combinedSeriesData.data[i];
     var x = ((dataPoint[0] !== null) ? ((dataPoint[0] - xExtremes[0])*xFact) : NaN);
     var y = ((dataPoint[1] !== null) ? (canvasHeight - (dataPoint[1] - combinedSeriesData.yMin)*yFact) : NaN);
+
+    // Skip points that don't change the x-value. Overly fine-grained points
+    // can cause major slowdowns with the ctx.fill() call below.
+    if (!stepPlot && prevX !== null && Math.round(x) == Math.round(prevX)) {
+      continue;
+    }
+
     if (isFinite(x) && isFinite(y)) {
       if(prevX === null) {
         ctx.lineTo(x, canvasHeight);
index 52792dd..8527b5c 100644 (file)
@@ -38,6 +38,9 @@
       Demo of range selecor without the chart. (interesting if multiple charts should be synced with one range selector).
     </p>
     <div id="nochart" style="width:800px; height:30px;"></div>
+    <p>Demo of range selector with stepPlot</p>
+    <div id="stepplot" style="width:800px; height:320px;"></div>
+
     <script type="text/javascript">
       g1 = new Dygraph(
           document.getElementById("noroll"),
             rangeSelectorHeight: 30
           }
       );
+      g5 = new Dygraph(document.getElementById("stepplot"),
+                      "Date,Idle,Used\n" +
+                      "2008-05-07,70,30\n" +
+                      "2008-05-08,42,88\n" +
+                      "2008-05-09,88,42\n" +
+                      "2008-05-10,33,37\n" +
+                      "2008-05-11,30,35\n",
+                       {
+                          stepPlot: true,
+                          fillGraph: true,
+                          stackedGraph: true,
+                          includeZero: true,
+                          showRangeSelector: true
+                       });
     </script>
   </body>
 </html>