From f008dd14c6042dcd52275cd7f8b223a96020ec42 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Mon, 3 Aug 2020 12:52:05 +0300 Subject: [PATCH] Change get index date for map widget --- .../modules/home/components/widget/lib/maps/maps-utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts index 51fdef7075..b67925038c 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts @@ -249,10 +249,11 @@ export function parseData(input: DatasourceData[]): FormattedData[] { deviceType: null }; entityArray.filter(el => el.data.length).forEach(el => { - obj[el?.dataKey?.label] = el?.data[0][0] ? el?.data[0][1] : null; - obj[el?.dataKey?.label + '|ts'] = el?.data[0][0] || null; + const indexDate = el?.data?.length ? el.data.length - 1 : 0; + obj[el?.dataKey?.label] = el?.data[indexDate][0] ? el?.data[indexDate][1] : null; + obj[el?.dataKey?.label + '|ts'] = el?.data[indexDate][0] || null; if (el?.dataKey?.label === 'type') { - obj.deviceType = el?.data[0][1]; + obj.deviceType = el?.data[indexDate][1]; } }); return obj;