maint: cleanup and some helpful comments

This commit is contained in:
Jeremy Wall 2024-02-11 20:26:00 -06:00
parent 631fedfa2f
commit 0ee19320f6
2 changed files with 6 additions and 3 deletions

View File

@ -19,8 +19,9 @@ use axum::{
routing::get, routing::get,
Json, Router, Json, Router,
}; };
use axum_macros::debug_handler;
use maud::{html, Markup, PreEscaped}; // https://maud.lambda.xyz/getting-started.html
use maud::{html, Markup};
use tracing::debug; use tracing::debug;
use crate::dashboard::{Dashboard, Graph}; use crate::dashboard::{Dashboard, Graph};
@ -28,7 +29,6 @@ use crate::query::{to_samples, QueryResult};
type Config = State<Arc<Vec<Dashboard>>>; type Config = State<Arc<Vec<Dashboard>>>;
//#[axum_macros::debug_handler]
pub async fn graph_query( pub async fn graph_query(
State(config): Config, State(config): Config,
Path((dash_idx, graph_idx)): Path<(usize, usize)>, Path((dash_idx, graph_idx)): Path<(usize, usize)>,

View File

@ -102,6 +102,7 @@ class TimeseriesGraph extends HTMLElement {
async updateGraph() { async updateGraph() {
const data = await this.fetchData(); const data = await this.fetchData();
if (data.Series) { if (data.Series) {
// https://plotly.com/javascript/reference/scatter/
var traces = []; var traces = [];
for (const pair of data.Series) { for (const pair of data.Series) {
const series = pair[1]; const series = pair[1];
@ -123,6 +124,7 @@ class TimeseriesGraph extends HTMLElement {
traces.push(trace); traces.push(trace);
} }
console.log("Traces: ", traces); console.log("Traces: ", traces);
// https://plotly.com/javascript/plotlyjs-function-reference/#plotlyreact
Plotly.react(this.getTargetNode(), traces, Plotly.react(this.getTargetNode(), traces,
{ {
legend: { legend: {
@ -134,6 +136,7 @@ class TimeseriesGraph extends HTMLElement {
responsive: true responsive: true
}); });
} else if (data.Scalar) { } else if (data.Scalar) {
// https://plotly.com/javascript/reference/bar/
console.log("scalar data: ", data.Scalar); console.log("scalar data: ", data.Scalar);
var traces = []; var traces = [];
for (const pair of data.Scalar) { for (const pair of data.Scalar) {