diviseed
Posts: 1
Joined: Tue Oct 12, 2021 5:14 am

Update data on Button Click with Split Bubble Chart

I have two button which need to update and change the data when button is clicked in the same bubble chart but the issue is that when I click on the button it throws an error "bubbleChart.series.setData is not a function". I have included the code through jsfiddle. not sure why this is happening. Should I try different

Code: Select all


document.getElementById('updateIndia').addEventListener('click', () => {
     bubbleChart.series.setData(newData);
 
});

Working Code
https://jsfiddle.net/diviseed/eskt9qo3/10/
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Update data on Button Click with Split Bubble Chart

Hello diviseed,

Welcome to our forum and thanks for contacting us with your question!

The error is being thrown because bubbleChart.series is not a single series, it is an array of series. You should use setData function on specific series, for example bubbleChart.series[0].setData().

Also, I'm not sure if I concluded correctly from your demo, but it seems to me that you want to add a new series, not update old one. In this case you should use chart.addSeries function.
Demo:https://jsfiddle.net/BlackLabel/ngcd9hw6/
API reference: https://api.highcharts.com/class-refere ... #addSeries

Let me know if that was what you were looking for!
Best regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”