Skip to content

Commit 4a62c17

Browse files
authored
Add data.datasets[].tooltip.callbacks to Typescript types (#12099)
1 parent beb77e4 commit 4a62c17

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/types/index.d.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2678,10 +2678,23 @@ export interface Tooltip extends Plugin {
26782678

26792679
export declare const Tooltip: Tooltip;
26802680

2681-
export interface TooltipCallbacks<
2681+
export interface TooltipDatasetCallbacks<
26822682
TType extends ChartType,
26832683
Model = TooltipModel<TType>,
26842684
Item = TooltipItem<TType>> {
2685+
beforeLabel(this: Model, tooltipItem: Item): string | string[] | void;
2686+
label(this: Model, tooltipItem: Item): string | string[] | void;
2687+
afterLabel(this: Model, tooltipItem: Item): string | string[] | void;
2688+
2689+
labelColor(this: Model, tooltipItem: Item): TooltipLabelStyle | void;
2690+
labelTextColor(this: Model, tooltipItem: Item): Color | void;
2691+
labelPointStyle(this: Model, tooltipItem: Item): { pointStyle: PointStyle; rotation: number } | void;
2692+
}
2693+
2694+
export interface TooltipCallbacks<
2695+
TType extends ChartType,
2696+
Model = TooltipModel<TType>,
2697+
Item = TooltipItem<TType>> extends TooltipDatasetCallbacks<TType, Model, Item> {
26852698

26862699
beforeTitle(this: Model, tooltipItems: Item[]): string | string[] | void;
26872700
title(this: Model, tooltipItems: Item[]): string | string[] | void;
@@ -2913,6 +2926,10 @@ export interface TooltipOptions<TType extends ChartType = ChartType> extends Cor
29132926
callbacks: TooltipCallbacks<TType>;
29142927
}
29152928

2929+
export interface TooltipDatasetOptions<TType extends ChartType = ChartType> {
2930+
callbacks: TooltipDatasetCallbacks<TType>;
2931+
}
2932+
29162933
export interface TooltipItem<TType extends ChartType> {
29172934
/**
29182935
* The chart the tooltip is being shown on
@@ -2960,6 +2977,10 @@ export interface TooltipItem<TType extends ChartType> {
29602977
element: Element;
29612978
}
29622979

2980+
export interface PluginDatasetOptionsByType<TType extends ChartType> {
2981+
tooltip: TooltipDatasetOptions<TType>;
2982+
}
2983+
29632984
export interface PluginOptionsByType<TType extends ChartType> {
29642985
colors: ColorsPluginOptions;
29652986
decimation: DecimationOptions;
@@ -3800,13 +3821,17 @@ export type ChartDataset<
38003821
TData = DefaultDataPoint<TType>
38013822
> = DeepPartial<
38023823
{ [key in ChartType]: { type: key } & ChartTypeRegistry[key]['datasetOptions'] }[TType]
3824+
> & DeepPartial<
3825+
PluginDatasetOptionsByType<TType>
38033826
> & ChartDatasetProperties<TType, TData>;
38043827

38053828
export type ChartDatasetCustomTypesPerDataset<
38063829
TType extends ChartType = ChartType,
38073830
TData = DefaultDataPoint<TType>
38083831
> = DeepPartial<
38093832
{ [key in ChartType]: { type: key } & ChartTypeRegistry[key]['datasetOptions'] }[TType]
3833+
> & DeepPartial<
3834+
PluginDatasetOptionsByType<TType>
38103835
> & ChartDatasetPropertiesCustomTypesPerDataset<TType, TData>;
38113836

38123837
/**

0 commit comments

Comments
 (0)