-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathGraph.tsx
101 lines (92 loc) · 2.58 KB
/
Graph.tsx
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import * as React from 'react';
import { useStore } from '../store';
import GrapherComponent from './GrapherComponent';
import TimelineControls from './TimelineControls';
interface Props {}
const Graph: React.FC<Props> = () => {
const { grapher, formulas, variables } = useStore();
const [theme, setTheme] = React.useState('Dark');
const [range, setRange] = React.useState('Free');
const [grid, setGrid] = React.useState('Grid Dec');
const grapherToggleVisualizer = () => {
grapher.toggleVisualizer();
};
const grapherToggleTheme = () => {
grapher.toggleTheme();
if (grapher.mTheme === 0) setTheme('Dark');
if (grapher.mTheme === 1) setTheme('Light');
};
const grapherToggleShowAxes = () => {
grapher.toggleShowAxes();
if (grapher.mShowAxes === 0) setGrid('Grid Off');
if (grapher.mShowAxes === 1) setGrid('Grid Dec');
if (grapher.mShowAxes === 2) setGrid('Grid Bin');
};
const grapherToggleRange = () => {
grapher.toggleRange();
if (grapher.mRangeType === 0) setRange('0..1');
if (grapher.mRangeType === 1) setRange('-1..1');
if (grapher.mRangeType === 2) setRange('Free');
};
return (
<div
className="guiWindow"
title="Pan: Left Mouse Button
Zoom: Mouse Wheel, or Shift+Left Mouse Button"
>
<div
style={{
display: 'flex',
flexWrap: 'wrap',
alignItems: 'flex-start',
justifyContent: 'center',
paddingBottom: 8,
}}
>
<div
id="myTheme"
className="userInputButtonsBig"
style={{ marginRight: 12 }}
onClick={grapherToggleVisualizer}
title="Toggle Visualizer"
>
Visualizer
</div>
<div
id="myTheme"
className="userInputButtonsBig"
style={{ marginRight: 12 }}
onClick={grapherToggleTheme}
title="Set Color Scheme"
>
{theme}
</div>
<div
id="myAxes"
className="userInputButtonsBig"
style={{ marginRight: 12 }}
onClick={grapherToggleShowAxes}
title="Show/Hide Grid"
>
{grid}
</div>
<div
id="myRange"
className="userInputButtonsBig"
style={{ marginRight: 12 }}
onClick={grapherToggleRange}
title="Choose navigation mode"
>
{range}
</div>
</div>
<GrapherComponent
formulas={formulas}
variables={variables}
grapher={grapher}
/>
<TimelineControls />
</div>
);
};
export default Graph;