From: Bojidar Marinov Date: Fri, 11 Jul 2025 19:53:20 +0000 (+0300) Subject: Add data.datasets[].tooltip.callbacks to Typescript types (#12099) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=thirdparty%2FChart.js.git Add data.datasets[].tooltip.callbacks to Typescript types (#12099) --- 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; /**