如何在Highcharts中为Stacked Chart的图例创建表格?

时间:2014-11-20 06:54:30

标签: javascript html highcharts

这是高图中堆栈图表的javascript代码 -

 legend: {
 align: 'right',
 x: -70,
 verticalAlign: 'top',
 y: 20,
 floating: true,
 backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
 borderColor: '#CCC',
 borderWidth: 1,
 shadow: false
},

以下是我的一系列数据 -

series: [{
        name: 'A',
        data: [5]
    }, {
        name: 'B',
        data: [2]
    }, {
        name: 'C',
        data: [3]
    }]

是否可以以表格格式显示Highcharts(堆积图表)的上述数据的图例?

1 个答案:

答案 0 :(得分:-1)

表格格式的Highcharts(堆积图表)

http://jsfiddle.net/ntg7qz3q/1/

工作小提琴

 $(function () {
        $('#container').highcharts({
            chart: {
                type: 'bar'
            },
            title: {
                text: 'Stacked bar chart'
            },
            xAxis: {
                categories: ['A', 'B', 'C']
            },
            yAxis: {
                min: 0,
                title: {
                    text: 'Total fruit consumption'
                }
            },
            legend: {
     align: 'right',
     x: -70,
     verticalAlign: 'top',
     y: 20,
     floating: true,
     backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
     borderColor: '#CCC',
     borderWidth: 1,
     shadow: false
    },
            plotOptions: {
                series: {
                    stacking: 'normal'
                }
            },
            series: [{
            name: 'A',
            data: [5]
        }, {
            name: 'B',
            data: [2]
        }, {
            name: 'C',
            data: [3]
        }]
        });
    });