首页 > 解决方案 > 使用带有 max 属性的滚动时,标签单击事件在高图条形图中不起作用

问题描述

Highcharts.chart(
    chart: {
        type: 'column',
        renderTo: selector,
        events: {
            load: function () {
                console.log(this)
                const axis = this.xAxis[0]
                const ticks = axis.ticks
                const points = this.series[0].points
                points.forEach(function (point, i) {
                    if (ticks[i]) {
                        const label = ticks[i].label.element
                        label.onclick = function () {
                            alert('label clicked')
                        }
                    }

                })
            }
        }
    },
    title: {
        text: titleText
    },
    xAxis: {
        categories: categories,
        min: 0,
        max: max,
        scrollbar: {
            enabled: true,
        },

    },
    series: seriesData,
)

标签: javascripthighcharts

解决方案


推荐阅读