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

update: improve chart appearance

parent 8ce6d7cd
No related branches found
No related tags found
1 merge request!11Clhp map
...@@ -10,12 +10,12 @@ class BarData extends StatefulWidget { ...@@ -10,12 +10,12 @@ class BarData extends StatefulWidget {
class _BarDataState extends State<BarData> { class _BarDataState extends State<BarData> {
static const double barWidth = 18; static const double barWidth = 30;
// NB should be rounded to two decimals in server // NB should be rounded to two decimals in server
// NB should be allocated values dynamically // NB should be allocated values dynamically
// Bar items show data for 10 previous days // Bar items show data for 10 previous days
static const bars = <int, List<double>>{ static const barData = <int, List<double>>{
0: [1.5, 4, 2.5], 0: [1.5, 4, 2.5],
1: [1.8, 5.6, 3], 1: [1.8, 5.6, 3],
2: [1.5, 3.1, 3.5], 2: [1.5, 3.1, 3.5],
...@@ -23,9 +23,6 @@ class _BarDataState extends State<BarData> { ...@@ -23,9 +23,6 @@ class _BarDataState extends State<BarData> {
4: [2, 2, 5], 4: [2, 2, 5],
5: [1.2, 1.5, 4.3], 5: [1.2, 1.5, 4.3],
6: [1.2, 4.8, 5], 6: [1.2, 4.8, 5],
7: [1.2, 5.5, 4],
8: [1.2, 3.2, 2],
9: [1.2, 1, 1.5],
}; };
int touchedIndex = -1; int touchedIndex = -1;
...@@ -105,46 +102,56 @@ class _BarDataState extends State<BarData> { ...@@ -105,46 +102,56 @@ class _BarDataState extends State<BarData> {
padding: const EdgeInsets.only(top: 16), padding: const EdgeInsets.only(top: 16),
child: Column( child: Column(
children: [ children: [
BarChart( SizedBox(
BarChartData( width: MediaQuery.of(context).size.width, // Set the desired width
alignment: BarChartAlignment.center, child: BarChart(
maxY: 12, BarChartData(
minY: 0, alignment: BarChartAlignment.center,
titlesData: FlTitlesData( maxY: 12,
show: true, minY: 0,
bottomTitles: SideTitles( titlesData: FlTitlesData(
showTitles: true, show: true,
reservedSize: 5, bottomTitles: SideTitles(
getTextStyles: (value) => const TextStyle(color: Colors.white60), showTitles: true,
), reservedSize: 5,
leftTitles: SideTitles( getTextStyles: (value) => const TextStyle(color: Colors.white60),
showTitles: true, ),
getTextStyles: (value) => const TextStyle(color: Colors.white60), leftTitles: SideTitles(
margin: 10, showTitles: true,
reservedSize: 30, getTextStyles: (value) => const TextStyle(color: Colors.white60),
interval: 2, margin: 10,
), reservedSize: 30,
), interval: 2,
groupsSpace: 12, ),
gridData: FlGridData( rightTitles: SideTitles(
show: true, showTitles: true,
), getTextStyles: (value) => const TextStyle(color: Colors.white60),
borderData: FlBorderData( margin: 10,
show: false, reservedSize: 30,
), interval: 2,
barGroups: bars.entries ),
.map( ),
(e) => generateGroup( groupsSpace: 14,
e.key, gridData: FlGridData(
e.value[0], show: true,
e.value[1],
e.value[2],
), ),
).toList(), borderData: FlBorderData(
show: false,
),
barGroups: barData.entries
.map(
(e) => generateGroup(
e.key,
e.value[0],
e.value[1],
e.value[2],
),
).toList(),
),
), ),
), ),
Padding( // Legend items Padding( // Legend items
padding: const EdgeInsets.only(top: 16), padding: const EdgeInsets.only(top: 20),
child: Center( child: Center(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
......
...@@ -220,7 +220,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ...@@ -220,7 +220,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
ClipRRect( ClipRRect(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
child: SizedBox( child: SizedBox(
width: screenWidth * boxWidth, width: screenWidth * boxWidth * 1.2,
height: screenWidth * boxHeight * 1.5, // NB: make dynamic height: screenWidth * boxHeight * 1.5, // NB: make dynamic
child: Align( child: Align(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
......
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