@@ -2,6 +2,7 @@ import logo from './logo.svg';
2
2
import './App.css' ;
3
3
import { BasicStream } from './BasicStream'
4
4
import React , { useCallback , useState , useEffect } from 'react'
5
+ import { LineChart , Line , XAxis , YAxis , CartesianGrid , Tooltip , Legend , ResponsiveContainer } from 'recharts' ;
5
6
import { Container , Row , Col , Button } from 'react-bootstrap' ;
6
7
window . addEventListener ( 'error' , e => {
7
8
if ( e . message === 'ResizeObserver loop limit exceeded' || e . message === 'ResizeObserver loop completed with undelivered notifications.' ) {
@@ -38,16 +39,35 @@ function App() {
38
39
39
40
const handleAzimuthChange = ( amount ) => {
40
41
var new_azimuth = azimuth + amount ;
42
+ if ( new_azimuth > 360 ) {
43
+ new_azimuth = new_azimuth % 360 ;
44
+ }
45
+ if ( new_azimuth < 0 ) {
46
+ new_azimuth = 360 + new_azimuth ;
47
+ }
41
48
setAzimuth ( new_azimuth ) ;
42
49
}
43
50
44
51
const handleElevationChange = ( amount ) => {
52
+
45
53
var new_elevation = elevation + amount ;
54
+ if ( new_elevation > 90 ) {
55
+ new_elevation = 90 ;
56
+ }
57
+ if ( new_elevation < 0 ) {
58
+ new_elevation = 0 ;
59
+ }
46
60
setElevation ( new_elevation ) ;
47
61
}
48
62
49
63
const handleZoomChange = ( amount ) => {
50
64
var new_zoom = zoom + amount ;
65
+ if ( new_zoom > 9999 ) {
66
+ new_zoom = 9999 ;
67
+ }
68
+ if ( new_zoom < 1 ) {
69
+ new_zoom = 1 ;
70
+ }
51
71
setZoom ( new_zoom ) ;
52
72
}
53
73
@@ -84,30 +104,83 @@ function App() {
84
104
}
85
105
console . log ( mapping ) ;
86
106
}
107
+
108
+ const saveMapping = ( ) => {
109
+ fetch ( 'http://localhost:5000/save-mapping' , {
110
+ method : 'POST' ,
111
+ headers : {
112
+ 'Content-Type' : 'application/json' ,
113
+ } ,
114
+ body : JSON . stringify ( mapping ) ,
115
+ } )
116
+ . then ( response => response . json ( ) )
117
+ . then ( data => {
118
+ console . log ( 'Success:' , data ) ;
119
+ } )
120
+ . catch ( ( error ) => {
121
+ console . error ( 'Error:' , error ) ;
122
+ } ) ;
123
+ }
124
+
125
+
87
126
return (
88
127
< div >
89
128
< table >
90
129
< tr >
91
130
< td className = "App" > < BasicStream /> </ td >
92
131
< td >
93
132
< div >
94
- < button onClick = { ( ) => { handleAzimuthChange ( - 10 ) } } > Decrease Azimuth</ button >
133
+ < h3 > Azimuth</ h3 >
134
+ < button onClick = { ( ) => { handleAzimuthChange ( - 10 ) } } > -10</ button >
135
+ < button onClick = { ( ) => { handleAzimuthChange ( - 5 ) } } > -5</ button >
136
+ < button onClick = { ( ) => { handleAzimuthChange ( - 1 ) } } > -1</ button >
95
137
{ azimuth }
96
- < button onClick = { ( ) => { handleAzimuthChange ( 10 ) } } > Increase Azimuth</ button > </ div >
138
+ < button onClick = { ( ) => { handleAzimuthChange ( 1 ) } } > +1</ button >
139
+ < button onClick = { ( ) => { handleAzimuthChange ( 5 ) } } > +5</ button >
140
+ < button onClick = { ( ) => { handleAzimuthChange ( 10 ) } } > +10</ button > </ div >
97
141
98
142
< div >
99
- < button onClick = { ( ) => { handleElevationChange ( - 10 ) } } > Decrease Elevation</ button >
143
+ < h3 > Elevation</ h3 >
144
+ < button onClick = { ( ) => { handleElevationChange ( - 10 ) } } > -10</ button >
145
+ < button onClick = { ( ) => { handleElevationChange ( - 5 ) } } > -5</ button >
146
+ < button onClick = { ( ) => { handleElevationChange ( - 1 ) } } > -1</ button >
100
147
{ elevation }
101
- < button onClick = { ( ) => { handleElevationChange ( 10 ) } } > Increase Elevation</ button > </ div >
148
+ < button onClick = { ( ) => { handleElevationChange ( 1 ) } } > 1</ button >
149
+ < button onClick = { ( ) => { handleElevationChange ( 5 ) } } > 5</ button >
150
+ < button onClick = { ( ) => { handleElevationChange ( 10 ) } } > 10</ button > </ div >
102
151
< div >
103
- < button onClick = { ( ) => { handleZoomChange ( - 200 ) } } > Decrease Zoom</ button >
152
+ < h3 > Zoom</ h3 >
153
+ < button onClick = { ( ) => { handleZoomChange ( - 1000 ) } } > -1000</ button >
154
+ < button onClick = { ( ) => { handleZoomChange ( - 200 ) } } > -200</ button >
104
155
{ zoom }
105
- < button onClick = { ( ) => { handleZoomChange ( 200 ) } } > Increase Zoom</ button > </ div >
156
+ < button onClick = { ( ) => { handleZoomChange ( 200 ) } } > 200</ button >
157
+ < button onClick = { ( ) => { handleZoomChange ( 200 ) } } > 1000</ button > </ div >
158
+ < div >
159
+ < h3 > Mapping</ h3 >
106
160
< button onClick = { upsertMapping } > Add Point</ button >
161
+ < button onClick = { saveMapping } > Save Mapping</ button >
162
+ </ div >
107
163
</ td >
108
164
</ tr >
109
165
</ table >
110
-
166
+ < div >
167
+ < ResponsiveContainer width = "95%" height = { 400 } >
168
+ < LineChart
169
+ height = { 300 }
170
+ data = { mapping }
171
+ margin = { {
172
+ top : 5 , right : 30 , left : 20 , bottom : 5 ,
173
+ } }
174
+ >
175
+ < CartesianGrid strokeDasharray = "3 3" />
176
+ < XAxis dataKey = "azimuth" domain = { [ 0 , 360 ] } />
177
+ < YAxis dataKey = "elevation" domain = { [ 0 , 90 ] } /> // Set the Y-axis domain to [0, 90]
178
+ < Tooltip />
179
+ < Legend />
180
+ < Line type = "monotone" dataKey = "elevation" stroke = "#8884d8" activeDot = { { r : 8 } } />
181
+ </ LineChart >
182
+ </ ResponsiveContainer >
183
+ </ div >
111
184
112
185
</ div >
113
186
) ;
0 commit comments