From 5cee846ad51468f16f60e18e3410ceddf3b27da4 Mon Sep 17 00:00:00 2001 From: rozetko Date: Tue, 24 May 2022 23:06:27 +0400 Subject: [PATCH 1/2] isSeriesAvailable: check for datapoints emptiness --- src/models/series.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 { From e77ba07ba220973f654be58ea15e40e1725c996b Mon Sep 17 00:00:00 2001 From: rozetko Date: Tue, 24 May 2022 23:06:35 +0400 Subject: [PATCH 2/2] 0.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",