Skip to content

Commit e21cf42

Browse files
committed
Small fixes
1 parent 9de6156 commit e21cf42

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

frontend/src/App.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template>
22
<h1 id="app">
33
<NdviComparisonGraph />
4+
<NdviSelectMonthGraph />
5+
<NdviOverlayGraph />
46
<MedianTempGraph />
57
<MeanSoilTempGraph />
68
<MeanSoilMoistureGraph />
@@ -10,7 +12,9 @@
1012
</template>
1113

1214
<script>
13-
import NdviComparisonGraph from "./components/NdviComparisonGraph.vue"
15+
import NdviComparisonGraph from "./components/NdviGraphs/NdviComparisonGraph.vue"
16+
import NdviSelectMonthGraph from "./components/NdviGraphs/NdviSelectMonthGraph.vue"
17+
import NdviOverlayGraph from "./components/NdviGraphs/NdviOverlayGraph.vue"
1418
import MedianTempGraph from "./components/MedianTempGraph.vue"
1519
import MeanSoilTempGraph from "./components/SoilTempGraph.vue"
1620
import MeanSoilMoistureGraph from "./components/SoilMoistureGraph.vue"
@@ -21,6 +25,8 @@
2125
name: 'App',
2226
components: {
2327
NdviComparisonGraph,
28+
NdviSelectMonthGraph,
29+
NdviOverlayGraph,
2430
MedianTempGraph,
2531
MeanSoilTempGraph,
2632
MeanSoilMoistureGraph,

frontend/src/components/NdviGraphs/NdviComparisonGraph.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@
3030
<v-row>
3131
<div
3232
id="plotlyGraphNdviComparison"
33-
v-show="ndviData"
34-
style="width: 100%"
33+
style="width: 100%; height: 400px"
3534
class="d-flex justify-center"
3635
></div>
3736
</v-row>
3837
</v-container>
3938
</template>
4039

4140
<script>
42-
import { ref, nextTick, watch, onMounted } from 'vue'
41+
import { ref, watch, onMounted } from 'vue'
4342
import axios from 'axios'
4443
import Plotly from 'plotly.js-dist-min'
4544
@@ -48,7 +47,7 @@ export default {
4847
setup() {
4948
const ndviData = ref(null)
5049
const startDate = ref(1514761200) // 2018-01-01
51-
const endDate = ref(1704063599) // 2023-12-31
50+
const endDate = ref(1704063599) // 2023-12-31
5251
const temporalResolution = ref("Monthly")
5352
const aggregation = ref("Mean")
5453
const temporalResolutionOptions = ["Monthly", "Daily"]
@@ -59,7 +58,6 @@ export default {
5958
try {
6059
const response = await axios.get(apiUrl, { params })
6160
ndviData.value = response.data
62-
await nextTick()
6361
renderPlot()
6462
} catch (error) {
6563
console.error("Error fetching NDVI data:", error)
@@ -76,11 +74,11 @@ export default {
7674
mode: 'lines+markers',
7775
type: 'scatter',
7876
name: '',
79-
line: { color: 'green' }
77+
line: { color: 'blue' }
8078
}
8179
const layout = {
8280
title: 'NDVI of Tempelhofer Feld',
83-
xaxis: { title: '', type: 'date' },
81+
xaxis: { title: '', type: 'date', rangeslider: { visible: true } },
8482
yaxis: { title: 'NDVI Value' },
8583
}
8684
Plotly.newPlot('plotlyGraphNdviComparison', [trace], layout)

frontend/src/components/NdviGraphs/NdviOverlayGraph.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<template>
22
<v-container>
3-
<h2 class="pb-10">NDVI Year Overlay (2018-2023)</h2>
3+
<h2 class="pb-4">NDVI Year Overlay (2018-2023)</h2>
44
<v-row>
55
<div
66
id="plotlyGraphNdviOverlay"
7-
v-show="ndviData"
8-
style="width: 100%"
7+
style="width: 100%; height: 400px"
98
class="d-flex justify-center"
109
></div>
1110
</v-row>
1211
</v-container>
1312
</template>
1413

1514
<script>
16-
import { ref, nextTick, onMounted } from 'vue'
15+
import { ref, onMounted } from 'vue'
1716
import axios from 'axios'
1817
import Plotly from 'plotly.js-dist-min'
1918
@@ -30,7 +29,6 @@
3029
try {
3130
const response = await axios.get(apiUrl, { params })
3231
ndviData.value = response.data
33-
await nextTick()
3432
renderPlot()
3533
} catch (error) {
3634
console.error("Error fetching NDVI data:", error)
@@ -83,7 +81,7 @@
8381
8482
return {
8583
ndviData,
86-
years,
84+
years
8785
}
8886
}
8987
}

frontend/src/components/NdviGraphs/NdviSelectMonthGraph.vue

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,30 @@
1616
<v-row>
1717
<div
1818
id="plotlyGraphNdviMonthly"
19-
v-show="ndviData"
20-
style="width: 100%"
19+
style="width: 100%; height: 400px"
2120
class="d-flex justify-center"
2221
></div>
2322
</v-row>
2423
</v-container>
2524
</template>
2625

2726
<script>
28-
import { ref, nextTick, watch, onMounted } from 'vue'
27+
import { ref, watch, onMounted } from 'vue'
2928
import axios from 'axios'
3029
import Plotly from 'plotly.js-dist-min'
3130
3231
export default {
3332
name: 'NdviSelectMonthGraph',
3433
setup() {
3534
const ndviData = ref(null)
36-
const month = ref("August")
35+
const month = ref("January")
3736
const monthOptions = [
3837
"January", "February", "March", "April",
3938
"May", "June", "July", "August",
4039
"September", "October", "November", "December"
4140
]
4241
const startDate = ref(1514761200) // 2018-01-01
43-
const endDate = ref(1704063599) // 2023-12-31
42+
const endDate = ref(1704063599) // 2023-12-31
4443
4544
const fetchNdviData = async () => {
4645
const apiUrl = 'http://localhost:8000/index/ndvi'
@@ -55,7 +54,6 @@ export default {
5554
}
5655
})
5756
ndviData.value = response.data
58-
await nextTick()
5957
renderPlot()
6058
} catch (error) {
6159
console.error("Error fetching NDVI data:", error)
@@ -89,15 +87,11 @@ export default {
8987
}
9088
}
9189
92-
const updateGraph = () => {
93-
if (ndviData.value) {
94-
renderPlot()
95-
}
96-
}
97-
98-
watch(month, updateGraph)
90+
watch(month, renderPlot)
9991
100-
onMounted(fetchNdviData)
92+
onMounted(() => {
93+
fetchNdviData()
94+
})
10195
10296
return {
10397
ndviData,

0 commit comments

Comments
 (0)