From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 21 Nov 2019 12:06:15 +0000 (-0800) Subject: Remove Element.initialize (#6777) X-Git-Tag: v3.0.0-alpha~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64bc48ab53ac207cf4011130ad9289e22c778342;p=thirdparty%2FChart.js.git Remove Element.initialize (#6777) --- diff --git a/docs/getting-started/v3-migration.md b/docs/getting-started/v3-migration.md index 3dfd79bd0..f803f5b3a 100644 --- a/docs/getting-started/v3-migration.md +++ b/docs/getting-started/v3-migration.md @@ -71,6 +71,7 @@ Chart.js 3.0 introduces a number of breaking changes. Chart.js 2.0 was released * `DatasetController.addElementAndReset` * `Element.getArea` * `Element.height` +* `Element.initialize` * `Element.inLabelRange` * `IPlugin.afterScaleUpdate`. Use `afterLayout` instead * `Line.calculatePointY` diff --git a/src/core/core.controller.js b/src/core/core.controller.js index a1325394a..dee8ebc53 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -952,7 +952,7 @@ helpers.extend(Chart.prototype, /** @lends Chart */ { _chart: me, _data: me.data, _options: me.options.tooltips - }, me); + }); }, /** diff --git a/src/core/core.element.js b/src/core/core.element.js index 799ec82a4..f4feb4bd6 100644 --- a/src/core/core.element.js +++ b/src/core/core.element.js @@ -58,12 +58,8 @@ class Element { helpers.extend(this, configuration); // this.hidden = false; we assume Element has an attribute called hidden, but do not initialize to save memory - - this.initialize.apply(this, arguments); } - initialize() {} - pivot(animationsDisabled) { var me = this; if (animationsDisabled) { diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index e6a439f83..c23a4073a 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -485,6 +485,12 @@ function getBeforeAfterBodyLines(callback) { } class Tooltip extends Element { + constructor(config) { + super(config); + + this.initialize(); + } + initialize() { var me = this; me._model = getBaseModel(me._options); diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index 83f1cf3d9..8bceb9f53 100644 --- a/src/plugins/plugin.legend.js +++ b/src/plugins/plugin.legend.js @@ -113,8 +113,10 @@ function getBoxWidth(labelOpts, fontSize) { */ class Legend extends Element { - initialize(config) { - var me = this; + constructor(config) { + super(); + + const me = this; helpers.extend(me, config); // Contains hit boxes for each dataset (in dataset order) diff --git a/src/plugins/plugin.title.js b/src/plugins/plugin.title.js index fd64c3d5b..158d023c7 100644 --- a/src/plugins/plugin.title.js +++ b/src/plugins/plugin.title.js @@ -21,7 +21,9 @@ defaults._set('global', { * IMPORTANT: this class is exposed publicly as Chart.Legend, backward compatibility required! */ class Title extends Element { - initialize(config) { + constructor(config) { + super(); + var me = this; helpers.extend(me, config);