Reputation: 2675
I am trying to capture the drillup event on the Sunburst chart but I am not able to achieve it.
I added the events object to the chart object and still not able to get an alert fired within the function.
I basically want an alert/console.log to fired when we drillup by clicking on the button on the top right side after a level/levels are drilled down.
A codepen is here for your reference.
Highcharts.chart('container', {
chart: {
height: '100%',
events: {
drillup: function() {
alert('Drilling up')
}
}
},
title: {
text: 'World population 2017'
},
subtitle: {
text: 'Source <href="https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)">Wikipedia</a>'
},
series: [{
type: "sunburst",
data: data,
allowDrillToNode: true,
cursor: 'pointer',
dataLabels: {
format: '{point.name}',
filter: {
property: 'innerArcLength',
operator: '>',
value: 16
}
},
levels: [{
level: 1,
levelIsConstant: false,
dataLabels: {
filter: {
property: 'outerArcLength',
operator: '>',
value: 64
}
}
}, {
level: 2,
colorByPoint: true
},
{
level: 3,
colorVariation: {
key: 'brightness',
to: -0.5
}
}, {
level: 4,
colorVariation: {
key: 'brightness',
to: 0.5
}
}]
}],
tooltip: {
headerFormat: "",
pointFormat: 'The population of <b>{point.name}</b> is <b>{point.value}</b>'
}
});
Please advice.
Upvotes: 0
Views: 841
Reputation: 7372
You can make a wrapper to sunburst.prototype.drillUp method and add your code before or after drill up occurs.
(function(H) {
H.wrap(H.seriesTypes.sunburst.prototype, 'drillUp', function (proceed) {
console.log("Before drillup.");
proceed.apply(this, Array.prototype.slice.call(arguments, 1));
console.log("After drillup.");
});
})(Highcharts);
Wrapping prototype functions documentation:
https://www.highcharts.com/docs/extending-highcharts/extending-highcharts
Online demo:
https://jsfiddle.net/wchmiel/gsx1bacu/
Upvotes: 2