Browse Source

getters to methods

merge-requests/6/head
vargburz 3 years ago
parent
commit
2f719b69cc
  1. 11
      src/index.ts
  2. 18
      src/state.ts

11
src/index.ts

@ -827,20 +827,19 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
// TODO: move to State
get absXScale(): d3.ScaleLinear<number, number> {
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<number, number> {
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<number, number> {
return this.state.xScale;
}
@ -991,7 +990,7 @@ abstract class ChartwerkPod<T extends TimeSerie, O extends Options> {
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<T extends TimeSerie, O extends Options> {
}
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;
}

18
src/state.ts

@ -42,9 +42,9 @@ export class PodState<T extends TimeSerie, O extends Options> {
}
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<T extends TimeSerie, O extends Options> {
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<T extends TimeSerie, O extends Options> {
return minValue;
}
get maxValueY(): number {
public getMaxValueY(): number {
if(this.isSeriesUnavailable) {
return DEFAULT_AXIS_RANGE[1];
}
@ -171,7 +171,7 @@ export class PodState<T extends TimeSerie, O extends Options> {
return maxValue;
}
get minValueX(): number {
public getMinValueX(): number {
if(this.isSeriesUnavailable) {
return DEFAULT_AXIS_RANGE[0];
}
@ -189,7 +189,7 @@ export class PodState<T extends TimeSerie, O extends Options> {
return minValue;
}
get maxValueX(): number {
public getMaxValueX(): number {
if(this.isSeriesUnavailable) {
return DEFAULT_AXIS_RANGE[1];
}
@ -206,7 +206,7 @@ export class PodState<T extends TimeSerie, O extends Options> {
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<T extends TimeSerie, O extends Options> {
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];
}

Loading…
Cancel
Save