Skip to content

Commit 0e3fc0f

Browse files
authored
Merge pull request #81 from a-lie101/main
fix: auto-scale Y-axis, increase chart window to 200 points, add test…
2 parents 2b5fa51 + 2a052f8 commit 0e3fc0f

File tree

14 files changed

+76
-5
lines changed

14 files changed

+76
-5
lines changed

.DS_Store

0 Bytes
Binary file not shown.

frontend/210.png

69.2 KB
Loading

frontend/app/test-chart/page.tsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
'use client';
2+
import { useState, useMemo } from 'react';
3+
import SignalGraphView from '@/components/nodes/signal-graph-node/signal-graph-full';
4+
import { GlobalProvider } from '@/context/GlobalContext';
5+
6+
const WINDOW_SIZE = 200; // how many points visible at once
7+
8+
export default function TestChartPage() {
9+
const [allData, setAllData] = useState<any[]>([]);
10+
const [windowStart, setWindowStart] = useState(0);
11+
12+
const handleFile = (e: React.ChangeEvent<HTMLInputElement>) => {
13+
const file = e.target.files?.[0];
14+
if (!file) return;
15+
const reader = new FileReader();
16+
reader.onload = (event) => {
17+
const text = event.target?.result as string;
18+
const lines = text.trim().split('\n');
19+
const parsed = lines.slice(1).map(line => {
20+
const values = line.split(',');
21+
const timeOnly = values[0].trim().split(' ')[1]?.slice(0, 12) ?? values[0];
22+
return {
23+
time: timeOnly,
24+
signal1: Number(values[1]),
25+
signal2: Number(values[2]),
26+
signal3: Number(values[3]),
27+
signal4: Number(values[4]),
28+
};
29+
});
30+
setAllData(parsed);
31+
setWindowStart(0);
32+
};
33+
reader.readAsText(file);
34+
};
35+
36+
// only the visible slice
37+
const visibleData = useMemo(
38+
() => allData.slice(windowStart, windowStart + WINDOW_SIZE),
39+
[allData, windowStart]
40+
);
41+
42+
const maxStart = Math.max(0, allData.length - WINDOW_SIZE);
43+
44+
return (
45+
<GlobalProvider>
46+
<div className="w-screen h-screen p-8" style={{ backgroundColor: '#EAF1F0' }}>
47+
48+
<input type="file" accept=".csv" onChange={handleFile} className="mb-4" />
49+
50+
{allData.length > 0 && (
51+
<div className="mb-4 flex items-center gap-4">
52+
<span className="text-sm text-gray-500">
53+
{allData.length} rows — showing {windowStart + 1}{Math.min(windowStart + WINDOW_SIZE, allData.length)}
54+
</span>
55+
<input
56+
type="range"
57+
min={0}
58+
max={maxStart}
59+
value={windowStart}
60+
onChange={(e) => setWindowStart(Number(e.target.value))}
61+
className="w-full"
62+
/>
63+
</div>
64+
)}
65+
66+
{allData.length > 0 && <SignalGraphView data={visibleData} />}
67+
</div>
68+
</GlobalProvider>
69+
);
70+
}

frontend/arm5

90.6 KB
Binary file not shown.

frontend/arm6

141 KB
Binary file not shown.

frontend/arm7

224 KB
Binary file not shown.

frontend/components/nodes/signal-graph-node/signal-graph-full.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ export default function SignalGraphView({ data }: SignalGraphViewProps) {
6464
<ResponsiveContainer width="100%" height="100%">
6565
<LineChart data={data} syncId="SignalChart">
6666
<CartesianGrid strokeDasharray="3 3" stroke="#f0f0f0" />
67-
<XAxis dataKey="time" />
67+
<XAxis dataKey="time" interval={Math.floor(data.length / 10)} />
6868
<YAxis
6969
type="number"
70-
domain={[0, 100]}
71-
ticks={[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]}
70+
domain={['auto', 'auto']}
71+
7272
/>
7373
{signals.map((s) => (
7474
<Line
@@ -120,7 +120,7 @@ export default function SignalGraphView({ data }: SignalGraphViewProps) {
120120

121121
{/* ---- BOTTOM HALF: TABLE ---- */}
122122
<div className="bg-white border shadow-lg rounded-2xl p-4 overflow-auto">
123-
<DataTable data={data} />
123+
<DataTable data={data} rowCount={50} />
124124
</div>
125125

126126

frontend/components/ui/progressbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use client"
1+
"use client"
22

33
import { cn } from "@/lib/utils"
44
import * as ProgressPrimitive from "@radix-ui/react-progress"

frontend/m68k

143 KB
Binary file not shown.

frontend/ppc

131 KB
Binary file not shown.

0 commit comments

Comments
 (0)