Show the last tick (fixes issue #506) issue-506-last-tick
authorDan Vanderkam <danvdk@gmail.com>
Tue, 21 Apr 2015 20:27:59 +0000 (16:27 -0400)
committerDan Vanderkam <danvdk@gmail.com>
Tue, 21 Apr 2015 20:27:59 +0000 (16:27 -0400)
auto_tests/tests/axis_labels.js
auto_tests/tests/multi_csv.js
auto_tests/tests/multiple_axes.js
src/dygraph-layout.js

index dfa7ef1..1d8010d 100644 (file)
@@ -84,7 +84,7 @@ it('testSmallRangeNearZero', function() {
 
   opts.valueRange = [-0.01, 0.01];
   g.updateOptions(opts);
-  assert.deepEqual([-0.01,-0.005,0,0.005],
+  assert.deepEqual([-0.01,-0.005,0,0.005,0.01],
                    Util.makeNumbers(Util.getYLabels()));
 
   g.setSelection(1);
@@ -855,7 +855,7 @@ it('testLabelFormatterOverridesLabelsKMB', function() {
         }
       });
   assert.deepEqual(["0:X","500:X","1000:X","1500:X","2000:X"], Util.getYLabels());
-  assert.deepEqual(["1:X","2:X","3:X"], Util.getXLabels());
+  assert.deepEqual(["1:X","2:X","3:X","4:X"], Util.getXLabels());
 });
 
 /*
@@ -880,8 +880,8 @@ it('testLabelsKMBPerAxis', function() {
       });
 
   // labelsKMB doesn't apply to the x axis. This value should be different.
-  // BUG : https://code.google.com/p/dygraphs/issues/detail?id=488
-  assert.deepEqual(["1000","2000","3000"], Util.getXLabels());
+  // BUG : https://github.com/danvk/dygraphs/issues/409
+  assert.deepEqual(["1000","2000","3000","4000"], Util.getXLabels());
   assert.deepEqual(["0","500","1000","1500","2000"], Util.getYLabels(1));
   assert.deepEqual(["0","500","1K","1.5K","2K"], Util.getYLabels(2));
 });
@@ -910,7 +910,7 @@ it('testLabelsKMBG2IPerAxis', function() {
   // It is weird that labelsKMG2 does something on the x axis but KMB does not.
   // Plus I can't be sure they're doing the same thing as they're done in different
   // bits of code.
-  // BUG : https://code.google.com/p/dygraphs/issues/detail?id=488
+  // BUG : https://github.com/danvk/dygraphs/issues/409
   assert.deepEqual(["1024","2048","3072"], Util.getXLabels());
   assert.deepEqual(["0","500","1000","1500","2000"], Util.getYLabels(1));
   assert.deepEqual(["0","500","1000","1.46k","1.95k"], Util.getYLabels(2));
@@ -939,7 +939,7 @@ it('testSigFigsPerAxis', function() {
       });
   // sigFigs doesn't apply to the x axis. This value should be different.
   // BUG : https://code.google.com/p/dygraphs/issues/detail?id=488
-  assert.deepEqual(["1000","2000","3000"], Util.getXLabels());
+  assert.deepEqual(["1000","2000","3000","4000"], Util.getXLabels());
   assert.deepEqual(["0.0","5.0e+2","1.0e+3","1.5e+3","2.0e+3"], Util.getYLabels(1));
   assert.deepEqual(["0.00000","500.000","1000.00","1500.00","2000.00"], Util.getYLabels(2));
 });
@@ -1025,13 +1025,13 @@ it('testMaxNumberWidthPerAxis', function() {
   assert.deepEqual(["1.28e+4","1.28e+4","1.28e+4","1.28e+4","1.28e+4","1.28e+4","1.28e+4"], Util.getYLabels(2));
 
   // maxNumberWidth is ignored for the x-axis.
-  // BUG : https://code.google.com/p/dygraphs/issues/detail?id=488
+  // BUG : https://github.com/danvk/dygraphs/issues/409
   g.updateOptions({ axes: { x: { maxNumberWidth: 4 }}});
-  assert.deepEqual(["12401","12402","12403"], Util.getXLabels());
+  assert.deepEqual(["12401","12402","12403","12404"], Util.getXLabels());
   g.updateOptions({ axes: { x: { maxNumberWidth: 5 }}});
-  assert.deepEqual(["12401","12402","12403"], Util.getXLabels());
+  assert.deepEqual(["12401","12402","12403","12404"], Util.getXLabels());
   g.updateOptions({ axes: { x: { maxNumberWidth: null }}});
-  assert.deepEqual(["12401","12402","12403"], Util.getXLabels());
+  assert.deepEqual(["12401","12402","12403","12404"], Util.getXLabels());
 });
 
 // Regression test for https://github.com/danvk/dygraphs/issues/506
@@ -1052,6 +1052,9 @@ it('should draw top and bottom ticks', function() {
       y: { ticker: firstLastTicker }
     }
   });
+
+  assert.deepEqual(['0', '3'], Util.getXLabels());
+  assert.deepEqual(['0', '1.2'], Util.getYLabels());
 });
 
 /*
index c6b8d4f..bc34b08 100644 (file)
@@ -36,7 +36,7 @@ it('testOneCSV', function() {
   var graph = document.getElementById("graph");
   var g = new Dygraph(graph, data, opts);
 
-  assert.deepEqual(['0', '1', '2'], getXLabels());
+  assert.deepEqual(['0', '1', '2', '3'], getXLabels());
 });
 
 it('testTwoCSV', function() {
@@ -54,11 +54,11 @@ it('testTwoCSV', function() {
   var graph = document.getElementById("graph");
   var g = new Dygraph(graph, data, opts);
 
-  assert.deepEqual(['0', '1', '2'], getXLabels());
+  assert.deepEqual(['0', '1', '2', '3'], getXLabels());
 
   g.updateOptions({file: data});
 
-  assert.deepEqual(['0', '1', '2'], getXLabels());
+  assert.deepEqual(['0', '1', '2', '3'], getXLabels());
 });
 
 });
index 3935b52..b9dd45e 100644 (file)
@@ -195,9 +195,9 @@ it('testValueRangePerAxisOptions', function() {
       y2label: 'Secondary y-axis',
     }
   );
-  assert.deepEqual(["40", "45", "50", "55", "60", "65"], Util.getYLabels("1"));
-  assert.deepEqual(["900K","1.1M","1.3M","1.5M","1.7M","1.9M"], Util.getYLabels("2"));
-  
+  assert.deepEqual(["40", "45", "50", "55", "60", "65", "70"], Util.getYLabels("1"));
+  assert.deepEqual(["900K","1.1M","1.3M","1.5M","1.7M","1.9M","2.1M"], Util.getYLabels("2"));
+
   g.updateOptions(
     {
       axes: {
@@ -210,8 +210,8 @@ it('testValueRangePerAxisOptions', function() {
      }
     }
   );
-  assert.deepEqual(["40", "45", "50", "55", "60", "65", "70", "75"], Util.getYLabels("1"));
-  assert.deepEqual(["1M", "1.02M", "1.05M", "1.08M", "1.1M", "1.13M", "1.15M", "1.18M"], Util.getYLabels("2"));
+  assert.deepEqual(["40", "45", "50", "55", "60", "65", "70", "75", "80"], Util.getYLabels("1"));
+  assert.deepEqual(["1M", "1.02M", "1.05M", "1.08M", "1.1M", "1.13M", "1.15M", "1.18M", "1.2M"], Util.getYLabels("2"));
 });
 
 it('testDrawPointCallback', function() {
index ef1df91..3597a0a 100644 (file)
@@ -282,7 +282,7 @@ DygraphLayout.prototype._evaluateLineTicks = function() {
     tick = this.xTicks_[i];
     label = tick.label;
     pos = this.dygraph_.toPercentXCoord(tick.v);
-    if ((pos >= 0.0) && (pos < 1.0)) {
+    if ((pos >= 0.0) && (pos <= 1.0)) {
       this.xticks.push([pos, label]);
     }
   }
@@ -294,7 +294,7 @@ DygraphLayout.prototype._evaluateLineTicks = function() {
       tick = axis.ticks[j];
       label = tick.label;
       pos = this.dygraph_.toPercentYCoord(tick.v, i);
-      if ((pos > 0.0) && (pos <= 1.0)) {
+      if ((pos >= 0.0) && (pos <= 1.0)) {
         this.yticks.push([i, pos, label]);
       }
     }