score:0
i guess you already got the answer. still it might be helpful for others.
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/data.js"></script>
<script src="http://code.highcharts.com/modules/drilldown.js"></script>
<div id="container" style="width: 700px; height: 400px; margin: 0 auto"></div>
<button id="pie">reset</button>
javascript part
var chart;
$(document).ready(function() { /*begin chart render*/
var colors = highcharts.getoptions().colors,
categories = ['the americas', 'asia pacific', 'europe & africa'],
//name = 'sectors',
data = [{
name: 'a-1',
y: 55,
color: colors[0],
drilldown: {
//begin alcohol
name: 'a-1',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [122252, 3516, 4036, 3557, 4021, 3624, 3847],
color: colors[0],
data: [{
y: 33.06,
name: 'a',
drilldown: {
name: 'budweiser',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [10838, 11349, 11894, 11846, 11878, 11662, 11652, 11438, 11833, 12252],
color: colors[0]
}},
{
y: 10.85,
name: 'b',
drilldown: {
name: 'heinekein',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [2266, 2396, 2431, 2380, 2357, 3516],
color: colors[0]
}},
{
y: 7.35,
name: 'c',
drilldown: {
name: 'jack daniels',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [1583, 1580, 1612, 4036],
color: colors[0]
}},
{
y: 2.41,
name: 'd',
drilldown: {
name: 'johnnie walker',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [1649, 1654, 1724, 3557],
color: colors[0]
}},
{
y: 2.41,
name: 'e',
drilldown: {
name: 'moet & chandon',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [2470, 2445, 2524, 2861, 2991, 3257, 3739, 3951, 3754, 4021],
color: colors[0]
}},
{
y: 2.41,
name: 'f',
drilldown: {
name: 'smirnoff',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [2594, 2723, 5600, 2975, 3097, 3032, 3379, 3590, 7350, 3624],
color: colors[0]
}},
{
y: 2.41,
name: 'g',
drilldown: {
name: 'corona',
categories: ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
data: [3847],
color: colors[0]
}}],
}},
{
name: 'b-1',
y: 11.94,
color: colors[2],
drilldown: {
name: 'b',
categories: ['a-2', 'b-2', 'c-2'],
color: colors[2],
data: [{
y: 33.06,
name: 'a',
drilldown: {
name: 'a',
categories: ['a', 'b'],
data: [4444, 6666],
color: colors[3]
},
},
{
name: 'b',
y: 10.85,
drilldown: {
name: 'b',
categories: ['a', 'b'],
data: [22222, 6005],
color: colors[3]
},
},
{
name: 'c',
y: 7.35,
drilldown: {
name: 'c',
categories: ['2011'],
data: [3605],
color: colors[3]
}}],
}},
];
window.chart = new highcharts.chart({
chart: {
renderto: 'container',
type: 'pie',
/* changes bar size */
pointpadding: -0.3,
borderwidth: 0,
pointwidth: 10,
shadow: false,
backgroundcolor: '#e2dfd3'
},
title: {
text: 'pie test'
},
subtitle: {
text: 'pie chart triple breakdown'
},
xaxis: {
categories: categories
},
yaxis: {
title: {
text: 'total brand value',
categories: categories
}
},
//drilldown plot
plotoptions: {
pie: {
cursor: 'pointer',
allowpointselect: true,
pointpadding: -0.3,
borderwidth: 0,
pointwidth: 15,
shadow: false,
point: {
events: {
click: function() {
var chart = this.series.chart,
drilldown = this.drilldown;
if (drilldown) { // drill down
chart.setchart(drilldown.name, drilldown.categories, drilldown.data, drilldown.color);
}
}
}
},
datalabels: {
enabled: true,
color: '#000',
//label colors
connectorcolor: '#000',
// connector label colors
formatter: function() {
return '<b>' + this.point.name + '</b>: ' + this.y;
}
}
}
},
//formatting over hover tooltip
tooltip: {
formatter: function() {
var point = this.point,
s = point.name + ':<b>' + this.y + '% market share</b><br/>';
if (point.drilldown) {
s = point.name + ':<b>' + this.y + '222</b><br/>';
s += 'click to view ' + point.name + ' versions';
} else {
s = point.name + ':<b>' + this.y + '333</b><br/>';
s += 'click to return to browser brands';
}
return s;
}
},
credits: {
enabled: false
},
series: [{
name: name,
data: data,
/* changes bar size */
pointpadding: -0.3,
borderwidth: 0,
pointwidth: 15,
shadow: false,
color: 'black' //sectors icon
}],
exporting: {
enabled: false
}
}, function(chart){
chart.upper = [];
var up = false;
chart.setchart = function(name, categories, data, color) {
//chart.xaxis[0].setcategories(categories);
if (name === true && chart.upper.length) {
chart.series[0].remove();
chart.addseries( chart.upper.pop() );
if( chart.upper.length === 0 ) {
$("#pie").hide('up');
up = false;
}
return true;
}
if (up === false) {
$("#pie").show().bind('click', function(){ chart.setchart(true); });
up = true;
}
chart.upper.push( chart.series[0].options );
chart.series[0].remove();
chart.addseries({
name: name,
data: data,
color: color || 'white'
});
}
});
});
score:3
not sure if this helps you. but i think it will be easier for you to implement this using the data from server side. you can just change the data of the piechart as shown below that can take you to any level. you just have to keep an identified to identify which level you are in.
var chart = new highcharts.chart({
chart: {
renderto: 'container',
type: 'pie'
},
series: [{
data: myinitialdataarray, // make sure each data point has an id
point: {
events: {
click: function () {
$.post('/get/data/url/' + this.id, function(data) {
// you may need to format your data here
// set the level here. e.g level 1, 2 or 3 and then depending on that you can also change the url also or any other logic
chart.series[0].setdata(data);
});
}
}
}
}]
});
Source: stackoverflow.com
Related Query
- HighCharts - Pie chart drilldown for multilevel (3 to 4 level)
- Highcharts display label for pie chart using html table as data source
- Highcharts how to make a set number of colors for pie chart data and drilldown data
- Highcharts not displaying data labels for Pie chart in arabic
- highcharts - chart names for multiple pie chart series in one chart
- Highcharts Pie Chart Drilldown not showing on third drill
- Highcharts - Display legend for Pie chart in two columns
- Highcharts --- Change sliced color on drilldown pie chart
- highcharts donut pie - different color for the data than its drilldown
- Drilldown for grouped column chart in highcharts
- Highcharts - where to place style and changing style for one wedge in a pie chart
- highcharts pie chart color for dynamic data
- Show/Update Separate Bar graphs with Drilldown Pie chart of Highcharts
- Gson to get Json value for a pie chart using Highcharts
- Highcharts drilldown to pie chart - Clicking on axis label with multiple series causes pie charts to overlap
- Creating a drilldown chart with Highcharts that contain double(multiple) columns for each column (see example for better explanation)
- Highcharts to populate data for pie chart using json object
- 3D Pie Drilldown chart in highcharts
- highcharts shows exception "c is undefined" for pie chart
- Highcharts - How to combine unique legend for multi-series pie chart which perform same action for both series? (like onclick: show/hide)
- Highcharts stacked column chart 3 level drilldown from JSON
- Highcharts - Pie chart Color for each slice
- how to show legend in PIE chart from chart to pie drilldown highcharts
- How to convert a highcharts Pie chart to HTML/Table on drilldown
- Dynamic highcharts pie chart with drilldown
- Disabling a slice for a Highcharts pie chart when creating the chart
- Highcharts issues in [object Object]:0.0 for pie chart
- Highcharts piechart with slice animation and drilldown on click together throws exception in chart and breaks the pie chart
- HighCharts API pie chart CSS how to select drilldown labels
- How to define format for Drilldown Pie Charts in Highcharts
More Query from same tag
- Angular highcharts treemap squarified fit tiles
- Highcharts activity gauge in Shiny
- How to display rounded corners in a highcharts column on a Y Axis that starts above 0
- highchart, TypeError: obj is null
- Highcharts axis does not show properly values when numbers are so small
- Highcharts redundant time data with multiple axes
- Highcharts: X and Y Axis cross at zero in scatter chart
- Highcharts - more series then data
- How to change chart's width to fill up div using angular2-highcharts when hide/open left side nav menu?
- Multiple series data on HighCharts column
- Highcharts Column Chart
- HighCharts: Remove GridLine Overhang (Angular/TypeScript)
- Highcharts - too many series are displayed
- Simple bar chart in jQuery HighCharts and MVC 2 application?
- Highcharts 24 hour setup for hourly values
- undefined value in Highchart
- Getting problems to Set Icons(Image) on HighCharts
- highcharts style modification in R
- chart.series[id].remove() is not able to refresh legend properties of other series in highcharts/highstock
- Highcharts how to use column title as X axis and not as Legend
- highcharts - Custom legend - sending the name of the filter to a php file
- yii2 : dynamic dosamigos HighCharts from database
- Modifying text in resetZoomButton doesn't work - highcharts
- Create highchart density with more than 2 groups
- Only a limited number of rows in my excel sheet can be plotted on Highchart
- highcharts pie chart multiple sections selection
- Highcharts tooltip is not working for large data
- Highchart does not load data from hidden input when using .val
- Rcharts Shiny : not reload all variables after just one variable update
- How to align lines marker in middle/centre of the bars - High Charts