var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
g.updateOptions({
- xAxisLabelFormatter: function (totalMinutes) {
- var hours = Math.floor( totalMinutes / 60);
- var minutes = Math.floor((totalMinutes - (hours * 60)));
- var seconds = Math.round((totalMinutes * 60) - (hours * 3600) - (minutes * 60));
-
- if (hours < 10) hours = "0" + hours;
- if (minutes < 10) minutes = "0" + minutes;
- if (seconds < 10) seconds = "0" + seconds;
-
- return hours + ':' + minutes + ':' + seconds;
+ axes : {
+ x : {
+ axisLabelFormatter : function (totalMinutes) {
+ var hours = Math.floor( totalMinutes / 60);
+ var minutes = Math.floor((totalMinutes - (hours * 60)));
+ var seconds = Math.round((totalMinutes * 60) - (hours * 3600) - (minutes * 60));
+
+ if (hours < 10) hours = "0" + hours;
+ if (minutes < 10) minutes = "0" + minutes;
+ if (seconds < 10) seconds = "0" + seconds;
+
+ return hours + ':' + minutes + ':' + seconds;
+ }
+ }
}
});
assertEquals(["00:05:00","00:05:12","00:05:24","00:05:36","00:05:48"], getXLabels());
- // The legend does not use the xAxisLabelFormatter:
+ // The legend does not use the axisLabelFormatter:
g.setSelection(1);
assertEquals('5.1: Y1:1', getLegend());
};
var opts = {
width: 480,
height: 320,
- xAxisLabelFormatter: function(x, granularity, opts, dg) {
- assertEquals('number', typeof(x));
- assertEquals('number', typeof(granularity));
- assertEquals('function', typeof(opts));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + x;
- },
- yAxisLabelFormatter: function(y, granularity, opts, dg) {
- assertEquals('number', typeof(y));
- assertEquals('number', typeof(granularity));
- assertEquals('function', typeof(opts));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'y' + y;
+ axes : {
+ x : {
+ axisLabelFormatter : function(x, granularity, opts, dg) {
+ assertEquals('number', typeof(x));
+ assertEquals('number', typeof(granularity));
+ assertEquals('function', typeof(opts));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'x' + x;
+ }
+ },
+ y : {
+ axisLabelFormatter : function(y, granularity, opts, dg) {
+ assertEquals('number', typeof(y));
+ assertEquals('number', typeof(granularity));
+ assertEquals('function', typeof(opts));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'y' + y;
+ }
+ }
},
labels: ['x', 'y']
};
var opts = {
width: 480,
height: 320,
- xAxisLabelFormatter: function(x, granularity, opts, dg) {
- assertTrue(Dygraph.isDateLike(x));
- assertEquals('number', typeof(granularity));
- assertEquals('function', typeof(opts));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + x.strftime('%Y/%m/%d');
- },
- yAxisLabelFormatter: function(y, granularity, opts, dg) {
- assertEquals('number', typeof(y));
- assertEquals('number', typeof(granularity));
- assertEquals('function', typeof(opts));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'y' + y;
+ axes : {
+ x : {
+ axisLabelFormatter : function(x, granularity, opts, dg) {
+ assertTrue(Dygraph.isDateLike(x));
+ assertEquals('number', typeof(granularity));
+ assertEquals('function', typeof(opts));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'x' + x.strftime('%Y/%m/%d');
+ }
+ },
+ y : {
+ axisLabelFormatter : function(y, granularity, opts, dg) {
+ assertEquals('number', typeof(y));
+ assertEquals('number', typeof(granularity));
+ assertEquals('function', typeof(opts));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'y' + y;
+ }
+ }
},
labels: ['x', 'y']
};
var opts = {
width: 480,
height: 320,
- xValueFormatter: function(x, opts, series_name, dg) {
- assertEquals('number', typeof(x));
- assertEquals('function', typeof(opts));
- assertEquals('string', typeof(series_name));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + x;
- },
- yValueFormatter: function(y, opts, series_name, dg) {
- assertEquals('number', typeof(y));
- assertEquals('function', typeof(opts));
- assertEquals('string', typeof(series_name));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'y' + y;
+ axes : {
+ x : {
+ valueFormatter: function(x, opts, series_name, dg) {
+ assertEquals('number', typeof(x));
+ assertEquals('function', typeof(opts));
+ assertEquals('string', typeof(series_name));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'x' + x;
+ }
+ },
+ y : {
+ valueFormatter: function(y, opts, series_name, dg) {
+ assertEquals('number', typeof(y));
+ assertEquals('function', typeof(opts));
+ assertEquals('string', typeof(series_name));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'y' + y;
+ }
+ }
},
labels: ['x', 'y']
};
var opts = {
width: 480,
height: 320,
- xValueFormatter: function(x, opts, series_name, dg) {
- assertEquals('number', typeof(x));
- assertEquals('function', typeof(opts));
- assertEquals('string', typeof(series_name));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'x' + new Date(x).strftime('%Y/%m/%d');
- },
- yValueFormatter: function(y, opts, series_name, dg) {
- assertEquals('number', typeof(y));
- assertEquals('function', typeof(opts));
- assertEquals('string', typeof(series_name));
- assertEquals('[Dygraph graph]', dg.toString());
- return 'y' + y;
+ axes : {
+ x : {
+ valueFormatter: function(x, opts, series_name, dg) {
+ assertEquals('number', typeof(x));
+ assertEquals('function', typeof(opts));
+ assertEquals('string', typeof(series_name));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'x' + new Date(x).strftime('%Y/%m/%d');
+ }
+ },
+ y : {
+ valueFormatter: function(y, opts, series_name, dg) {
+ assertEquals('number', typeof(y));
+ assertEquals('function', typeof(opts));
+ assertEquals('string', typeof(series_name));
+ assertEquals('[Dygraph graph]', dg.toString());
+ return 'y' + y;
+ }
+ }
},
labels: ['x', 'y']
};
var opts = {
width: 480,
height: 320,
- xValueFormatter: function(x) {
- return 'xvf' + x;
- },
- yValueFormatter: function(y) {
- return 'yvf' + y;
- },
- xAxisLabelFormatter: function(x, granularity) {
- return 'x' + x;
- },
- yAxisLabelFormatter: function(y) {
- return 'y' + y;
+ axes : {
+ x : {
+ valueFormatter: function(x) {
+ return 'xvf' + x;
+ },
+ axisLabelFormatter: function(x, granularity) {
+ return 'x' + x;
+ }
+ },
+ y : {
+ valueFormatter: function(y) {
+ return 'yvf' + y;
+ },
+ axisLabelFormatter: function(y) {
+ return 'y' + y;
+ }
+ }
},
labels: ['x', 'y']
};
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
g.updateOptions({
- xValueFormatter: function(x) {
- return 'xvf' + x;
+ axes : {
+ x : {
+ valueFormatter: function(x) {
+ return 'xvf' + x;
+ }
+ }
}
});
g.updateOptions({
- yValueFormatter: function(y) {
- return 'yvf' + y;
+ axes : {
+ y : {
+ valueFormatter: function(y) {
+ return 'yvf' + y;
+ }
+ }
}
});
g.updateOptions({
- xAxisLabelFormatter: function(x, granularity) {
- return 'x' + x;
+ axes : {
+ x : {
+ axisLabelFormatter: function(x, granularity) {
+ return 'x' + x;
+ }
+ }
}
});
g.updateOptions({
- yAxisLabelFormatter: function(y) {
- return 'y' + y;
+ axes : {
+ y : {
+ axisLabelFormatter: function(y) {
+ return 'y' + y;
+ }
+ }
}
});