mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Rename Chart.layout to Chart.layouts (#5118)
Chart.layouts seems more consistent with other service names (Chart.plugins, Chart.scales, etc.) but also more inline with the service which handle many layout (one per charts).
This commit is contained in:
parent
fb3ea03440
commit
6bea15e7cf
@ -12,7 +12,7 @@ Chart.defaults = require('./core/core.defaults');
|
||||
Chart.Element = require('./core/core.element');
|
||||
Chart.elements = require('./elements/index');
|
||||
Chart.Interaction = require('./core/core.interaction');
|
||||
Chart.layout = require('./core/core.layout');
|
||||
Chart.layouts = require('./core/core.layouts');
|
||||
Chart.platform = require('./platforms/platform');
|
||||
Chart.plugins = require('./core/core.plugins');
|
||||
Chart.Ticks = require('./core/core.ticks');
|
||||
@ -113,10 +113,10 @@ Chart.PluginBase = Chart.Element.extend({});
|
||||
Chart.canvasHelpers = Chart.helpers.canvas;
|
||||
|
||||
/**
|
||||
* Provided for backward compatibility, use Chart.layout instead.
|
||||
* Provided for backward compatibility, use Chart.layouts instead.
|
||||
* @namespace Chart.layoutService
|
||||
* @deprecated since version 2.8.0
|
||||
* @todo remove at version 3
|
||||
* @private
|
||||
*/
|
||||
Chart.layoutService = Chart.layout;
|
||||
Chart.layoutService = Chart.layouts;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
var defaults = require('./core.defaults');
|
||||
var helpers = require('../helpers/index');
|
||||
var Interaction = require('./core.interaction');
|
||||
var layout = require('./core.layout');
|
||||
var layouts = require('./core.layouts');
|
||||
var platform = require('../platforms/platform');
|
||||
var plugins = require('./core.plugins');
|
||||
|
||||
@ -47,7 +47,7 @@ module.exports = function(Chart) {
|
||||
var newOptions = chart.options;
|
||||
|
||||
helpers.each(chart.scales, function(scale) {
|
||||
layout.removeBox(chart, scale);
|
||||
layouts.removeBox(chart, scale);
|
||||
});
|
||||
|
||||
newOptions = helpers.configMerge(
|
||||
@ -436,7 +436,7 @@ module.exports = function(Chart) {
|
||||
return;
|
||||
}
|
||||
|
||||
layout.update(this, this.width, this.height);
|
||||
layouts.update(this, this.width, this.height);
|
||||
|
||||
/**
|
||||
* Provided for backward compatibility, use `afterLayout` instead.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
var defaults = require('./core.defaults');
|
||||
var helpers = require('../helpers/index');
|
||||
var layout = require('./core.layout');
|
||||
var layouts = require('./core.layouts');
|
||||
|
||||
module.exports = function(Chart) {
|
||||
|
||||
@ -39,7 +39,7 @@ module.exports = function(Chart) {
|
||||
scale.fullWidth = scale.options.fullWidth;
|
||||
scale.position = scale.options.position;
|
||||
scale.weight = scale.options.weight;
|
||||
layout.addBox(chart, scale);
|
||||
layouts.addBox(chart, scale);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
var defaults = require('../core/core.defaults');
|
||||
var Element = require('../core/core.element');
|
||||
var helpers = require('../helpers/index');
|
||||
var layout = require('../core/core.layout');
|
||||
var layouts = require('../core/core.layouts');
|
||||
|
||||
var noop = helpers.noop;
|
||||
|
||||
@ -523,8 +523,8 @@ function createNewLegendAndAttach(chart, legendOpts) {
|
||||
chart: chart
|
||||
});
|
||||
|
||||
layout.configure(chart, legend, legendOpts);
|
||||
layout.addBox(chart, legend);
|
||||
layouts.configure(chart, legend, legendOpts);
|
||||
layouts.addBox(chart, legend);
|
||||
chart.legend = legend;
|
||||
}
|
||||
|
||||
@ -556,13 +556,13 @@ module.exports = {
|
||||
helpers.mergeIf(legendOpts, defaults.global.legend);
|
||||
|
||||
if (legend) {
|
||||
layout.configure(chart, legend, legendOpts);
|
||||
layouts.configure(chart, legend, legendOpts);
|
||||
legend.options = legendOpts;
|
||||
} else {
|
||||
createNewLegendAndAttach(chart, legendOpts);
|
||||
}
|
||||
} else if (legend) {
|
||||
layout.removeBox(chart, legend);
|
||||
layouts.removeBox(chart, legend);
|
||||
delete chart.legend;
|
||||
}
|
||||
},
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
var defaults = require('../core/core.defaults');
|
||||
var Element = require('../core/core.element');
|
||||
var helpers = require('../helpers/index');
|
||||
var layout = require('../core/core.layout');
|
||||
var layouts = require('../core/core.layouts');
|
||||
|
||||
var noop = helpers.noop;
|
||||
|
||||
@ -206,8 +206,8 @@ function createNewTitleBlockAndAttach(chart, titleOpts) {
|
||||
chart: chart
|
||||
});
|
||||
|
||||
layout.configure(chart, title, titleOpts);
|
||||
layout.addBox(chart, title);
|
||||
layouts.configure(chart, title, titleOpts);
|
||||
layouts.addBox(chart, title);
|
||||
chart.titleBlock = title;
|
||||
}
|
||||
|
||||
@ -239,13 +239,13 @@ module.exports = {
|
||||
helpers.mergeIf(titleOpts, defaults.global.title);
|
||||
|
||||
if (titleBlock) {
|
||||
layout.configure(chart, titleBlock, titleOpts);
|
||||
layouts.configure(chart, titleBlock, titleOpts);
|
||||
titleBlock.options = titleOpts;
|
||||
} else {
|
||||
createNewTitleBlockAndAttach(chart, titleOpts);
|
||||
}
|
||||
} else if (titleBlock) {
|
||||
layout.removeBox(chart, titleBlock);
|
||||
layouts.removeBox(chart, titleBlock);
|
||||
delete chart.titleBlock;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,14 @@
|
||||
// Tests of the scale service
|
||||
describe('Test the layout service', function() {
|
||||
describe('Chart.layouts', function() {
|
||||
it('should be exposed through Chart.layouts', function() {
|
||||
expect(Chart.layouts).toBeDefined();
|
||||
expect(typeof Chart.layouts).toBe('object');
|
||||
expect(Chart.layouts.defaults).toBeDefined();
|
||||
expect(Chart.layouts.addBox).toBeDefined();
|
||||
expect(Chart.layouts.removeBox).toBeDefined();
|
||||
expect(Chart.layouts.configure).toBeDefined();
|
||||
expect(Chart.layouts.update).toBeDefined();
|
||||
});
|
||||
|
||||
// Disable tests which need to be rewritten based on changes introduced by
|
||||
// the following changes: https://github.com/chartjs/Chart.js/pull/2346
|
||||
// using xit marks the test as pending: http://jasmine.github.io/2.0/introduction.html#section-Pending_Specs
|
||||
@ -1,9 +1,9 @@
|
||||
describe('Deprecations', function() {
|
||||
describe('Version 2.8.0', function() {
|
||||
describe('Chart.layoutService', function() {
|
||||
it('should be defined and an alias of Chart.layout', function() {
|
||||
it('should be defined and an alias of Chart.layouts', function() {
|
||||
expect(Chart.layoutService).toBeDefined();
|
||||
expect(Chart.layoutService).toBe(Chart.layout);
|
||||
expect(Chart.layoutService).toBe(Chart.layouts);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -311,8 +311,8 @@ describe('Deprecations', function() {
|
||||
'afterLayout'
|
||||
];
|
||||
|
||||
var override = Chart.layout.update;
|
||||
Chart.layout.update = function() {
|
||||
var override = Chart.layouts.update;
|
||||
Chart.layouts.update = function() {
|
||||
sequence.push('layoutUpdate');
|
||||
override.apply(this, arguments);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user