Change chart.js chart type

CoreUI chart.js

//Change chart type by clicking the radio button

-- mychart.html
<form>
  <mat-radio-group aria-label="Select an option" (change)="radioChange($event)">
    <mat-radio-button value="bar" checked="{{ barChecked }}">Bar Chart</mat-radio-button>
    <mat-radio-button value="line" checked="{{ lineChecked }}">Line Chart</mat-radio-button>
  </mat-radio-group>
</form>

<c-card class="mb-1" style="width: 100%; text-align: center">
  <c-card-body>
    <c-row>
      <c-col sm="12">
        <h4 class="card-title mb-0" id="traffic">NET (t) - last 20 records</h4>
        <div class="small text-medium-emphasis"></div>
      </c-col>
    </c-row>
    <c-chart
      [data]="chart.data"
      [height]="760"
      [ngStyle]="{ 'marginTop.px': 20 }"
      [type]="chart.type"
    >
      Main chart
    </c-chart>
  </c-card-body>
</c-card>

Last updated

Was this helpful?