From e202f08193835250c54b30ba2ef7cd0c302563d2 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 21 Dec 2017 22:25:21 +0200 Subject: [PATCH] Charts fixes (#742) --- src/cards/ha-history_graph-card.html | 36 +++++++++++++++++++-------- src/data/ha-state-history-data.html | 15 +++++++++-- src/dialogs/more-info-dialog.html | 37 ++++++++++++++-------------- 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/cards/ha-history_graph-card.html b/src/cards/ha-history_graph-card.html index a3261156b0..56ab7f4f92 100644 --- a/src/cards/ha-history_graph-card.html +++ b/src/cards/ha-history_graph-card.html @@ -32,7 +32,7 @@ entity-id='[[computeHistoryEntities(stateObj)]]' data='{{stateHistory}}' is-loading='{{stateHistoryLoading}}' - cache-config='[[computeCacheConfig(stateObj)]]' + cache-config='[[cacheConfig]]' > { @@ -68,6 +68,17 @@ } }); return result; + }).filter((element, index, arr) => { + // Remove data point if it is equal to previous point and next point. + if (index === 0 || index === (arr.length - 1)) return true; + function compare(obj1, obj2) { + if (obj1.state !== obj2.state) return false; + if (!obj1.attributes && !obj2.attributes) return true; + if (!obj1.attributes || !obj2.attributes) return false; + return LINE_ATTRIBUTES_TO_KEEP.every(attr => + obj1.attributes[attr] === obj2.attributes[attr]); + } + return !compare(element, arr[index - 1]) || !compare(element, arr[index + 1]); }) }; }), @@ -191,7 +202,7 @@ const oldEntity = oldLine.data.find(cacheEntity => entity.entity_id === cacheEntity.entity_id); if (oldEntity) { - oldEntity.states = oldEntity.state.concat(entity.states); + oldEntity.states = oldEntity.states.concat(entity.states); } else { oldLine.data.push(entity); } diff --git a/src/dialogs/more-info-dialog.html b/src/dialogs/more-info-dialog.html index 5a0d0efb59..3a23f82951 100644 --- a/src/dialogs/more-info-dialog.html +++ b/src/dialogs/more-info-dialog.html @@ -2,13 +2,10 @@ - - - + + @@ -61,11 +58,6 @@ width: 100%; } } - - dom-if { - display: none; - } - @@ -83,7 +75,7 @@ entity-id='[[stateObj.entity_id]]' data='{{stateHistory}}' is-loading='{{stateHistoryLoading}}' - cache-config='[[computeCacheConfig(stateObj)]]' + cache-config='[[cacheConfig]]' >