Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/473.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
Javascript 如何显示x轴图表的第一个和最后一个标签_Javascript_Highcharts - Fatal编程技术网

Javascript 如何显示x轴图表的第一个和最后一个标签

Javascript 如何显示x轴图表的第一个和最后一个标签,javascript,highcharts,Javascript,Highcharts,我在其他答案上尝试了一些解决方案,但没有得到我想要的结果。。请帮帮我 我想在highcharts中显示第一个x轴标签和最后一个x轴标签 我从这个答案()中尝试了{endOnTick:true,showLastLabel:true},但它在最后一个答案上只显示了一些数字。。不是实际的最后一个标签 这是我的x轴选项 xAxis: { type: 'Month', // tickInterval is 5 this time tickInterval: <?php ech

我在其他答案上尝试了一些解决方案,但没有得到我想要的结果。。请帮帮我

我想在highcharts中显示第一个x轴标签和最后一个x轴标签

我从这个答案()中尝试了{endOnTick:true,showLastLabel:true},但它在最后一个答案上只显示了一些数字。。不是实际的最后一个标签

这是我的x轴选项

xAxis: {
    type: 'Month',
    // tickInterval is 5 this time
    tickInterval: <?php echo number_format($num_results/5, 0);?>,
    endOnTick: true, // it shows "25" at the end of the label. not "2019-06"
    showLastLabel: true, // Default is true though..
    labels: {
        autoRotation: 0
    },
    //I get those categories from server
    //so it could be different every time
    //but this time I just write the result of it.
    categories:  ["2017-07","2017-08","2017-09","2017-10","2017-11","2017-12","2018-01","2018-02","2018-03","2018-04","2018-05","2018-06","2018-07","2018-08","2018-09","2018-10","2018-11","2018-12","2019-01","2019-02","2019-03","2019-04","2019-05","2019-06"]
}
xAxis:{
键入:“月”,
//这次间隔时间是5分钟
时间间隔:,
endOnTick:true,//标签末尾显示“25”,而不是“2019-06”
showLastLabel:true,//但默认值为true。。
标签:{
自动旋转:0
},
//我从服务器上获取这些类别
//所以每次都不一样
//但这次我只写了结果。
类别:[“2017-07”、“2017-08”、“2017-09”、“2017-10”、“2017-11”、“2017-12”、“2018-01”、“2018-02”、“2018-03”、“2018-04”、“2018-05”、“2018-06”、“2018-07”、“2018-08”、“2018-09”、“2018-10”、“2018-11”、“2018-12”、“2019-01”、“2019-02”、“2019-03”、“2019-04”、“2019-05”、“2019-06”]
}
预期的x轴标签为 “2017-07 2017-12 2018-05 2018-10 2019-03 2019-06”

实际结果是
“2017-07 2017-12 2018-05 2018-10 2019-03 25”

您缺少两个类别来显示
2019-06

...
categories:  ["2017-07","2017-08","2017-09","2017-10","2017-11",
              "2017-12","2018-01","2018-02","2018-03","2018-04",
              "2018-05","2018-06","2018-07","2018-08","2018-09",
              "2018-10","2018-11","2018-12","2019-01","2019-02",
              "2019-03","2019-04","2019-05","2019-06","24th","the 25th"]
},

啊,我用滴答声定位器解决了它

xAxis: {
    type: 'Linear',
    tickmarkPlacement: 'on',
    tickPositioner: function() {
        var positions = [],
            ext = this.getExtremes(),
            xMax = Math.round(ext.max),
            xMin = Math.round(ext.min);

        for (var i = xMin; i < xMax; i++) {
            if (i % <?php echo number_format($num_results/3,0);?> == 0) {
                positions.push(i);
            }
        }
        positions.push(xMax);
        return positions;
    },
    labels: {
        autoRotation: 0,
    },
    categories:  ["2017-07","2017-08","2017-09","2017-10","2017-11","2017-12","2018-01","2018-02","2018-03","2018-04","2018-05","2018-06","2018-07","2018-08","2018-09","2018-10","2018-11","2018-12","2019-01","2019-02","2019-03","2019-04","2019-05","2019-06"]
}
xAxis:{
类型:'线性',
勾选位置:“on”,
定位器:函数(){
var头寸=[],
ext=this.getExtremes(),
xMax=数学四舍五入(ext.max),
xMin=数学圆(ext.min);
对于(var i=xMin;i
但2019-06年之后没有数据。。我可以用其他方法解决它。谢谢你的回答!