mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 11:51:10 +08:00
Add support for Tooltip positioners for Chart.Js
This commit is contained in:
@@ -65,3 +65,23 @@ if (chart.chartArea) {
|
||||
console.log(chart.chartArea.bottom);
|
||||
console.log(chart.chartArea.left);
|
||||
}
|
||||
|
||||
// http://www.chartjs.org/docs/latest/configuration/tooltip.html#position-modes
|
||||
/**
|
||||
* Custom positioner
|
||||
* @function Chart.Tooltip.positioners.custom
|
||||
* @param elements {Chart.Element[]} the tooltip elements
|
||||
* @param eventPosition {Point} the position of the event in canvas coordinates
|
||||
* @returns {Point} the tooltip position
|
||||
*/
|
||||
Chart.Tooltip.positioners.custom = function(elements: any, eventPosition: any) {
|
||||
/** @type {Chart.Tooltip} */
|
||||
var tooltip = this;
|
||||
|
||||
/* ... */
|
||||
|
||||
return {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
}
|
||||
7
types/chart.js/index.d.ts
vendored
7
types/chart.js/index.d.ts
vendored
@@ -44,6 +44,9 @@ declare class Chart {
|
||||
static controllers: {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
// Tooltip Static Options
|
||||
static Tooltip: Chart.ChartTooltipsStaticConfiguartion;
|
||||
}
|
||||
declare class PluginServiceStatic {
|
||||
register(plugin: PluginServiceRegistrationOptions): void;
|
||||
@@ -275,6 +278,10 @@ declare namespace Chart {
|
||||
borderWidth?: number;
|
||||
}
|
||||
|
||||
interface ChartTooltipsStaticConfiguartion {
|
||||
positioners: any;
|
||||
}
|
||||
|
||||
interface ChartHoverOptions {
|
||||
mode?: string;
|
||||
animationDuration?: number;
|
||||
|
||||
Reference in New Issue
Block a user