diff --git a/src/App.tsx b/src/App.tsx index 5804970..097704e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -43,6 +43,7 @@ export default function App() { serialPort: serialPortExtracted, connected, generate, + dataPointThreshold, } = message.data.monitorUISettings || {}; let updateTitle = false; @@ -130,6 +131,10 @@ export default function App() { typeof generate === "undefined" ? prevConfig?.monitorUISettings?.generate : generate, + dataPointThreshold: + typeof dataPointThreshold === "undefined" + ? prevConfig?.monitorUISettings?.dataPointThreshold + : dataPointThreshold, }, })); @@ -195,6 +200,9 @@ export default function App() { serialPort: urlParams.get("serialPort") || "/serial/port/address", connected: urlParams.get("connected") === "true", generate: urlParams.get("generate") === "true", + dataPointThreshold: parseInt( + urlParams.get("dataPointThreshold") || "50" + ), }, }; diff --git a/src/ChartPlotter.tsx b/src/ChartPlotter.tsx index 972e04e..c3da115 100644 --- a/src/ChartPlotter.tsx +++ b/src/ChartPlotter.tsx @@ -43,7 +43,9 @@ function _Chart( const [connected, setConnected] = useState( config?.monitorUISettings?.connected ); - const [dataPointThreshold] = useState(50); + const [dataPointThreshold, setDataPointThreshold] = useState( + config?.monitorUISettings?.dataPointThreshold || 50 + ); const [cubicInterpolationMode, setCubicInterpolationMode] = useState< "default" | "monotone" >(config?.monitorUISettings?.interpolate ? "monotone" : "default"); @@ -230,6 +232,8 @@ function _Chart( wsSend={wsSend} setPause={togglePause} setInterpolate={setInterpolate} + dataPointThreshold={dataPointThreshold} + setDataPointThreshold={setDataPointThreshold} />
diff --git a/src/Legend.tsx b/src/Legend.tsx index c5a1769..6d07609 100644 --- a/src/Legend.tsx +++ b/src/Legend.tsx @@ -4,6 +4,7 @@ import { LegendItem } from "./LegendItem"; import { MonitorSettings, PluggableMonitor } from "./utils"; import { Scrollbars } from "react-custom-scrollbars"; import Switch from "react-switch"; +import Select from "react-select"; import classNames from "classnames"; export function Legend({ @@ -14,16 +15,20 @@ export function Legend({ wsSend, setPause, setInterpolate, + dataPointThreshold, + setDataPointThreshold, }: { chartRef: ChartJSOrUndefined<"line">; pause: boolean; config: Partial; cubicInterpolationMode: "monotone" | "default"; + dataPointThreshold: number; wsSend: ( clientCommand: PluggableMonitor.Protocol.ClientCommandMessage ) => void; setPause: (pause: boolean) => void; setInterpolate: (interpolate: boolean) => void; + setDataPointThreshold: (dataPointThreshold: number) => void; }): React.ReactElement { const scrollRef = useRef(null); @@ -131,6 +136,41 @@ export function Legend({ )}
+