-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComparisonControls.jsx
More file actions
63 lines (60 loc) · 2.13 KB
/
Copy pathComparisonControls.jsx
File metadata and controls
63 lines (60 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from 'react';
import { BarChart2 } from 'lucide-react';
export function ComparisonControls({
compareMode,
onCompareModeChange
}) {
const modes = [
{ value: 'normal', label: '📊 平均误差 (normal)', description: '未取绝对值的平均误差' },
{ value: 'absolute', label: '📈 平均误差 (absolute)', description: '绝对值差值的平均' },
{ value: 'relative-normal', label: '📉 相对误差 (normal)', description: '不取绝对值的相对误差' },
{ value: 'relative', label: '📊 平均相对误差 (absolute)', description: '绝对相对误差的平均' }
];
return (
<section className="card" aria-labelledby="comparison-controls-heading">
<div className="flex items-center gap-2 mb-2">
<BarChart2
size={16}
className="text-gray-600 dark:text-gray-300"
aria-hidden="true"
/>
<h3
id="comparison-controls-heading"
className="card-title"
>
⚖️ 对比模式
</h3>
</div>
<fieldset className="space-y-2">
<legend className="sr-only">选择数据对比模式</legend>
{modes.map(mode => (
<label
key={mode.value}
className="flex items-center cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 p-1 rounded"
>
<input
type="radio"
name="compareMode"
value={mode.value}
checked={compareMode === mode.value}
onChange={(e) => onCompareModeChange(e.target.value)}
className="radio"
aria-describedby={`mode-${mode.value}-description`}
/>
<div className="ml-2">
<div className="text-xs font-medium text-gray-700 dark:text-gray-300">
{mode.label}
</div>
<div
id={`mode-${mode.value}-description`}
className="text-xs text-gray-500 dark:text-gray-400"
>
{mode.description}
</div>
</div>
</label>
))}
</fieldset>
</section>
);
}