2016-04-13 11 views
1

最大値を動的に最大値に設定しようとしています。私は間違いをしているのか分かりません...ハイチャート - yAxis最大データに対するtickInterval

何か助けてください?

Online Demo

予想:

enter image description here

私は何を取得しています:

enter image description here

PS:私は最大値(例:この例では100)を見つけたいととして、第1 yAxisLabelと、次の値があるべきことを示してマイナス( - )20等...

チャート1つの値[39, 35, 19, 38, 39, 48, 56, 57]

チャート2つの値[39, 35, 19, 38, 39, 48, 56, 57]

運のないしようとしたオプション:

yAxis: { 
    min: 0, 
    max: 100, 
    tickInterval: 20, 
}, 

yAxis: { 
    tickInterval: 20, 
    tickPositioner: function(min,max){ 
     var act = min, 
      ticks = []; 
     console.log(this); 
     while(act <= max){ 
     ticks.push(act); 
     act+= this.tickInterval; 
     } 
     return ticks; 
    }, 
    min: 0, 
    max: 100, 
}, 

@Kacper Madejのおかげコードの下に与えられた enter image description here

答えて

2

を結果はtockPositionerを使用することが可能であるとのセットが好きティック:

showLastLabel: false, 
    tickPositioner: function(min, max) { 
     var ticks = [], 
     tick = min, 
     step = Math.round((max - min)/7); 

     while (tick < max - step/2) { 
     ticks.push(Math.round(tick)); 
     tick += step; 
     } 
     ticks.push(Math.round(max)); 
     ticks.push(Math.round(max+step)); //hidden - added for top padding 

     return ticks; 
    } 

例:http://jsfiddle.net/e6har510/

+0

** @ Kacper Madej ** ...お返事ありがとうございます。しかし、それは私の問題を解決しませんでした:(私のすべての値は '[59,56,50,52,61,80,79,100]'と '[39,35,19,38,39,48,56,57 ] 'は** 100 **未満ですが、yAxisでは** 157 **として最大値を取得しています...チャートの最大値を特定し、maxLabelとして設定したい – Reddy

+1

@Reddy Sineスタッキングセットがあります、最大値は100 + 57なので、157.スタックを無効にして最大100を得る - http://jsfiddle.net/e6har510/1/ –

+0

** @ Kacper Madej **これはまさに私が探しているものです。 ..チップをありがとう – Reddy

関連する問題