diff --git a/src/core/core.config.js b/src/core/core.config.js index 18fe50a1e19..1523eb5c5c9 100644 --- a/src/core/core.config.js +++ b/src/core/core.config.js @@ -48,6 +48,12 @@ function mergeScaleConfig(config, options) { // First figure out first scale id's per axis. Object.keys(configScales).forEach(id => { const scaleConf = configScales[id]; + if (!isObject(scaleConf)) { + return console.error(`Invalid scale configuration for scale: ${id}`); + } + if (scaleConf._proxy) { + return console.warn(`Ignoring resolver passed as options for scale: ${id}`); + } const axis = determineAxis(id, scaleConf); const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis); const defaultScaleOptions = chartDefaults.scales || {}; diff --git a/test/specs/core.controller.tests.js b/test/specs/core.controller.tests.js index 809b721d9d4..cb4eba08c07 100644 --- a/test/specs/core.controller.tests.js +++ b/test/specs/core.controller.tests.js @@ -498,6 +498,49 @@ describe('Chart', function() { expect(Chart.defaults.scales.linear._jasmineCheck).not.toBeDefined(); expect(Chart.defaults.scales.category._jasmineCheck).not.toBeDefined(); }); + + it('should ignore proxy passed as scale options', function() { + let failure = false; + const chart = acquireChart({ + type: 'line', + data: [], + options: { + scales: { + x: { + grid: { + color: ctx => { + if (!ctx.tick) { + failure = true; + } + } + } + } + } + } + }); + chart.options.scales = { + x: chart.options.scales.x, + y: { + type: 'linear', + position: 'right' + } + }; + chart.update(); + expect(failure).toEqual(false); + }); + + it('should ignore array passed as scale options', function() { + const chart = acquireChart({ + type: 'line', + data: [], + options: { + scales: { + xAxes: [{id: 'xAxes', type: 'category'}] + } + } + }); + expect(chart.scales.xAxes).not.toBeDefined(); + }); }); describe('Updating options', function() {