Chartjs-Angular-ChartJs : Use a service inside a custom tooltip of a graphic chartJs

0👍

When inside a function, this refers to the inner scope of the function.

To call refer outside the scope of a function using this, you should use an arrow function.

tooltips: {
  custom: (tooltipModel) => {
    // will refer to the myService instance outside of this function
    const title = this.myService.getTitle(); 
  }
}

Additionally, you shouldn’t be modifying the DOM manually when you’re using Angular, apart from in exceptional circumstances. Does this library not offer a way to set the tooltip via the API?

Leave a comment