Commit 34e0f9db42ceb13c83c6efab4d0a909dfa5d0515
1 parent
76ed49493a
Exists in
master
actualise map on vessel change
Showing 1 changed file with 7 additions and 19 deletions Side-by-side Diff
src/app/component/graph/graph.component.ts
View file @
34e0f9d
| ... | ... | @@ -8,8 +8,9 @@ | 
| 8 | 8 | styleUrls: ['./graph.component.scss'] | 
| 9 | 9 | }) | 
| 10 | 10 | export class GraphComponent implements OnInit { | 
| 11 | - selectedVessel: Vessel; | |
| 12 | - | |
| 11 | + private selectedVessel: Vessel; | |
| 12 | + private yType = ''; | |
| 13 | + private xType = ''; | |
| 13 | 14 | trace = { | 
| 14 | 15 | x: [], | 
| 15 | 16 | y: [], | 
| ... | ... | @@ -21,20 +22,6 @@ | 
| 21 | 22 | constructor(private selectedVesselService: SelectedVesselService) { | 
| 22 | 23 | } | 
| 23 | 24 | |
| 24 | - // var trace1 = { | |
| 25 | - // x: [1, 2, 3, 4, 5], | |
| 26 | - // y: [1, 6, 3, 6, 1], | |
| 27 | - // mode: 'markers+text', | |
| 28 | - // type: 'scatter', | |
| 29 | - // name: 'Team A', | |
| 30 | - // text: ['A-1', 'A-2', 'A-3', 'A-4', 'A-5'], | |
| 31 | - // textposition: 'top center', | |
| 32 | - // textfont: { | |
| 33 | - // family: 'Raleway, sans-serif' | |
| 34 | - // }, | |
| 35 | - // marker: { size: 12 } | |
| 36 | - // }; | |
| 37 | - | |
| 38 | 25 | public graph = { | 
| 39 | 26 | data: [], | 
| 40 | 27 | layout: { | 
| ... | ... | @@ -65,6 +52,7 @@ | 
| 65 | 52 | } | 
| 66 | 53 | |
| 67 | 54 | updateXaxis(valueType: string): void { | 
| 55 | + this.xType = valueType; | |
| 68 | 56 | this.trace.x = []; | 
| 69 | 57 | switch (valueType) { | 
| 70 | 58 | case 'mmsi': | 
| ... | ... | @@ -154,6 +142,7 @@ | 
| 154 | 142 | } | 
| 155 | 143 | |
| 156 | 144 | updateYaxis(valueType: string): void { | 
| 145 | + this.yType = valueType; | |
| 157 | 146 | this.trace.y = []; | 
| 158 | 147 | switch (valueType) { | 
| 159 | 148 | case 'mmsi': | 
| ... | ... | @@ -244,9 +233,8 @@ | 
| 244 | 233 | |
| 245 | 234 | |
| 246 | 235 | initGraph(): void { | 
| 247 | - this.graph.data.push(this.trace); | |
| 248 | - this.graph.layout.xaxis.title = ''; | |
| 249 | - this.graph.layout.yaxis.title = ''; | |
| 236 | + this.updateXaxis(this.xType); | |
| 237 | + this.updateYaxis(this.yType); | |
| 250 | 238 | } | 
| 251 | 239 | |
| 252 | 240 | } |