fix: got rid of shadowRoot

plotly didn't play well with it.
This commit is contained in:
Jeremy Wall 2024-02-10 16:51:57 -06:00
parent d78c1ea26c
commit 59f8a5401a
2 changed files with 5 additions and 10 deletions

View File

@ -122,10 +122,6 @@ pub async fn index(State(config): State<Config>) -> Markup {
script src="/js/plotly.js" { }
script src="/js/htmx.js" { }
script src="/js/lib.js" { }
template id="timeseries_template" {
div;
div;
}
(app(State(config.clone())).await)
}
}

View File

@ -5,14 +5,13 @@ class TimeseriesGraph extends HTMLElement {
#intervalId;
#pollSeconds;
#label;
#targetNode = null;
constructor() {
super();
const root = this.attachShadow({ mode: "open" });
var template = document.getElementById("timeseries_template");
this.#width = 800;
this.#height = 600;
this.#pollSeconds = 30;
root.appendChild(template.content.cloneNode(true));
this.#targetNode = this.appendChild(document.createElement("div"));
}
static observedAttributes = ['uri', 'width', 'height', 'poll-seconds'];
@ -56,8 +55,8 @@ class TimeseriesGraph extends HTMLElement {
static elementName = "timeseries-graph";
getTargetNode() {
console.log("shadowroot: ", this.shadowRoot);
return this.shadowRoot.firstChild;
console.log("targetNode: ", this.#targetNode);
return this.#targetNode;
}
stopInterval() {
@ -96,7 +95,7 @@ class TimeseriesGraph extends HTMLElement {
const labels = pair[0];
var trace = {
type: "scatter",
mode: "lines",
mode: "lines+text",
x: [],
y: []
};