You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/05/09 03:06:00 UTC

[GitHub] [incubator-echarts] Ovilia commented on issue #10423: 使用dataset传入数据,以及x轴类型为time时,横轴不能正确显示时间

Ovilia commented on issue #10423: 使用dataset传入数据,以及x轴类型为time时,横轴不能正确显示时间
URL: https://github.com/apache/incubator-echarts/issues/10423#issuecomment-490725688
 
 
   这个 `time` 是秒的,time 轴接受的是毫秒的,类似 `new Date().getTime()` 可以看到是你数据的 1000 多倍。
   可以通过自定义 formatter 实现:
   ```js
   axisLabel: {
       formatter: function (v) {
           var date = new Date(v * 1000);
           return date.getFullYear() + '-' + (date.getMonth() + 1)
               + '-' + date.getDate() + ' '
               + date.getHours() + ':' + date.getMinutes()
               + ':' + date.getSeconds();
       }
   }
   ```
   已更新到 https://gallery.echartsjs.com/editor.html?c=xzwYtSuCNn&v=3

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org