【发布时间】:2017-02-18 19:17:24
【问题描述】:
我正在尝试为我的对象中的每个键动态设置数据类型。
对象看起来像:
{"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'
}
}
}
});
};
我该怎么做?
【问题讨论】:
标签: javascript json c3.js