diff --git a/src/logic/tile/tiles/SensorLineChartTile.html b/src/logic/tile/tiles/SensorLineChartTile.html index 1a5e850437cf44361b5a66e73173ab565ef8fb1e..f101b29d3ef0f9af09d37fb0c7a7f8b515ddbf93 100644 --- a/src/logic/tile/tiles/SensorLineChartTile.html +++ b/src/logic/tile/tiles/SensorLineChartTile.html @@ -62,21 +62,31 @@ <script> function createChart_{{ chartId | replace('-', '_') }}() { - let data = [{ - x: {{ x }}, - y: {{ y }}, - text: {{ textLabels }}, - fill: 'tozeroy', - type: 'scatter', - mode: 'lines', - line: { - shape: 'spline', - color: '{{ lineColor }}', - width: 3 + let data = [ + { + x: {{ x }}, + y: {{ y }}, + text: {{ textLabels }}, + fill: 'tozeroy', + type: 'scatter', + mode: 'lines', + line: { + shape: 'spline', + color: '{{ lineColor }}', + width: 3 + }, + hoverinfo: 'text', + fillcolor: '{{ fillColor }}' }, - hoverinfo: 'text', - fillcolor: '{{ fillColor }}' - }]; + { + x: {{ ghostTraceX }}, + y: {{ ghostTraceY }}, + fill: 'tozeroy', + type: 'scatter', + mode: 'none', + fillcolor: '{{ fillColor }}' + } + ]; let layout = { xaxis: { diff --git a/src/logic/tile/tiles/SensorLineChartTile.py b/src/logic/tile/tiles/SensorLineChartTile.py index 7aeb33a39cfb19b162aadd9447d3521100de3414..a9d4a2f94a2fd3396fd47162890df83136c461ae 100644 --- a/src/logic/tile/tiles/SensorLineChartTile.py +++ b/src/logic/tile/tiles/SensorLineChartTile.py @@ -75,13 +75,24 @@ class SensorLineChartTile(Tile): endDateTime, storageLeafService) + # Check if all values are above zero and the min value for the sensor group is below zero. + # Therefore a ghost trace must be generated that fills the area underneath the x-axis. + ghostTraceX = [] + ghostTraceY = [] + if all(float(i) >= 0 for i in y): + if minValue < 0: + ghostTraceX = [x[0], x[-1]] + ghostTraceY = [minValue, minValue] + return { 'latest': latest, 'x': x, 'y': y, 'sensorInfo': sensorData['sensorInfo'], 'min': minValue, - 'max': maxValue + 'max': maxValue, + 'ghostTraceX': ghostTraceX, + 'ghostTraceY': ghostTraceY } def __get_min_and_max(self, pageName: str, sensorType: Dict, @@ -138,7 +149,9 @@ class SensorLineChartTile(Tile): title=self._settings['title'], lineColor=self._settings['lineColor'], fillColor=self._settings['fillColor'], - chartId=str(uuid.uuid4())) + chartId=str(uuid.uuid4()), + ghostTraceX=data['ghostTraceX'], + ghostTraceY=data['ghostTraceY']) def __format_date(self, dateTime: str): parsedDateTime = datetime.strptime(dateTime, self.DATE_FORMAT)