dygraph on mouse over date format

◇◆丶佛笑我妖孽 提交于 2020-01-15 11:24:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!