2014-01-13 192 views
2

我想顯示儀表數據標籤上一定數目的這樣的計highcharts一些specefic號:
gauge with user select number顯示軸標籤

我嘗試使用categoryyAxis這樣formatter選項,但zhcon失敗!

categories: ['0','3','7','14'], 

labels: { 
    formatter: function() { 
     if(this.value == '0' ||this.value == '3' ||this.value == '7' ||this.value == '14') 
      return this.value; 
    } 
}, 

有什麼不對這種方法嗎?另外任何其他解決方案將不勝感激。
這是一個fiddle我打算繼續努力。

+0

請檢查下面的小提琴。 http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/gauge-dual/ –

+0

@APaul這些數字是自動生成的。但我想要顯示一些特定的數字。 – osyan

回答

5

最後我解決了這個問題。這裏是我添加到yAxis

rotation:'auto',  
    labels: { 
     distance: 20, 
     formatter: function() { 
      if(this.value == '0' ||this.value == '3' ||this.value == '7' ||this.value == '14') 
       return this.value; 
     } 
    }, 
    tickInterval: 1, 
    minorTickLength:0, 

這裏是Fiddle

+1

Intersting,你必須指定minorTickLength。好點。 – SteveP

+0

@SteveP YaH :)我必須閱讀文檔,是的,但它沒有提及它或任何提琴。 – osyan