Display min and max values in timeseries
This commit is contained in:
parent
e57e333942
commit
7ab45d3e90
15
dashboard.py
15
dashboard.py
|
@ -396,7 +396,7 @@ class TimeSeries(Widget):
|
|||
dt = (t_last - data[-5][0]) / 4
|
||||
k = math.log((t_last - data[0][0]) / dt / n + 1)
|
||||
|
||||
max_value = max([d[1] for d in self.lts.data])
|
||||
max_value = max([d[3] if len(d) >= 4 else d[1] for d in self.lts.data])
|
||||
max_value = max(max_value, 0.001) # ensure positive
|
||||
if self.yscale == "log":
|
||||
try:
|
||||
|
@ -422,9 +422,17 @@ class TimeSeries(Widget):
|
|||
for i in range(n):
|
||||
t = data[i][0]
|
||||
v = data[i][1]
|
||||
if len(data[i]) >= 4:
|
||||
v_min = data[i][2]
|
||||
v_max = data[i][3]
|
||||
else:
|
||||
v_min = data[i][1]
|
||||
v_max = data[i][1]
|
||||
x = t2x(t)
|
||||
t_h = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t))
|
||||
y = v2y(v)
|
||||
y_min = v2y(v_min)
|
||||
y_max = v2y(v_max)
|
||||
#print(t, t_h, x)
|
||||
v_data.append(
|
||||
{
|
||||
|
@ -432,6 +440,8 @@ class TimeSeries(Widget):
|
|||
"v": v,
|
||||
"x": x,
|
||||
"y": y,
|
||||
"y_min": y_min,
|
||||
"y_max": y_max,
|
||||
"color": self.criticalcolor(v),
|
||||
})
|
||||
|
||||
|
@ -450,7 +460,8 @@ class TimeSeries(Widget):
|
|||
html += f"<line x1=0 y1={tm['y']} x2=1000 y2={tm['y']} stroke='#CCC' />"
|
||||
html += f"<text x=1005 y={tm['y']} fill='#888'>{tm['v_h']}</text>"
|
||||
for v in v_data:
|
||||
html += f"<circle cx={v['x']} cy={v['y']} r=3 fill='{v['color']}' />"
|
||||
html += f"<line x1={v['x']-3} x2={v['x']+3} y1={v['y']} y2={v['y']} stroke='{v['color']}' />"
|
||||
html += f"<line x1={v['x']} x2={v['x']} y1={v['y_min']} y2={v['y_max']} stroke='{v['color']}' />"
|
||||
html += "</svg>"
|
||||
log.debug("len(html) = %s", len(html))
|
||||
return Markup(html)
|
||||
|
|
Loading…
Reference in New Issue