Browse Source

isSeriesAvailable: check for datapoints emptiness

merge-requests/22/head
rozetko 3 years ago
parent
commit
5cee846ad5
  1. 21
      src/models/series.ts

21
src/models/series.ts

@ -9,6 +9,8 @@ import lodashMin from 'lodash/min';
import lodashMinBy from 'lodash/minBy'; import lodashMinBy from 'lodash/minBy';
import lodashMax from 'lodash/max'; import lodashMax from 'lodash/max';
import lodashMaxBy from 'lodash/maxBy'; import lodashMaxBy from 'lodash/maxBy';
import lodashIsNil from 'lodash/isNil';
import lodashIncludes from 'lodash/includes';
const SERIE_DEFAULTS = { const SERIE_DEFAULTS = {
@ -61,8 +63,25 @@ export class CoreSeries<T extends Serie> {
return this._coreDefaults; return this._coreDefaults;
} }
private _isSerieEmpty(serie: T): boolean {
if(serie.datapoints.length > 0) {
for(const datapoint of serie.datapoints) {
// TODO: axis-related
if(!lodashIsNil(datapoint[1])) {
return false;
}
}
}
return true;
}
get isSeriesAvailable(): boolean { get isSeriesAvailable(): boolean {
return this.visibleSeries.length > 0; if(this.visibleSeries.length > 0) {
const seriesEmptiness = lodashMap(this.visibleSeries, this._isSerieEmpty.bind(this));
return lodashIncludes(seriesEmptiness, false);
}
return false;
} }
get visibleSeries(): Array<T> { get visibleSeries(): Array<T> {

Loading…
Cancel
Save