Chrintz
Posts: 4
Joined: Thu Nov 03, 2022 12:29 pm

Problem pushing new data to map with markers

I have a map with markers for some countries and I want to dynamically be able to push additional data/markers to the map over time.

My issue is that I cannot make Highcharts draw the additional data/markers.

I have made a simple example here:
https://jsfiddle.net/Chrintz/59q2bem6/1/

Can anyone see what I'm missing?

Quick description of the example:
I'm drawing the map with some initial data and then a second after I'm pushing new data
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Problem pushing new data to map with markers

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

You are trying to add data to the first series, which contains data for the map (base map series). Your map points are in the third series, so you should set new data for the third series :)

Code: Select all

chart.series[2].setData(newData);
Demo: https://jsfiddle.net/BlackLabel/pcsarw75/

Please, keep in mind, that there is also series.addPoint method, which will allow you to not lose 'old' points and just push a new point to existing series - like in the demo below.
Demo: https://jsfiddle.net/BlackLabel/ud0yLxcq/
API Reference: https://api.highcharts.com/class-refere ... s#addPoint

Let me know if you have any further questions.
Regards!
Hubert Kozik
Highcharts Developer
Chrintz
Posts: 4
Joined: Thu Nov 03, 2022 12:29 pm

Re: Problem pushing new data to map with markers

Thank you!
That makes sence :)
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Problem pushing new data to map with markers

You're welcome! In case of any further questions, feel free to contact us again.
Hubert Kozik
Highcharts Developer

Return to “Highcharts Maps”