Hightcharts - Not showing column datalabels when chart type is column

余生颓废 提交于 2019-12-13 04:23:28

问题


Below is the code fiddle to display highchart. It doesn't show datalabels when chart type is column. when it is 'bar' it shows datalabels.

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]
        }]
    });
});

Is there anything which I am missing?


回答1:


yes when you change the type from 'bar' to 'column', the same has to be done in plotOptions also change 'bar' to 'column' as shown below

$(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]
            }]
        });
    });

updated your fiddle at http://jsfiddle.net/LuxRK/1/



来源:https://stackoverflow.com/questions/17082936/hightcharts-not-showing-column-datalabels-when-chart-type-is-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!