module.exports = [
{
path: 'dist/chart.js',
- limit: '77 KB',
+ limit: '77.2 KB',
webpack: false,
running: false
},
},
{
path: 'dist/chart.js',
- limit: '22.2 KB',
+ limit: '22.4 KB',
import: '{ CategoryScale, LinearScale, LogarithmicScale, RadialLinearScale, TimeScale, TimeSeriesScale }',
running: false,
modifyWebpackConfig
]);
```
+## isPluginEnabled(pluginId)
+
+Returns a boolean if a plugin with the given ID has been registered to the chart instance.
+
+```javascript
+chart.isPluginEnabled('filler');
+```
+
## Static: getChart(key)
Finds the chart instance from the given key. If the key is a `string`, it is interpreted as the ID of the Canvas node for the Chart. The key can also be a `CanvasRenderingContext2D` or an `HTMLDOMElement`. This will return `undefined` if no Chart is found. To be found, the chart must have previously been created.
return this._plugins.notify(this, hook, args, filter);
}
+ /**
+ * Check if a plugin with the specific ID is registered and enabled
+ * @param {string} pluginId - The ID of the plugin of which to check if it is enabled
+ * @returns {boolean}
+ */
+ isPluginEnabled(pluginId) {
+ return this._plugins._cache.filter(p => p.plugin.id === pluginId).length === 1;
+ }
+
/**
* @private
*/
this.linkScales();
meta._stacked = isStacked(meta.vScale, meta);
this.addElements();
+
+ if (this.options.fill && !this.chart.isPluginEnabled('filler')) {
+ console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options");
+ }
}
updateIndex(datasetIndex) {
describe('Plugin.filler', function() {
+ const fillerPluginRegisterWarning = 'Tried to use the \'fill\' option without the \'Filler\' plugin enabled. Please import and register the \'Filler\' plugin and make sure it is not disabled in the options';
function decodedFillValues(chart) {
return chart.data.datasets.map(function(dataset, index) {
var meta = chart.getDatasetMeta(index) || {};
describe('auto', jasmine.fixture.specs('plugin.filler'));
describe('dataset.fill', function() {
+ it('Should show a warning when trying to use the filler plugin in the dataset when it\'s not registered', function() {
+ spyOn(console, 'warn');
+ Chart.unregister(Chart.Filler);
+ window.acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ fill: true
+ }]
+ }
+ });
+
+ expect(console.warn).toHaveBeenCalledWith(fillerPluginRegisterWarning);
+
+ Chart.register(Chart.Filler);
+ });
+
+ it('Should show a warning when trying to use the filler plugin in the root options when it\'s not registered', function() {
+ // jasmine.createSpy('warn');
+ spyOn(console, 'warn');
+ Chart.unregister(Chart.Filler);
+ window.acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ }]
+ },
+ options: {
+ fill: true
+ }
+ });
+
+ expect(console.warn).toHaveBeenCalledWith(fillerPluginRegisterWarning);
+
+ Chart.register(Chart.Filler);
+ });
+
it('should support boundaries', function() {
var chart = window.acquireChart({
type: 'line',
notifyPlugins(hook: string, args?: AnyObject): boolean | void;
+ isPluginEnabled(pluginId: string): boolean;
+
static readonly defaults: Defaults;
static readonly overrides: Overrides;
static readonly version: string;