问题
Is it possible to change the format on the onMouseOver event in Dygraph? Currently the format is: YYYY/MM/DD HH:MM:SS
I would like it to display as
MM/DD/YYYY HH:MM:SS
Is it possible to change the current format? Thanks for your assistance. Jay
回答1:
You want to set the valueFormatter
option on the x-axis: http://dygraphs.com/options.html#valueFormatter
For example,
new Dygraph(div, data, {
axes: {
x: {
valueFormatter: function(ms) {
return new Date(ms).strftime("%m/%d/%y %H:%M:%S");
}
}
}
});
Live example here: http://jsfiddle.net/eM2Mg/772/
It's worth noting that Date.strftime() is not a standard JavaScript method: it's provided by strftime.js, which is included in the standard dygraphs bundle.
来源:https://stackoverflow.com/questions/16846944/dygraph-on-mouse-over-date-format