Basic graph for INT values
This commit is contained in:
parent
047f39cfa7
commit
f0a6ce7b95
1
main.go
1
main.go
@ -699,6 +699,7 @@ func pageDatapointValues(w http.ResponseWriter, r *http.Request, _ *session.T) {
|
||||
page.Data = map[string]any{
|
||||
"Datapoint": datapoint,
|
||||
"Values": values,
|
||||
"Display": r.URL.Query().Get("display"),
|
||||
}
|
||||
page.Render(w)
|
||||
return
|
||||
|
@ -67,3 +67,7 @@
|
||||
grid-template-columns: min-content min-content;
|
||||
grid-gap: 8px;
|
||||
}
|
||||
.graph {
|
||||
height: 600px;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
@ -67,3 +67,7 @@
|
||||
grid-template-columns: min-content min-content;
|
||||
grid-gap: 8px;
|
||||
}
|
||||
.graph {
|
||||
height: 600px;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
8
static/js/lib/plotly-2.32.0.min.js
vendored
Normal file
8
static/js/lib/plotly-2.32.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -81,3 +81,8 @@
|
||||
grid-gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.graph {
|
||||
height: 600px;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
@ -1,13 +1,35 @@
|
||||
{{ define "page" }}
|
||||
{{ $version := .VERSION }}
|
||||
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/{{ .CONFIG.THEME }}/datapoints.css">
|
||||
<script src="/js/{{ .VERSION }}/lib/plotly-2.32.0.min.js" charset="utf-8"></script>
|
||||
|
||||
{{ block "page_label" . }}{{end}}
|
||||
|
||||
{{ if eq .Data.Display "list" }}
|
||||
<div id="values">
|
||||
{{ range .Data.Values }}
|
||||
<div class="value">{{ format_time .Ts }}</div>
|
||||
<div class="value">{{ .Value }}</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="graph" id="tester"></div>
|
||||
<script type="text/javascript">
|
||||
const tester = document.getElementById('tester');
|
||||
let data = {{ .Data }}
|
||||
let x = data.Values.map(d => d.Ts)
|
||||
let y = data.Values.map(d => d.ValueInt.Int64)
|
||||
Plotly.newPlot(
|
||||
tester,
|
||||
[
|
||||
{
|
||||
x,
|
||||
y,
|
||||
},
|
||||
], {
|
||||
margin: { t: 0 },
|
||||
}
|
||||
);
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user