如何使用PrimeNg Chart的宽度和高度?
<p-chart type="bar" width="400" height="400" [data]="data"></p-chart>
Run Code Online (Sandbox Code Playgroud)
当我使用宽度和高度时没有效果.请让我知道如何使用宽度和高度图表.
Ben*_*ikt 11
https://www.reddit.com/r/webdev/comments/4gjuvp/chartjs_canvas_height_width_ignored/
根据该链接,您必须为图表设置两个选项:
<p-chart type="bar" width="400" height="400" [data]="data" [options]="options"></p-chart>
Run Code Online (Sandbox Code Playgroud)
在你的打字稿代码中:
options = {
responsive: false,
maintainAspectRatio: false
};
Run Code Online (Sandbox Code Playgroud)
查看源代码,p-chart 将宽度和高度作为组件输入,因此将它们放在 [] 中应该可以解决问题:
<p-chart type="bar" [width]="400" [height]="400" [data]="data"></p-chart>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7857 次 |
| 最近记录: |