@@ -29,10 +29,10 @@ class VisualizationTab extends StatefulWidget {
29
29
30
30
class VisualizationTabState extends State <VisualizationTab > {
31
31
String ? _selectedExercise;
32
- String _selectedTable = 'Exercise' ; // Default selected table
32
+ String _selectedTable = 'Exercise' ;
33
33
late String _aggregationMethod;
34
34
late String _chartType;
35
- String _dataType = 'Weight' ; // Default data type for Fitness table
35
+ String _dataType = 'Weight' ;
36
36
List <String > _exerciseNames = [];
37
37
List <ScatterSpot > _dataPoints = [];
38
38
DateTimeRange ? _selectedDateRange;
@@ -44,7 +44,7 @@ class VisualizationTabState extends State<VisualizationTab> {
44
44
void initState () {
45
45
super .initState ();
46
46
_initializeDefaults ();
47
- _fetchExerciseNames (); // Fetch exercise names initially
47
+ _fetchExerciseNames ();
48
48
}
49
49
50
50
void _initializeDefaults () {
@@ -231,7 +231,7 @@ class VisualizationTabState extends State<VisualizationTab> {
231
231
case 'Weight' :
232
232
return widget.isKg
233
233
? value
234
- : value * 2.20462 ; // Convert to lbs if needed
234
+ : value * 2.20462 ;
235
235
case 'Height' :
236
236
return value; // Assuming height is already in the desired unit
237
237
case 'Age' :
@@ -269,6 +269,7 @@ class VisualizationTabState extends State<VisualizationTab> {
269
269
270
270
// Get the height of the screen
271
271
final screenHeight = MediaQuery .of (context).size.height;
272
+
272
273
// Define the maximum height for the chart as 45% of the screen height
273
274
final chartMaxHeight = screenHeight * 0.45 ;
274
275
@@ -291,13 +292,14 @@ class VisualizationTabState extends State<VisualizationTab> {
291
292
onChanged: (newValue) {
292
293
if (newValue != null && newValue != _selectedTable) {
293
294
setState (() {
295
+ // reset
294
296
_selectedTable = newValue;
295
- _selectedExercise = null ; // Reset the selected exercise
296
- _exerciseNames = []; // Clear the exercise names
297
- _dataPoints = []; // Clear the data points
298
- _dataType = 'Weight' ; // Reset data type to default
297
+ _selectedExercise = null ;
298
+ _exerciseNames = [];
299
+ _dataPoints = [];
300
+ _dataType = 'Weight' ;
299
301
});
300
- _fetchExerciseNames (); // Fetch the new exercise names if needed
302
+ _fetchExerciseNames ();
301
303
}
302
304
},
303
305
hint: 'Select Table' ,
@@ -311,7 +313,7 @@ class VisualizationTabState extends State<VisualizationTab> {
311
313
onChanged: (newValue) {
312
314
if (newValue != null ) {
313
315
setState (() {
314
- _dataPoints = []; // Clear the data points
316
+ _dataPoints = []; // reset
315
317
_selectedExercise = newValue;
316
318
});
317
319
_fetchDataPoints (newValue);
0 commit comments