Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert feature to disable plugins by TS #11422

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading