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

add: inital chart/diagram

parent 00a64ada
No related branches found
No related tags found
No related merge requests found
......@@ -74,7 +74,7 @@ class _DefaultPageState extends State<DefaultPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My Page'),
title: Text('IceMap'),
),
body: ListView(
children: [
......
......@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../marker_data.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:fl_chart/fl_chart.dart';
class MapContainerWidget extends StatefulWidget {
final List<MarkerTemplate> markerList;
......@@ -18,6 +19,17 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
@override
Widget build(BuildContext context) {
// NB: temporary test data
final List<FlSpot> chartData = [
FlSpot(0, 10),
FlSpot(1, 20),
FlSpot(2, 30),
FlSpot(3, 40),
];
double barWidth = 30; // Width for bars in bar chart
const double contPadding = 30; // Container padding space
double screenWidth = MediaQuery.of(context).size.width;
double boxWidth = 0.9;
double boxHeight = 1.5;
......@@ -80,10 +92,10 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
],
),
),
const SizedBox(height: 30), // Padding between containers
const SizedBox(height: contPadding), // Padding between containers
Container(
width: screenWidth * boxWidth,
height: screenWidth * boxHeight,
//width: screenWidth * boxWidth,
height: screenWidth * boxHeight*1.5, // NB: make dynamic
color: const Color(0xFF64B5F6),
child: Align(
alignment: Alignment.topLeft,
......@@ -104,6 +116,105 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
'Longitude: ${selectedMarker?.geoData.longitude}',
style: const TextStyle(fontSize: 20, color: Colors.black),
),
const SizedBox(height: contPadding),
SizedBox(
width: screenWidth-screenWidth/10,
height: 200,
child: LineChart(
LineChartData(
backgroundColor: const Color(0xFFCAF0F8),
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: [const Color(0xFF0077B6)],
),
],
),
),
),
const SizedBox(height: contPadding),
SizedBox(
width: screenWidth-screenWidth/10,
height: 200,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
maxY: 20, // Maximum y-axis value
barTouchData: BarTouchData(enabled: false),
titlesData: FlTitlesData(
bottomTitles: SideTitles(
showTitles: true,
getTextStyles: (value) => const TextStyle(color: Colors.black, fontSize: 14),
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, fontSize: 14),
margin: 10,
reservedSize: 30,
interval: 5,
),
),
borderData: FlBorderData(
show: true,
border: Border.all(color: Colors.black, 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,
),
],
),
],
),
)
)
],
),
),
......
......@@ -41,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
equatable:
dependency: transitive
description:
name: equatable
sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
url: "https://pub.dev"
source: hosted
version: "2.0.5"
fake_async:
dependency: transitive
description:
......@@ -49,6 +57,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
fl_chart:
dependency: "direct main"
description:
name: fl_chart
sha256: a92c5677c820884abc7cd7980ef2ecc6df094ecd2730074cbb77f7d195afefd4
url: "https://pub.dev"
source: hosted
version: "0.20.1"
flutter:
dependency: "direct main"
description: flutter
......@@ -171,6 +187,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.8.3"
path_drawing:
dependency: transitive
description:
name: path_drawing
sha256: "3bdd251dae9ffaef944450b73f168610db7e968e7b20daf0c3907f8b4aafc8a2"
url: "https://pub.dev"
source: hosted
version: "0.5.1+1"
path_parsing:
dependency: transitive
description:
name: path_parsing
sha256: ee5c47c1058ad66b4a41746ec3996af9593d0858872807bcd64ac118f0700337
url: "https://pub.dev"
source: hosted
version: "0.2.1"
pedantic:
dependency: transitive
description:
name: pedantic
sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
polylabel:
dependency: transitive
description:
......
......@@ -13,6 +13,7 @@ dependencies:
http: ^0.13.3
latlong2: ^0.8.2
provider: ^5.0.0
fl_chart: ^0.20.0-nullsafety1
......
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