(either at range end or just past it).
This has the effect of making a (grid lines, axis label) pair always
show up together or not at all. Previously it was possible to get a
label but no gridline at the edge of the chart.
Squashed commit of the following:
commit
32955f836c3c32c11f009ae250cd35682d641e5c
Merge: d3b7c40 0b99641
Author: Dan Vanderkam <danvdk@gmail.com>
Date: Mon Sep 16 17:18:40 2013 -0400
Merge branch 'master' of https://github.com/blindmonkey/dygraphs into 269-end-ticks
commit
0b996410efcb7a53315347c8cea38dc225f069ee
Author: Sergey <grabkovsky.s@gmail.com>
Date: Mon Sep 16 17:08:36 2013 -0400
Reverting multi-csv
commit
3f72c23c3ebc23adc64dd2605175ff163491d8e2
Author: Sergey <grabkovsky.s@gmail.com>
Date: Mon Sep 16 17:07:26 2013 -0400
Changing it so that the right-most X axis tick isn't displayed, and changing the tests to reflect that
commit
3605ec18fb45718dca3dbd3bfb818adb5acc79eb
Author: Sergey <grabkovsky.s@gmail.com>
Date: Mon Sep 16 16:40:18 2013 -0400
Reverting whitespace stuff
commit
11959a26e45be3481425f3ba68d78e63730eab4a
Author: Sergey <grabkovsky.s@gmail.com>
Date: Mon Sep 16 14:43:41 2013 -0400
Reverting multiple axes old test
commit
4d91af0850a1fa72f693c497ac62e88e35c505eb
Author: Sergey <grabkovsky.s@gmail.com>
Date: Mon Sep 16 14:42:56 2013 -0400
Reverting multiple axes test
commit
40b6ea279591df646f10d3ec44f760a20b42cf8a
Author: Sergey <grabkovsky.s@gmail.com>
Date: Fri Sep 13 14:14:29 2013 -0400
Changing layout to not layout ticks whose gridline is slightly offscreen.
commit
cec9c2857c3c03b14521ccfb4a44bbb4d7163776
Author: Sergey <grabkovsky.s@gmail.com>
Date: Thu Sep 12 13:26:12 2013 -0400
Adding tests for the numeric ticker algorithm change.
commit
106c0318cdf6c763a06545cf25f6ef66084cadf7
Author: Sergey <grabkovsky.s@gmail.com>
Date: Thu Sep 12 12:16:35 2013 -0400
Changing numericTicks so that it returns the last nice value that might be just outside the axis
<script type="text/javascript" src="../tests/multiple_axes.js"></script>
<script type="text/javascript" src="../tests/multiple_axes-old.js"></script>
<script type="text/javascript" src="../tests/no_hours.js"></script>
+ <script type="text/javascript" src="../tests/numeric_ticker.js"></script>
<script type="text/javascript" src="../tests/parser.js"></script>
<script type="text/javascript" src="../tests/pathological_cases.js"></script>
<script type="text/javascript" src="../tests/per_axis.js"></script>
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- assertEquals(["x2011/01/01", "x2011/01/02", "x2011/01/03", "x2011/01/04", "x2011/01/05", "x2011/01/06", "x2011/01/07", "x2011/01/08", "x2011/01/09"], Util.getXLabels());
+ assertEquals(["x2011/01/01", "x2011/01/02", "x2011/01/03", "x2011/01/04", "x2011/01/05", "x2011/01/06", "x2011/01/07", "x2011/01/08"], Util.getXLabels());
assertEquals(['y2','y4','y6','y8','y10','y12','y14','y16','y18'], Util.getYLabels());
g.setSelection(0);
var g = new Dygraph(graph, data, opts);
// valueFormatters do not affect ticks.
- assertEquals(['01Jan','02Jan','03Jan','04Jan','05Jan','06Jan','07Jan','08Jan','09Jan'], Util.getXLabels());
+ assertEquals(['01Jan','02Jan','03Jan','04Jan','05Jan','06Jan','07Jan','08Jan'], Util.getXLabels());
assertEquals(['2','4','6','8','10','12','14','16','18'], Util.getYLabels());
// the valueFormatter options also affect the legend.
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- assertEquals(["x2011/01/01", "x2011/01/02", "x2011/01/03", "x2011/01/04", "x2011/01/05", "x2011/01/06", "x2011/01/07", "x2011/01/08", "x2011/01/09"], Util.getXLabels());
+ assertEquals(["x2011/01/01", "x2011/01/02", "x2011/01/03", "x2011/01/04", "x2011/01/05", "x2011/01/06", "x2011/01/07", "x2011/01/08"], Util.getXLabels());
assertEquals(['y2','y4','y6','y8','y10','y12','y14','y16','y18'], Util.getYLabels());
g.setSelection(0);
var g = new Dygraph(graph, data, opts);
// valueFormatters do not affect ticks.
- assertEquals(['01Jan','02Jan','03Jan','04Jan','05Jan','06Jan','07Jan','08Jan','09Jan'], Util.getXLabels());
+ assertEquals(['01Jan','02Jan','03Jan','04Jan','05Jan','06Jan','07Jan','08Jan'], Util.getXLabels());
assertEquals(['2','4','6','8','10','12','14','16','18'], Util.getYLabels());
// the valueFormatter options also affect the legend.
--- /dev/null
+/**
+ * @fileoverview Test cases for the numeric tick-generating functions.
+ * These were generated by adding logging code to the old ticker functions. The
+ * tests serve to track existing behavior should it change in the future.
+ *
+ * @author danvdk@gmail.com (Dan Vanderkam)
+ */
+
+var NumericTickerTestCase = TestCase("numeric-ticker-tests");
+
+NumericTickerTestCase.prototype.setUp = function() {
+ document.body.innerHTML = "<div id='graph'></div>";
+};
+
+NumericTickerTestCase.prototype.createOptionsViewForAxis = function(axis, dict) {
+ return function (x) {
+ if (dict && dict.hasOwnProperty(x)) {
+ return dict[x];
+ }
+ if (Dygraph.DEFAULT_ATTRS.axes[axis].hasOwnProperty(x)) {
+ return Dygraph.DEFAULT_ATTRS.axes[axis][x];
+ }
+ if (Dygraph.DEFAULT_ATTRS.hasOwnProperty(x)) {
+ return Dygraph.DEFAULT_ATTRS[x];
+ }
+ if (x == 'axisLabelFormatter') return null;
+ throw "mysterious " + axis + "-axis option: " + x;
+ };
+};
+
+NumericTickerTestCase.prototype.testBasicNumericTicker = function() {
+ var opts = {"logscale":null,"labelsKMG2":false,"labelsKMB":false};
+ var options = this.createOptionsViewForAxis('y', opts);
+
+ var ticks = Dygraph.numericTicks(-0.4, 4.4, 320, options);
+ var expected_ticks = [
+ {"v":-0.5,"label":"-0.5"},
+ {"v":0,"label":"0"},
+ {"v":0.5,"label":"0.5"},
+ {"v":1,"label":"1"},
+ {"v":1.5,"label":"1.5"},
+ {"v":2,"label":"2"},
+ {"v":2.5,"label":"2.5"},
+ {"v":3,"label":"3"},
+ {"v":3.5,"label":"3.5"},
+ {"v":4,"label":"4"},
+ {"v":4.5,"label":"4.5"}];
+ assertEquals(expected_ticks, ticks);
+
+ ticks = Dygraph.numericTicks(1, 84, 540, options);
+ var expected_ticks = [
+ {"v":0,"label":"0"},
+ {"v":5,"label":"5"},
+ {"v":10,"label":"10"},
+ {"v":15,"label":"15"},
+ {"v":20,"label":"20"},
+ {"v":25,"label":"25"},
+ {"v":30,"label":"30"},
+ {"v":35,"label":"35"},
+ {"v":40,"label":"40"},
+ {"v":45,"label":"45"},
+ {"v":50,"label":"50"},
+ {"v":55,"label":"55"},
+ {"v":60,"label":"60"},
+ {"v":65,"label":"65"},
+ {"v":70,"label":"70"},
+ {"v":75,"label":"75"},
+ {"v":80,"label":"80"},
+ {"v":85,"label":"85"}
+ ];
+ assertEquals(expected_ticks, ticks);
+};
tick = this.xTicks_[i];
label = tick.label;
pos = this.xscale * (tick.v - this.minxval);
- if ((pos >= 0.0) && (pos <= 1.0)) {
+ if ((pos >= 0.0) && (pos < 1.0)) {
this.xticks.push([pos, label]);
}
}
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]);
}
}
// Construct the set of ticks.
// Allow reverse y-axis if it's explicitly requested.
if (low_val > high_val) scale *= -1;
- for (i = 0; i < nTicks; i++) {
+ for (i = 0; i <= nTicks; i++) {
tickV = low_val + i * scale;
ticks.push( {v: tickV} );
}