Y轴在Highcharts中打勾

时间:2014-10-14 02:08:52

标签: highcharts

在highcharts中,默认情况下x轴上有刻度线,就像在x轴上一样(下面的代码片段),但我找不到任何方法在y轴上创建刻度线。这是可能的吗?

enter image description here

$(function () {
    $('#container').highcharts({
        title:{
            text:''
        },
        
        xAxis: {
            gridLineColor: 'transparent',
            title: {
                text: "x"
            },
            gridLineWidth: 1,
            min: -5,
            max: 5,
            tickInterval: 1,
        },
        yAxis: {
            gridLineColor: 'transparent',
            title: {
                text: "y"
            },
            min: -5,
            max: 5,
            tickInterval: 1,
            lineWidth: 1,
            title: {
                text: null
            }
        },
        
        legend: {
            enabled: false
        },

        series: [{
            type: "line",
             marker: {
                 enabled: false
             },
            
            data: [
                [-3, 3],
                [-2, 2],
                [-1, 1],
                [0, 0],
                [1, 1],
                [2, 2],
                [3, 3]

            ]
        }]

    });
});
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="width: 400px; height: 400px"></div>

1 个答案:

答案 0 :(得分:4)

只需使用tickLengthtickWidth

yAxis: {
    tickLength: 10,
    tickWidth: 1
}

示例:http://jsfiddle.net/7ox30pmy/