2013-12-17 70 views
0

我無法獲得flot來註冊我發送的自定義ticks。我的代碼工作正常,但滴答仍然出現,因爲無論選擇默認的滴答。js plotting library flot中的自定義ticks

HTML:

<div class="flot" id="flotcontainer"></div>'; 

JS:

var $hist_data = [[1.0, 0],[2.0, 2],[3.0, 1],[4.0, 1],[5.0, 0],[6.0, 1],[7.0, 2],[8.0, 1],[9.0, 1],[10.0, 1]]; 

var $hist_ticks = [[1.0, 1.0],[2.0, 2.0],[3.0, 3.0],[4.0, 4.0],[5.0, 5.0],[6.0, 6.0],[7.0, 7.0],[8.0, 8.0],[9.0, 9.0],[10.0, 10.0]]; 



<script type="text/javascript"> 

    $.plot($("#flotcontainer"), 

     [ 
      { 
      data: $hist_data, 

      bars: { show: true, barWidth: 1, fill:0.8}, 

      color: "#227dda", 

      xaxis: {ticks: $hist_ticks} 

      } 
     ] 

    ); 

</script> 

回答

2

你有你的xaxis性質混淆。令人困惑的是,數據本身有一個xaxis屬性,但這只是一個數字,用於指定應針對哪個數據系列進行繪圖。要實際設置軸蜱,你需要使用傳遞給.plot選項參數:

$.plot($("#flotcontainer"), [{ 
     data: $hist_data, 

     bars: { 
      show: true, 
      barWidth: 1, 
      fill: 0.8 
     }, 

     color: "#227dda" 

    }], {xaxis: { ticks: $hist_ticks} } 

); 

Fiddle

+0

釘吧!謝謝 –