[chart.js] Definition of parameter attributes for custom tooltip method (#39346)

This commit is contained in:
Adrián Caballero
2019-10-23 14:49:58 -07:00
committed by Wesley Wigham
parent b02210215e
commit 7c6cf9d1a7
2 changed files with 56 additions and 1 deletions
+14
View File
@@ -279,3 +279,17 @@ const linearScaleChart: Chart = new Chart(ctx, {
}
}
});
// custom tooltips
const customTooltipsPieChart = new Chart(ctx, {
type: 'pie',
data: {},
options: {
tooltips: {
enabled: false,
custom: (tooltipModel) => {
// do whatever
},
},
},
});
+42 -1
View File
@@ -302,7 +302,7 @@ declare namespace Chart {
interface ChartTooltipOptions {
enabled?: boolean;
custom?(a: any): void;
custom?: (tooltipModel: ChartTooltipModel) => void;
mode?: InteractionMode;
intersect?: boolean;
backgroundColor?: ChartColor;
@@ -341,6 +341,47 @@ declare namespace Chart {
borderWidth?: number;
}
interface ChartTooltipModel {
backgroundColor: string;
bodyFontColor: string;
bodyFontSize: number;
bodySpacing: number;
borderColor: string;
borderWidth: number;
caretSize: number;
caretX: number;
caretY: number;
cornerRadius: number;
displayColors: boolean;
footerFontColor: string;
footerFontSize: number;
footerMarginTop: number;
footerSpacing: number;
height: number;
legendColorBackground: string;
opacity: number;
titleFontColor: string;
titleFontSize: number;
titleMarginBottom: number;
titleSpacing: number;
width: number;
x: number;
xAlign: string;
xPadding: number;
y: number;
yAlign: string;
yPadding: number;
_bodyAlign: string;
_bodyFontFamily: string;
_bodyFontStyle: string;
_footerAlign: string;
_footerFontFamily: string;
_footerFontStyle: string;
_titleAlign: string;
_titleFontFamily: string;
_titleFontStyle: string;
}
// NOTE: declare plugin options as interface instead of inline '{ [plugin: string]: any }'
// to allow module augmentation in case some plugins want to strictly type their options.
interface ChartPluginsOptions {