From 68310155fd6fa8dad4a1883b611dacdf80d52d32 Mon Sep 17 00:00:00 2001
From: Sara <sarasdj@stud.ntnu.no>
Date: Sat, 10 Feb 2024 14:04:26 +0100
Subject: [PATCH] add: inital chart/diagram

---
 app/lib/pages/default_page.dart       |   2 +-
 app/lib/pages/widgets/map_widget.dart | 117 +++++++++++++++++++++++++-
 app/pubspec.lock                      |  40 +++++++++
 app/pubspec.yaml                      |   1 +
 4 files changed, 156 insertions(+), 4 deletions(-)

diff --git a/app/lib/pages/default_page.dart b/app/lib/pages/default_page.dart
index af5fa79d..8bdf5687 100644
--- a/app/lib/pages/default_page.dart
+++ b/app/lib/pages/default_page.dart
@@ -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: [
diff --git a/app/lib/pages/widgets/map_widget.dart b/app/lib/pages/widgets/map_widget.dart
index 59c5af05..e98d84d1 100644
--- a/app/lib/pages/widgets/map_widget.dart
+++ b/app/lib/pages/widgets/map_widget.dart
@@ -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,
+                              ),
+                            ],
+                          ),
+                        ],
+                      ),
+                    )
+                  )
                 ],
               ),
             ),
diff --git a/app/pubspec.lock b/app/pubspec.lock
index 93f48673..839fa15f 100644
--- a/app/pubspec.lock
+++ b/app/pubspec.lock
@@ -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:
diff --git a/app/pubspec.yaml b/app/pubspec.yaml
index 70f39083..0e2b2e79 100644
--- a/app/pubspec.yaml
+++ b/app/pubspec.yaml
@@ -13,6 +13,7 @@ dependencies:
   http: ^0.13.3
   latlong2: ^0.8.2
   provider: ^5.0.0
+  fl_chart: ^0.20.0-nullsafety1
 
 
 
-- 
GitLab