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).
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');
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;
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');
var newOptions = chart.options;
helpers.each(chart.scales, function(scale) {
- layout.removeBox(chart, scale);
+ layouts.removeBox(chart, scale);
});
newOptions = helpers.configMerge(
return;
}
- layout.update(this, this.width, this.height);
+ layouts.update(this, this.width, this.height);
/**
* Provided for backward compatibility, use `afterLayout` instead.
var defaults = require('./core.defaults');
var helpers = require('../helpers/index');
-var layout = require('./core.layout');
+var layouts = require('./core.layouts');
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);
});
}
};
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;
chart: chart
});
- layout.configure(chart, legend, legendOpts);
- layout.addBox(chart, legend);
+ layouts.configure(chart, legend, legendOpts);
+ layouts.addBox(chart, legend);
chart.legend = legend;
}
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;
}
},
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;
chart: chart
});
- layout.configure(chart, title, titleOpts);
- layout.addBox(chart, title);
+ layouts.configure(chart, title, titleOpts);
+ layouts.addBox(chart, title);
chart.titleBlock = title;
}
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;
}
}
-// 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
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);
});
});
});
'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);
};