]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Revert feature to disable plugins by TS (#11422)
authorstockiNail <stocki.nail@gmail.com>
Wed, 26 Jul 2023 12:59:42 +0000 (14:59 +0200)
committerGitHub <noreply@github.com>
Wed, 26 Jul 2023 12:59:42 +0000 (08:59 -0400)
docs/developers/plugins.md
src/types/index.d.ts
test/types/defaults.ts
test/types/overrides.ts
test/types/plugins/defaults.ts
test/types/plugins/disable.ts [deleted file]
test/types/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts

index 4468a58f52e0c2bc54334f6c81b625c349070f22..60747416b919f7b4c2ac1b0ef405735c3d10f591 100644 (file)
@@ -197,7 +197,7 @@ declare module 'chart.js' {
   interface PluginOptionsByType<TType extends ChartType> {
     customCanvasBackgroundColor?: {
       color?: string
-    } | false
+    }
   }
 }
 ```
index 0eb9b5eb679f2fffc5f2bbfe1545628d2a87b3c3..5cf2d0cc9021a3de4501c3f1fd838fd7f4ba5e52 100644 (file)
@@ -2929,13 +2929,13 @@ export interface TooltipItem<TType extends ChartType> {
 }
 
 export interface PluginOptionsByType<TType extends ChartType> {
-  colors: ColorsPluginOptions | false;
-  decimation: DecimationOptions | false;
-  filler: FillerOptions | false;
-  legend: LegendOptions<TType> | false;
-  subtitle: TitleOptions | false;
-  title: TitleOptions | false;
-  tooltip: TooltipOptions<TType> | false;
+  colors: ColorsPluginOptions;
+  decimation: DecimationOptions;
+  filler: FillerOptions;
+  legend: LegendOptions<TType>;
+  subtitle: TitleOptions;
+  title: TitleOptions;
+  tooltip: TooltipOptions<TType>;
 }
 export interface PluginChartOptions<TType extends ChartType> {
   plugins: PluginOptionsByType<TType>;
index d20415df1cae2dea909ffec7c7a2fca713ebb5d1..8407184924545afcf6e31f03dbedb8e2a206c762 100644 (file)
@@ -1,8 +1,8 @@
-import { Chart, TitleOptions, TooltipOptions } from '../../src/types.js';
+import { Chart } from '../../src/types.js';
 
 Chart.defaults.scales.time.time.minUnit = 'day';
 
-(Chart.defaults.plugins.title as TitleOptions).display = false;
+Chart.defaults.plugins.title.display = false;
 
 Chart.defaults.datasets.bar.backgroundColor = 'red';
 
@@ -27,4 +27,4 @@ Chart.defaults.layout = {
   },
 };
 
-(Chart.defaults.plugins.tooltip as TooltipOptions).boxPadding = 3;
+Chart.defaults.plugins.tooltip.boxPadding = 3;
index 9085dd983569e8f9df1d93919af3e466477d0e33..b4da296a32274d84879809719ba00c5af9c07dca 100644 (file)
@@ -1,8 +1,8 @@
-import { Chart, TitleOptions } from '../../src/types.js';
+import { Chart } from '../../src/types.js';
 
 Chart.overrides.bar.scales.x.type = 'time';
 
-(Chart.overrides.bar.plugins.title as TitleOptions).display = false;
+Chart.overrides.bar.plugins.title.display = false;
 
 Chart.overrides.line.datasets.bar.backgroundColor = 'red';
 
index a11c4dce09adf9c689d5fc7bd5d2d330bd30f277..55a08ac7ad8d23b1fc2cac352989e596093972b0 100644 (file)
@@ -1,9 +1,8 @@
-import { defaults, LegendOptions } from '../../../src/types.js';
+import { defaults } from '../../../src/types.js';
 
 // https://github.com/chartjs/Chart.js/issues/8711
-const original = (defaults.plugins.legend as LegendOptions<"line">).labels.generateLabels;
+const original = defaults.plugins.legend.labels.generateLabels;
 
-// @ts-ignore
 defaults.plugins.legend.labels.generateLabels = function(chart) {
   return [{
     datasetIndex: 0,
diff --git a/test/types/plugins/disable.ts b/test/types/plugins/disable.ts
deleted file mode 100644 (file)
index d6ed066..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Chart } from '../../../src/types.js';\r
-\r
-const chart = new Chart('id', {\r
-  type: 'bubble',\r
-  data: {\r
-    labels: [],\r
-    datasets: [{\r
-      data: []\r
-    }]\r
-  },\r
-  options: {\r
-    plugins: {\r
-      legend: false\r
-    }\r
-  }\r
-});
\ No newline at end of file
index b5584adeb43d398565fad6b4a9c610f353e1af37..5072824bcf9f8d38053a61593179174ec3ac7e20 100644 (file)
@@ -1,6 +1,6 @@
-import { Chart, TooltipOptions } from '../../../../src/types.js';
+import { Chart } from '../../../../src/types.js';
 
-(Chart.overrides.bubble.plugins.tooltip as TooltipOptions<'bubble'>).callbacks.label = (item) => {
+Chart.overrides.bubble.plugins.tooltip.callbacks.label = (item) => {
   const { x, y, _custom: r } = item.parsed;
   return `${item.label}: (${x}, ${y}, ${r})`;
 };