Highcharts Stacked column drill down down work?>如何为我的场景设置向下钻取系列?

时间:2015-02-04 22:51:29

标签: jquery html5 highcharts

我已经在不同条件下为堆积柱高图创建了5个不同的系列,并向下钻取。堆积的列显示但是向下钻取不起作用。

       $.each(brands, function (name, y) {
            brandsData1.push({
                name: name,
                y: y,
                drilldown: versions[name] ? name : null
            });
        });
        $.each(versions, function (key, value) {
            drilldownSeries1.push({
                name: key,
                id: key,
                data: value
            });
        });

        $.each(brands, function (name, y) {
            brandsData2.push({
                name: name,
                y: y,
                drilldown: versions[name] ? name : null
            });
        });
        $.each(versions, function (key, value) {
            drilldownSeries2.push({
                name: key,
                id: key,
                data: value
            });
        });

            $.each(brands, function (name, y) {
            brandsData3.push({
                name: name,
                y: y,
                drilldown: versions[name] ? name : null
            });
        });
        $.each(versions, function (key, value) {
            drilldownSeries3.push({
                name: key,
                id: key,
                data: value
            });
        });
            $.each(brands, function (name, y) {
            brandsData4.push({
                name: name,
                y: y,
                drilldown: versions[name] ? name : null
            });
        });
        $.each(versions, function (key, value) {
            drilldownSeries4.push({
                name: key,
                id: key,
                data: value
            });
        });
            $.each(brands, function (name, y) {
            brandsData5.push({
                name: name,
                y: y,
                drilldown: versions[name] ? name : null
            });
        });
        $.each(versions, function (key, value) {
            drilldownSeries5.push({
                name: key,
                id: key,
                data: value
            });
        });

在Highchart上:

               series: [{
                            name: 'Brand1',
                            data: brandsData1
                        }, {
                            name: 'Brand2',
                            data: brandsData2
                        }, {
                            name: 'Brand3',
                            data: brandsData3
                        }, {
                            name: 'Brand4',
                            data: brandsData4
                        }, {
                            name: 'Brand5',
                            data: brandsData5
                        }
                        ]

如何在这里设置Drilldown系列?

1 个答案:

答案 0 :(得分:0)

以下是带有向下钻取的堆叠列的示例:

http://jsfiddle.net/8zfcsssu

您可以使用以下内容进行动态下钻:

$.ajax({
    type:"GET",
    dataType: "json",
    contentType: "application/json",
    async: false,
    crossDomain: true,
    url: "your service which returns json",
    success: function(data) {
        drilldowns = data;
        series = drilldowns[e.point.name];
    },
    error: function(jqXHR, textStatus, errorThrown) {
        console.log(textStatus);
        console.log(errorThrown);
    }
});
setTimeout(function () {
    chart.hideLoading();
    chart.addSeriesAsDrilldown(e.point, series);
    chart.xAxis[0].setCategories([]);
}, 1000);

如果将其添加到jsfiddle示例的向下钻取事件处理程序中,它将正常工作。

希望这有帮助

彼得