繁体   English   中英

使用Morris.js悬停回调的人工日期值

[英]Human date value with Morris.js Hover callback

我正在尝试在Morris.js折线图中显示人类可读的日期,但是,它显示的是时间戳记。 我已经看过hoverCallback区域,但是不确定要更改什么:

update_host_info.js.erb

new Morris.Line({
  element: 'device_security_trend',
  data: $('#device_security_trend').data('security-trend'),
  smooth: false,
  ymax: 'auto[99]',
  xkey: 'created_at',
  ykeys: ['security_percentage'],
  labels: ['Security Percentage'],
  postUnits: '%',
  resize: true,
  hoverCallback: function(index, options, content) {
    return(content);
  }
});

device_security_trend元素

 <div data-security-trend="[{"created_at":"2016-02-23T13:28:05.160-04:00", "security_percentage" :0},{"created_at":"2016-02-23T16:24:56.128-04:00","security_percentage":99},{"created_at":"2016-02-23T16:24:57.560-04:00","security_percentage":0}" id="device_security_trend" style="width: 100%; position: relative; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);" class="selected"><div class="morris-hover-row-label">2016-02-23T13:28:05.160-04:00</div><div class="morris-hover-point" style="color: #689bc3"> Security Percentage: 0% </div></div> 

正确,现在这是我的悬停工具提示:

在此处输入图片说明

相反,我希望日期/时间更具可读性,例如:

4/19/2016 - 9:30am

最终只是通过将时间转换为人类可读的帮助器方法来更改将日期输入Morris.js的方式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM