Chartjs-How to plot line chart with multiple datas, but only 2 labels?

1👍

In Chart.js the labels can be provided as an array.

Example

component.html

<canvas baseChart width="400" height="400"
                    [datasets]="lineChartData"
                    [labels]="lineChartLabels"
                    chartType="line"></canvas>

component.ts

  public lineChartData: ChartDataSets[] = [
    { data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A' }
  ];
  public lineChartLabels: Label[] = ['January', '', '', '', '', '', 'July'];

As per your requirement, you can set empty values for labels except first and last one.

Leave a comment