-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugging channels, first draft decoding layout, added graphs
- Loading branch information
1 parent
b137462
commit 09f23e7
Showing
8 changed files
with
347 additions
and
41 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { useSocketStore } from '@/stores'; | ||
import Plotly from 'plotly.js-basic-dist-min'; | ||
import { | ||
Box, | ||
Typography, | ||
FormControl, | ||
InputLabel, | ||
Select, | ||
MenuItem, | ||
} from '@mui/material'; | ||
|
||
export const HeatmapGraph = () => { | ||
const [selectedChannel, setSelectedChannel] = useState('channel1'); | ||
const heatmapData = useSocketStore((state) => state.heatmapData[selectedChannel] || { x: [], y: [], z: [] }); | ||
const graphRef = useRef(null); | ||
const plotlyRef = useRef(null); | ||
|
||
const handleChannelChange = (event) => { | ||
setSelectedChannel(event.target.value); | ||
}; | ||
|
||
useEffect(() => { | ||
const layout = { | ||
title: { text: 'Heatmap', font: { color: '#f4f4f4' } }, | ||
autosize: true, | ||
height: 400, | ||
paper_bgcolor: '#333', | ||
plot_bgcolor: '#333', | ||
xaxis: { | ||
title: { text: 'Time', font: { color: '#f4f4f4' } }, | ||
color: '#cccccc', | ||
}, | ||
yaxis: { | ||
title: { text: 'Features', font: { color: '#f4f4f4' } }, | ||
color: '#cccccc', | ||
}, | ||
margin: { l: 50, r: 50, b: 50, t: 50 }, | ||
font: { color: '#f4f4f4' }, | ||
}; | ||
|
||
if (graphRef.current) { | ||
Plotly.react( | ||
graphRef.current, | ||
[ | ||
{ | ||
z: heatmapData.z, | ||
x: heatmapData.x, | ||
y: heatmapData.y, | ||
type: 'heatmap', | ||
colorscale: 'Viridis', | ||
}, | ||
], | ||
layout, | ||
{ responsive: true, displayModeBar: false } | ||
).then((gd) => { | ||
plotlyRef.current = gd; | ||
}); | ||
} | ||
}, [heatmapData]); | ||
|
||
return ( | ||
<Box> | ||
<Box display="flex" alignItems="center" mb={2}> | ||
<Typography variant="h6" sx={{ flexGrow: 1 }}> | ||
Heatmap | ||
</Typography> | ||
<FormControl variant="outlined" size="small"> | ||
<InputLabel id="heatmap-channel-select-label"> | ||
Channel Selection | ||
</InputLabel> | ||
<Select | ||
labelId="heatmap-channel-select-label" | ||
value={selectedChannel} | ||
onChange={handleChannelChange} | ||
label="Channel Selection" | ||
> | ||
<MenuItem value="channel1">Channel 1</MenuItem> | ||
<MenuItem value="channel2">Channel 2</MenuItem> | ||
{/* TODO: bind channels */} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
<div ref={graphRef} /> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { useSocketStore } from '@/stores'; | ||
import Plotly from 'plotly.js-basic-dist-min'; | ||
import { | ||
Box, | ||
Typography, | ||
FormControl, | ||
InputLabel, | ||
Select, | ||
MenuItem, | ||
} from '@mui/material'; | ||
|
||
export const PSDGraph = () => { | ||
const [selectedChannel, setSelectedChannel] = useState('channel1'); | ||
const psdData = useSocketStore((state) => state.psdData[selectedChannel] || { frequencies: [], powers: [] }); | ||
const graphRef = useRef(null); | ||
const plotlyRef = useRef(null); | ||
|
||
const handleChannelChange = (event) => { | ||
setSelectedChannel(event.target.value); | ||
}; | ||
|
||
useEffect(() => { | ||
const layout = { | ||
title: { text: 'PSD Trace', font: { color: '#f4f4f4' } }, | ||
autosize: true, | ||
height: 400, | ||
paper_bgcolor: '#333', | ||
plot_bgcolor: '#333', | ||
xaxis: { | ||
title: { text: 'Frequency (Hz)', font: { color: '#f4f4f4' } }, | ||
color: '#cccccc', | ||
}, | ||
yaxis: { | ||
title: { text: 'Power', font: { color: '#f4f4f4' } }, | ||
color: '#cccccc', | ||
}, | ||
margin: { l: 50, r: 50, b: 50, t: 50 }, | ||
font: { color: '#f4f4f4' }, | ||
}; | ||
|
||
if (graphRef.current) { | ||
Plotly.react( | ||
graphRef.current, | ||
[ | ||
{ | ||
x: psdData.frequencies, | ||
y: psdData.powers, | ||
type: 'scatter', | ||
mode: 'lines', | ||
line: { simplify: false, color: '#1a73e8' }, | ||
}, | ||
], | ||
layout, | ||
{ responsive: true, displayModeBar: false } | ||
).then((gd) => { | ||
plotlyRef.current = gd; | ||
}); | ||
} | ||
}, [psdData]); | ||
|
||
return ( | ||
<Box> | ||
<Box display="flex" alignItems="center" mb={2}> | ||
<Typography variant="h6" sx={{ flexGrow: 1 }}> | ||
PSD Trace | ||
</Typography> | ||
<FormControl variant="outlined" size="small"> | ||
<InputLabel id="psd-channel-select-label"> | ||
Channel Selection | ||
</InputLabel> | ||
<Select | ||
labelId="psd-channel-select-label" | ||
value={selectedChannel} | ||
onChange={handleChannelChange} | ||
label="Channel Selection" | ||
> | ||
<MenuItem value="channel1">Channel 1</MenuItem> | ||
<MenuItem value="channel2">Channel 2</MenuItem> | ||
{/* TODO Bind Channels */} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
<div ref={graphRef} /> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import { Graph } from "@/components"; | ||
import { Box } from "@mui/material"; | ||
import { RawDataGraph } from '@/components/RawDataGraph'; | ||
import { PSDGraph } from '@/components/PSDGraph'; | ||
import { HeatmapGraph } from '@/components/HeatmapGraph'; | ||
import { Box, Grid } from '@mui/material'; | ||
|
||
export const Dashboard = () => ( | ||
<Box> | ||
<Graph /> | ||
<Box p={2}> | ||
<Grid container spacing={4}> | ||
<Grid item xs={12}> | ||
<RawDataGraph /> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<PSDGraph /> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<HeatmapGraph /> | ||
</Grid> | ||
</Grid> | ||
</Box> | ||
); |
Oops, something went wrong.