javascript - Highcharts : dynamic data with drill down

标签 javascript jquery highcharts

我需要生成具有向下钻取功能的交互式图表。我遇到了 HighCharts,它非常好而且很酷,但数据似乎是静态的。有什么办法可以在HighChart中做动态数据和动态数据做drill down。

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

关于javascript - Highcharts : dynamic data with drill down,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9123013/

相关文章:

javascript - (异步 () => { })();这是什么?

javascript - Onclick 不与按钮重复(变量最大值为整数 1)

javascript - 当用户开始输入时如何清除表单的默认值(jquery)

R highcharts多堆积条形图

javascript - Highcharts不显示柱形图

javascript - jQuery Click 不工作/注册

javascript - 使用 Knockout、Breeze、Durandal 搜索可观察数组

javascript - 当我输入一个 £ 符号时,使用 jQuery 输出 html 会创建一个随机的 'Â'

jquery - 将 ASP.NET updatepanel 与 jQuery UI DatePicker 组合时出现奇怪的错误

r - R 中 Highcharter 中的两个 y 轴