简体   繁体   English

使用d3js显示时间线

[英]Showing Time line using d3js

I am new to d3js, trying to display a graph with X axis having time series, 00:00 to 23:59. 我是d3js的新手,试图显示具有时间序列从00:00到23:59的X轴的图形。 Trying to configure d3js to parse time as below 尝试将d3js配置为解析时间,如下所示

var parseTime = d3.time.format("%H%M").parse;
var mytime = "2045"; // I expect it to be 8 45 PM
mytime = parseTime(mytime);
alert(JSON.stringify(mytime));

But the alert shows "1900-01-01T15:15:00.000Z" instead of 20:45. 但是警报显示为“ 1900-01-01T15:15:00.000Z”,而不是20:45。 I know something is terribly wrong, may be my understanding itself is wrong. 我知道发生了严重错误,可能是我的理解本身是错误的。

Any pointers to have timeseries data on x series would be helpful. 在x系列上具有时间序列数据的任何指针都将有所帮助。

Try to add .tickFormat(d3.timeFormat("%H%M")) in your x-axis declaration. 尝试在x轴声明中添加.tickFormat(d3.timeFormat(“%H%M”))。

For a more general explanation of tickformat you can read this post: https://bl.ocks.org/mbostock/9764126 有关tickformat的更一般说明,您可以阅读以下文章: https ://bl.ocks.org/mbostock/9764126

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

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