首页 > 解决方案 > highchart轴标签不能设置在标签的开头?

问题描述

我继续遇到 highchart 的问题。

我正在生成带有给定数据的图表。

我的 x 轴标签需要自定义,所以我传递了一组数组

xAxis: {    
    min: -3.5,
    //catagories: [xaxis],                
    //type: 'linear',
    tickInterval: 1,
    //showFirstLabel: true,
    //startOnTick: true,
    labels: {
        formatter: function () {                    
            return xaxis[this.value];
        },
        //tickPositions: -3,
        rotation: -90,
    },    
},

我环顾四周并尝试了很多事情,我做错了什么?标签从 0 开始,我需要它从图表的开头开始

在此处输入图像描述

标签: javascripthighcharts

解决方案


感谢@codeer,

xAxis: {    
    min: -3.5,
    //catagories: [xaxis],                
    //type: 'linear',
    tickInterval: 1,
    //showFirstLabel: true,
    //startOnTick: true,
    labels: {
        formatter: function () {                    
            return xaxis[this.value+3];
        },
        //tickPositions: -3,
        rotation: -90,
    },    
},

+3 确实解决了我的问题,我确实尝试过 -3,但从未尝试过 +3 .. 谢谢!


推荐阅读