Johnnerz Johnnerz - 1 year ago 179
jQuery Question

Issue with highcharts on jsfiddle where series is not being removed on drillup

The Demo I am basing my project on is here:

I have changed this around for my own country and information but the problem exists here for the drillup function.

Reproduction steps:
Open the jsfiddle in the link above and click on CA (california) in the map, then click the button '< Back to USA'

Next click somewhere else on the West coast to see that the california drilldown has not been removed from the map. I need these to be removed once the back button is clicked.

issue with old map showing outside selection

Here is the main body of the code:

Highcharts.mapChart('container', {
chart: {
events: {
drilldown: function (e) {

if (!e.seriesOptions) {
var chart = this,
mapKey = 'countries/us/' + e.point.drilldown + '-all',
// Handle error, the timeout is cleared on success
fail = setTimeout(function () {
if (!Highcharts.maps[mapKey]) {
chart.showLoading('<i class="icon-frown"></i> Failed loading ' +;

fail = setTimeout(function () {
}, 1000);
}, 3000);

// Show the spinner
chart.showLoading('<i class="icon-spinner icon-spin icon-3x"></i>'); // Font Awesome spinner

// Load the drilldown map
$.getScript('' + mapKey + '.js', function () {

data = Highcharts.geojson(Highcharts.maps[mapKey]);

// Set a non-random bogus value
$.each(data, function (i) {
this.value = i;

// Hide loading and add series
chart.addSeriesAsDrilldown(e.point, {
data: data,
dataLabels: {
enabled: true,
format: '{}'

this.setTitle(null, { text: });
drillup: function () {
this.setTitle(null, { text: 'USA' });

I know of one way of doing it, and this is by doing a window.history.go(-1) in the drillup function but this removes the zooming graphics and breaks the button after one click. history.go(-1) doesn't break the button but does not work properly after one click either.

I have found a similar issue here: Proper way to remove all series data from a highcharts chart? but this deals with a bar chart so the code is different.

The solution for this issue is to change

for (var i = 0; i < chart.series.length; i++)


while(chart.series.length > 0)

I had thought that not saving the cache on jsfiddle could solve this too but I could not get that working either.

Any help would be great. Thanks.

Answer Source

It is a regression bug from 5.0.3 to 5.0.4 version. It is fixed in the latest development version, so use 5.0.3/latest github version.

<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>

<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download