2016-06-16 31 views
0

我正在嘗試編輯使用ember-cli-chart來顯示圖表的選項。ember-cli-chart獲取beginAtZero工作

這裏是我的代碼:

// hbs template 
{{ember-chart type="Line" data=journeyData options=lineOptions height=100 width=400}} 

// route 
journeyData: Ember.computed('model.journey', function(){ 
    return { 
     labels: this.get('model.journey').mapBy('date'), 
     datasets: [{ 
      label: "Emissions", 
      fill:false, 
      tension: 0, 
      fillColor: "rgba(0,0,0,0)", 
      strokeColor: "#4caf50", 
      data: this.get('model.journey').mapBy('emissions'), 
     }] 
    } 
}), 
lineOptions: { 
    scales: { 
     yAxes: [{ 
      ticks: { 
       max: 5, 
       min: 0, 
       stepSize: 0.5, 
       beginAtZero: true 
      } 
     }] 
    }, 
    responsive: true, 
    maintainAspectRatio: true, 
} 

這是載列的文件說,但沒有下「」天平正在工作的選項。響應和維護AspectRatio選項的工作。

我把它放在正確的地方嗎?

+0

有你嘗試設置在控制器中的數據? –

回答

0

找到了解決辦法:

lineOptions: { 
    scaleBeginAtZero: true, // ADDED 
    scales: { 
     yAxes: [{ 
     display:true, 
     ticks: { 
      max:   5, 
      min:   0, 
      stepSize: 0.5, 
     } 
     }] 
    }, 
    responsive:   true, 
    maintainAspectRatio: true, 
    }