annotate client/src/components/fairway/Fairwayprofile.vue @ 4335:2f212f520a04

client: (minor) beautify code format
author Bernhard Reiter <bernhard@intevation.de>
date Thu, 05 Sep 2019 15:02:06 +0200
parents f9c620cf0dd3
children 3543af71d04c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1 <template>
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
2 <div class="d-flex flex-column flex-fill">
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
3 <UIBoxHeader icon="chart-area" :title="title" :closeCallback="close" />
3683
4a00ff7e44f0 client: fairway profile: avoid console error spamming by properly checking properties
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
4 <div class="d-flex flex-fill" v-if="openLayersMap()">
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
5 <DiagramLegend>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
6 <div class="legend">
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
7 <span
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
8 style="background-color: #5995ff; width: 20px; height: 20px;"
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
9 ></span>
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
10 Water
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
11 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
12 <div class="legend">
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
13 <span
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
14 :style="
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
15 'width: 16px; height: 16px; background-color:' +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
16 this.getLayerStyle(1).fillColor +
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
17 ',' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
18 '); border: dotted 2px ' +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
19 this.getLayerStyle(1).strokeColor +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
20 '; background-clip: padding-box; box-sizing: content-box;'
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
21 "
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
22 ></span>
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
23 Fairway (LOS 1)
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
24 </div>
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
25 <div class="legend">
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
26 <span
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
27 :style="
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
28 'width: 16px; height: 16px; background-color:' +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
29 this.getLayerStyle(2).fillColor +
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
30 ',' +
4252
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
31 '); border: dashed 2px ' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
32 this.getLayerStyle(2).strokeColor +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
33 '; background-clip: padding-box; box-sizing: content-box;'
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
34 "
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
35 ></span>
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
36 Fairway (LOS 2)
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
37 </div>
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
38 <div class="legend">
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
39 <span
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
40 :style="
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
41 'width: 16px; height: 16px; background-color:' +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
42 this.getLayerStyle(3).fillColor +
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
43 ',' +
4252
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
44 '); border: solid 2px ' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
45 this.getLayerStyle(3).strokeColor +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
46 '; background-clip: padding-box; box-sizing: content-box;'
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
47 "
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
48 ></span>
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
49 Fairway (LOS 3)
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
50 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
51 <div class="legend">
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
52 <span
3534
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
53 style="width: 14px; height: 14px; background-color: #4a2f06; border: solid 3px black; background-clip: padding-box; box-sizing: content-box;"
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
54 ></span>
3534
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
55 Sediment
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
56 </div>
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
57 <div class="legend">
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
58 <span
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
59 style="width: 14px; height: 14px; background-color: rgba(74, 47, 6, 0.6); border: solid 3px #943007; background-clip: padding-box; box-sizing: content-box;"
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
60 ></span>
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
61 Sediment (Compare)
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
62 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
63 <div>
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
64 <select
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
65 v-model="form.template"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
66 @change="applyChange"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
67 class="form-control d-block custom-select-sm w-100"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
68 >
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
69 <option
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
70 v-for="template in templates"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
71 :value="template"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
72 :key="template.name"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
73 >
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
74 {{ template.name }}
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
75 </option>
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
76 </select>
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
77 <button
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
78 @click="downloadPDF"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
79 type="button"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
80 class="btn btn-sm btn-info d-block w-100 mt-2"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
81 >
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
82 <translate>Export to PDF</translate>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
83 </button>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
84 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
85 </DiagramLegend>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
86 <div
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
87 ref="pdfContainer"
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
88 id="pdfContainer"
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
89 class="d-flex flex-fill justify-content-center align-items-center diagram-container position-relative"
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
90 >
3644
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
91 <div class="direction-indicator"></div>
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
92 <div v-if="!fairwayData">
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
93 <translate>No data available.</translate>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
94 </div>
2854
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
95 </div>
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
96 </div>
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
97 </div>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
98 </template>
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
99
3644
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
100 <style lang="sass" scoped>
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
101 .direction-indicator
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
102 width: 70px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
103 height: 0
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
104 border-top: dashed 2px #333
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
105 position: absolute
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
106 bottom: 50px
3644
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
107 left: 115px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
108 margin-left: -35px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
109 &::after
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
110 content: ""
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
111 width: 0
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
112 height: 0
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
113 border-width: 10px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
114 border-top-width: 5px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
115 border-bottom-width: 5px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
116 border-style: solid
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
117 border-color: transparent
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
118 border-left-color: #333
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
119 position: absolute
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
120 right: -20px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
121 top: -6px
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
122 </style>
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
123
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
124 <script>
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1361
diff changeset
125 /* This is Free Software under GNU Affero General Public License v >= 3.0
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
126 * without warranty, see README.md and license for details.
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1313
diff changeset
127 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
128 * SPDX-License-Identifier: AGPL-3.0-or-later
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
129 * License-Filename: LICENSES/AGPL-3.0.txt
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1313
diff changeset
130 *
3799
f4deb4aae485 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3785
diff changeset
131 * Copyright (C) 2018, 2019 by via donau
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
132 * – Österreichische Wasserstraßen-Gesellschaft mbH
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
133 * Software engineering by Intevation GmbH
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1313
diff changeset
134 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
135 * Author(s):
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
136 * Thomas Junk <thomas.junk@intevation.de>
2549
9bf6b767a56a client: refactored and improved splitscreen for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 2540
diff changeset
137 * Markus Kottländer <markus.kottlaender@intevation.de>
3285
aac1ca73e92a client: diagram-template:(cleanup) move reusable pdf-functions to mixins.js
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3250
diff changeset
138 * Fadi Abbud <fadi.abbud@intevation.de>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
139 */
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
140 import * as d3 from "d3";
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
141 import { mapState, mapGetters } from "vuex";
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
142 import debounce from "debounce";
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
143 import { diagram, pdfgen, templateLoader } from "@/lib/mixins";
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
144 import { HTTP } from "@/lib/http";
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
145 import { displayError } from "@/lib/errors";
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
146 import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
147
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
148 const GROUND_COLOR = "#4A2F06";
2854
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
149 const WATER_COLOR = "#005DFF";
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
150
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
151 export default {
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
152 mixins: [diagram, pdfgen, templateLoader],
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
153 name: "fairwayprofile",
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
154 components: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
155 DiagramLegend: () => import("@/components/DiagramLegend")
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
156 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
157 data() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
158 return {
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
159 resizeListenerFunction: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
160 width: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
161 height: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
162 form: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
163 template: null
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
164 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
165 templates: [],
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
166 defaultTemplate: defaultDiagramTemplate,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
167 pdf: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
168 doc: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
169 width: 32,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
170 height: 297
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
171 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
172 templateData: null
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
173 };
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
174 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
175 computed: {
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
176 ...mapGetters("map", ["openLayersMap"]),
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
177 ...mapGetters("fairwayprofile", ["totalLength"]),
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
178 ...mapState("fairwayprofile", [
2392
0b8793a1947c fairway_profile: calc relative depth WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2389
diff changeset
179 "additionalSurvey",
0b8793a1947c fairway_profile: calc relative depth WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2389
diff changeset
180 "currentProfile",
2566
83b938bf4da9 client: prepared store and minimized splitscreens for multiple simultaneous diagrams
Markus Kottlaender <markus@intevation.de>
parents: 2549
diff changeset
181 "startPoint",
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
182 "endPoint",
2392
0b8793a1947c fairway_profile: calc relative depth WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2389
diff changeset
183 "fairwayData",
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
184 "maxAlt",
3512
30a47d9fc667 client: fairway profiles: removed some old code
Markus Kottlaender <markus@intevation.de>
parents: 3408
diff changeset
185 "selectedWaterLevel"
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
186 ]),
3513
ca9590be1da2 client: fairway profiles: removed more code
Markus Kottlaender <markus@intevation.de>
parents: 3512
diff changeset
187 ...mapState("bottlenecks", ["selectedSurvey", "selectedBottleneck"]),
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
188 ...mapState("application", ["paneSetup"]),
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
189 title() {
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
190 let dates = [this.selectedSurvey.date_info];
3531
804df080c826 client: fairway profiles: added waterlevel to title and used title as pdf filename
Markus Kottlaender <markus@intevation.de>
parents: 3527
diff changeset
191 let waterlevelLabel =
804df080c826 client: fairway profiles: added waterlevel to title and used title as pdf filename
Markus Kottlaender <markus@intevation.de>
parents: 3527
diff changeset
192 this.selectedWaterLevel === "ref"
804df080c826 client: fairway profiles: added waterlevel to title and used title as pdf filename
Markus Kottlaender <markus@intevation.de>
parents: 3527
diff changeset
193 ? this.selectedSurvey.depth_reference
804df080c826 client: fairway profiles: added waterlevel to title and used title as pdf filename
Markus Kottlaender <markus@intevation.de>
parents: 3527
diff changeset
194 : "Current";
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
195 if (this.additionalSurvey) dates.push(this.additionalSurvey.date_info);
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
196 dates.map(d => this.$options.filters.dateTime(d, true));
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
197 return `${this.$gettext("Fairwayprofile")}: ${
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
198 this.selectedBottleneck
3576
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
199 } (${dates.join(
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
200 ", "
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
201 )}) WL: ${waterlevelLabel} (${this.$options.filters.waterlevel(
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
202 this.waterlevel
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
203 )} m)`;
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
204 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
205 currentData() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
206 if (
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
207 !this.selectedSurvey ||
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
208 !this.currentProfile.hasOwnProperty(this.selectedSurvey.date_info)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
209 )
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
210 return [];
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
211 return this.currentProfile[this.selectedSurvey.date_info].points;
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
212 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
213 additionalData() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
214 if (
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
215 !this.additionalSurvey ||
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
216 !this.currentProfile.hasOwnProperty(this.additionalSurvey.date_info)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
217 )
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
218 return [];
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
219 return this.currentProfile[this.additionalSurvey.date_info].points;
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
220 },
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
221 bottleneck() {
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
222 return this.openLayersMap()
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
223 .getLayer("BOTTLENECKS")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
224 .getSource()
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
225 .getFeatures()
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
226 .find(f => f.get("objnam") === this.selectedBottleneck);
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
227 },
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
228 waterlevel() {
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
229 return this.selectedWaterLevel === "ref"
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
230 ? this.refWaterlevel
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
231 : this.bottleneck.get("gm_waterlevel");
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
232 },
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
233 refWaterlevel() {
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
234 return this.selectedSurvey.waterlevel_value;
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
235 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
236 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
237 watch: {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
238 currentData() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
239 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
240 },
1382
8b85032ed3cd added loading animation to profile
Markus Kottlaender <markus@intevation.de>
parents: 1372
diff changeset
241 additionalData() {
8b85032ed3cd added loading animation to profile
Markus Kottlaender <markus@intevation.de>
parents: 1372
diff changeset
242 this.drawDiagram();
8b85032ed3cd added loading animation to profile
Markus Kottlaender <markus@intevation.de>
parents: 1372
diff changeset
243 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
244 width() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
245 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
246 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
247 height() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
248 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
249 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
250 waterLevels() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
251 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
252 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
253 selectedWaterLevel() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
254 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
255 },
2264
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
256 fairwayData() {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
257 this.drawDiagram();
3149
a90091aaef67 client: fairwayprofile: close profile diagram when switching bottlenecks
Markus Kottlaender <markus@intevation.de>
parents: 3146
diff changeset
258 },
a90091aaef67 client: fairwayprofile: close profile diagram when switching bottlenecks
Markus Kottlaender <markus@intevation.de>
parents: 3146
diff changeset
259 selectedBottleneck() {
a90091aaef67 client: fairwayprofile: close profile diagram when switching bottlenecks
Markus Kottlaender <markus@intevation.de>
parents: 3146
diff changeset
260 this.$store.commit("application/paneSetup", "DEFAULT");
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
261 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
262 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
263 methods: {
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
264 close() {
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
265 this.$store.commit(
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
266 "application/paneSetup",
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
267 this.paneSetup === "COMPARESURVEYS_FAIRWAYPROFILE"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
268 ? "COMPARESURVEYS"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
269 : "DEFAULT"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
270 );
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
271 this.$store.dispatch("fairwayprofile/clearCurrentProfile");
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
272 },
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
273 getLayerStyle(los) {
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
274 let style = this.openLayersMap()
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
275 .getLayer("FAIRWAYDIMENSIONSLOS" + los)
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
276 .getStyle()()[0];
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
277
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
278 // use spread operator to clone arrays
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
279 let fillColor = style.getFill().getColor();
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
280 let fillOpacity =
4252
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
281 fillColor.length < 8
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
282 ? 0.8
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
283 : parseFloat(parseInt(fillColor.slice(7), 16) / 255).toFixed(2);
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
284 let strokeColor = style.getStroke().getColor();
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
285 let strokeOpacity =
4252
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
286 strokeColor.length < 8
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
287 ? 0.8
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
288 : parseFloat(parseInt(strokeColor.slice(7), 16) / 255).toFixed(2);
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
289 let strokeDash = style.getStroke().getLineDash();
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
290 return { fillColor, fillOpacity, strokeColor, strokeOpacity, strokeDash };
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
291 },
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
292 applyChange() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
293 if (this.form.template.hasOwnProperty("properties")) {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
294 this.templateData = this.defaultTemplate;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
295 return;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
296 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
297 if (this.form.template) {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
298 this.loadTemplates("/templates/diagram/" + this.form.template.name)
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
299 .then(response => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
300 this.prepareImages(response.data.template_data.elements).then(
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
301 values => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
302 values.forEach(v => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
303 response.data.template_data.elements[v.index].url = v.url;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
304 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
305 this.templateData = response.data.template_data;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
306 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
307 );
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
308 })
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
309 .catch(e => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
310 const { status, data } = e.response;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
311 displayError({
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
312 title: this.$gettext("Backend Error"),
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
313 message: `${status}: ${data.message || data}`
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
314 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
315 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
316 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
317 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
318 downloadPDF() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
319 let fairwayInfo =
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
320 this.selectedBottleneck + " (" + this.selectedSurvey.date_info + ")";
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
321
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
322 this.generatePDF({
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
323 templateData: this.templateData,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
324 diagramTitle: fairwayInfo
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
325 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
326
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
327 this.pdf.doc.save(
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
328 this.title.replace(/\s/g, "_").replace(/[():,]/g, "") + ".pdf"
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
329 );
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
330 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
331
3129
136b86794453 client: improve pdf-gen code for diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3061
diff changeset
332 // Diagram legend
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
333 addDiagramLegend(position, offset, color) {
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
334 let x = offset.x,
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
335 y = offset.y;
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
336 this.pdf.doc.setFontSize(10);
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
337 let width =
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
338 (this.pdf.doc.getStringUnitWidth("Sediment (Compare)") * 10) /
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
339 (72 / 25.6) +
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
340 4;
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
341 if (["topright", "bottomright"].indexOf(position) !== -1) {
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
342 x = this.pdf.width - offset.x - width;
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
343 }
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
344 if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
345 y = this.pdf.height - offset.y - this.getTextHeight(8);
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
346 }
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
347
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
348 this.pdf.doc.setTextColor(color);
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
349 this.pdf.doc.setDrawColor("#5995ff");
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
350 this.pdf.doc.setFillColor("#5995ff");
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
351 this.pdf.doc.circle(x, y, 2, "FD");
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
352 this.pdf.doc.text(x + 3, y + 1, "Water");
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
353
3785
0c5816af79a5 client: improve pdf generation of Fairwayprofile
Bernhard Reiter <bernhard@intevation.de>
parents: 3784
diff changeset
354 this.pdf.doc.setLineDashPattern([0.8], 0);
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
355 this.pdf.doc.setDrawColor("#0000ff");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
356 this.pdf.doc.setFillColor("#fcfacc");
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
357 this.pdf.doc.circle(x, y + 5, 2, "FD");
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
358 this.pdf.doc.text(x + 3, y + 6, "Fairway (LOS 1)");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
359
3785
0c5816af79a5 client: improve pdf generation of Fairwayprofile
Bernhard Reiter <bernhard@intevation.de>
parents: 3784
diff changeset
360 this.pdf.doc.setLineDashPattern([1.8], 0);
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
361 this.pdf.doc.setFillColor("#fdfce5");
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
362 this.pdf.doc.circle(x, y + 10, 2, "FD");
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
363 this.pdf.doc.text(x + 3, y + 11, "Fairway (LOS 2)");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
364
3784
110436ee8ed2 Fairwayprofile: dashed patterns in PDF
Thomas Junk <thomas.junk@intevation.de>
parents: 3783
diff changeset
365 this.pdf.doc.setLineDashPattern([], 0);
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
366 this.pdf.doc.setFillColor("#ffffff");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
367 this.pdf.doc.circle(x, y + 15, 2, "FD");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
368 this.pdf.doc.text(x + 3, y + 16, "Fairway (LOS 3)");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
369
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
370 this.pdf.doc.setDrawColor("black");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
371 this.pdf.doc.setFillColor("#4a2e06");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
372 this.pdf.doc.circle(x, y + 20, 2, "FD");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
373 this.pdf.doc.text(x + 3, y + 21, "Sediment");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
374
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
375 this.pdf.doc.setDrawColor("#943007");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
376 this.pdf.doc.setFillColor("#928269");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
377 this.pdf.doc.circle(x, y + 25, 2, "FD");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
378 this.pdf.doc.text(x + 3, y + 26, "Sediment (Compare)");
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
379 },
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
380 getPrintLayout(svgHeight, svgWidth) {
3941
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
381 return {
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
382 main: {
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
383 top: Math.floor(0.08 * svgHeight),
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
384 right: Math.floor(0.08 * svgWidth),
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
385 bottom: Math.floor(0.2 * svgHeight),
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
386 left: Math.floor(0.08 * svgWidth)
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
387 }
3941
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
388 };
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
389 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
390 drawDiagram() {
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
391 d3.select(".diagram-container svg").remove();
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
392 this.scaleFairwayProfile();
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
393 if (!this.height || !this.width) return; // do not try to render when height and width are unknown
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
394 const layout = this.getPrintLayout(this.height, this.width);
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
395 this.renderTo({
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
396 element: ".diagram-container",
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
397 dimensions: this.getDimensions({
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
398 svgWidth: this.width,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
399 svgHeight: this.height,
3941
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
400 ...layout
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
401 })
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
402 });
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
403 },
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
404 renderTo({ element, dimensions }) {
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
405 let svg = d3.select(element).append("svg");
2854
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
406 svg.attr("width", "100%");
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
407 svg.attr("height", "100%");
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
408 const width = dimensions.width;
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
409 const height = dimensions.mainHeight;
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
410 const offsetY = 15;
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
411 const currentData = this.currentData;
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
412 const additionalData = this.additionalData;
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
413 const { xScale, yScaleRight, graph } = this.generateScalesAndGraph({
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
414 svg,
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
415 height,
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
416 width,
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
417 dimensions,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
418 offsetY
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
419 });
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
420 this.drawWaterlevel({ graph, xScale, yScaleRight, height, offsetY });
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
421 this.drawLabels({ graph, dimensions });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
422 if (currentData) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
423 this.drawProfile({
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
424 graph,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
425 xScale,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
426 yScaleRight,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
427 currentData,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
428 height,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
429 color: GROUND_COLOR,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
430 strokeColor: "black",
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
431 opacity: 1,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
432 offsetY
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
433 });
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
434 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
435 if (additionalData) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
436 this.drawProfile({
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
437 graph,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
438 xScale,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
439 yScaleRight,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
440 currentData: additionalData,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
441 height,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
442 color: GROUND_COLOR,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
443 strokeColor: "#943007",
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
444 opacity: 0.6,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
445 offsetY
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
446 });
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
447 }
4017
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
448 this.drawFairway({ graph, xScale, yScaleRight, offsetY });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
449 },
4017
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
450 drawFairway({ graph, xScale, yScaleRight, offsetY }) {
2264
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
451 if (this.fairwayData === undefined) {
2265
940ae7c20326 client: pdf-gen: use default template when backend does not provide any
Markus Kottlaender <markus@intevation.de>
parents: 2264
diff changeset
452 return;
2264
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
453 }
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
454 for (let data of this.fairwayData) {
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
455 data.coordinates.forEach(coordinates => {
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
456 const [startPoint, endPoint, depth] = coordinates;
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
457 let fairwayArea = d3
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
458 .area()
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
459 .x(function(d) {
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
460 return xScale(d.x);
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
461 })
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
462 .y0(yScaleRight(0))
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
463 .y1(function(d) {
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
464 return yScaleRight(d.y);
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
465 });
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
466 graph
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
467 .append("path")
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
468 .datum([{ x: startPoint, y: depth }, { x: endPoint, y: depth }])
4252
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
469 .attr("fill", `${this.getLayerStyle(data.los).fillColor}`)
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
470 .attr("fill-opacity", this.getLayerStyle(data.los).fillOpacity)
4252
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
471 .attr("stroke", `${this.getLayerStyle(data.los).strokeColor}`)
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
472 .attr("stroke-opacity", this.getLayerStyle(data.los).strokeOpacity)
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
473 .attr("stroke-dasharray", this.getLayerStyle(data.los).strokeDash)
4017
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
474 .attr("d", fairwayArea)
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
475 .attr("transform", `translate(0 ${-offsetY})`);
3571
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
476 });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
477 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
478 },
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
479 drawLabels({ graph, dimensions }) {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
480 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
481 .append("text")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
482 .attr("transform", ["rotate(-90)"])
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
483 .attr("y", dimensions.width + Math.floor(0.06 * dimensions.width))
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
484 .attr("x", -dimensions.mainHeight / 2)
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
485 .attr("fill", "black")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
486 .style("text-anchor", "middle")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
487 .text("Depth [m]");
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
488 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
489 .append("text")
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
490 .attr("transform", ["rotate(-90)"])
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
491 .attr("y", -1 * Math.floor(0.065 * dimensions.width))
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
492 .attr("x", -dimensions.mainHeight / 2)
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
493 .attr("fill", "black")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
494 .style("text-anchor", "middle")
3576
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
495 .text("Waterlevel [m]");
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
496 graph
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
497 .append("text")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
498 .attr("y", 0)
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
499 .attr("x", 0)
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
500 .attr("dy", "1em")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
501 .attr("fill", "black")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
502 .style("text-anchor", "middle")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
503 .attr("transform", [
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
504 `translate(${dimensions.width / 2} ${dimensions.mainHeight})`,
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
505 "rotate(0)"
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
506 ])
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
507 .text("Width [m]");
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
508 },
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
509 generateScalesAndGraph({ svg, height, width, dimensions, offsetY }) {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
510 let xScale = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
511 .scaleLinear()
3512
30a47d9fc667 client: fairway profiles: removed some old code
Markus Kottlaender <markus@intevation.de>
parents: 3408
diff changeset
512 .domain([0, this.totalLength])
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
513 .rangeRound([0, width]);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
514
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
515 let yScaleRight = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
516 .scaleLinear()
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
517 .domain([
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
518 this.maxAlt * 1.1 +
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
519 Math.abs(this.waterlevel - this.refWaterlevel) / 100,
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
520 -(this.maxAlt * 0.1)
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
521 ])
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
522 .rangeRound([height, 0]);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
523
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
524 let yScaleLeft = d3
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
525 .scaleLinear()
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
526 .domain([
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
527 this.waterlevel -
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
528 (this.maxAlt * 100 +
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
529 Math.abs(this.waterlevel - this.refWaterlevel)),
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
530 this.waterlevel + this.maxAlt * 0.1 * 100
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
531 ])
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
532 .rangeRound([height, 0]);
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
533
3512
30a47d9fc667 client: fairway profiles: removed some old code
Markus Kottlaender <markus@intevation.de>
parents: 3408
diff changeset
534 let xAxis = d3.axisBottom(xScale).ticks(5);
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
535 let yAxisRight = d3.axisRight(yScaleRight);
3576
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
536 let yAxisLeft = d3
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
537 .axisLeft(yScaleLeft)
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
538 .tickFormat(d => this.$options.filters.waterlevel(d));
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
539
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
540 let graph = svg
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
541 .append("g")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
542 .attr(
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
543 "transform",
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
544 "translate(" +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
545 dimensions.mainMargin.left +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
546 "," +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
547 dimensions.mainMargin.top +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
548 ")"
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
549 );
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
550 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
551 .append("g")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
552 .attr("transform", `translate(0 ${height - offsetY})`)
3512
30a47d9fc667 client: fairway profiles: removed some old code
Markus Kottlaender <markus@intevation.de>
parents: 3408
diff changeset
553 .call(xAxis)
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
554 .selectAll(".tick text")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
555 .attr("fill", "black")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
556 .select(function() {
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
557 return this.parentNode;
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
558 })
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
559 .selectAll(".tick line")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
560 .attr("stroke", "black");
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
561 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
562 .append("g")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
563 .attr("transform", `translate(${width} ${-offsetY})`)
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
564 .call(yAxisRight)
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
565 .selectAll(".tick text")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
566 .attr("fill", "black")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
567 .select(function() {
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
568 return this.parentNode;
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
569 })
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
570 .selectAll(".tick line")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
571 .attr("stroke", "black");
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
572 graph
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
573 .append("g")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
574 .attr("transform", `translate(0 ${-offsetY})`)
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
575 .call(yAxisLeft)
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
576 .selectAll(".tick text")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
577 .attr("fill", "black")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
578 .select(function() {
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
579 return this.parentNode;
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
580 })
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
581 .selectAll(".tick line")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
582 .attr("stroke", "black");
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
583
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
584 graph.selectAll(".domain").attr("stroke", "black");
2368
96b0314f2bd6 fairway_profile: consuming the offered waterlevel WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2358
diff changeset
585 return { xScale, yScaleRight, graph };
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
586 },
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
587 drawWaterlevel({ graph, xScale, yScaleRight, height, offsetY }) {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
588 let waterArea = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
589 .area()
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
590 .x(function(d) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
591 return xScale(d.x);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
592 })
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
593 .y0(height)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
594 .y1(function(d) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
595 return yScaleRight(d.y);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
596 });
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
597 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
598 .append("path")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
599 .datum([{ x: 0, y: 0 }, { x: this.totalLength, y: 0 }])
2264
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
600 .attr("fill-opacity", 0.65)
2854
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
601 .attr("fill", WATER_COLOR)
3520
70cd7383325b client: fairway profiles: removed strokes for sharper edges
Markus Kottlaender <markus@intevation.de>
parents: 3514
diff changeset
602 .attr("stroke", "transparent")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
603 .attr("d", waterArea)
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
604 .attr("transform", `translate(0 ${-offsetY})`);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
605 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
606 drawProfile({
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
607 graph,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
608 xScale,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
609 yScaleRight,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
610 currentData,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
611 height,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
612 color,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
613 strokeColor,
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
614 opacity,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
615 offsetY
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
616 }) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
617 for (let part of currentData) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
618 let profileLine = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
619 .line()
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
620 .x(d => {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
621 return xScale(d.x);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
622 })
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
623 .y(d =>
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
624 yScaleRight(
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
625 d.y + Math.abs(this.waterlevel - this.refWaterlevel) / 100
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
626 )
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
627 );
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
628 let profileArea = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
629 .area()
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
630 .x(function(d) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
631 return xScale(d.x);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
632 })
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
633 .y0(height)
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
634 .y1(d =>
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
635 yScaleRight(
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
636 d.y + Math.abs(this.waterlevel - this.refWaterlevel) / 100
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
637 )
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
638 );
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
639 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
640 .append("path")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
641 .datum(part)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
642 .attr("fill", color)
3534
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
643 .attr("stroke", "transparent")
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
644 .attr("fill-opacity", opacity)
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
645 .attr("d", profileArea)
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
646 .attr("transform", `translate(0 ${-offsetY})`);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
647 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
648 .append("path")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
649 .datum(part)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
650 .attr("fill", "none")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
651 .attr("stroke", strokeColor)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
652 .attr("stroke-linejoin", "round")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
653 .attr("stroke-linecap", "round")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
654 .attr("stroke-width", 3)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
655 .attr("stroke-opacity", opacity)
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
656 .attr("fill-opacity", 0)
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
657 .attr("d", profileLine)
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
658 .attr("transform", `translate(0 ${-offsetY})`);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
659 }
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
660 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
661 scaleFairwayProfile() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
662 if (!document.querySelector(".diagram-container")) return;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
663 const clientHeight = document.querySelector(".diagram-container")
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
664 .clientHeight;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
665 const clientWidth = document.querySelector(".diagram-container")
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
666 .clientWidth;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
667 if (!clientHeight || !clientWidth) return;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
668 this.height = clientHeight;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
669 this.width = clientWidth;
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
670 }
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
671 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
672 created() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
673 this.resizeListenerFunction = debounce(this.drawDiagram, 100);
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
674 window.addEventListener("resize", this.resizeListenerFunction);
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
675 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
676 mounted() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
677 // Nasty but necessary if we don't want to use the updated hook to re-draw
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
678 // the diagram because this would re-draw it also for irrelevant reasons.
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
679 // In this case we need to wait for the child component (DiagramLegend) to
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
680 // render. According to the docs (https://vuejs.org/v2/api/#mounted) this
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
681 // should be possible with $nextTick() but it doesn't work because it does
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
682 // not guarantee that the DOM is not only updated but also re-painted on the
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
683 // screen.
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
684 setTimeout(this.drawDiagram, 150);
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
685
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
686 this.templates[0] = this.defaultTemplate;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
687 this.form.template = this.templates[0];
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
688 this.templateData = this.form.template;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
689 HTTP.get("/templates/diagram", {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
690 headers: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
691 "X-Gemma-Auth": localStorage.getItem("token"),
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
692 "Content-type": "text/xml; charset=UTF-8"
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
693 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
694 })
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
695 .then(response => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
696 if (response.data.length) {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
697 this.templates = response.data;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
698 this.form.template = this.templates[0];
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
699 this.templates[this.templates.length] = this.defaultTemplate;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
700 this.applyChange();
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
701 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
702 })
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
703 .catch(e => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
704 const { status, data } = e.response;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
705 displayError({
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
706 title: this.$gettext("Backend Error"),
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
707 message: `${status}: ${data.message || data}`
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
708 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
709 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
710 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
711 updated() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
712 this.drawDiagram();
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
713 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
714 destroyed() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
715 window.removeEventListener("resize", this.resizeListenerFunction);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
716 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
717 };
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
718 </script>