如何在高图表中设置导航器标签格式化程序


我需要设置导航器 x 轴标签

格式化程序但不起作用?无论如何可以为导航器设置 x 轴标签值?

请参阅下面的代码

   navigator: {
        handles: {
            backgroundColor: 'white',
            borderColor: 'red',
        },
        labels: {
            align: 'center',
            x: 3,
            y: 16,
            formatter: function () {
                if (((this.value * 4) % 1000) == 0) {
                    if ((((this.value) * 4) / 1000) % 5 == 0) {
                        alert("inside");
                        return (((this.value) * 4) / 1000) + "s";
                    }
                    else {
                        alert("inside else");
                        return (((this.value) * 4) / 1000) + "s";
                    }
                }
                else {
                    return (((this.value) * 4) / 1000) + "s";
                }
            }
        },
        enabled: true,

您的labels选项应嵌套在xAxis选项中:

   navigator: {
        handles: {
            backgroundColor: 'white',
            borderColor: 'red'
        },
        xAxis: { // you are missing this level
            labels: {
                formatter: function () {
                    if (((this.value * 4) % 1000) == 0) {
                        if ((((this.value) * 4) / 1000) % 5 == 0) {
                            alert("inside");
                            return (((this.value) * 4) / 1000) + "s";
                        }
                        else {
                            alert("inside else");
                            return (((this.value) * 4) / 1000) + "s";
                        }
                    }
                    else {
                        return (((this.value) * 4) / 1000) + "s";
                    }
                }
            }
        }
    }

最新更新