javascript - Replacing chart datasets with d3.js / c3.js -


demo here

in demo attempting unload current datasets , load new ones this:

using c3.js

chart.unload(); chart.load({     columns: [         ['data1', 130, 120, 150, 140, 160],         ['data2', 30, 20, 50, 40, 60, 50],     ], }); 

this not correct way handle process demo shows, not work correctly.

the c3 tutorial states data sets should replaced this:

chart.load({     columns: [         ['data1', 130, 120, 150, 140, 160],         ['data2', 30, 20, 50, 40, 60, 50],     ],     unload: ['data3', 'data4', 'data5'], }); 

again demo shows works correctly however...

question

how can unload all current datasets , replace them new ones without having specify individual data names (data3,data4) etc?

note: the data sets variable in name , quanity, hence why want unload all.

fundamentally want replace data sets new ones on click.

i don't know if usefull you, in past have used (unload in same function of load). code should be

chart.load({      columns: [           ['data1', 130, 120, 150, 140, 160, 150],           ['data4', 30, 20, 50, 40, 60, 50],       ],      unload: chart.columns, }); 

working fiddle

$('#a').on('click', function () {      chart.load({         columns: [             ['data1', 130, 120, 150, 140, 160, 150],             ['data4', 30, 20, 50, 40, 60, 50],         ],             unload: chart.columns,     }); });  $('#b').on('click', function () {     chart.load({         columns: [             ['data1', 130, 120, 150, 140, 160, 150],             ['data4', 30, 20, 50, 40, 60, 50],         ],         unload: chart.columns,     }); }); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -