我是 dc.js 新手。
在 x 轴上,我获取 pm/am 时间值,并且需要 24 小时时间值。 我的代码有什么问题?:
<script type="text/javascript">
var data = [
{ "quarter": "Q1", "hits": 10410, "date": "16:00" },
{ "quarter": "Q1", "hits": 10601, "date": "16:15" },
{ "quarter": "Q1", "hits": 10851, "date": "16:30" },
var timeFormat = d3.time.format('%H:%M');
hitslineChart
.width(500).height(200)
.dimension(dateDim)
.group(hits_2011,"2011")
.renderArea(true)
.x(d3.time.scale().domain([timeFormat.parse('15:00'), timeFormat.parse('20:00')]))
.elasticX(true)
.brushOn(false)
.mouseZoomable(true)
;
最佳答案
您应该像这样单独定义轴的tickFormat
:
hitslineChart.xAxis().tickFormat(timeFormat);
在此处查看正在运行的 JFiddle:http://jsfiddle.net/henbox/q1rbq6a2/1/
文档:https://github.com/dc-js/dc.js/blob/master/web/docs/api-1.6.0.md#xaxisxaxis
关于javascript - dc.js 时间格式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27799828/