鼠标悬停在日期格式上的笔画 [英] dygraph on mouse over date format
问题描述
是否可以在Dygraph中的onMouseOver事件上更改格式? 当前格式为: YYYY/MM/DD HH:MM:SS
Is it possible to change the format on the onMouseOver event in Dygraph? Currently the format is: YYYY/MM/DD HH:MM:SS
我希望它显示为
MM/DD/YYYY HH:MM:SS
MM/DD/YYYY HH:MM:SS
是否可以更改当前格式? 谢谢你的协助. 杰伊
Is it possible to change the current format? Thanks for your assistance. Jay
推荐答案
You want to set the valueFormatter
option on the x-axis: http://dygraphs.com/options.html#valueFormatter
例如,
new Dygraph(div, data, {
axes: {
x: {
valueFormatter: function(ms) {
return new Date(ms).strftime("%m/%d/%y %H:%M:%S");
}
}
}
});
此处为实时示例: http://jsfiddle.net/eM2Mg/772/
值得注意的是,Date.strftime()不是标准的JavaScript方法:它是由strftime.js提供的,它包含在标准音标捆绑中.
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.
这篇关于鼠标悬停在日期格式上的笔画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!