2011-11-04 45 views

回答

-3

嘗試parseInt(y_axis)

(填料文字,回答太短)

27

如果我理解你想要什麼,是在y軸的整數值顯示。

試試這個,

axesDefaults: 
{ 
    min: 0, 
    tickInterval: 1, 
    tickOptions: { 
      formatString: '%d' 
     } 
} 
+3

我只用了「tickOptions:formatString:'%d'」,它效果很好。 –

+0

但是對於y軸上的最大1pt,它顯示y軸上的o,1,1 – jbmyid

1

覆蓋createTicks功能和推出新的軸布爾屬性 - integersOnly。

// jqplot adding integersOnly option for an axis 
var oldCreateTicks = $.jqplot.LinearAxisRenderer.prototype.createTicks; 
$.jqplot.LinearAxisRenderer.prototype.createTicks = function (plot) { 
    if (this.integersOnly == true) { 
     var db = this._dataBounds; 
     var min = ((this.min != null) ? this.min : db.min); 
     var max = ((this.max != null) ? this.max : db.max); 
     var range = max - min; 
     if (range < 3) { 
      if (this.min == null) { 
       this.min = 0; 
      } 
      this.tickInterval = 1; 
     } 
    } 
    return oldCreateTicks.apply(this, plot); 
} 
1

只是建立在最上面的答案。

axes: { 
     yaxis: { 
      min: 0, 
      tickInterval: 1, 
      tickOptions: { 
        formatString: '%d' 
      } 

      } 
     } 

只適用於yaxis。有幫助的,如果你有一個條形圖或其他圖表,並且你想要隔離軸線。