HighCharts:具有向下钻取功能的动态数据

HighCharts : dynamic data with drill down

本文关键字:功能 动态 数据 钻取 HighCharts      更新时间:2023-09-26

我需要生成一个具有向下搜索功能的交互式图表。我遇到了HighCharts,它非常好,很酷,但数据似乎是静态的。有没有任何方法可以在HighChart中进行动态数据和向下钻取的动态数据。

data = [{
                    y: 55.11,
                    color: colors[0],
                    drilldown: {
                        name: null,
                        categories: null,
                        data: null,
                        color: colors[0]
                    }
                }, {
                    y: 21.63,
                    color: colors[1],
                    drilldown: {
                        name: 'Firefox versions',
                        categories: ['Firefox 2.0', 'Firefox 3.0', 'Firefox 3.5', 'Firefox 3.6', 'Firefox 4.0'],
                        data: [0.20, 0.83, 1.58, 13.12, 5.43],
                        color: colors[1]
                    }
                }];

其中y的值被赋予静态值。我需要它是动态的,并为每个值分配一个向下钻取。它可以在HighCharts中完成吗?或者有其他工具可以使用吗?

这里有一些可以作为起点的东西:

var level = 0;
var refreshChart = function(){  
    new Highcharts.Chart({
        chart: {
            renderTo: 'chart'
        },
        xAxis: {
            categories: getXAxisValues()
        },
        series: [
                    {
                        data: getSeries1()
                    },
                    {
                        data: getSeries2()
                    }
            ],
        plotOptions: {
            series: {
                point: {
                    events: {
                        click: function () {
                            level = 1;
                            refreshChart();
                        }
                    }
                }
            }
        }
    });
};
var getSeries1 = function(){
    if(level == 0)
        // returns series data as described in highcharts documentation
    else
        // return some other data
}
// similar to getXAxisValues() if you have it and for getSeries2 if you have another serie