It is currently Tue Dec 12, 2017 5:46 pm Advanced search

Highmaps

Technical support, bug reports and more.

Highmaps

Postby JimFL » Wed Feb 15, 2017 6:18 pm

Hi,

I have a world map with a series of pie charts created dynamically inside the MAP series object. I am trying to tell if the the series has loaded. I cannot see how this can be achieved, is there something in the API that will help me here?

Any thoughts appreciated.

Kind regards
JimFL
JimFL
 
Posts: 3
Joined: Tue Feb 07, 2017 5:50 pm

Re: Highmaps

Postby stpoa » Wed Feb 15, 2017 6:41 pm

Hi,

There are many ways with you can check if your series exists on a chart. For example you could check your series data length, if it is different from 0 then your series is loaded, you could also check different parameter.

Example:
Code: Select all
var options = {
  series: [{}]
}

var chart = Highcharts.chart('container', options);

setTimeout(() => {
   chart.series[0].setData([1,2,3])
}, 5000)

setInterval(() => {
   console.log(chart.series[0].data.length ? 'Series is loaded' : 'Series is not loaded')
}, 500)


Live example:
https://jsfiddle.net/ygdn62ww/

Regards.
Sławomir Stypuła
Highcharts Developer
stpoa
 
Posts: 1016
Joined: Thu Oct 06, 2016 12:56 pm

Re: Highmaps

Postby JimFL » Thu Feb 16, 2017 11:15 am

Ok thanks for this, this may help but I think another part of my problem is that the map seems to redraw every time when the map navigation is used. For example I am using the formatted to dynamically assign the pie charts to the map. Is there a way to stop the redraw on any navigation and then only programmatically call the redraw method?
JimFL
 
Posts: 3
Joined: Tue Feb 07, 2017 5:50 pm

Re: Highmaps

Postby stpoa » Thu Feb 16, 2017 2:01 pm

Hi,

You could backup and overwrite chart.redraw with any function.

Code: Select all
var options = {
   chart: {
     zoomType: 'x'
  },
  xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
      'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
    ]
  },
  series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
    type: 'column'
  }]
}

const chart = Highcharts.chart('container', options);

// Backup chart.redraw
const chartRedraw = chart.redraw
// Overwrite redraw with different function
chart.redraw = function () {
   console.log('redraw does nothing')
}

// Call redraw after 2 seconds
setTimeout(chart.redraw, 2000)
// Restore original chart.redraw
setTimeout(() => {chart.redraw = chartRedraw}, 2000)
// Log chart redraw function
setTimeout(() => console.log(chart.redraw), 4000)


Live example:
https://jsfiddle.net/L5kyw7yr/

Regards.
Sławomir Stypuła
Highcharts Developer
stpoa
 
Posts: 1016
Joined: Thu Oct 06, 2016 12:56 pm


Return to Highmaps Usage

Who is online

Users browsing this forum: No registered users and 1 guest