feat: Dynamische Einheit in Redux für Schleifen- und Isolationswiderstand hinzugefügt

- Redux-Slice erweitert um `unit`-State (kOhm/MOhm)
- `setSelectedSlotType` aktualisiert die Einheit basierend auf der Auswahl
- Dropdown in `LoopChartActionBar.tsx` angepasst, um Einheit zu setzen
- Y-Achse und Tooltip in `LoopMeasurementChart.tsx` zeigen dynamisch die Einheit aus Redux
- Initialwert von `bisDatum` auf das heutige Datum gesetzt
This commit is contained in:
ISA
2025-03-14 08:49:28 +01:00
parent e426cd6218
commit 8c638acfc7
2 changed files with 15 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ import {
} from "recharts";
import { setBrushRange } from "../../../../../../redux/slices/brushSlice";
const CustomTooltip = ({ active, payload, label }: any) => {
const CustomTooltip = ({ active, payload, label, unit }: any) => {
if (active && payload && payload.length) {
const messwertMax = payload.find(
(p: any) => p.dataKey === "messwertMaximum"
@@ -40,12 +40,12 @@ const CustomTooltip = ({ active, payload, label }: any) => {
<strong>{new Date(label).toLocaleString()}</strong>
{messwertMax && (
<div style={{ color: "grey" }}>
Messwert Maximum: {messwertMax.value.toFixed(2)} kOhm
Messwert Maximum: {messwertMax.value.toFixed(2)} {unit}
</div>
)}
{messwert && (
<div style={{ color: "#00AEEF", fontWeight: "bold" }}>
Messwert: {messwert.value.toFixed(2)} kOhm
Messwert: {messwert.value.toFixed(2)} {unit}
</div>
)}
{messwertDurchschnitt && (
@@ -53,12 +53,12 @@ const CustomTooltip = ({ active, payload, label }: any) => {
style={{ color: "#00AEEF" }}
>{`Messwert Durchschnitt: ${messwertDurchschnitt.value.toFixed(
2
)} kOhm`}</div>
)} ${unit}`}</div>
)}
{messwertMin && (
<div
style={{ color: "grey" }}
>{`Messwert Minimum: ${messwertMin.value.toFixed(2)} kOhm`}</div>
>{`Messwert Minimum: ${messwertMin.value.toFixed(2)} ${unit}`}</div>
)}
</div>
);
@@ -68,6 +68,9 @@ const CustomTooltip = ({ active, payload, label }: any) => {
const LoopMeasurementChart = () => {
const dispatch = useDispatch();
const unit = useSelector(
(state: RootState) => state.kabelueberwachungChart.unit
);
const brushRange = useSelector((state: RootState) => state.brush);
const {
@@ -156,11 +159,11 @@ const LoopMeasurementChart = () => {
tickFormatter={(zeit) => new Date(zeit).toLocaleDateString()}
/>
<YAxis
label={{ value: "kOhm", angle: -90, position: "insideLeft" }}
label={{ value: unit, angle: -90, position: "insideLeft" }}
domain={["auto", "auto"]}
tickFormatter={(wert) => `${wert.toFixed(2)} kOhm`}
tickFormatter={(wert) => `${wert.toFixed(0)} `}
/>
<Tooltip content={<CustomTooltip />} />
<Tooltip content={<CustomTooltip unit={unit} />} />
<Legend
verticalAlign="top"
align="center"