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

update: move chart widgets to separate files

parent 9dd2a309
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:fl_chart/fl_chart.dart';
import 'quick_view_chart.dart';
import 'stat_charts.dart';
class MapContainerWidget extends StatefulWidget {
final List<MarkerTemplate> markerList;
......@@ -148,104 +149,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
style: regTextStyle,
),
const SizedBox(height: contPadding),
SizedBox(
width: screenWidth * boxWidth - contPadding * 2,
height: 200,
child: LineChart(
LineChartData(
backgroundColor: lightBlue,
titlesData: FlTitlesData(
leftTitles: SideTitles(showTitles: true),
bottomTitles: SideTitles(showTitles: true),
),
borderData: FlBorderData(
show: true,
),
minX: 0,
maxX: 4,
minY: 0,
maxY: 50,
lineBarsData: [
LineChartBarData(
spots: chartData,
isCurved: true,
colors: [barBlue],
),
],
),
),
),
const SizedBox(height: contPadding),
SizedBox(
width: screenWidth * boxWidth - contPadding * 2,
height: 160,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
maxY: 20,
barTouchData: BarTouchData(enabled: false),
titlesData: FlTitlesData(
bottomTitles: SideTitles(
showTitles: true,
getTextStyles: (value) => chartTextStyle,
margin: 10,
getTitles: (value) {
switch (value.toInt()) {
case 0:
return 'Placeholder1';
case 1:
return 'Placeholder2';
case 2:
return 'Placeholder3';
default:
return '';
}
},
),
leftTitles: SideTitles(
showTitles: true,
getTextStyles: (value) => chartTextStyle,
margin: 10,
reservedSize: 30,
interval: 5,
),
),
borderData: FlBorderData(
show: true,
border: Border.all(color: Colors.white, width: 1),
),
barGroups: [
BarChartGroupData(
x: 0,
barRods: [
BarChartRodData(
y: 15, // Bar height
width: barWidth, // Bar width
),
],
),
BarChartGroupData(
x: 1,
barRods: [
BarChartRodData(
y: 10,
width: barWidth,
),
],
),
BarChartGroupData(
x: 2,
barRods: [
BarChartRodData(
y: 18,
width: barWidth,
),
],
),
],
),
)
)
const StatCharts(),
],
),
),
......
import 'package:flutter/material.dart';
import 'package:fl_chart/fl_chart.dart';
class StatCharts extends StatelessWidget {
const StatCharts({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
children: [
LineChart(
LineChartData(
backgroundColor: Colors.lightBlue,
titlesData: FlTitlesData(
leftTitles: SideTitles(showTitles: true),
bottomTitles: SideTitles(showTitles: true),
),
borderData: FlBorderData(show: true),
minX: 0,
maxX: 4,
minY: 0,
maxY: 50,
lineBarsData: [
LineChartBarData(
spots: [
FlSpot(0, 10),
FlSpot(1, 20),
FlSpot(2, 30),
FlSpot(3, 40),
],
isCurved: true,
colors: [Colors.blue],
),
],
),
),
const SizedBox(height: 20), // Add appropriate padding between charts
SizedBox(
width: MediaQuery.of(context).size.width * 0.8, // Adjust width as needed
height: 160, // Adjust height as needed
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
maxY: 20,
barTouchData: BarTouchData(enabled: false),
titlesData: FlTitlesData(
bottomTitles: SideTitles(
showTitles: true,
getTextStyles: (value) => const TextStyle(color: Colors.black),
margin: 10,
getTitles: (value) {
switch (value.toInt()) {
case 0:
return 'Placeholder1';
case 1:
return 'Placeholder2';
case 2:
return 'Placeholder3';
default:
return '';
}
},
),
leftTitles: SideTitles(
showTitles: true,
getTextStyles: (value) => const TextStyle(color: Colors.black),
margin: 10,
reservedSize: 30,
interval: 5,
),
),
borderData: FlBorderData(
show: true,
border: Border.all(color: Colors.white, width: 1),
),
barGroups: [
BarChartGroupData(
x: 0,
barRods: [
BarChartRodData(y: 15, width: 10), // Example width
],
),
BarChartGroupData(
x: 1,
barRods: [
BarChartRodData(y: 10, width: 10), // Example width
],
),
BarChartGroupData(
x: 2,
barRods: [
BarChartRodData(y: 18, width: 10), // Example width
],
),
],
),
),
),
],
);
}
}
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