The expected type comes from property 'XAxes' and 'yAxes' which is declared here on type '_DeepPartialObject<{ [key: string]:

Viewed 1956

I trying the EMI calculator module however encounter the error on property 'xAxes' and which is declared here on type '_DeepPartialObject<{ [key: string]: ScaleOptionsByType; }>' .

I'm unable to rech out to developer in github. May I seek for advise in this group?

https://github.com/eskutti/EMI-Calculator/issues/1

this.barChart = new Chart(this.barCanvas.nativeElement, {
  type: 'bar',
  data: {
    labels: labels,
    datasets: [{
      label: 'Perincipal',
      backgroundColor: "rgba(0, 179, 0,0.5)",
      data: principals
    }, {
      label: 'Interest',
      backgroundColor: "rgba(255, 26, 26, 0.5)",
      data: interests
    }]
  },
  options: {
    title: {
      display: false,
    },
    tooltips: {
      mode: 'index',
      intersect: false
    },
    responsive: true,
    scales: {
      xAxes: [{
        gridLines: {
          display: false
        },
        stacked: true,
      }],
      yAxes: [{
        gridLines: {
          display: false
        }, ticks: {
          // Include a dollar sign in the ticks
          callback: function (value, index, values) {
            let n = value;
            let d = 2;
            let x = ('' + n).length;
            let p = Math.pow;
            d = p(10, d)
            x -= x % 3
            return Math.round(n * d / p(10, x)) / d + " kMGTPE"[x / 3]
            //return this.abbrNum(value, 2);
          }
        },
        stacked: true,
      }]
    }
  }
});
1 Answers

From the error it seems like you are running chart.js version 3, while your config is v2 syntax so it might need chart.js version 2,

try running npm i chart.js@2.9.4 to install the latest version of v2, than it should work.

Related