mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-12 03:06:54 +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,3 +1,37 @@
|
||||
describe('Plugin.colors', () => {
|
||||
describe('auto', jasmine.fixture.specs('plugin.colors'));
|
||||
|
||||
describe('Plugin.colors.chartDefaults', () => {
|
||||
beforeAll(() => {
|
||||
Chart.defaults.backgroundColor = ['green', 'yellow'];
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
Chart.defaults.backgroundColor = 'rgba(0,0,0,0.1)';
|
||||
});
|
||||
|
||||
it('should not use colors plugin when chart defaults are given', () => {
|
||||
const chart = window.acquireChart({
|
||||
type: 'bar',
|
||||
data: {
|
||||
datasets: [{
|
||||
data: [1, 10],
|
||||
label: 'dataset1'
|
||||
}],
|
||||
labels: ['label1', 'label2']
|
||||
},
|
||||
options: {
|
||||
plugins: {
|
||||
colors: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const meta = chart.getDatasetMeta(0);
|
||||
expect(meta.data[0].options.backgroundColor).toBe('green');
|
||||
expect(meta.data[1].options.backgroundColor).toBe('yellow');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user