X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=tests%2Fx-axis-formatter.html;h=63b9e053ebc6eecfb11ad2cfedd1cfcac1829eda;hb=623dd1d6e1562941750eb9f00ac28f2481b07f95;hp=b008ad855001783be11b2522342da3c154ab6721;hpb=48e614acf3084b9836803f8b014bf0e65f1ca119;p=dygraphs.git
diff --git a/tests/x-axis-formatter.html b/tests/x-axis-formatter.html
index b008ad8..63b9e05 100644
--- a/tests/x-axis-formatter.html
+++ b/tests/x-axis-formatter.html
@@ -1,16 +1,13 @@
-
+
X Axis Label Formatting
-
-
+
@@ -35,36 +32,39 @@
"2009/07/12 05:00:00,3,6\n" +
"2009/07/12 06:00:00,4,6"
}
+ function zeropad(x) {
+ return (x < 10) ? '0' + x : x;
+ }
- new Dygraph(
+ var g1 = new Dygraph(
document.getElementById("normal"),
HourlyData()
);
- new Dygraph(
+ var g2 = new Dygraph(
document.getElementById("offby2"),
HourlyData(),
{
axes: {
x: {
- axisLabelFormatter: function(d, gran) {
- return Dygraph.dateAxisFormatter(new Date(d.getTime() + 7200*1000), gran);
+ axisLabelFormatter: function(d, gran, opts) {
+ return Dygraph.dateAxisLabelFormatter(new Date(d.getTime() + 7200*1000), gran, opts);
}
}
}
});
- new Dygraph(
+ var g3 = new Dygraph(
document.getElementById("seconds"),
HourlyData(),
{
- xAxisLabelWidth: 70,
axes: {
x: {
+ axisLabelWidth: 70,
axisLabelFormatter: function(d, gran) {
- return Dygraph.zeropad(d.getHours()) + ":"
- + Dygraph.zeropad(d.getMinutes()) + ":"
- + Dygraph.zeropad(d.getSeconds());
+ return zeropad(d.getHours()) + ":"
+ + zeropad(d.getMinutes()) + ":"
+ + zeropad(d.getSeconds());
}
}
}