2016-07-15 85 views
0

所以我有一個畫布元素,我想用Angular庫繪製圖表。我設法繪製它,但問題是canvas元素不佔用包含div的高度,它需要一個隨機的高度。有沒有人有過這個問題?我還使用ChartJs庫中的resize()方法(http://www.chartjs.org/docs/),但它似乎不起作用。有人有想法嗎?無法設置畫布高度AngularJS

提前致謝!

+0

嗨@blaa,是可以爲我們提供一個codepen?謝謝:) –

回答

0

嘗試更改默認值。

// Boolean - whether or not the chart should be responsive and resize when the browser does. 
responsive: true, 
// Boolean - whether to maintain the starting aspect ratio or not when  responsive, if set to false, will take up entire container 
maintainAspectRatio: false 

更多詳情:http://www.chartjs.org/docs/#chart-configuration-global-configuration

+0

我改變了默認設置,但它不起作用。它不能保持容器的高度 – blaa

+0

是否可以添加一個codepen,以便我們可以仔細查看確切的問題? –