diff --git a/core/client.js b/core/client.js index ff4b6dd7..dd7cc2a4 100644 --- a/core/client.js +++ b/core/client.js @@ -221,6 +221,7 @@ class TfSparkLineElement extends LitElement { this.min = 0; this.max = 1.0; this.lines = []; + this.k_values_max = 100; } append(key, value) { @@ -236,23 +237,22 @@ class TfSparkLineElement extends LitElement { line = { name: key, style: k_colors[this.lines.length % k_colors.length], - values: [], + values: Array(this.k_values_max).fill(0), }; this.lines.push(line); } - line.values.push(value); - if (line.values.length > 100) { + if (line.values.length >= this.k_values_max) { line.values.shift(); } + line.values.push(value); this.requestUpdate(); } render_line(line) { if (line?.values?.length >= 2) { - let points = [].concat(...line.values.map((x, i) => [100.0 * i / (line.values.length - 1), 10.0 - 10.0 * (x - this.min) / (this.max - this.min)])); - return svg` - - `; + let max = Math.max(this.max, ...line.values); + let points = [].concat(...line.values.map((x, i) => [100.0 * i / (line.values.length - 1), 10.0 - 10.0 * (x - this.min) / (max - this.min)])); + return svg``; } } @@ -834,18 +834,6 @@ function _receive_websocket_message(message) { } } -function keyEvent(event) { - send({ - event: "key", - type: event.type, - which: event.which, - keyCode: event.keyCode, - charCode: event.charCode, - character: String.fromCharCode(event.keyCode || event.which), - altKey: event.altKey, - }); -} - function setStatusMessage(message, color) { document.getElementsByTagName('tf-navigation')[0].status = {message: message, color: color}; } diff --git a/core/index.html b/core/index.html index 462e8c02..bdbd69b1 100644 --- a/core/index.html +++ b/core/index.html @@ -34,7 +34,6 @@
-