数据:
nvd3TestData = [ { values:[ {x:"M",y:1},{x:"T",y:2},{x:"W",y:3},{x:"R",{x:"F",y:4},{x:"S",y:5},{x:"U",y:6} ],key:"Apples" },{ values:[ {x:"M",y:6},y:8},y:1} ],key:"Zebras" } ]
创建图表(从angularjs指令中拉出):
nv.addGraph – >
chart = nv.models.multiBarChart()
.stacked(真)
.showControls(假)
chart.xAxis .axisLabel(attrs.xAxisLabel) chart.yAxis .axisLabel(attrs.yAxisLabel) .tickFormat(d3.format(',r')) console.log element d3.select(element[0].children[0]) .datum(nvd3TestData) .call(chart) nv.utils.windowResize(chart.update)
输出:
我看着nvd3.org,找不到任何真正的文档,但是检查源代码,我发现
https://github.com/novus/nvd3/blob/master/src/models/multiBarChart.js显示了一个布尔图参数“reduceXTicks”,并带有一个注释,表示它会做你想要的.我尝试了一个示例图表,它的工作.具体来说,我用:
chart .reduceXTicks(true)