首页 > 解决方案 > Highcharts 流图 - 如何按 Y 轴进行 1:1 缩放?

问题描述

这是我的代码 - https://jsfiddle.net/rxqpt8u4/1/

var colors = Highcharts.getOptions().colors;
Highcharts.chart('container', {

    chart: {
        type: 'streamgraph',
        marginBottom: 30,
        zoomType: 'x'
    },


   yAxis: {

        min:0           
    },  
    // Data parsed with olympic-medals.node.js
    series: [
    {
        "name": "Austria",
        "data": [
            2, 3, 4, 5, 5, 6, 6, 6, 7
        ]
    }]

});

无法理解为什么值不按 1:1 比例缩放。取而代之的是,它们的比例为 0.5:1。请指教。

标签: javascripthighcharts

解决方案


轴适应数据并且彼此独立。要在轴上设置相同的比例,请设置相同的tickInterval,maxmin属性:

    events: {
        load: function() {
            var xAxis = this.xAxis[0];

            this.yAxis[0].update({
                tickInterval: xAxis.tickInterval,
                max: xAxis.dataMax
            });
        }
    }

现场演示:https ://jsfiddle.net/BlackLabel/289jtzp1/


推荐阅读