鼠标悬停在日期格式上的笔画 [英] dygraph on mouse over date format

查看:110
本文介绍了鼠标悬停在日期格式上的笔画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在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

推荐答案

您要在x轴上设置valueFormatter选项:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