From 2f719b69ccfc05e7b2cc1b6f1d86e1dc7ada171d Mon Sep 17 00:00:00 2001 From: vargburz Date: Mon, 1 Nov 2021 19:47:41 +0300 Subject: [PATCH] getters to methods --- src/index.ts | 11 +++++------ src/state.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/index.ts b/src/index.ts index 11a1a9c..331cec9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -827,20 +827,19 @@ abstract class ChartwerkPod { // TODO: move to State get absXScale(): d3.ScaleLinear { - const domain = [0, Math.abs(this.state.maxValueX - this.state.minValueX)]; + const domain = [0, Math.abs(this.state.getMaxValueX() - this.state.getMinValueX())]; return this.d3.scaleLinear() .domain(domain) .range([0, this.width]); } get absYScale(): d3.ScaleLinear { - const domain = [0, Math.abs(this.state.maxValueY - this.state.minValueY)]; + const domain = [0, Math.abs(this.state.getMaxValueY() - this.state.getMinValueY())]; return this.d3.scaleLinear() .domain(domain) .range([0, this.height]); } - // TODO: these getters can be removed, but it will break all Pods. get xScale(): d3.ScaleLinear { return this.state.xScale; } @@ -991,7 +990,7 @@ abstract class ChartwerkPod { return mergeWith({}, DEFAULT_MARGIN, this.extraMargin, add); } - formatedBound(alias: string, target: string): string { + formattedBound(alias: string, target: string): string { const confidenceMetric = replace(alias, '$__metric_name', target); return confidenceMetric; } @@ -1023,8 +1022,8 @@ abstract class ChartwerkPod { } let series = []; this.series.forEach(serie => { - series.push(this.formatedBound(this.options.bounds.upper, serie.target)); - series.push(this.formatedBound(this.options.bounds.lower, serie.target)); + series.push(this.formattedBound(this.options.bounds.upper, serie.target)); + series.push(this.formattedBound(this.options.bounds.lower, serie.target)); }); return series; } diff --git a/src/state.ts b/src/state.ts index 2c7c447..d5afd72 100755 --- a/src/state.ts +++ b/src/state.ts @@ -42,9 +42,9 @@ export class PodState { } protected setInitialRanges(): void { - this._xValueRange = [this.minValueX, this.maxValueX]; - this._yValueRange = [this.minValueY, this.maxValueY]; - this._y1ValueRange = [this.minValueY1, this.maxValueY1]; + this._xValueRange = [this.getMinValueX(), this.getMaxValueX()]; + this._yValueRange = [this.getMinValueY(), this.getMaxValueY()]; + this._y1ValueRange = [this.getMinValueY1(), this.getMaxValueY1()]; } protected initScales(): void { @@ -137,7 +137,7 @@ export class PodState { this._transform.k = transform.k !== undefined ? transform.k : this._transform.k; } - get minValueY(): number { + public getMinValueY(): number { if(this.isSeriesUnavailable) { return DEFAULT_AXIS_RANGE[0]; } @@ -154,7 +154,7 @@ export class PodState { return minValue; } - get maxValueY(): number { + public getMaxValueY(): number { if(this.isSeriesUnavailable) { return DEFAULT_AXIS_RANGE[1]; } @@ -171,7 +171,7 @@ export class PodState { return maxValue; } - get minValueX(): number { + public getMinValueX(): number { if(this.isSeriesUnavailable) { return DEFAULT_AXIS_RANGE[0]; } @@ -189,7 +189,7 @@ export class PodState { return minValue; } - get maxValueX(): number { + public getMaxValueX(): number { if(this.isSeriesUnavailable) { return DEFAULT_AXIS_RANGE[1]; } @@ -206,7 +206,7 @@ export class PodState { return maxValue; } - get minValueY1(): number { + public getMinValueY1(): number { if(this.isSeriesUnavailable || this.options.axis.y1 === undefined || this.options.axis.y1.isActive === false) { return DEFAULT_AXIS_RANGE[0]; } @@ -223,7 +223,7 @@ export class PodState { return minValue; } - get maxValueY1(): number { + public getMaxValueY1(): number { if(this.isSeriesUnavailable || this.options.axis.y1 === undefined || this.options.axis.y1.isActive === false) { return DEFAULT_AXIS_RANGE[1]; }