Skip to content
Snippets Groups Projects
Commit c3ab18e5 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #35 - handle negative temperatures

parent 4a195f58
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,8 @@ ...@@ -62,7 +62,8 @@
<script> <script>
function createChart_{{ chartId | replace('-', '_') }}() function createChart_{{ chartId | replace('-', '_') }}()
{ {
let data = [{ let data = [
{
x: {{ x }}, x: {{ x }},
y: {{ y }}, y: {{ y }},
text: {{ textLabels }}, text: {{ textLabels }},
...@@ -76,7 +77,16 @@ ...@@ -76,7 +77,16 @@
}, },
hoverinfo: 'text', hoverinfo: 'text',
fillcolor: '{{ fillColor }}' fillcolor: '{{ fillColor }}'
}]; },
{
x: {{ ghostTraceX }},
y: {{ ghostTraceY }},
fill: 'tozeroy',
type: 'scatter',
mode: 'none',
fillcolor: '{{ fillColor }}'
}
];
let layout = { let layout = {
xaxis: { xaxis: {
......
...@@ -75,13 +75,24 @@ class SensorLineChartTile(Tile): ...@@ -75,13 +75,24 @@ class SensorLineChartTile(Tile):
endDateTime, endDateTime,
storageLeafService) 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 { return {
'latest': latest, 'latest': latest,
'x': x, 'x': x,
'y': y, 'y': y,
'sensorInfo': sensorData['sensorInfo'], 'sensorInfo': sensorData['sensorInfo'],
'min': minValue, 'min': minValue,
'max': maxValue 'max': maxValue,
'ghostTraceX': ghostTraceX,
'ghostTraceY': ghostTraceY
} }
def __get_min_and_max(self, pageName: str, sensorType: Dict, def __get_min_and_max(self, pageName: str, sensorType: Dict,
...@@ -138,7 +149,9 @@ class SensorLineChartTile(Tile): ...@@ -138,7 +149,9 @@ class SensorLineChartTile(Tile):
title=self._settings['title'], title=self._settings['title'],
lineColor=self._settings['lineColor'], lineColor=self._settings['lineColor'],
fillColor=self._settings['fillColor'], fillColor=self._settings['fillColor'],
chartId=str(uuid.uuid4())) chartId=str(uuid.uuid4()),
ghostTraceX=data['ghostTraceX'],
ghostTraceY=data['ghostTraceY'])
def __format_date(self, dateTime: str): def __format_date(self, dateTime: str):
parsedDateTime = datetime.strptime(dateTime, self.DATE_FORMAT) parsedDateTime = datetime.strptime(dateTime, self.DATE_FORMAT)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment