0
我想動態地爲我的對象中的每個鍵設置數據類型。如何使用我的數據對象中的鍵設置c3.js圖表數據類型?
物體看起來像:
{"x":["2016-01-1", "2016-01-02", etc], "uniqueKey":[4234, 4324, etc], "uniqueKey2":[432, 543, etc], ... }
鍵和名稱將取決於我搶什麼數據變化的數字,但我需要爲每一個關鍵的圖表數據類型。
function show_chart1(data) {
var json = JSON.parse(data);
var chart = c3.generate({
bindto: '#chart',
data: {
x: 'x',
xFormat: '%Y-%m-%d',
json: json,
#### need these to be the unique key names
types: {
uniqueKey: 'area-spline',
uniqueKey2: 'area-spline'
...
},
groups: [[uniqueKey, uniqueKey2, etc]]
},
axis: {
x: {
type: 'timeseries',
tick: {
format: '%Y-%m-%d'
}
}
}
});
};
我該怎麼做?