]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Types: Add `tooltip` to chart instance (#9490)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Wed, 28 Jul 2021 11:57:55 +0000 (14:57 +0300)
committerGitHub <noreply@github.com>
Wed, 28 Jul 2021 11:57:55 +0000 (07:57 -0400)
types/index.esm.d.ts
types/tests/plugins/plugin.tooltip/chart.tooltip.ts [new file with mode: 0644]

index fdb23250bbc9b11bcf3c088f380ad2657d609024..41095e03d9d7f4d41554c5fd968c1ddc70f91f0b 100644 (file)
@@ -480,6 +480,8 @@ export declare class Chart<
   readonly scales: { [key: string]: Scale };
   readonly attached: boolean;
 
+  readonly tooltip?: TooltipModel<TType>; // Only available if tooltip plugin is registered and enabled
+
   data: ChartData<TType, TData, TLabel>;
   options: ChartOptions<TType>;
 
diff --git a/types/tests/plugins/plugin.tooltip/chart.tooltip.ts b/types/tests/plugins/plugin.tooltip/chart.tooltip.ts
new file mode 100644 (file)
index 0000000..7aacb72
--- /dev/null
@@ -0,0 +1,13 @@
+import { Chart } from '../../../index.esm';
+
+const chart = new Chart('id', {
+  type: 'line',
+  data: {
+    labels: [],
+    datasets: [{
+      data: []
+    }]
+  },
+});
+
+const tooltip = chart.tooltip;