Highcharts - 图表类型为列时不显示列数据标签

时间:2013-06-13 08:52:23

标签: highcharts

下面是显示高图的代码。当图表类型为列时,它不显示数据标签。当它是'bar'时它会显示数据标签。

http://jsfiddle.net/LuxRK/embedded/result/

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Historic World Population by Region'
        },
        subtitle: {
            text: 'Source: Wikipedia.org'
        },
        xAxis: {
            categories: ['Nominated', 'Approved','Rejected', 'Pending']

        },
        yAxis: {
            labels:
            {
                enabled:false
            }

        },

        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                }
            }
        },


        series: [{
            name: 'Employment',
            data: [107, 31, 635, 203]
        }, {
            name: 'Internship',
            data: [973, 914, 4054, 732]
        }]
    });
});

我有什么遗失的吗?

1 个答案:

答案 0 :(得分:3)

是的,当你将类型从'bar'更改为'column'时,必须在plotOptions中完成同样的操作,同时将'bar'更改为'column',如下所示

$(function () {
        $('#container').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: 'Historic World Population by Region'
            },
            subtitle: {
                text: 'Source: Wikipedia.org'
            },
            xAxis: {
                categories: ['Nominated', 'Approved','Rejected', 'Pending']

            },
            yAxis: {
                labels:
                {
                    enabled:false
                }

            },

            plotOptions: {
                column: {
                    dataLabels: {
                        enabled: true
                    }
                }
            },


            series: [{
                name: 'Employment',
                data: [107, 31, 635, 203]
            }, {
                name: 'Internship',
                data: [973, 914, 4054, 732]
            }]
        });
    });

http://jsfiddle.net/LuxRK/1/

更新了你的小提琴