score:37

Accepted answer

it's possible, just add all drilldown series, then create a connection between point and drilldown. see: https://jsfiddle.net/blacklabel/rpt741xc/

    series: [{
        name: 'things',
        colorbypoint: true,
        data: [{
            name: 'animals',
            y: 5,
            drilldown: 'animals'
        }]
    }],
    drilldown: {
        series: [{
            id: 'animals',
            name: 'animals',
            data: [{
                name: 'cats',
                y: 4,
                drilldown: 'cats'
            }, ['dogs', 2],
                ['cows', 1],
                ['sheep', 2],
                ['pigs', 1]
            ]
        }, {

            id: 'cats',
            data: [1, 2, 3]
        }]
    }

score:-1

this.eixox = ["jun/2016","jul/2016","ago/2016","set/2016","out/2016","nov/2016","dez/2016"];
	this.eixoy = "reais";
	this.class = "divgraficolinhadotempo";
	this.titulo = "média de vendas por equipe";
	this.subtitulo;
	this.valoresbarras =[{
				name:"ecleia",
				data: [30000, 32000, 54000, 50000, 54000, 50000], //jan, fev, mar, abr, may, jun
				vendedores: [{name:"ecleiav1",data:[32000,40005,40005,27002,20002,70001]},{name:"ecleiav2",data:[30000,55000,45000,22000,32000,33001]}]
				},{
				name:"joana",
				data: [43000, 12000, 34000, 4000, 30004, 4000],
				vendedores: [{name:"joanav1",data:[72000,55005,70005,90002,70002,50001]},{name:"joanav2",data:[22000,50005,40005,40002,30002,66001]}]
				},{
				name:"gabriele",
				data: [22000, 22000, 34000, 20004, 30004, 4000],
				vendedores: [{name:"gabrielev1",data:[11000,30005,60005,40002,30002,30001],vendedores: [{name:"gabrielev1sub1",data:[11000,30005,60005,40002,30002,30001]},{name:"gabrielev1sub2",data:[60000,50005,40005,24502,55502,70001]}]},{name:"gabrielev2",data:[60000,50005,40005,24502,55502,70001]}]
				},{
				name:"francisco",
				data: [54000, 12000, 30004, 4000, 30004, 4000],
				vendedores: [{name:"franciscov1",data:[52000,60005,20005,11002,66002,40001]},{name:"franciscov2",data:[50000,56005,40005,25002,30002,38001]}]
				}];
        
	this.valoreslinha = [{
				name:"média",
				data: [54000, 12000, 30004, 4000, 30004, 4000]
			
				}];
	//atributos auxiliares

	this.nivel;
	this.indexmes;
	this.indexvendedor;
	this.drilldownniveis;
	var drilldowntitle = "equipe de ";


	///usercoderegionstart:[user functions] (do not remove this comment.)
	var _this = this;
	//var vetornomesx	= [];

  var colors = highcharts.getoptions().colors;

		$(function () {
			highcharts.tick.prototype.drillable = function () {}; //remove links dos labels do eixo x(mes), pois cada mes possui "n" vendedores
			var options = {
				type:"column",
				chart: {
					renderto: "container",
					events: {
							 drilldown: function(e) {
								 //console.log(e.point);
									 chart.settitle({ text: drilldowntitle + e.point.name });
							 },
							 drillup: function(e) {
									 chart.settitle({ text: _this.titulo });
							 }
					 }
				},
				title: {
					text: _this.titulo
				},
				subtitle: {
					text: _this.subtitulo
				},
				xaxis: {
					categories: _this.eixox
				},
				yaxis: {
					labels: {
						formatter: function () {
							return highcharts.numberformat(this.value,0);
						}
					},
					title: {
						text: _this.eixoy
					}
				},
				plotoptions: {

					column: {
											cursor: "pointer",
											point: {
													events: {
															click: function (e) {

																_this.indexmes = e.point.x;
																_this.indexvendedor = e.point.series.columnindex;
																																//lógica para avanço de niveis
																if(_this.drilldownniveis){
																	chart.settitle({ text: drilldowntitle + _this.drilldownniveis[_this.indexvendedor].name });
																	_this.drilldownniveis = _this.drilldownniveis[_this.indexvendedor].drilldown;
																	}else{
																		chart.settitle({ text: drilldowntitle + options.series[_this.indexvendedor].name });
			 														_this.drilldownniveis = options.series[_this.indexvendedor].data[_this.indexmes].drilldown;

																	if(options.series[_this.indexvendedor].data[_this.indexmes].drilldown.length<=0){ //se drilldown = 0 mesma coisa que não ter (undefined), então seto null!
																	_this.drilldownniveis = null;
																	}
															}
																//setchart de acordo com novas variaveis
																		if (_this.drilldownniveis) { // drill down
																					if(_this.drilldownniveis.length<=0){
																						_this.drilldownniveis = options.series;
																					}

																					var media = new array(0,0,0,0,0,0,0); //zera array para poder somar valores

																					for(var x=0;x<_this.eixox.length;x++){
																					$(_this.drilldownniveis).each(function(index, el) {
																						media[x] += el.data[x];
																						});
																					}
																					for(var x=0;x<_this.eixox.length;x++){
																							media[x] = media[x]/_this.drilldownniveis.length;
																					}

																						_this.drilldownniveis.push({
																								"name": "média",
																								"type":"spline",
																								"data": media
																						});

																				setchart(null, _this.eixox, _this.drilldownniveis, null, 1);
																				_this.drilldownniveis.pop();

																	} else if(!_this.drilldownniveis){ // restore
																		chart.settitle({ text: _this.titulo });
																		setchart(null, _this.eixox,options.series, null,2);
																	}else if(options.series){ // não vai entrar aqui
																		setchart(null, _this.eixox,options.series, null,2);
																	}
															}
													}
											}
									}
				},
				legend: {
					layout: "horizontal",
					align: "right",
					verticalalign: "bottom",
					floating: false,
					borderwidth: 0
				},
				credits: {
					enabled: false
				},
				series: []
				// drilldown: {
				// 	series: drill_down_data
				// }
			};

			function setchart(name, categories, series, color, tipo) {

				if(series.length<=0){

				}else{

			                chart.xaxis[0].setcategories(categories);
			                while (chart.series.length > 0) {
			                    chart.series[0].remove(true);
			                }
										  for (var i = 0; i < series.length; i++) {
												var tipocolumn="column";
												var marcador=[];

												if(i==series.length-1 ){
													tipocolumn="spline";
													marcador= {
														linewidth: 2,
														symbol: "circle",
														linecolor: highcharts.getoptions().colors[3],
														fillcolor: "white"
													};
												}
							 			//	chart.settitle({ text: _this.titulo });
			                    chart.addseries({
														 type: tipocolumn,
														marker: marcador,
			                        name: series[i].name,
			                        data: series[i].data,
															drilldown: series[i].drilldown,
			                        color: colors[i]
			                    });
			                }
										}

			            }

//inicialização das series do highcharts
$(_this.valoresbarras).each(function(index, el) {
	var drilldownseries =[];

	var series = {
		name: el.name,
		type: "column",
		data: []
				};
			for(var count=0;count<_this.eixox.length;count++){

				series.data.push({
						"name": el.name,
						"y": el.data[count],
						"colors": colors[index],
						"drilldown": drilldownseries
				});
			}

				$(el.vendedores).each(function(index2, vendedor) {
					drilldownseries.push({
			        "name" : vendedor.name,
			        "data"  : vendedor.data,
							"drilldown": vendedor.vendedores
							});
				});

	options.series.push(series);
});

$(_this.valoreslinha).each(function(index, el) {
		var series = {
			type: "spline",
			name: "",
			data: [],
			marker: {
				linewidth: 2,
				linecolor: highcharts.getoptions().colors[3],
				fillcolor: "white",
			}
		};
		series.name = el.name;
		series.data = el.data;
		options.series.push(series);
	});



			var chart = new highcharts.chart(options);
			/*$("#" + obj).highcharts({
			});*/
		});

	///usercoderegionend: (do not remove this comment.):
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script src="http://code.highcharts.com/modules/drilldown.js"></script>

