Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start moving lecacy scale hooks to plugin #10631

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
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
Loading