Basic graph for INT values

This commit is contained in:
Magnus Åhall 2024-06-26 11:58:54 +02:00
parent 047f39cfa7
commit f0a6ce7b95
6 changed files with 44 additions and 0 deletions

View File

@ -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

View File

@ -67,3 +67,7 @@
grid-template-columns: min-content min-content;
grid-gap: 8px;
}
.graph {
height: 600px;
border: 1px solid #fff;
}

View File

@ -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

File diff suppressed because one or more lines are too long

View File

@ -81,3 +81,8 @@
grid-gap: 8px;
}
}
.graph {
height: 600px;
border: 1px solid #fff;
}

View File

@ -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 }}