4
votes

I followed the instructions on the ng2-charts demo page to get set up. I'm using angular-cli so I also imported the packages using System.JS. Then I copied the demo code, but it won't display. The canvas is being created but no chart is being drawn. My component and template code are exactly the same as here.

2
do you have a solution I have added ng2 charts : Can't bind to 'datasets' since it isn't a known property of 'base-chart'.EL missaoui habib

2 Answers

8
votes

Use <div style="display: block"> around canvas tag

Your final html code should look similar to this

<div style="display: block">
  <canvas
    baseChart
    [chartType]="'line'"
    [datasets]="chartData"
    [labels]="chartLabels"
    [options]="chartOptions"
    [legend]="true"
    (chartClick)="onChartClick($event)">
  </canvas>
</div>
5
votes

responsive: true sometimes the problem. When changed to false the will canvas appear.