【问题标题】:Unable to set canvas height AngularJS无法设置画布高度AngularJS
【发布时间】:2016-11-18 14:18:34
【问题描述】:

所以我有一个画布元素,我想使用 Angular 库绘制一个图表。我设法绘制它,但问题是画布元素不采用包含 div 的高度,它采用随机高度。以前有人遇到过这个问题吗?我还使用了 ChartJs 库 (http://www.chartjs.org/docs/) 中的 resize() 方法,但它似乎不起作用。有人有想法吗?

提前致谢!

【问题讨论】:

  • 嗨@blaa,可以为我们提供一个codepen吗?谢谢:)

标签: html angularjs canvas resize


【解决方案1】:

尝试更改默认值。

// 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

【讨论】:

  • 我更改了默认设置,但它不起作用。它不保持容器的高度
  • 是否可以添加一个 codepen 以便我们更仔细地查看确切的问题?
猜你喜欢
  • 2016-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-30
  • 2014-06-15
  • 2011-10-25
相关资源
最近更新 更多