Actually i want to show the chart by using JSON data. I Need the Volume Sales data into an array.
JSON:
{
  "year1": {
    "volumeSales": "0.09",
    "valueSales": "1.23"
  },
  "year2": {
    "volumeSales": "0.11",
    "valueSales": "1.56"
  },
  "year3": {
    "volumeSales": "0.12",
    "valueSales": "1.69"
  },
  "year4": {
    "volumeSales": "0.12",
    "valueSales": "1.64"
  },
  "year5": {
    "volumeSales": "0.10",
    "valueSales": "1.41"
  },
  "total": {
    "volumeSales": "0.55",
    "valueSales": "7.53"
  }
}
I tried it by taking the volumesales into an array and assigned it to dataset in chart. But it is not working.
Ts File
import { Component, OnInit } from '@angular/core';
import {Chart} from 'chart.js';
import { DataService } from "src/app/data.service";
@Component({
  selector: 'app-about',
  templateUrl: './about.component.html',
  styleUrls: ['./about.component.scss']
})
export class AboutComponent implements OnInit {
  BarChart = [];
  BarChart1 = []; 
  dataChart = [];
  volumeSales = [];
  i : number;
  constructor(private _emp: DataService) { 
    this._emp.getSales().subscribe(data => 
      {
        this.dataChart = data;
        this.dataChart = this.dataChart[0]
       // this.volumeSales.push(this.dataChart[`year${2}`]['volumeSales']);
       for(let i=1;i<=5;i++)
        {
          this.volumeSales.push(this.dataChart[`year${i}`]['volumeSales']);
        }
      });
  }
  ngOnInit() {
    this.BarChart = new Chart('barChart', {
      type: 'bar',
    data: {
     labels: ["Year1", "Year2", "Year3", "Year4", "Year5"],
     datasets: [{
         data: this.volumeSales,
     }]
   }
    });
} 
}
I need the volumeSales,valueSales data into an array. How can i do that?
 
     
    