Skip to content

Commit

Permalink
start moving lecacy scale hooks to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeLenaleee committed Aug 25, 2022
1 parent f957aad commit e4b08c1
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default class Scale extends Element {
// Any function can be extended by the scale type

beforeUpdate() {
call(this.options.beforeUpdate, [this]);
this._callHooks('beforeUpdate');
}

/**
Expand Down Expand Up @@ -489,13 +489,11 @@ export default class Scale extends Element {
}

afterUpdate() {
call(this.options.afterUpdate, [this]);
this._callHooks('afterUpdate');
}

//

beforeSetDimensions() {
call(this.options.beforeSetDimensions, [this]);
this._callHooks('beforeSetDimensions');
}
setDimensions() {
// Set the unconstrained dimension before label rotation
Expand All @@ -519,7 +517,7 @@ export default class Scale extends Element {
this.paddingBottom = 0;
}
afterSetDimensions() {
call(this.options.afterSetDimensions, [this]);
this._callHooks('afterSetDimension');
}

_callHooks(name) {
Expand All @@ -536,10 +534,10 @@ export default class Scale extends Element {
this._callHooks('afterDataLimits');
}

//
beforeBuildTicks() {
this._callHooks('beforeBuildTicks');
}

/**
* @return {object[]} the ticks
*/
Expand All @@ -551,8 +549,9 @@ export default class Scale extends Element {
}

beforeTickToLabelConversion() {
call(this.options.beforeTickToLabelConversion, [this]);
this._callHooks('beforeTickToLabelConversion');
}

/**
* Convert ticks to label strings
* @param {Tick[]} ticks
Expand All @@ -566,14 +565,13 @@ export default class Scale extends Element {
}
}
afterTickToLabelConversion() {
call(this.options.afterTickToLabelConversion, [this]);
this._callHooks('afterTickToLabelConversion');
}

//

beforeCalculateLabelRotation() {
call(this.options.beforeCalculateLabelRotation, [this]);
this._callHooks('beforeCalculateLabelRotation');
}

calculateLabelRotation() {
const options = this.options;
const tickOpts = options.ticks;
Expand Down Expand Up @@ -612,16 +610,17 @@ export default class Scale extends Element {

this.labelRotation = labelRotation;
}

afterCalculateLabelRotation() {
call(this.options.afterCalculateLabelRotation, [this]);
this._callHooks('afterCalculateLabelRotation');
}
afterAutoSkip() {}

//
afterAutoSkip() {}

beforeFit() {
call(this.options.beforeFit, [this]);
this._callHooks('beforeFit');
}

fit() {
// Reset
const minSize = {
Expand Down Expand Up @@ -741,7 +740,7 @@ export default class Scale extends Element {
}

afterFit() {
call(this.options.afterFit, [this]);
this._callHooks('afterFit');
}

// Shared Methods
Expand Down

0 comments on commit e4b08c1

Please sign in to comment.