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

fix: rounding of bar chart data

parent 104db491
Branches Sentinenl_hub_integration
No related tags found
No related merge requests found
......@@ -28,32 +28,31 @@ class _BarDataState extends State<BarData> {
/// Extracts the ice statistics from the currently selected subdivision
void setBarChartData() {
print("Updating bar chart data!!");
setState(() {
// Allocate bar data dynamically based from the selected subdivision
for (int i = 0; i < 7; i++) {
var entry = selectedSubDiv?.iceStats[i];
if (entry != null) {
// NB test data for demo
// NB randomized test data for demo, remove after demo
Random random = Random();
double blackIce = 2.0 + random.nextDouble() * (4.0 - 2.0);
double slushIce = 1.0 + random.nextDouble() * (1.5 - 1.0);
double snowDepth = random.nextDouble() * 1.3;
double blackIce = double.parse((2.0 + random.nextDouble() * (3.6 - 2.0)).toStringAsFixed(1));
double slushIce = double.parse((1.0 + random.nextDouble() * (1.5 - 0.7)).toStringAsFixed(1));
double snowDepth = double.parse((random.nextDouble() * 1.3).toStringAsFixed(1));
barData[i] = [
//entry.blackIce,
//entry.slushIce,
//entry.snowDepth,
blackIce, // NB test data for demo
blackIce, // NB test data for demo, replace with the three lines above
slushIce, // ...
snowDepth, // ..
];
// NB test data for demo
totalHeight = blackIce + slushIce + snowDepth + 0.3; // NB demo data
// Calculate and round the total ice height
entry.totalIce = double.parse((blackIce + slushIce + snowDepth).toStringAsFixed(1));
// Find tallest layer
if (entry.totalIce > totalHeight) {
// Find tallest layer NB commented for demo
if (i > 0 && (entry.totalIce > totalHeight)) {
totalHeight = entry.totalIce;
}
} else {
......@@ -139,7 +138,7 @@ class _BarDataState extends State<BarData> {
child: BarChart(
BarChartData(
alignment: BarChartAlignment.center,
maxY: totalHeight + totalHeight/4, // NB Set
maxY: totalHeight + totalHeight/5,
minY: 0,
titlesData: FlTitlesData(
show: true,
......
No preview for this file type
This diff is collapsed.
This diff is collapsed.
......@@ -26,3 +26,4 @@ interval_from,interval_to,default_B0_min,default_B0_max,default_B0_mean,default_
2024-05-14,2024-05-15,136.0,199.0,169.73,10.25,65536,0,No ice
2024-05-16,2024-05-17,130.0,170.0,151.3,5.28,65536,0,Ice
2024-05-21,2024-05-22,143.0,196.0,173.33,6.91,65536,0,No ice
2024-06-03,2024-06-04,74.0,112.0,95.12,4.79,65536,0,Ice
......@@ -26,3 +26,4 @@ interval_from,interval_to,default_B0_min,default_B0_max,default_B0_mean,default_
2024-05-14,2024-05-15,141.0,208.0,174.17,7.8,65536,0,No ice
2024-05-16,2024-05-17,121.0,178.0,151.29,7.98,65536,0,No ice
2024-05-21,2024-05-22,89.0,204.0,173.47,11.43,65536,0,No ice
2024-06-03,2024-06-04,79.0,116.0,95.43,4.22,65536,0,Ice
No preview for this file type
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