[英]updating the data of bar chart in c3.js
I want to display only the 'data1' data. 我只想显示“ data1”数据。 for that I am doing it with a timeout.
为此,我正在超时。 but after it still shows me the values of 'data2'.
但之后仍然显示“ data2”的值。 How can I solve that?
我该如何解决?
https://jsfiddle.net/1q5zyftL/ 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);
Use the unload()
method to get rid of data by it's ID. 使用
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.