简体   繁体   English

Highcharts yAxis max无法正常工作

[英]Highcharts yAxis max not working

Anyone know why the yAxis still goes up to 15 despite the max value being set to 14? 任何人都知道为什么yAxis仍然达到15,尽管最大值设置为14? I tried playing around with startOnTick and maxPadding and didn't get very far. 我尝试使用startOnTickmaxPadding ,并没有走得太远。

http://jsfiddle.net/sag8W/ http://jsfiddle.net/sag8W/

$(function () {
    $('#container').highcharts({
        chart: {                
                type: 'line'
            },
            yAxis: {
                min: 0, 
                max: 14
            },
            startOnTick: true,
            maxPadding: 0.02,
            series: [                                                           
                    {name: "2013/10/10",
                    data: [5.0, 3.0, 2.5, 3.0, 3.0, 5.0]},                                                          
                    {name: "2014/01/10",
                    data: [4.0, 1.5, 2.0, 2.0, 2.0, 4.0]}                                                                                               
            ]
    });
});

You need to set the tickInterval . 您需要设置tickInterval For some funky reason it is trying to divide the 15 points you have evenly into ticks (0 to 14 is 15 points) and it doesn't want to end on an odd value of ticks so it rounds up. 由于一些时髦的原因,它试图将你所拥有的15个点均匀地划分为刻度线(0到14是15个点)并且它不希望以奇数值的刻度结束,所以它向上舍入。 This is all supposition. 这都是假设。 Anyway, try this: 无论如何,试试这个:

    yAxis: {
        min: 0, 
        max: 14,
        tickInterval: 2
    },

This problem bugged me for days, and I kept hitting this page with Bing. 这个问题困扰了我好几天,我一直用Bing打这个页面。 Anwer here has been helpful, but the issue in my side was fixed following another sample, since I had static tick to set. Anwer在这里有所帮助,但是我的另一个样本中的问题已经修复,因为我有静态滴答设置。

Here is something similar to my final result (though it can be set dynamic); 这与我的最终结果类似(尽管它可以设置为动态);

    yAxis: {
        tickPositioner: function () {
            var positions = [0,1,2,3,4,5,6,7,8,9,10];
            return positions;
        }
    },

Example: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/xaxis/tickpositions-tickpositioner/ 示例: http//jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/xaxis/tickpositions-tickpositioner/

hope this helps. 希望这可以帮助。

Sol no olvides colocar lo siguiente, saludos. Sol no olvides colocar lo siguiente,saludos。

            chart: {
                alignTicks:false
            },
            ...
            yAxis: [{ // Primary yAxis
                min:-10,
                max:40,
                tickInterval:10,
            ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM