How to use PrimeNg width and height chart?

How can I use width and height for a PrimeNg chart?

 <p-chart type="bar" width="400" height="400" [data]="data"></p-chart>

There is no effect when I use width and height. Please let me know how to use the width and height chart.

+4
source share
2 answers

https://www.reddit.com/r/webdev/comments/4gjuvp/chartjs_canvas_height_width_ignored/

According to this link you should set two parameters for the chart:

<p-chart type="bar" width="400" height="400" [data]="data" [options]="options"></p-chart>

And in Typescript code, Code:

options = {
  responsive: false,
  maintainAspectRatio: false
};
+8
source

Looking through the source code , p-chart takes the width and height as component inputs, so including them in [] should do the trick

<p-chart type="bar" [width]="400" [height]="400" [data]="data"></p-chart>
+2
source

Source: https://habr.com/ru/post/1661425/