Disable all plugins when options.plugins = false (#8098)

Disabling all plugins when options.plugins = false
This commit is contained in:
Jukka Kurkela 2020-11-24 00:58:03 +02:00 committed by GitHub
parent c4f61d2670
commit 021561072b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
351 changed files with 415 additions and 704 deletions

View File

@ -106,6 +106,16 @@ var chart = new Chart(ctx, {
});
```
To disable all plugins for a specific chart instance, set `options.plugins` to `false`:
```javascript
var chart = new Chart(ctx, {
options: {
plugins: false // all plugins are disabled for this instance
}
});
```
## Plugin Core API
Read more about the [existing plugin extension hooks](../jsdoc/IPlugin.html).

View File

@ -1,6 +1,6 @@
import defaults from './core.defaults';
import registry from './core.registry';
import {mergeIf} from '../helpers/helpers.core';
import {mergeIf, valueOrDefault} from '../helpers/helpers.core';
/**
* @typedef { import("./core.controller").default } Chart
@ -51,9 +51,10 @@ export default class PluginService {
}
const config = chart && chart.config;
const options = (config.options && config.options.plugins) || {};
const options = valueOrDefault(config.options && config.options.plugins, {});
const plugins = allPlugins(config);
const descriptors = createDescriptors(plugins, options);
// options === false => all plugins are disabled
const descriptors = options === false ? [] : createDescriptors(plugins, options);
this._cache = descriptors;

View File

@ -43,7 +43,16 @@ function specFromFixture(description, inputs) {
it(input, function(done) {
loadConfig(input, function(json) {
var descr = json.description || (json.description = description);
var chart = utils.acquireChart(json.config, json.options);
var config = json.config;
var options = config.options || (config.options = {});
// plugins are disabled by default, except if the path contains 'plugin' or there are instance plugins
if (input.indexOf('plugin') === -1 && config.plugins === undefined) {
options.plugins = options.plugins || false;
}
var chart = utils.acquireChart(config, json.options);
if (!inputs.png) {
fail(descr + '\r\nMissing PNG comparison file for ' + input);
done();

View File

@ -23,8 +23,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: [

View File

@ -20,8 +20,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: [

View File

@ -22,8 +22,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: function(ctx) {

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: '#00ff00'

View File

@ -14,8 +14,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -12,8 +12,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -16,9 +16,7 @@ module.exports = {
]
},
options: {
legend: false,
skipNull: true,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -17,9 +17,7 @@ module.exports = {
]
},
options: {
legend: false,
skipNull: true,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -13,8 +13,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -13,8 +13,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -13,8 +13,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -13,8 +13,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -13,8 +13,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -13,8 +13,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -12,8 +12,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"bar": {
"datasets": {
"barPercentage": 1,

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"bar": {
"datasets": {
"barPercentage": 1,

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"bar": {
"datasets": {
"barPercentage": 1,

View File

@ -21,8 +21,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"bar": {
"datasets": {
"barPercentage": 1,

View File

@ -12,8 +12,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -12,8 +12,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"type": "time",

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"bar": {
"datasets": {
"barPercentage": 1,

View File

@ -20,8 +20,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
indexAxis: 'y',
elements: {
bar: {

View File

@ -23,8 +23,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -22,8 +22,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -23,8 +23,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -22,8 +22,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -31,8 +31,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -24,8 +24,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -23,8 +23,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -25,8 +25,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: '#888',

View File

@ -17,8 +17,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -20,8 +20,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -19,8 +19,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
bar: {
backgroundColor: 'transparent',

View File

@ -11,8 +11,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
layout: {
padding: {
left: 0,

View File

@ -15,8 +15,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -29,8 +29,6 @@ module.exports = {
}]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -15,8 +15,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
indexAxis: 'y',
scales: {
x: {display: false, min: 0},

View File

@ -15,8 +15,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false, stacked: true},
y: {display: false, min: 0}

View File

@ -15,8 +15,6 @@
}]
},
"options": {
"title": false,
"legend": false,
"indexAxis": "y",
"scales": {
"x": {

View File

@ -15,8 +15,6 @@
}]
},
"options": {
"title": false,
"legend": false,
"indexAxis": "y",
"scales": {
"x": {

View File

@ -15,8 +15,6 @@
}]
},
"options": {
"title": false,
"legend": false,
"scales": {
"x": {
"display": false,

View File

@ -15,8 +15,6 @@
}]
},
"options": {
"title": false,
"legend": false,
"scales": {
"x": {
"display": false,

View File

@ -18,8 +18,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
indexAxis: 'y',
elements: {
bar: {

View File

@ -13,8 +13,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
indexAxis: 'y',
scales: {
x: {

View File

@ -13,8 +13,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
indexAxis: 'y',
scales: {
x: {

View File

@ -13,8 +13,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
indexAxis: 'y',
scales: {
x: {

View File

@ -13,8 +13,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {

View File

@ -13,8 +13,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {

View File

@ -13,8 +13,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {

View File

@ -12,8 +12,6 @@ module.exports = {
labels: ['label1', 'label2', 'label3', 'label4']
},
options: {
legend: false,
title: false,
bar: {
datasets: {
barPercentage: 1,

View File

@ -12,8 +12,6 @@ module.exports = {
labels: ['label1', 'label2', 'label3', 'label4']
},
options: {
legend: false,
title: false,
bar: {
datasets: {
barPercentage: 1,

View File

@ -16,8 +16,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"display": false,

View File

@ -19,8 +19,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {
"display": false,

View File

@ -12,7 +12,6 @@ module.exports = {
}]
},
options: {
legend: false,
scales: {
x: {ticks: {display: false}},
y: {

View File

@ -90,8 +90,6 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false,
"scales": {
"x": {"display": false},
"y": {

View File

@ -18,8 +18,6 @@ module.exports = {
}]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -17,8 +17,6 @@ module.exports = {
}]
},
options: {
legend: false,
title: false,
scales: {
x: {display: false},
y: {display: false}

View File

@ -23,8 +23,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: [

View File

@ -22,8 +22,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: function(ctx) {

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: '#00ff00'

View File

@ -24,8 +24,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -20,8 +20,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -17,8 +17,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -23,8 +23,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -22,8 +22,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -23,8 +23,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -19,8 +19,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
arc: {
backgroundColor: 'transparent',

View File

@ -23,9 +23,7 @@
}]
},
"options": {
"responsive": false,
"legend": false,
"title": false
"responsive": false
}
}
}

View File

@ -24,9 +24,7 @@
}]
},
"options": {
"responsive": false,
"legend": false,
"title": false
"responsive": false
}
}
}

View File

@ -16,9 +16,7 @@
},
"options": {
"circumference": 400,
"responsive": false,
"legend": false,
"title": false
"responsive": false
}
}
}

View File

@ -25,9 +25,7 @@ module.exports = {
},
options: {
circumference: 57.32,
responsive: false,
legend: false,
title: false
responsive: false
}
}
};

View File

@ -24,9 +24,7 @@
},
"options": {
"circumference": 57.32,
"responsive": false,
"legend": false,
"title": false
"responsive": false
}
}
}

View File

@ -24,8 +24,12 @@ module.exports = {
},
options: {
responsive: false,
legend: false,
title: false
plugins: {
legend: false,
title: false,
tooltip: false,
filler: false
}
},
plugins: [{
id: 'hide',

View File

@ -43,9 +43,7 @@ module.exports = {
},
options: {
circumference: 180,
responsive: false,
legend: false,
title: false
responsive: false
}
}
};

View File

@ -35,10 +35,6 @@
"borderWidth": 0
}],
"labels": [ "label0", "label1" ]
},
"options": {
"legend": false,
"title": false
}
},
"options": {
@ -47,4 +43,4 @@
"width": 500
}
}
}
}

View File

@ -23,9 +23,7 @@
}]
},
"options": {
"responsive": false,
"legend": false,
"title": false
"responsive": false
}
}
}

View File

@ -25,8 +25,11 @@
},
"options": {
"responsive": false,
"legend": false,
"title": false
"plugins": {
"legend": false,
"title": false,
"tooltip": false
}
}
}
}

View File

@ -24,9 +24,7 @@
},
"options": {
"circumference": 57.32,
"responsive": false,
"legend": false,
"title": false
"responsive": false
}
}
}

View File

@ -37,10 +37,6 @@
}
],
"labels": [ "label0", "label1" ]
},
"options": {
"legend": false,
"title": false
}
},
"options": {
@ -49,4 +45,4 @@
"width": 500
}
}
}
}

View File

@ -21,8 +21,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
backgroundColor: function(ctx) {
@ -46,6 +44,12 @@ module.exports = {
display: false,
beginAtZero: true
}
},
plugins: {
legend: false,
title: false,
tooltip: false,
filler: true
}
}
},

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
backgroundColor: '#00ff00'
@ -32,6 +30,12 @@ module.exports = {
scales: {
x: {display: false},
y: {display: false}
},
plugins: {
legend: false,
title: false,
tooltip: false,
filler: true
}
}
},

View File

@ -25,8 +25,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderCapStyle: function(ctx) {

View File

@ -21,8 +21,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderCapStyle: 'butt',

View File

@ -21,8 +21,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderColor: function(ctx) {

View File

@ -16,8 +16,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderColor: '#0000ff',

View File

@ -18,8 +18,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderColor: '#00ff00',

View File

@ -17,8 +17,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderColor: '#00ff00',

View File

@ -20,8 +20,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderColor: '#00ff00',

View File

@ -18,8 +18,6 @@ module.exports = {
]
},
options: {
legend: false,
title: false,
elements: {
line: {
borderColor: '#00ff00',

Some files were not shown because too many files have changed in this diff Show More