How to set a static minimum value for axes in Highcharts

后端 未结 2 1721
無奈伤痛
無奈伤痛 2020-12-09 21:40

I have time-based data that ranges from 1 to 500. Time is plotted on the x axis and the values are on the y axis.

When the range between the minimum and maximum data

2条回答
  •  借酒劲吻你
    2020-12-09 22:09

    I am amazed how difficult this is. Not an optimal solution, but the best I can dream up with HighChart's api:

    var someData = [1,5,82,9,300,5,42,199,5,6,99,1,56,52,250,64];
    
    var chart = new Highcharts.Chart({
    
        chart: {
            renderTo: 'container'
        },
        yAxis:{
            min: -10,
            tickInterval: 1,
            labels: {
                formatter: function() {
                    if (this.value < someData[0])
                        return null;
                    else if (this.value == someData[0])
                        return this.value;
                    else if (this.value % 50 == 0)
                        return this.value;
                }
            }
        },
        series: [{
            data: someData
        }]
    
    });
    

    enter image description here

提交回复
热议问题