diff --git a/open_earable/lib/sensor_data_tab/sensor_chart.dart b/open_earable/lib/sensor_data_tab/sensor_chart.dart index de37740..1b80915 100644 --- a/open_earable/lib/sensor_data_tab/sensor_chart.dart +++ b/open_earable/lib/sensor_data_tab/sensor_chart.dart @@ -34,6 +34,13 @@ class _EarableDataChartState extends State { late SimpleKalman kalmanX, kalmanY, kalmanZ; late String _sensorName; int _numDatapoints = 200; + Map _units = { + "Accelerometer": "m/s\u00B2", + "Gyroscope": "°/s", + "Magnetometer": "µT", + "Pressure": "Pa", + "Temperature": "°C" + }; _setupListeners() { if (_title == "Pressure" || _title == "Temperature") { _dataSubscription = @@ -168,7 +175,7 @@ class _EarableDataChartState extends State { if (_title == 'Pressure' || _title == 'Temperature') { seriesList = [ charts.Series( - id: '$_title${_data.isNotEmpty ? " (${_data[0].units[_title]})" : ""}', + id: '$_title${_data.isNotEmpty ? " (${_units[_title]})" : ""}', colorFn: (_, __) => charts.Color.fromHex(code: colors[0]), domainFn: (SensorData data, _) => data.timestamp, measureFn: (SensorData data, _) => data.values[0], @@ -178,21 +185,21 @@ class _EarableDataChartState extends State { } else { seriesList = [ charts.Series( - id: 'X${_data.isNotEmpty ? " (${_data[0].units['X']})" : ""}', + id: 'X${_data.isNotEmpty ? " (${_units[_title]})" : ""}', colorFn: (_, __) => charts.Color.fromHex(code: colors[0]), domainFn: (SensorData data, _) => data.timestamp, measureFn: (SensorData data, _) => data.values[0], data: _data, ), charts.Series( - id: 'Y${_data.isNotEmpty ? " (${_data[0].units['Y']})" : ""}', + id: 'Y${_data.isNotEmpty ? " (${_units[_title]})" : ""}', colorFn: (_, __) => charts.Color.fromHex(code: colors[1]), domainFn: (SensorData data, _) => data.timestamp, measureFn: (SensorData data, _) => data.values[1], data: _data, ), charts.Series( - id: 'Z${_data.isNotEmpty ? " (${_data[0].units['Z']})" : ""}', + id: 'Z${_data.isNotEmpty ? " (${_units[_title]})" : ""}', colorFn: (_, __) => charts.Color.fromHex(code: colors[2]), domainFn: (SensorData data, _) => data.timestamp, measureFn: (SensorData data, _) => data.values[2],