Skip to content

Commit bda2ae7

Browse files
authored
Revert feature to disable plugins by TS (#11422)
1 parent dd03016 commit bda2ae7

File tree

7 files changed

+17
-34
lines changed

7 files changed

+17
-34
lines changed

docs/developers/plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ declare module 'chart.js' {
197197
interface PluginOptionsByType<TType extends ChartType> {
198198
customCanvasBackgroundColor?: {
199199
color?: string
200-
} | false
200+
}
201201
}
202202
}
203203
```

src/types/index.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,13 +2929,13 @@ export interface TooltipItem<TType extends ChartType> {
29292929
}
29302930

29312931
export interface PluginOptionsByType<TType extends ChartType> {
2932-
colors: ColorsPluginOptions | false;
2933-
decimation: DecimationOptions | false;
2934-
filler: FillerOptions | false;
2935-
legend: LegendOptions<TType> | false;
2936-
subtitle: TitleOptions | false;
2937-
title: TitleOptions | false;
2938-
tooltip: TooltipOptions<TType> | false;
2932+
colors: ColorsPluginOptions;
2933+
decimation: DecimationOptions;
2934+
filler: FillerOptions;
2935+
legend: LegendOptions<TType>;
2936+
subtitle: TitleOptions;
2937+
title: TitleOptions;
2938+
tooltip: TooltipOptions<TType>;
29392939
}
29402940
export interface PluginChartOptions<TType extends ChartType> {
29412941
plugins: PluginOptionsByType<TType>;

test/types/defaults.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Chart, TitleOptions, TooltipOptions } from '../../src/types.js';
1+
import { Chart } from '../../src/types.js';
22

33
Chart.defaults.scales.time.time.minUnit = 'day';
44

5-
(Chart.defaults.plugins.title as TitleOptions).display = false;
5+
Chart.defaults.plugins.title.display = false;
66

77
Chart.defaults.datasets.bar.backgroundColor = 'red';
88

@@ -27,4 +27,4 @@ Chart.defaults.layout = {
2727
},
2828
};
2929

30-
(Chart.defaults.plugins.tooltip as TooltipOptions).boxPadding = 3;
30+
Chart.defaults.plugins.tooltip.boxPadding = 3;

test/types/overrides.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Chart, TitleOptions } from '../../src/types.js';
1+
import { Chart } from '../../src/types.js';
22

33
Chart.overrides.bar.scales.x.type = 'time';
44

5-
(Chart.overrides.bar.plugins.title as TitleOptions).display = false;
5+
Chart.overrides.bar.plugins.title.display = false;
66

77
Chart.overrides.line.datasets.bar.backgroundColor = 'red';
88

test/types/plugins/defaults.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { defaults, LegendOptions } from '../../../src/types.js';
1+
import { defaults } from '../../../src/types.js';
22

33
// https://github.com/chartjs/Chart.js/issues/8711
4-
const original = (defaults.plugins.legend as LegendOptions<"line">).labels.generateLabels;
4+
const original = defaults.plugins.legend.labels.generateLabels;
55

6-
// @ts-ignore
76
defaults.plugins.legend.labels.generateLabels = function(chart) {
87
return [{
98
datasetIndex: 0,

test/types/plugins/disable.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/types/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Chart, TooltipOptions } from '../../../../src/types.js';
1+
import { Chart } from '../../../../src/types.js';
22

3-
(Chart.overrides.bubble.plugins.tooltip as TooltipOptions<'bubble'>).callbacks.label = (item) => {
3+
Chart.overrides.bubble.plugins.tooltip.callbacks.label = (item) => {
44
const { x, y, _custom: r } = item.parsed;
55
return `${item.label}: (${x}, ${y}, ${r})`;
66
};

0 commit comments

Comments
 (0)