防止 highcharts 上特定 series/y-axis 的 y 缩放

Prevent y-zoom for specific series/y-axis on highcharts

我有一个带有两个 y 轴的样条图表,它们都使用相同的 x 轴周期(秒)。缩放 (xy) 已启用并且工作正常,但现在我只想在连接到两个 y 轴之一的系列上缩放 xy。其他系列的 y 轴应该是静态的(禁用 y 缩放),这样它们就不会放大到 y 轴...这可能吗?

chart: {
        renderTo: 'container',
        type: 'spline',
        zoomType: 'xy',
        alignTicks: false,
        resetZoomButton: {
            theme: {
                display: 'none'
            }
        }
    },
    title: {
        text: '',
        x: -20 //center
    },
    legend: {
        enabled: false  //Hide the legend
    },
    credits: {
        enabled: false  //Hide credits (highcarts.com link)
    },
    exporting: {
        enabled: false  //Hide export menu
    },
    xAxis: {
        title: {
            text: 'sec'
        },
        type:'second',
        lineColor: '#666666',
        lineWidth: 2,

        endOnTick: false,
        showFirstLabel: false,
        startOnTick: true,

        gridLineWidth: 0,               //Shows a grid starting from the tick within the data content
        tickInterval:1,
        tickLength: 10,                 //Tick length (height)
        tickWidth: 2,                   //Tick width (2px)
        tickColor: '#666666',

        minorGridLineWidth: 0,          //Shows a grid starting from the tick within the data content
        minorTickInterval:.1,
        minorTickLength: 6,             //Minortick length (height -> half of tick tickLength)
        minorTickWidth: 1,              //Minortick width (1px)
        minorTickColor: '#666666',

        min: 0, //Prevent for generating sizes lower than 0 on x-axis
        max: 15,

        labels:{
            y: 25
        }
    },
    yAxis: [{
        title: {
            text: 'm/s'
        },
        gridLineWidth: 0,
        lineColor: '#8BC926',
        lineWidth: 2,

        min: 0,
        max: 200,

        offset: 15      //Space between y-axis and x-axis
    }, {
        title: {
            text: 'Bar'
        },
        gridLineWidth: 0,
        lineColor: '#389FFF',
        maxZoom: 0,
        lineWidth: 2,

        min: 0,
        max: 300
    }],
    plotOptions: {
        spline: {
            marker: {
                enabled: true
            }
        }
    },
    series: [{
        color: '#8BC926',
        data: [
            {x: 0, y: 80},
            {x: 1, y: 110},
            {x: 2, y: 100},
            {x: 3, y: 50},
            {x: 4, y: 75},
            {x: 5, y: 90}
        ],
        yAxis: 0
    },
    {
        color: '#389FFF',
        data: [
            {x: 0, y: 170},
            {x: 1, y: 210},
            {x: 2, y: 240},
            {x: 3, y: 210},
            {x: 4, y: 170},
            {x: 5, y: 100}
        ],
        yAxis: 1
    }]

JS Fiddle (Full example code)

它不是 API 的一部分,但您可以使用 yAxis.zoomEnabled 选项:http://jsfiddle.net/0zczvLr9/ - 只需为您不想启用缩放的这些轴设置。