From 4a62c17b1cebbd3190a6c76a5d4073e62cea88e7 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Fri, 11 Jul 2025 22:53:20 +0300 Subject: [PATCH] Add data.datasets[].tooltip.callbacks to Typescript types (#12099) --- src/types/index.d.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 69a4cfccb..e96fddadc 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -2678,10 +2678,23 @@ export interface Tooltip extends Plugin { export declare const Tooltip: Tooltip; -export interface TooltipCallbacks< +export interface TooltipDatasetCallbacks< TType extends ChartType, Model = TooltipModel, Item = TooltipItem> { + beforeLabel(this: Model, tooltipItem: Item): string | string[] | void; + label(this: Model, tooltipItem: Item): string | string[] | void; + afterLabel(this: Model, tooltipItem: Item): string | string[] | void; + + labelColor(this: Model, tooltipItem: Item): TooltipLabelStyle | void; + labelTextColor(this: Model, tooltipItem: Item): Color | void; + labelPointStyle(this: Model, tooltipItem: Item): { pointStyle: PointStyle; rotation: number } | void; +} + +export interface TooltipCallbacks< + TType extends ChartType, + Model = TooltipModel, + Item = TooltipItem> extends TooltipDatasetCallbacks { beforeTitle(this: Model, tooltipItems: Item[]): string | string[] | void; title(this: Model, tooltipItems: Item[]): string | string[] | void; @@ -2913,6 +2926,10 @@ export interface TooltipOptions extends Cor callbacks: TooltipCallbacks; } +export interface TooltipDatasetOptions { + callbacks: TooltipDatasetCallbacks; +} + export interface TooltipItem { /** * The chart the tooltip is being shown on @@ -2960,6 +2977,10 @@ export interface TooltipItem { element: Element; } +export interface PluginDatasetOptionsByType { + tooltip: TooltipDatasetOptions; +} + export interface PluginOptionsByType { colors: ColorsPluginOptions; decimation: DecimationOptions; @@ -3800,6 +3821,8 @@ export type ChartDataset< TData = DefaultDataPoint > = DeepPartial< { [key in ChartType]: { type: key } & ChartTypeRegistry[key]['datasetOptions'] }[TType] +> & DeepPartial< +PluginDatasetOptionsByType > & ChartDatasetProperties; export type ChartDatasetCustomTypesPerDataset< @@ -3807,6 +3830,8 @@ export type ChartDatasetCustomTypesPerDataset< TData = DefaultDataPoint > = DeepPartial< { [key in ChartType]: { type: key } & ChartTypeRegistry[key]['datasetOptions'] }[TType] +> & DeepPartial< +PluginDatasetOptionsByType > & ChartDatasetPropertiesCustomTypesPerDataset; /** -- 2.39.5