rework option as showInRangeSelector
[dygraphs.git] / auto_tests / tests / custom_bars.js
index 493e86c..231dcd8 100644 (file)
@@ -6,16 +6,16 @@
  */
 var CustomBarsTestCase = TestCase("custom-bars");
 
-var _origFunc = Dygraph.getContext;
+CustomBarsTestCase._origFunc = Dygraph.getContext;
 CustomBarsTestCase.prototype.setUp = function() {
   document.body.innerHTML = "<div id='graph'></div>";
   Dygraph.getContext = function(canvas) {
-    return new Proxy(_origFunc(canvas));
+    return new Proxy(CustomBarsTestCase._origFunc(canvas));
   }
 };
 
 CustomBarsTestCase.prototype.tearDown = function() {
-  Dygraph.getContext = _origFunc;
+  Dygraph.getContext = CustomBarsTestCase._origFunc;
 };
 
 // This test used to reliably produce an infinite loop.
@@ -151,3 +151,33 @@ CustomBarsTestCase.prototype.testCustomBarsLogScale = function() {
        [247.5, 152.02209814465604]],
       { fillStyle: "#00ff00" });
 };
+
+CustomBarsTestCase.prototype.testCustomBarsWithNegativeValuesInLogScale =
+    function() {
+  var graph = document.getElementById("graph");
+
+  var count = 0;
+  var drawPointCallback = function() {
+    count++;
+  };
+
+  var g = new Dygraph(graph,
+      [
+        [1, [10, 20,30]],
+        [2, [5, 10, 15]],
+        [3, [-1, 5, 10]]
+      ],
+      {
+        drawPoints: true,
+        drawPointCallback : drawPointCallback,
+        customBars: true
+      });
+
+  // Normally all three points would be drawn.
+  assertEquals(3, count);
+  count = 0;
+
+  // In log scale, the third point shouldn't be shown.
+  g.updateOptions({ logscale : true });
+  assertEquals(2, count);
+};