无论如何要在 xAxis 上居中柱形图

我只想将列居中放置在他们的 xAxis 上,有没有办法做到这一点?这是我的高图代码

看起来该列总是从刻度开始,我只想显示 2 个刻度之间的列。

检查这个https://imgur.com/lvV006M

Highcharts.chart('YearNS', {

        chart: {

            width: 1200,

            height: 450,

           type: 'column',

            events: {

                click: function (e) {

                    console.log(e.type, this.name);


            },

            }

        },

        exporting: {

            enabled: false

        },

        title: {

            text: 'This Year NS vs Last 4 Years'

        },

        subtitle: {

            text: 'Click the columns to view the breakdown by Term. Click again to view by Program. Updated as of ' + MyUpdateDate

        },

        credits: {

            enabled: false

        },

        xAxis: {

            min: 0,

            max: 4,


            categories: categories

        },

        yAxis: {

            title: {

                text: "Number of Students"

            }

        },

        legend: {

            enabled: true,

            align: 'center',

            layout: 'horizontal',

            verticalAlign: 'top',


            floating: false,

            borderWidth: 1,

            backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),

            shadow: true

        },

        plotOptions: {

            series: {


                point: {

                    events: {

                        click: function () {


                            ParamYear = this.category

                             var res = ParamYear.substring(0, 4);

                          // let urlParams = new URLSearchParams('=');

                            window.location = "http://localhost:37590/NewStudentReportTerm?ParYear="  + res


                        }

                    }

                },


我希望 th 列出现在这些线之间,每年的中心。这可能吗?


江户川乱折腾
浏览 95回答 1
1回答

森林海

您需要禁用grouping该系列的选项column: plotOptions: {     column: {         grouping: false     } }现场演示:http: //jsfiddle.net/BlackLabel/ow8vkq1f/API 参考:https ://api.highcharts.com/highcharts/plotOptions.column.grouping
打开App,查看更多内容
随时随地看视频慕课网APP