Currently, I am in the process of updating an old Angular platform to a newer version. One requirement is that everything must have its type declaration. I encountered a problem with the label callback showing this error:
The error message reads: "Type '(tooltipItem: any, data: any) => string' is not assignable to type '(this: TooltipModel<"pie">, tooltipItem: TooltipItem<"pie">) => string | string[]'."
Below is the code snippet where the issue arises:
callbacks:{
label: function (tooltipItem:any, data:any){
return data['labels'][tooltipItem['index']] + ': ' + data['datasets'][0]['data'][tooltipItem['index']] + '%';
}
}
I am trying to add the percentage symbol to the tooltip labels. While it worked fine on the old platform, I am unsure about how to resolve this error on the updated platform.
The specific reference to the label callback in Chart.js index is as follows:
label(this: Model, tooltipItem: Item): string | string[];