如何增加 highcharts 中特定 x 刻度的 tickLength

How to increase the tickLength of specific x ticks in highcharts

___________________________xAxis
| 10 ' 20 ' 30 | 40 ' 50 ' 60 | 70

如上所示,我想增加x轴10、40、70开始的tickLength

我找到了 Xaxis 的 tickLength 属性,它可以有一个数值,但它会更新轴上所有刻度的长度。

有什么方法可以实现我的目标吗?

您可以添加额外的 x 轴,这些轴将链接到主轴并且具有更长的选定刻度。在下面的示例中,刻度是使用 tickPositions 放置的,但如果需要先计算较长刻度的位置,则可以使用 tickPositioner。

JSFiddle:http://jsfiddle.net/qL550pmh/1/

/* Expect to increse the tick length infront of 2013, 2014 & 2015 */

//  |2013 |   |   |    | 2014 |    |    |    |2015
//  |                  |                     |

$(function () {

    var currentYear = '';
    var isMonthCombined = false;

    $('#container').highcharts({
        credits: {
            enabled: false
        },
        chart: {
            type: 'spline',
            style: {
                fontFamily: '"Open Sans", "Helvetica Neue", Helvetica, Arial',
                fontSize: 14
            },
            marginLeft: 78
        },
        title: {
            text: null
        },
        legend: {
            x: 40
        },
        xAxis: [{
            linkedTo: 1,
            categories: [],
            tickLength: 25,
            labels: {
                format: ' '
            },
            tickPositions: [3, 7]
        }, {
            gridLineColor: '#e0e0e0',
            gridLineWidth: 1,
            lineColor: '#e0e0e0',
            tickColor: '#e0e0e0',
            categories: ["Jan 2013 - Mar 2013",
                "Apr 2013 - Jun 2013",
                "Jul 2013 - Sep 2013",
                "Oct 2013 - Dec 2013",
                "Jan 2014 - Mar 2014",
                "Apr 2014 - Jun 2014",
                "Jul 2014 - Sep 2014",
                "Oct 2014 - Dec 2014",
                "Jan 2015"],
            labels: {
                formatter: function () {

                    var year = this.value.slice(-4);
                    if (currentYear != year) {
                        currentYear = year;
                        return currentYear;
                    }
                    return '';
                }
            }
        }],
        yAxis: {
            gridLineColor: '#e0e0e0',
            gridLineWidth: 1,
            lineColor: '#e0e0e0',
            title: {
                text: 'Views'
            },
            min: 0
        },
        plotOptions: {
            series: {
                allowPointSelect: true
            }
        },
        series: [{
            xAxis: 1,
            name: 'Views and Downloads',
            lineWidth: 6,
            color: '#f29400',
            marker: {
                symbol: 'circle',
                fillColor: '#FFFFFF',
                radius: 7,
                lineWidth: 5,
                lineColor: null
            },
            data: [21410,
            9413,
            3982,
            1000,
            0,
            5,
            176,
            104,
            3]
        }]
    });
});