Skip to content

Commit

Permalink
Revert feature to disable plugins by TS (#11422)
Browse files Browse the repository at this point in the history
  • Loading branch information
stockiNail authored Jul 26, 2023
1 parent dd03016 commit bda2ae7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/developers/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ declare module 'chart.js' {
interface PluginOptionsByType<TType extends ChartType> {
customCanvasBackgroundColor?: {
color?: string
} | false
}
}
}
```
14 changes: 7 additions & 7 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
6 changes: 3 additions & 3 deletions test/types/defaults.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -27,4 +27,4 @@ Chart.defaults.layout = {
},
};

(Chart.defaults.plugins.tooltip as TooltipOptions).boxPadding = 3;
Chart.defaults.plugins.tooltip.boxPadding = 3;
4 changes: 2 additions & 2 deletions test/types/overrides.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
5 changes: 2 additions & 3 deletions test/types/plugins/defaults.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
16 changes: 0 additions & 16 deletions test/types/plugins/disable.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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})`;
};
Expand Down

0 comments on commit bda2ae7

Please sign in to comment.