Add support for Tooltip positioners for Chart.Js

This commit is contained in:
Kiarash
2018-02-02 17:29:45 +01:00
parent 445d429fc6
commit 539d38aa82
2 changed files with 27 additions and 0 deletions

View File

@@ -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
};
}

View File

@@ -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;