我正在使用dc.js创建图表,您可以看到月份之间的间距不同。最值得注意的是2月至3月,因为2月只有28天。如何在几个月之间保持均匀间隔?
chart
//dimensions
.height(250)
.margins({top: 10, right: 50, bottom: 25, left: 50})
//x-axis
.x(d3.time.scale().domain(domain))
.round(d3.time.month.round)
.xUnits(d3.time.months)
.elasticX(true)
.xAxisPadding(20)
//left y-axis
.yAxisLabel('Dollars')
.elasticY(true)
.renderHorizontalGridLines(true)
// right y-axis
.rightYAxisLabel('Quantity')
//composition
.compose(composition)
.brushOn(false)
.xAxis().tickFormat(d3.time.format('%b %y'));
答案 0 :(得分:0)
我想你忘了设置gap
magnitudeChart.width(480) //you should also set the chart width too
.height(150)
.margins({top: 10, right: 10, bottom: 20, left: 40})
.dimension(magValue)
.group(magValueGroupCount)
.transitionDuration(500)
.centerBar(true)
.gap(65) //set the gap
.filter([3, 5])
.x(d3.scale.linear().domain([0.5, 7.5]))
.elasticY(true)
.xAxis().tickFormat();