mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-06 16:26:52 +01:00
Add check to colors plugin if defaults are set (#11927)
This commit is contained in:
committed by
GitHub
parent
5d2dfbe68d
commit
3f2968cb41
@@ -1,4 +1,4 @@
|
||||
import {DoughnutController, PolarAreaController} from '../index.js';
|
||||
import {DoughnutController, PolarAreaController, defaults} from '../index.js';
|
||||
import type {Chart, ChartDataset} from '../types.js';
|
||||
|
||||
export interface ColorsPluginOptions {
|
||||
@@ -87,6 +87,10 @@ function containsColorsDefinition(
|
||||
return descriptor && (descriptor.borderColor || descriptor.backgroundColor);
|
||||
}
|
||||
|
||||
function containsDefaultColorsDefenitions() {
|
||||
return defaults.borderColor !== 'rgba(0,0,0,0.1)' || defaults.backgroundColor !== 'rgba(0,0,0,0.1)';
|
||||
}
|
||||
|
||||
export default {
|
||||
id: 'colors',
|
||||
|
||||
@@ -106,7 +110,13 @@ export default {
|
||||
} = chart.config;
|
||||
const {elements} = chartOptions;
|
||||
|
||||
if (!options.forceOverride && (containsColorsDefinitions(datasets) || containsColorsDefinition(chartOptions) || (elements && containsColorsDefinitions(elements)))) {
|
||||
const containsColorDefenition = (
|
||||
containsColorsDefinitions(datasets) ||
|
||||
containsColorsDefinition(chartOptions) ||
|
||||
(elements && containsColorsDefinitions(elements)) ||
|
||||
containsDefaultColorsDefenitions());
|
||||
|
||||
if (!options.forceOverride && containsColorDefenition) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user