Highcharts 3.08 drilldown with multiple parent ser

2019-02-20 15:51发布

问题:

I am making my first drilldown charts with Highcharts, and I just installed version 3.09, in which drilldown has built-in support. The drilldown chart will be part of a page that already contains multiple charts. All charts have 3 series (State, Region, Sub-region) with data populated dynamically.

The problem is that the drilldown module doesn't seem to support multiple parent series. In my case, if I click on a column for a specific series (say, State), then the State series will disappear and its drilldown will appear, but the other series (Region, Sub-region) are still displayed and the graphic doesn't make any sense then. See this jsFiddle: http://jsfiddle.net/jmunger/6bBzt/ .

$(function () {
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: 'Monthly Average Rainfall'
            },
            subtitle: {
                text: 'Source: WorldClimate.com'
            },
            xAxis: {
                categories: [
                    'CAT 1',
                    'CAT2'
                ]
            },
            yAxis: {
                min: 0,
                title: {
                    text: 'Rainfall (mm)'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                    '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [{
                name: 'Tokyo',
                data: [{y:49.9, drilldown:'tokyo 1'}, {y:71.5, drilldown:'tokyo 2'}]

            }, {
                name: 'New York',
                data: [{y:49.9, drilldown:'ny 1'}, {y:71.5, drilldown:'ny 2'}]

            }],
            drilldown:{
                series: [{
                    id: 'tokyo 1',
                    data: [{y:39.9, name:'name1'}, {y:31.5, name:'name2'}]

                }, {
                    id: 'tokyo 2',
                    data: [{y:39.9, name:'name1'}, {y:31.5, name:'name2'}]

                },
                {
                    id: 'ny 1',
                    data: [{y:39.9, name:'name1'}, {y:31.5, name:'name2'}]

                }, {
                    id: 'ny 2',
                    data: [{y:39.9, name:'name1'}, {y:31.5, name:'name2'}]

                }]
              }
        });
    });

How can I make sure that all parent series are hidden when I perform a drilldown, and that they are then restored correctly when I drill up?

回答1:

It's bug in 3.0.8 and 3.0.9 version of drilldown. It's already fixed on master branch, see: http://jsfiddle.net/6bBzt/1/

<script src="http://github.highcharts.com/highcharts.js"></script>
<script src="http://github.highcharts.com/modules/exporting.js"></script>
<script src="http://github.highcharts.com/modules/drilldown.js"></script>