From a20b572cf4f32d9a84c5c5ae5a03e7615c19b966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Fri, 17 Jan 2020 20:30:20 +0100 Subject: [PATCH] feat(chart.js): allow to access charts container (#41537) This allows to access readonly container for charts from global namespace required in some use-case scenarios. Thanks! --- types/chart.js/chart.js-tests.ts | 5 +++++ types/chart.js/index.d.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/types/chart.js/chart.js-tests.ts b/types/chart.js/chart.js-tests.ts index d4cb0b189e..c4fa224b41 100644 --- a/types/chart.js/chart.js-tests.ts +++ b/types/chart.js/chart.js-tests.ts @@ -302,6 +302,11 @@ const customTooltipsPieChart = new Chart(ctx, { // platform global values Chart.platform.disableCSSInjection = true; +// Chart instances in the global namespace +for (const id in Chart.instances) { + Chart.instances[id].resize(); +} + // default global static values Chart.defaults.global.defaultFontColor = '#544615'; Chart.defaults.global.defaultFontFamily = 'Arial'; diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index 5793bfbf1e..7b35d9afa0 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -77,6 +77,10 @@ declare class Chart { // Tooltip Static Options static Tooltip: Chart.ChartTooltipsStaticConfiguration; + + static readonly instances: { + [key: string]: Chart; + }; } declare class PluginServiceStatic { register(plugin: Chart.PluginServiceGlobalRegistration & Chart.PluginServiceRegistrationOptions): void;