<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">

</div>

i create a multi drilldown with multi levels, if anybody needs:

[http://jsfiddle.net/alissondiel/vnfwk/253/][1]

score:0

you have to write a custom code for mutilple drill downs, we can achieve this by storing data series in each columns ( first charts ) and passing this series to next graph and so on

score:1

here is an example that preserves the names on the axis. (drilldown works on "animals" > "mammals")

drilldown options looks like this:

drilldown: {
  series: [{
    id: 'animals',
    data: [{
        name: 'mammals',
        y: 4,
        drilldown: 'mammals'
      },
      ['reptiles', 2],
      ['vertebrates', 1]
    ]
  }, {
    id: 'mammals',
    data: [['cats', 3], ['dogs', 2], ['platypus', 1]]
  },
  ...

http://jsfiddle.net/vcsqnr2z/

score:2

<script src="js/jquery-2.0.2.min.js"></script>  
    <script src="js/highcharts.js"></script>  
    <script src="js/drilldown.js"></script>  
    <script>  
        var chartseriesdata = [];
  var chartdrilldowndata = [];

$.ajax({
type: 'get',
url: 'abc.json',
success: function(data) {


    var agentjson = data;

    for (var i = 0;i <agentjson.countryinfo.length; i++)

        {

        var series_name = agentjson.countryinfo[i].name;
        var drill_id = agentjson.countryinfo[i].drilldown;
        var series_data = agentjson.countryinfo[i].y;

        var drill_data = agentjson.countryinfo[i].data;


              chartseriesdata.push({
                 name: series_name,
                 y: parsefloat(series_data),
                 drilldown : drill_id                                     
              }); 


         chartdrilldowndata.push({
             data : drill_data,
             id: drill_id,
             name: series_name,

         });


        }

    /// end for loop


    $('#countryinfo').highcharts({

        credits: {
            enabled: false
        },

        chart: {
            type: 'pie',
            backgroundcolor:'rgba(255, 255, 255, 0.1)'
        },
        title: {
            text: 'human resources'
        },

        subtitle: {
            text: ''
        },
        plotoptions: {
            series: {
                cursor: 'pointer',
                datalabels: {
                    enabled: true,
                    format: '{point.name}: {point.y:.1f}%',
                    style: {
                        color: '#000',
                        fontweight: 'bold',
                        fontsize: '12px',
                        textshadow: "0px #ffffff"

                     }
                }
            }
        },

        tooltip: {
            headerformat: '<span style="font-size:11px">{series.name}</span><br>',
            pointformat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
        },
        series: [{
            name: 'country',
            colorbypoint: true,
            data: chartseriesdata
        }],
        drilldown: {
             series: chartdrilldowndata
            }
    });



}


});


    </script>  


and your json file look likes:

{"countryinfo":[{"name":"firefox","y":4,"drilldown":"firefox","data":[["desktop",1]]},{"name":"chrome","y":176,"drilldown":"chrome","data":[["desktop",1],["desktop",18]]}]}

score:8

for a mutiple levels pie chart check out http://jsfiddle.net/bge14m3a/1/

$(function () {

    // create the chart
    $('#container').highcharts({
        chart: {
            type: 'pie'
        },
        title: {
            text: 'deep drilldown'
        },
        xaxis: {
            type: 'category'
        },

        legend: {
            enabled: false
        },

        plotoptions: {
            series: {
                borderwidth: 0,
                datalabels: {
                    enabled: true,
                }
            }
        },

        series: [{
            name: 'things',
            colorbypoint: true,
            data: [{
                name: 'animals',
                y: 5,
                drilldown: 'animals'
            },{
                name: 'food',
                y: 4,
                drilldown: 'food'
            }]
        }],
        drilldown: {
            series: [{
                id: 'food',
                name: 'food',
                data: [{
                    name: 'apple',
                    y: 1.5,
                    drilldown: 'apple'
                },
                    ['banana', 1],
                    ['peer', 0.5],
                    ['pineapple', 1]
                ]
            }, {

                id: 'apple',
                data: [['1/6' ,1],
                      ['1/3' , 2],
                      ['1/2' , 3]]
            },{
                id: 'animals',
                name: 'animals',
                data: [{
                    name: 'cats',
                    y: 5,
                    drilldown: 'cats'
                }, ['dogs', 2],
                    ['cows', 1],
                    ['sheep', 1],
                    ['pigs', 1]
                ]
            }, {

                id: 'cats',
                data: [1, 2, 3]
            }]
        }
    })
});

Related Query

More Query from same tag