Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, I'm just wondering now, do we actually need a Chart.layout variable? shouldn't folks just call require('./core/core.layout') when they need the layout?

@simonbrunel simonbrunel Jan 7, 2018

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layout (singleton) can be accessed from external plugins/charts, in which case it's not possible to require './core/core.layout'.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etimberg @benmccann Actually, I don't know why the layout is a singleton instead of an object attached to each chart and accessible via chartInstance.layout. Maybe that something we will like to change in v3.

For the alias, I would suggest another name to be consistent with other "Service" singletons: Chart.layouts (plural since it manages many layouts), as we have Chart.plugins and soon Chart.animations and Chart.scales.

What do you think?

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