Chartjs-How use data dynamically in LineChart.js

0👍

Your ngIf waits for lines to be not null, but ‘lines’ already has a value when you fill your dataset. Your chart is being created before your dataset is ready.
Try

<div class="ibox-body" *ngIf="lineChartData">
      <div style="display: block;">
        <canvas baseChart height="120"
                [datasets]="lineChartData" 
                [labels]="lineChartLabels" 
                [options]="lineChartOptions"
                [colors]="lineChartColors"
                [legend]="lineChartLegend"
                [chartType]="lineChartType"
                (chartHover)="chartHovered($event)"
                (chartClick)="chartClicked($event)"></canvas>
      </div>
    </div>  

If this doesn’t work, can you post your services’ function you use to get data?

Leave a comment