diff --git a/package.json b/package.json index 32dea8e..ddec0fe 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chartwerk/core", - "version": "0.6.2", + "version": "0.6.3", "description": "Chartwerk core", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/models/series.ts b/src/models/series.ts index a5be800..7028130 100644 --- a/src/models/series.ts +++ b/src/models/series.ts @@ -9,6 +9,8 @@ import lodashMin from 'lodash/min'; import lodashMinBy from 'lodash/minBy'; import lodashMax from 'lodash/max'; import lodashMaxBy from 'lodash/maxBy'; +import lodashIsNil from 'lodash/isNil'; +import lodashIncludes from 'lodash/includes'; const SERIE_DEFAULTS = { @@ -61,8 +63,25 @@ export class CoreSeries { 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 { - 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 {