Skip to content
Snippets Groups Projects
Commit 1edf35f0 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

update: convert chart index to date

parent 4c018ec6
No related branches found
No related tags found
1 merge request!12Clhp map
......@@ -33,6 +33,6 @@ final titleStyle = GoogleFonts.chakraPetch(
fontWeight: FontWeight.bold,
);
final regTextStyle = GoogleFonts.chakraPetch(fontSize: 16, color: textColor);
final regTextStyleBig = GoogleFonts.chakraPetch(fontSize: 18, color: textColor);
final regTextStyleBig = GoogleFonts.chakraPetch(fontSize: 20, color: textColor);
final chartTextStyle = GoogleFonts.chakraPetch(fontSize: 12, color: textColor);
final subHeadingStyle = GoogleFonts.chakraPetch(fontSize: 18, color: textColor, fontWeight: FontWeight.bold);
String formatMonth(int month) {
switch (month) {
case 1:
return 'Jan';
case 2:
return 'Feb';
case 3:
return 'Mar';
case 4:
return 'Apr';
case 5:
return 'May';
case 6:
return 'Jun';
case 7:
return 'Jul';
case 8:
return 'Aug';
case 9:
return 'Sep';
case 10:
return 'Oct';
case 11:
return 'Nov';
case 12:
return 'Dec';
default:
return '';
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:fl_chart/fl_chart.dart';
import '../../consts.dart';
import '../../utils/format_month.dart';
class BarData extends StatefulWidget {
const BarData({super.key});
......@@ -129,6 +130,23 @@ class _BarDataState extends State<BarData> {
showTitles: true,
reservedSize: 20,
getTextStyles: (value) => const TextStyle(color: Colors.white60),
getTitles: (value) {
// Convert bar indexes to dates
if (barData.isNotEmpty && value >= 0 && value < barData.length) {
int index = value.toInt();
DateTime today = DateTime.now();
// Subtract index from the day of the month of the current date
int day = today.day - (6-index);
String date = day.toString();
String month = formatMonth(today.month);
return '$month $date';
}
return '';
},
),
leftTitles: SideTitles(
showTitles: true,
......
......@@ -12,6 +12,7 @@ import 'choropleth_map.dart';
import '../data_classes.dart';
import 'satellite_layer.dart';
import 'quick_view_chart.dart';
import '../utils/format_month.dart';
/// MapContainerWidget is the main widget that contains the map with all
/// its layers, polygons and markers.
......@@ -246,19 +247,24 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
'Time: ${selectedTile?.timeMeasured.hour}:00',
style: regTextStyle,
),
const SizedBox(height: contPadding),
Text(
'Measuring point: (${selectedTile?.measurementID}, ${selectedTile?.measurementID})',
style: regTextStyle,
),
],
),
),
),
),
const SizedBox(height: contPadding*2),
const SizedBox(height: contPadding*2.5),
SizedBox(
width: screenWidth * boxWidth * 1.2,
child: Center(
child: Text(
'Measuring point: (${selectedTile?.measurementID}, ${selectedTile?.measurementID})',
style: regTextStyle,
),
child: Text(
'Ice layers',
style: regTextStyleBig,
),
),
),
SizedBox(
......@@ -305,34 +311,3 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
);
}
}
String formatMonth(int month) {
switch (month) {
case 1:
return 'Jan';
case 2:
return 'Feb';
case 3:
return 'Mar';
case 4:
return 'Apr';
case 5:
return 'May';
case 6:
return 'Jun';
case 7:
return 'Jul';
case 8:
return 'Aug';
case 9:
return 'Sep';
case 10:
return 'Oct';
case 11:
return 'Nov';
case 12:
return 'Dec';
default:
return '';
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment