Merge pull request #31440 from simonbrunel/fix/chartjs-plugins

Allow plugins options augmentation for chart.js
This commit is contained in:
Nathan Shively-Sanders
2018-12-19 09:58:56 -08:00
committed by GitHub
2 changed files with 12 additions and 3 deletions
+5 -1
View File
@@ -71,7 +71,11 @@ const chart: Chart = new Chart(ctx, {
padding: 40
}
},
devicePixelRatio: 2
devicePixelRatio: 2,
plugins: {
bar: false,
foo: {}
}
}
});
chart.update();
+7 -2
View File
@@ -284,8 +284,7 @@ declare namespace Chart {
circumference?: number;
rotation?: number;
devicePixelRatio?: number;
// Plugins can require any options
plugins?: { [pluginId: string]: any };
plugins?: ChartPluginsOptions;
}
interface ChartFontOptions {
@@ -367,6 +366,12 @@ declare namespace Chart {
borderWidth?: number;
}
// 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 {
[pluginId: string]: any;
}
interface ChartTooltipsStaticConfiguration {
positioners: { [mode: string]: ChartTooltipPositioner };
}