bar-line ts and html - 2023 Reporting

PHOTO EMBED

Mon Jun 17 2024 13:31:13 GMT+0000 (Coordinated Universal Time)

Saved by @iamkatmakhafola

//TS
import { Component } from '@angular/core';
import { Chart } from 'chart.js';
@Component({
  selector: 'app-bar-line',
  templateUrl: './bar-line.component.html',
  styleUrls: ['./bar-line.component.scss']
})
export class BarLineComponent {
  ngOnInit(): void {
    this.createChart();
  }
  public chart: any;
  createChart(){
    this.chart = new Chart("bar-line", {
      type: 'line',
      data: {
        labels: ['Shirt', 'Jacket', 'Men Tops', 'Men Pants', 
                 'Swimwear', 'Shoes', 'Sleepwear', 'Men Accessories'],
        datasets:[
          {
            label:"2022",
            data: ['446','551','462','158','171','553','566','231']
          },
          {
            type:'bar',
            label:"2023",
            data: ['623','431','525','306','100','369','417','420']
          }
        ]
      }
    });
  }
}
//HTML
<div class="chart-container">
    <h2>Product Sales</h2>
    <canvas id="bar-line">{{ chart }}</canvas>
</div>
content_copyCOPY

2023 - Bar-line ts and html 1.6 In the “bar-line.component.ts”: a. Create a method for the bar line chart. This should include the data and labels for the bar line chart. Note that 2022 data should be represented using the line graph while the 2023 data should be represented using the bar graph. 1.7 In the “bar-line.component.html”: a. The bar line chart should have a header titled “Product Sales”. b. Create a container and use angular string interpolation to render the bar line chart variable.