[英]D3.js - Plotting time series data - Format x-axis from JSON
I plot very simple data from a JSON file: I need help format my x-date-axis. 我从JSON文件中绘制了非常简单的数据:我需要帮助格式化我的x-date-axis。 I don't know how to specify the date format from the JSON-File for d3.js.
我不知道如何从d3.js的JSON文件指定日期格式。 I tried the following:
我尝试了以下方法:
var parseDate = d3.time.format("%Y%m%d").parse;
The JSON data looks like this: JSON数据如下所示:
var data = [
{"mytime": 20150801, "tt": 17.0},
{"mytime": 20150802, "tt": 17.6},
];
The result on the x-axis is not as expected. x轴上的结果不符合预期。 Find my fiddle here: https://jsfiddle.net/1m1qm6pv/1/
在这里找到我的小提琴: https : //jsfiddle.net/1m1qm6pv/1/
Problem i think is this: 我认为的问题是这样的:
data.forEach(function(d) {
d.mytime = parseDate(d.mytime);
});
With these 3 lines of code it doesn't work. 使用这三行代码,它不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.