数据:
nvd3TestData = [
{
values:[
{x:"M",y:1},
{x:"T",y:2},
{x:"W",y:3},
{x:"R",y:3},
{x:"F",y:4},
{x:"S",y:5},
{x:"U",y:6}
],
key:"Apples"
},
{
values:[
{x:"M",y:5},
{x:"T",y:2},
{x:"W",y:6},
{x:"R",y:8},
{x:"F",y:2},
{x:"S",y:4},
{x:"U",y:1}
],
key:"Zebras"
}
]
创建图表(从 angularjs 指令中提取):
nv.addGraph -> 图表 = nv.models.multiBarChart() .stacked(true) .showControls(false)
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)
输出:
预期输出将包含所有 7 个标签:MTWRFSU