Browse Source

state: new `getYScaleByOrientation` function

pull/51/head
rozetko 6 months ago
parent
commit
4f28c5dc13
  1. 3
      src/models/series.ts
  2. 11
      src/models/state.ts

3
src/models/series.ts

@ -35,6 +35,7 @@ export class CoreSeries<T extends Serie> {
_series: Array<T> = [];
constructor(series: T[], private _podDefaults?: Partial<T>) {
// TODO: create separate Serie class, and store instances in this._series
this.setSeries(series);
}
@ -83,7 +84,7 @@ export class CoreSeries<T extends Serie> {
get isSeriesAvailable(): boolean {
if(this.visibleSeries.length > 0) {
const seriesEmptiness = lodashMap(this.visibleSeries, this._isSerieEmpty.bind(this));
return lodashIncludes(seriesEmptiness, false);
}
return false;

11
src/models/state.ts

@ -1,4 +1,4 @@
import { Serie, Options } from '../types';
import { Serie, Options, yAxisOrientation } from '../types';
import { CoreSeries } from './series';
import { CoreOptions } from './options';
@ -89,6 +89,15 @@ export class PodState<T extends Serie, O extends Options> {
this._transform = { x: 0, y: 0, k: 1 };
}
getYScaleByOrientation(orientation?: yAxisOrientation): d3.ScaleLinear<number, number> {
// TODO: we set defaults in Series class, so we don't expect `undefined` here
// we can remove this check when we implement Serie class (see TODO in `series.ts`)
if(orientation === undefined) {
return this._yScale;
}
return orientation === yAxisOrientation.LEFT ? this._yScale : this._y1Scale;
}
get yScale(): d3.ScaleLinear<number, number> {
return this._yScale;
}

Loading…
Cancel
Save