0
,我有以下JSON數據:C3.js分組條形圖
var data = {
age:
{
male:
{ '0-9': 249.8740575482693,
'10-19': 238.2744788358169,
'20-29': 369.10362988529357,
'30-39': 156.9635033529556,
},
female:
{ '0-9': 182.36397053287214,
'10-19': 265.8954005792933,
'20-29': 210.98459487382183,
'30-39': 159.24536288458913,
},
}
}
,我試圖使男性和女性各年齡範圍內的分組C3條形圖,但避風港」沒有任何運氣。我錯過了什麼?
var sex = ['male', 'female'];
var chart = c3.generate({
bindto: '#chart2',
data: {
json: [data["age"]],
keys: {
value: ['0-9', '10-19', '20-29', '30-39']
},
type: 'bar',
},
axis: { x: {
type: 'category',
categories: sex,
}},
});