【发布时间】:2015-12-21 01:36:58
【问题描述】:
我有一个包含列 (arr_time_) 的 csv 文件,该列表示该特定交易发生的 15 分钟时间段。
此列中的值范围为0 to 28,每个代表从早上 6 点开始的 15 分钟时间段。所以0 表示6 am,1 表示6:15 am,等等。这就是我的折线图现在的样子:
这个折线图的 dc.js 代码是这样的:
timeChart
.width(800)
.height(230)
.margins({top: 10, right: 50, bottom: 30, left: 30})
.dimension(arrivalTimeDim)
.group(arrivalPer15min, "Observed")
// .ordinalColors(["orange"])
// .stack(histArrivalPer15min, "historical")
.transitionDuration(500)
.renderArea(true)
// .elasticX(true)
.elasticY(true)
.x(d3.scale.linear().domain([minDate, maxDate+.5]))//minDate=0, maxDate=28
.renderHorizontalGridLines(true)
// .legend(dc.legend().x(60).y(10).itemHeight(13).gap(5))
.xAxisLabel("Time")
.yAxis().ticks(4);
// .xAxis().ticks(5);
我想更改此图表中的 xAXis,使其显示 6, 6:15, ...。我尝试过使用.range 和xUnits,但可能是因为我做错了,它没有用。我该如何解决这个问题?
【问题讨论】:
-
也许您可以将 d3.time.scale 用于您的 x 轴?
-
我已经完成了这个 .x(d3.time.scale().domain([minDate, maxDate+.5])) .xUnits(d3.time.hour)