[英]updating the data of bar chart in c3.js
我只想顯示“ data1”數據。 為此,我正在超時。 但之后仍然顯示“ data2”的值。 我該如何解決?
https://jsfiddle.net/1q5zyftL/
var data1=[['data1', 35, 205, 150, 100, 100, 200], ['data2', 130, 120, 130, 190, 100, 40]];
var chart = c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 130, 100, 140, 200, 150, 50]
],
type: 'bar',
labels:true
},
type: 'bar',
bar: {
width: {
ratio: 0.5 // this makes bar width 50% of length between ticks
}
},
axis: {
rotated: true
}
});
setTimeout(function () {
chart.load({
columns: [
data1[0]
]
});
}, 1000);
使用unload()
方法通過ID清除數據。
var data1=[['data1', 35, 205, 150, 100, 100, 200], ['data2', 130, 120, 130, 190, 100, 40]];
var chart = c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 130, 100, 140, 200, 150, 50]
],
type: 'bar',
labels:true
},
type: 'bar',
bar: {
width: {
ratio: 0.5 // this makes bar width 50% of length between ticks
}
},
axis: {
rotated: true
}
});
setTimeout(function () {
chart.unload({
ids: ['data2']
});
}, 1000);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.