我有JSON数据
abc
示例:https://www.highcharts.com/demo/bar-stacked
参考setdata对象如何堆叠条形图?
我试试PickList
返回“1月”它的作品找不到
{
"data":[
{ "month" : "January",
"name" : "John",
"count" : 10
},
{
"month" : "January",
"name" : "Jane",
"count" : 15
}
]
},
{
"data":[
{ "month" : "February",
"name" : "Mark",
"count" : 20
},
{ "month" : "February",
"name" : "Max",
"count" : 30
}
]
}
这是错误。
答案 0 :(得分:0)
您可以使用d3堆积条形图 -
let innerColumns = {
'column1': ['value3'],
'column2': ['value1', 'value2'],
};
let dataset = d3.layout.stack()(['value1', 'value2', 'value3'].map((value) => {
return data.map((d: any) => {
return { x: obj[d.xAxis], y: d.value };
});
}));
let x = d3.scale.ordinal()
.domain(dataset[0].map((d) => { return d.x; }))
.rangeBands([0, width], 1);
let y = d3.scale.linear()
.domain([0, d3.max(dataset, (d) => {
return d3.max(d, (d1) => { return d1.y0 + d1.y; });
})])
.range([height, 0]);
更多: https://github.com/amanjain325/angular-d3-charts/tree/master/src/app/multi-bar-chart