2026-07-13 14:28:33 -07:00
|
|
|
import { Box, Text, Switch } from "@chakra-ui/react";
|
|
|
|
|
import { useDashboardStore } from "@/store/useDashboardStore.jsx";
|
|
|
|
|
|
|
|
|
|
export default function ExplosionEventsSettings({ widgetId, currentSettings }) {
|
|
|
|
|
const updateSettings = useDashboardStore(state => state.updateWidgetSettings);
|
|
|
|
|
|
|
|
|
|
// 1. Convert the saved string into a boolean for the toggle UI
|
2026-07-15 13:56:12 -07:00
|
|
|
const isSymlog = currentSettings?.yAxisScale === 'log';
|
2026-07-13 14:28:33 -07:00
|
|
|
|
|
|
|
|
const handleToggle = (details) => {
|
|
|
|
|
// 2. Chakra v3 passes { checked: boolean } in the details object.
|
|
|
|
|
// Convert it back to the string Plotly expects.
|
|
|
|
|
console.log("1. Toggle Clicked! Raw details from Chakra:", details);
|
|
|
|
|
|
2026-07-15 13:56:12 -07:00
|
|
|
const newScale = details.checked ? 'log' : 'normal';
|
2026-07-13 14:28:33 -07:00
|
|
|
|
|
|
|
|
updateSettings(widgetId, { yAxisScale: newScale });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box>
|
|
|
|
|
<Text fontWeight="bold" mb={3} fontSize="sm">Y-Axis Settings</Text>
|
|
|
|
|
|
|
|
|
|
<Switch.Root
|
|
|
|
|
checked={isSymlog}
|
|
|
|
|
onCheckedChange={handleToggle}
|
|
|
|
|
colorPalette="blue"
|
|
|
|
|
>
|
|
|
|
|
<Switch.HiddenInput />
|
|
|
|
|
<Switch.Control>
|
|
|
|
|
<Switch.Thumb />
|
|
|
|
|
</Switch.Control>
|
2026-07-15 13:56:12 -07:00
|
|
|
<Switch.Label>Use Log Scale</Switch.Label>
|
2026-07-13 14:28:33 -07:00
|
|
|
</Switch.Root>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
}
|