var opts = {
width: 480,
height: 320,
- xAxisLabelFormatter: function(x, granularity) {
+ xAxisLabelFormatter: function(x, granularity, b) {
return 'x' + x.strftime('%Y/%m/%d');
},
- yAxisLabelFormatter: function(y) {
+ yAxisLabelFormatter: function(y, a, b) {
return 'y' + y;
},
labels: ['x', 'y']
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- assertEquals(["0","2","4","6","8"], getXLabels());
-
- // This would be more consistent with the behavior of yValueFormatter:
- // assertEquals(['x0','x2','x4','x6','x8'], getXLabels());
-
- assertEquals(['y0','y2','y4','y6','y8','y10','y12','y14','y16','y18'], getYLabels());
+ // the valueFormatter options do not affect the ticks.
+ assertEquals(['0','2','4','6','8'], getXLabels());
+ assertEquals(['0','2','4','6','8','10','12','14','16','18'],
+ getYLabels());
- // the valueFormatter options also affect the legend.
+ // they do affect the legend, however.
g.setSelection(2);
assertEquals("x2: y:y4", getLegend());
};
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- // This is the existing behavior:
- assertEquals(["01Jan","02Jan","03Jan","04Jan","05Jan","06Jan","07Jan","08Jan","09Jan"], getXLabels());
-
- // This would be more consistent with the yValueFormatter behavior:
- // 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"], getXLabels());
- assertEquals(['y2','y4','y6','y8','y10','y12','y14','y16','y18'], getYLabels());
+ // valueFormatters do not affect ticks.
+ assertEquals(['01Jan','02Jan','03Jan','04Jan','05Jan','06Jan','07Jan','08Jan','09Jan'], getXLabels());
+ assertEquals(['2','4','6','8','10','12','14','16','18'], getYLabels());
// the valueFormatter options also affect the legend.
g.setSelection(2);
- assertEquals("x2011/01/03: y:y6", getLegend());
+ assertEquals('x2011/01/03: y:y6', getLegend());
};
// This test verifies that when both a valueFormatter and an axisLabelFormatter