Display min, max and last value in description
This commit is contained in:
parent
4b6e6c6eed
commit
4380210c34
|
@ -67,6 +67,7 @@ class Widget:
|
|||
self.type = d["type"]
|
||||
self.stops = d["stops"]
|
||||
self.yscale = d.get("yscale", "linear")
|
||||
self.extra = {}
|
||||
log.debug("data = %s", d["data"])
|
||||
self.lts = LTS(id=d["data"][0]) # by default we handle only one data source
|
||||
pass
|
||||
|
@ -137,6 +138,11 @@ class Widget:
|
|||
s += render_template_string(
|
||||
"<tr><th>{{d}}:</th><td>{{v}}</td></tr>",
|
||||
d=d, v=v)
|
||||
for d, v in self.extra.items():
|
||||
if v:
|
||||
s += render_template_string(
|
||||
"<tr class='extra'><th>{{d}}:</th><td>{{v}}</td></tr>",
|
||||
d=d, v=v)
|
||||
s += "</table>"
|
||||
return Markup(s)
|
||||
|
||||
|
@ -362,6 +368,7 @@ class TimeSeries(Widget):
|
|||
if self.yscale == "log":
|
||||
try:
|
||||
min_value = min(d[1] for d in self.lts.data if d[1] > 0)
|
||||
self.extra["min"] = "%g" % min_value
|
||||
except ValueError:
|
||||
# no non-negative values
|
||||
min_value = max_value / 2
|
||||
|
@ -375,6 +382,8 @@ class TimeSeries(Widget):
|
|||
# Make sure min_value is less than max_value
|
||||
min_value /= 2
|
||||
log.debug("min_value = %s, max_value = %s", min_value, max_value)
|
||||
self.extra["max"] = "%g" % max_value
|
||||
self.extra["last"] = "%g" % data[-1][1]
|
||||
log.debug("collecting data")
|
||||
v_data = []
|
||||
for i in range(n):
|
||||
|
|
|
@ -53,6 +53,9 @@
|
|||
border: 1px solid #CCC;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.extra {
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
|
Loading…
Reference in New Issue