我有这段代码可以绘制一个 d3js 多图表对象,值 time:Years 值以这种格式给出 Year=2011 ... 使用这种时间格式,代码工作正常,但是一旦我想以这种格式更改数据时间 Year= (YMD H:M:S)
var data = [{"Year":"2011-10-01 20:46:04","Happy":"63.4","Sad":"42.7","Angry":"12.2","Surprised":"44.2"},
{"Year":"2012-10-01 17:02:04","Happy":"75.4","Sad":"32.7","Angry":"78.2","Surprised":"82.2"},
{"Year":"2013-10-01 19:55:44","Happy":"73.4","Sad":"20.7","Angry":"92.2","Surprised":"75.4"}];
我解析了数据年份:
var parseDate=d3.time.format("%Y-%m-%d %H:%M:%S").parse; //line 13
d.Year=parseDate(d.Year); //and then line 53
但它不起作用,我怎样才能以这种格式读取数据年份:(YMD H:M:S)