我正在使用 dc.js 创建图表,您可以看到月份之间的间隔不同。最值得注意的是二月和三月之间,因为二月只有 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'));
最佳答案
我想你忘了设置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();
关于javascript - dc.js 月图表条间距不均匀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23944014/