Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c3 chart.load with multiple charts

I am using c3.js and c3.css to make several graphs on one page. I have multiple charts and want to update the data every 60 seconds so I use set interval, get the updated data, and then load it to a chart, however, it puts all of the data in the most recently made chart. I attempted to add a bindto to the data so it goes to the correct graph, but it still loads onto the bottom graph. how can I fix this?

...
<div id='chart1'></div>
<div id='chart2'></div>
...
function update()//this function collects the new data in arrays cols and xrows
...
setInterval(function(){
  update();
  chart.unload();
  chart.load({bindto:'#chart1',columns:cols, xs:xrows});
},3000);
like image 918
John Avatar asked Oct 31 '22 20:10

John


1 Answers

For showing update data atfirst

  • hide previous data's DIV
  • Use CLEAR to for cleaning Data
  • Again Load the DIV
like image 135
Mohammad Shahnewaz Sarker Avatar answered Nov 09 '22 04:11

Mohammad Shahnewaz Sarker