jquery - Making Javascript button toggle function work with dropdown selection -


i complete newbie in of world javascript, html , css. have html page several charts created using highcharts. page has dropdown menu containing list of indian states. when state selected, charts updated data state. each chart has set of 2 buttons attached (see fiddle link). on toggling buttons, different charts loaded.

now issue: need make both these functionalities work together. is, when select "andhra pradesh", data andhra pradesh should loaded on both charts. able make charts load respective data states "2017-18" couldn't "other years". can't fathom going wrong. here's link fiddle: https://jsfiddle.net/pr4chi/w9nq1cw3/110/

and here's code toggle chart:

$(document).on('click', '.chart-update', function() {     $('button').removeclass('selected');         $(this).addclass('selected');         chart.destroy();     $('#donut').highcharts(chartoptions[$(this).data('chartname')]);     chart = $('#donut').highcharts();   }); 

any appreciated!

you can bind change event select element , based on state chosen, update chart series' data. take @ example below. added dummy data (check dataforstates object) show how works.

api reference:
http://api.highcharts.com/highcharts/series.update
http://api.highcharts.com/highcharts/series.setdata
https://api.jquery.com/change/

example:
https://jsfiddle.net/vwyrwz61/


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -