Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Highcharts 有没有办法在y aixs标签的格式化程序函数中获取点信息?_Highcharts_Gantt Chart - Fatal编程技术网

Highcharts 有没有办法在y aixs标签的格式化程序函数中获取点信息?

Highcharts 有没有办法在y aixs标签的格式化程序函数中获取点信息?,highcharts,gantt-chart,Highcharts,Gantt Chart,我正在渲染highcharts甘特图,并希望修改y轴标签 在标签的格式化程序函数中,我得到的点是未定义的,我想知道如何获得该信息 yAxis: { useHTML: true, labels: { formatter: function() { console.log(this); return ` <a class="left"> <stro

我正在渲染highcharts甘特图,并希望修改y轴标签

在标签的格式化程序函数中,我得到的点是未定义的,我想知道如何获得该信息

yAxis: {
    useHTML: true,
    labels: {
        formatter: function() {
            console.log(this);
            return `
            <a class="left">
                <strong> ${this.value} </strong> 
                <br/> 
                <i>Job Type</i>
            </a>`;
        }
    }
}
yAxis:{
是的,
标签:{
格式化程序:函数(){
console.log(this);
返回`
${this.value}

工作类型 `; } } }
格式化程序函数被多次调用,并且在第一次调用中不存在点。但是,您可以在以后的调用中通过
this.chart.series[X].points
获取积分,并将
this.pos
point.y
进行比较:

yAxis: {
    labels: {
        useHTML: true,
        formatter: function() {
            var seriesPoints = this.chart.series[0].points,
                points,
                result = '<a class="left"><strong>',
                pos = this.pos;

            if (seriesPoints) {
                points = seriesPoints.filter(function(p) {
                    return p.y === pos;
                });

                points.forEach(function(p) {
                    result += p.name + '<br/>'
                });

                result += '</strong><i>Job Type</i></a>'

                return result
            }
        }
    }
}
yAxis:{
标签:{
是的,
格式化程序:函数(){
var seriesPoints=this.chart.series[0]。点,
要点,,
结果


API参考:

轴标签和任何点之间都没有真正的直接联系。幸运的是,至少有一个系列中有一个点处于该精确值,但也可能完全未命中。您可以在该系列中循环,找到靠近标签位置的东西,这样就可以了将此
this.chart.series
放入格式化程序。