Strange parameters of plotOptions.pie.dataLabels.formatter in angular-highcharts

I am trying to use plotOptions.pie.dataLabels.formatter to setup my custom label view dynamically. This field has type DataLabelsFormatterCallbackFunction that is equal to (this: PointLabelObject, options: DataLabelsOptions) => (number|string|null|undefined);

But when I try to setup callback like:

formatter: (p : PointLabelObject, options: DataLabelsOptions) => {
    return 'foo';
}

I have a typescript compilation error with message

Type '(p: PointLabelObject, options: DataLabelsOptions) => string' is not assignable to type 'DataLabelsFormatterCallbackFunction'.ts(2322)

If I try to setup callback due to example like:

formatter: (options: DataLabelsOptions) => {
    const self: any = this;
    const p : PointLabelObject = self;
    return p.point.name;
}

While debugging I can see that this has a type of my component and has no propery name.

How to access to PointLabelObject object in formatter?

PS: history of my propblem is: I just want to show different pie chart slice's labels when user move cursor on slices.


Ответы (0 шт):