|
|
@@ -1,13 +1,22 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<div class="chartContainer" v-if="chartData">
|
|
3
|
3
|
<GChart
|
|
|
4
|
+ class="chart"
|
|
|
5
|
+ width="100%"
|
|
4
|
6
|
type="ColumnChart"
|
|
5
|
7
|
:data="chartData"
|
|
6
|
8
|
:options="chartOptions"
|
|
7
|
9
|
/>
|
|
8
|
|
- <div class="miles">
|
|
9
|
|
- {{ distance }}
|
|
10
|
|
- {{ unit }}
|
|
|
10
|
+ <div class="gradeContainer">
|
|
|
11
|
+ <div class="miles">
|
|
|
12
|
+ Distance: {{ distance }} {{ unit }}
|
|
|
13
|
+ </div>
|
|
|
14
|
+ <div class="peakGrade">
|
|
|
15
|
+ Peak: {{ peakGrade }}%
|
|
|
16
|
+ </div>
|
|
|
17
|
+ <div class="avgGrade">
|
|
|
18
|
+ Average: {{ avgGrade }}%
|
|
|
19
|
+ </div>
|
|
11
|
20
|
</div>
|
|
12
|
21
|
</div>
|
|
13
|
22
|
</template>
|
|
|
@@ -53,6 +62,7 @@
|
|
53
|
62
|
this.chartData = [
|
|
54
|
63
|
['', '', { role: 'style' }]
|
|
55
|
64
|
]
|
|
|
65
|
+ // ------------------------------------------------------
|
|
56
|
66
|
this.elevationService.getElevationAlongPath({
|
|
57
|
67
|
'path': this.route.overview_path,
|
|
58
|
68
|
'samples': 264
|
|
|
@@ -72,6 +82,23 @@
|
|
72
|
82
|
Math.abs(this.elevations[i].elevation - this.elevations[i + 1].elevation) / interval
|
|
73
|
83
|
)
|
|
74
|
84
|
}
|
|
|
85
|
+ this.getAvgGrade()
|
|
|
86
|
+ this.getPeakGrade()
|
|
|
87
|
+ },
|
|
|
88
|
+ getAvgGrade () {
|
|
|
89
|
+ let avg = 0
|
|
|
90
|
+ avg = this.gradeReport.reduce((a, b) => a + b) / 263
|
|
|
91
|
+ this.avgGrade = this.round(avg)
|
|
|
92
|
+ },
|
|
|
93
|
+ getPeakGrade () {
|
|
|
94
|
+ let peakGrade = this.gradeReport[this.gradeReport.length - 1]
|
|
|
95
|
+ this.gradeReport.forEach(e => {
|
|
|
96
|
+ if (peakGrade < e) peakGrade = e
|
|
|
97
|
+ })
|
|
|
98
|
+ this.peakGrade = this.round(peakGrade)
|
|
|
99
|
+ },
|
|
|
100
|
+ round (value) {
|
|
|
101
|
+ return Math.round(value * 10000) / 100
|
|
75
|
102
|
},
|
|
76
|
103
|
displayPathElevation () {
|
|
77
|
104
|
for (let i = 0; i < this.elevations.length; i++) {
|
|
|
@@ -89,7 +116,32 @@
|
|
89
|
116
|
</script>
|
|
90
|
117
|
|
|
91
|
118
|
<style scoped>
|
|
|
119
|
+ .chartContainer {
|
|
|
120
|
+ display: grid;
|
|
|
121
|
+ grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
|
122
|
+ grid-template-rows: 1fr 8fr;
|
|
|
123
|
+ grid-template-areas:
|
|
|
124
|
+ "..... grade grade ....."
|
|
|
125
|
+ "chart chart chart chart";
|
|
|
126
|
+ align-items: center;
|
|
|
127
|
+ }
|
|
|
128
|
+ .chart {
|
|
|
129
|
+ padding-left: 20px;
|
|
|
130
|
+ grid-area: chart;
|
|
|
131
|
+ }
|
|
|
132
|
+ .gradeContainer {
|
|
|
133
|
+ grid-area: grade;
|
|
|
134
|
+ display: flex;
|
|
|
135
|
+ justify-content: space-around;
|
|
|
136
|
+ font-size: 1.15em;
|
|
|
137
|
+ }
|
|
92
|
138
|
.miles {
|
|
93
|
139
|
color: white;
|
|
94
|
140
|
}
|
|
|
141
|
+ .avgGrade {
|
|
|
142
|
+ color: white;
|
|
|
143
|
+ }
|
|
|
144
|
+ .peakGrade {
|
|
|
145
|
+ color: white;
|
|
|
146
|
+ }
|
|
95
|
147
|
</style>
|