Skip to content

Commit

Permalink
Make Chart.layout(Service) importable
Browse files Browse the repository at this point in the history
Rename (and deprecate) `Chart.layoutService` to `Chart.layout` and make it importable.
  • Loading branch information
simonbrunel committed Jan 7, 2018
1 parent 9ddb449 commit c4b95cf
Show file tree
Hide file tree
Showing 8 changed files with 448 additions and 431 deletions.
11 changes: 10 additions & 1 deletion src/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ 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.platform = require('./platforms/platform');
Chart.Ticks = require('./core/core.ticks');

require('./core/core.plugin')(Chart);
require('./core/core.animation')(Chart);
require('./core/core.controller')(Chart);
require('./core/core.datasetController')(Chart);
require('./core/core.layoutService')(Chart);
require('./core/core.scaleService')(Chart);
require('./core/core.scale')(Chart);
require('./core/core.tooltip')(Chart);
Expand Down Expand Up @@ -77,3 +77,12 @@ if (typeof window !== 'undefined') {
* @private
*/
Chart.canvasHelpers = Chart.helpers.canvas;

/**
* Provided for backward compatibility, use Chart.layout instead.
* @namespace Chart.layoutService
* @deprecated since version 2.8.0
* @todo remove at version 3
* @private
*/
Chart.layoutService = Chart.layout;
5 changes: 3 additions & 2 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var defaults = require('./core.defaults');
var helpers = require('../helpers/index');
var Interaction = require('./core.interaction');
var layout = require('./core.layout');
var platform = require('../platforms/platform');

module.exports = function(Chart) {
Expand Down Expand Up @@ -46,7 +47,7 @@ module.exports = function(Chart) {
var newOptions = chart.options;

helpers.each(chart.scales, function(scale) {
Chart.layoutService.removeBox(chart, scale);
layout.removeBox(chart, scale);
});

newOptions = helpers.configMerge(
Expand Down Expand Up @@ -435,7 +436,7 @@ module.exports = function(Chart) {
return;
}

Chart.layoutService.update(this, this.width, this.height);
layout.update(this, this.width, this.height);

/**
* Provided for backward compatibility, use `afterLayout` instead.
Expand Down
Loading

0 comments on commit c4b95cf

Please sign in to comment.