Documentation Is:
Please Explain in Detail...
The documents suggest using tooltip custom positioner like this:
const tooltipPlugin = Chart.registry.getPlugin('tooltip');
tooltipPlugin.positioners.myCustomPositioner = function(elements, eventPosition) {
/** @type {Tooltip} */
var tooltip = this;
getRegistry returns the tooltip as Plugin,
The element that can be used for customized positioning like above, is
export const Tooltip: Plugin & {
readonly positioners: {
[key: string]: (items: readonly ActiveElement[], eventPosition: { x: number; y: number }) => { x: number; y: number } | false;
};
getActiveElements(): ActiveElement[];
setActiveElements(active: ActiveDataPoint[], eventPosition: { x: number, y: number }): void;
};
Typescript 4.3.5 cannot cast the return object of getPlugin into an object with those functions. And if I mark the return object as type Plugin, typescript gives an error for not having those functions.
Your Proposal for Changes
Add interface Tooltip instead of const Tooltip
Example
Documentation Is:
Please Explain in Detail...
The documents suggest using tooltip custom positioner like this:
getRegistryreturns the tooltip asPlugin,The element that can be used for customized positioning like above, is
Typescript 4.3.5 cannot cast the return object of getPlugin into an object with those functions. And if I mark the return object as type Plugin, typescript gives an error for not having those functions.
Your Proposal for Changes
Add interface Tooltip instead of const Tooltip
Example