Parcourir la source

making some progress on the infographic

Jared Norris il y a 8 ans
Parent
révision
4f8342f9cb
1 fichiers modifiés avec 23 ajouts et 3 suppressions
  1. 23
    3
      VueApp/src/components/ElevationGraph.vue

+ 23
- 3
VueApp/src/components/ElevationGraph.vue Voir le fichier

@@ -1,20 +1,40 @@
1 1
 <template>
2
-
2
+  <GChart
3
+    type="ColumnChart"
4
+    :data="chartData"
5
+    :options="chartOptions"
6
+  />
3 7
 </template>
4 8
 
5 9
 <script>
10
+    import { GChart } from 'vue-google-charts'
11
+
6 12
     export default {
7 13
         name: "ElevationGraph",
14
+        components: { GChart },
8 15
         data () {
9 16
           return {
10 17
             elevationService: null,
11
-            graphService: null
18
+            chartData: [],
19
+            chartOptions: {
20
+              chart: {
21
+                title: 'Elevation Report'
22
+              }
23
+            }
12 24
           }
13 25
         },
14 26
         methods: {
15 27
           getPathElevation (path) {
28
+            this.chartData = []
16 29
             this.elevationService = new google.maps.ElevationService() // eslint-disable-line no-undef
17
-
30
+            this.elevationService.getElevationAlongPath({
31
+              'path': path,
32
+              'samples': 256
33
+            }, function (elevations, status) {
34
+               if (status === 'OK') {
35
+                  elevations.forEach(e => this.chartData.push(['', e.elevation]))
36
+               }
37
+            })
18 38
           }
19 39
         }
20 40
     }