[Chartjs]-How to use PrimeNg Chart of Width and Height?

15👍

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

According to that link you have to set two options for the chart:

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

And in your Typescript Code:

options = {
  responsive: false,
  maintainAspectRatio: false
};

7👍

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

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

Leave a comment