annotate client/src/components/fairway/Fairwayprofile.vue @ 5736:55892008ec96 default tip

Fixed a bunch of corner cases in WG import.
author Sascha Wilde <wilde@sha-bang.de>
date Wed, 29 May 2024 19:02:42 +0200
parents 84d01a536bec
children
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>
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
10 <span class="fix-trans-space" style="display:inline;" v-translate
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
11 >Water</span
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
12 >
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
13 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
14 <div class="legend">
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
15 <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
16 :style="
4695
a83e4721baaf fairwayprofile: fix broken legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4694
diff changeset
17 'width: 16px; height: 16px; background:' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
18 this.getLayerStyle(1).fillColor +
4695
a83e4721baaf fairwayprofile: fix broken legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4694
diff changeset
19 '; border: dotted 2px ' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
20 this.getLayerStyle(1).strokeColor +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
21 '; 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
22 "
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
23 ></span>
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
24 <span class="fix-trans-space" style="display:inline;" v-translate
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
25 >Fairway (LOS 1)</span
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
26 >
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
27 </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
28 <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
29 <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
30 :style="
4695
a83e4721baaf fairwayprofile: fix broken legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4694
diff changeset
31 'width: 16px; height: 16px; background:' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
32 this.getLayerStyle(2).fillColor +
4695
a83e4721baaf fairwayprofile: fix broken legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4694
diff changeset
33 '; border: dashed 2px ' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
34 this.getLayerStyle(2).strokeColor +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
35 '; 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
36 "
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 ></span>
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
38 <span class="fix-trans-space" style="display:inline;" v-translate
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
39 >Fairway (LOS 2)</span
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
40 >
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
41 </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
42 <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
43 <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
44 :style="
4695
a83e4721baaf fairwayprofile: fix broken legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4694
diff changeset
45 'width: 16px; height: 16px; background:' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
46 this.getLayerStyle(3).fillColor +
4695
a83e4721baaf fairwayprofile: fix broken legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4694
diff changeset
47 '; border: solid 2px ' +
4251
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
48 this.getLayerStyle(3).strokeColor +
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
49 '; 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
50 "
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
51 ></span>
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
52 <span class="fix-trans-space" style="display:inline;" v-translate
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
53 >Fairway (LOS 3)</span
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
54 >
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
55 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
56 <div class="legend">
3323
de0d0685a17b client: improve diagram-legends style
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3285
diff changeset
57 <span
3534
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
58 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
59 ></span>
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
60 <span class="fix-trans-space" style="display:inline;" v-translate
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
61 >Sediment</span
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
62 >
3534
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
63 </div>
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
64 <div class="legend">
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
65 <span
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
66 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
67 ></span>
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
68 <span class="fix-trans-space" style="display:inline;" v-translate
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
69 >Sediment (Compare)</span
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
70 >
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
71 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
72 <div>
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
73 <select
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
74 v-model="form.template"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
75 @change="applyChange"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
76 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
77 >
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
78 <option
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
79 v-for="template in templates"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
80 :value="template"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
81 :key="template.name"
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
82 >
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
83 {{ template.name }}
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
84 </option>
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
85 </select>
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
86 <button
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
87 @click="downloadPDF"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
88 type="button"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
89 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
90 >
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
91 <translate>Export to PDF</translate>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
92 </button>
4804
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
93 <a
4808
db450fcc8ed7 client: add title for the exported image
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4807
diff changeset
94 @click="downloadImage('fairwaypng', title)"
4807
7cd40008124b client: image-export: render diagram offscreen and use mixins in fairway-diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4804
diff changeset
95 id="fairwaypng"
4804
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
96 class="btn btn-sm btn-info text-white d-block w-100 mt-2"
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
97 :download="`${fileName}.png`"
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
98 >
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
99 <translate>Export as Image</translate>
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
100 </a>
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
101 </div>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
102 </DiagramLegend>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
103 <div
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
104 id="pdfContainer"
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
105 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
106 >
3644
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
107 <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
108 <div v-if="!fairwayData">
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
109 <translate>No data available.</translate>
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
110 </div>
4893
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
111 <div v-if="!refWaterlevelValid">
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
112 <translate>No valid reference waterlevel data available.</translate>
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
113 </div>
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
114 <div v-if="!waterlevelValid">
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
115 <translate>No valid waterlevel data available.</translate>
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
116 </div>
2854
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
117 </div>
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
118 </div>
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
119 </div>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
120 </template>
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
121
5629
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
122 <style scoped>
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
123 .direction-indicator {
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
124 width: 70px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
125 height: 0;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
126 border-top: dashed 2px #333;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
127 position: absolute;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
128 bottom: 50px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
129 left: 115px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
130 margin-left: -35px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
131 }
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
132 .direction-indicator::after {
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
133 content: "";
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
134 width: 0;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
135 height: 0;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
136 border-width: 10px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
137 border-top-width: 5px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
138 border-bottom-width: 5px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
139 border-style: solid;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
140 border-color: transparent;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
141 border-left-color: #333;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
142 position: absolute;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
143 right: -20px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
144 top: -6px;
84d01a536bec Transformed scss and sass styles into css
Luisa Beerboom <lbeerboom@intevation.de>
parents: 5579
diff changeset
145 }
3644
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
146 </style>
9e91b416d5bb client: cross profile: display arrow in diagram
Markus Kottlaender <markus@intevation.de>
parents: 3590
diff changeset
147
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
148 <script>
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1361
diff changeset
149 /* 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
150 * 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
151 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
152 * SPDX-License-Identifier: AGPL-3.0-or-later
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
153 * 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
154 *
3799
f4deb4aae485 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3785
diff changeset
155 * Copyright (C) 2018, 2019 by via donau
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
156 * – Österreichische Wasserstraßen-Gesellschaft mbH
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
157 * 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
158 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
159 * Author(s):
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
160 * Thomas Junk <thomas.junk@intevation.de>
2549
9bf6b767a56a client: refactored and improved splitscreen for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 2540
diff changeset
161 * 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
162 * Fadi Abbud <fadi.abbud@intevation.de>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
163 */
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
164 import * as d3 from "d3";
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
165 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
166 import debounce from "debounce";
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
167 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
168 import { HTTP } from "@/lib/http";
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
169 import { displayError } from "@/lib/errors";
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
170 import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
171
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
172 const GROUND_COLOR = "#4A2F06";
2854
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
173 const WATER_COLOR = "#005DFF";
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
174
4893
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
175 const isNumber = value => {
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
176 if (typeof value !== "number") {
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
177 return false;
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
178 }
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
179
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
180 if (value !== Number(value)) {
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
181 return false;
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
182 }
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
183
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
184 if (Number.isFinite(value) === false) {
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
185 return false;
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
186 }
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
187
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
188 return true;
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
189 };
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
190
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
191 export default {
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
192 mixins: [diagram, pdfgen, templateLoader],
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
193 name: "fairwayprofile",
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
194 components: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
195 DiagramLegend: () => import("@/components/DiagramLegend")
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
196 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
197 data() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
198 return {
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
199 resizeListenerFunction: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
200 width: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
201 height: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
202 form: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
203 template: null
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
204 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
205 templates: [],
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
206 defaultTemplate: defaultDiagramTemplate,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
207 pdf: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
208 doc: null,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
209 width: 32,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
210 height: 297
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
211 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
212 templateData: null
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
213 };
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
214 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
215 computed: {
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
216 ...mapGetters("map", ["openLayersMap"]),
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
217 ...mapGetters("fairwayprofile", ["totalLength"]),
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
218 ...mapState("fairwayprofile", [
2392
0b8793a1947c fairway_profile: calc relative depth WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2389
diff changeset
219 "additionalSurvey",
0b8793a1947c fairway_profile: calc relative depth WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2389
diff changeset
220 "currentProfile",
2566
83b938bf4da9 client: prepared store and minimized splitscreens for multiple simultaneous diagrams
Markus Kottlaender <markus@intevation.de>
parents: 2549
diff changeset
221 "startPoint",
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
222 "endPoint",
2392
0b8793a1947c fairway_profile: calc relative depth WIP
Thomas Junk <thomas.junk@intevation.de>
parents: 2389
diff changeset
223 "fairwayData",
4890
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
224 "minAlt",
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
225 "maxAlt",
4502
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
226 "selectedWaterLevel",
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
227 "depth",
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
228 "useCustomDepth"
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
229 ]),
3513
ca9590be1da2 client: fairway profiles: removed more code
Markus Kottlaender <markus@intevation.de>
parents: 3512
diff changeset
230 ...mapState("bottlenecks", ["selectedSurvey", "selectedBottleneck"]),
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
231 ...mapState("application", ["paneSetup"]),
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
232 title() {
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
233 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
234 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
235 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
236 ? 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
237 : "Current";
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
238 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
239 dates.map(d => this.$options.filters.dateTime(d, true));
4893
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
240 const waterlevelMeasurement =
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
241 this.waterlevelValid && this.refWaterlevelValid
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
242 ? `${this.$options.filters.waterlevel(this.waterlevel)} m`
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
243 : this.$gettext("No valid value available");
5572
3b842e951317 change use from name of bottleneck to its id.
Thomas Junk <thomas.junk@intevation.de>
parents: 5219
diff changeset
244 return `${this.$gettext("Fairwayprofile")}: ${this.bottleneck.get(
5579
f54932eec5c0 Adding comments for usage of objnam
Thomas Junk <thomas.junk@intevation.de>
parents: 5572
diff changeset
245 "objnam" //for title label objnam is okay
5572
3b842e951317 change use from name of bottleneck to its id.
Thomas Junk <thomas.junk@intevation.de>
parents: 5219
diff changeset
246 )} (${dates.join(
3576
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
247 ", "
4893
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
248 )}) WL: ${waterlevelLabel} ( ${waterlevelMeasurement} )`;
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
249 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
250 currentData() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
251 if (
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
252 !this.selectedSurvey ||
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
253 !this.currentProfile.hasOwnProperty(this.selectedSurvey.date_info)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
254 )
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
255 return [];
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
256 return this.currentProfile[this.selectedSurvey.date_info].points;
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
257 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
258 additionalData() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
259 if (
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
260 !this.additionalSurvey ||
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
261 !this.currentProfile.hasOwnProperty(this.additionalSurvey.date_info)
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 return [];
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
264 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
265 },
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
266 bottleneck() {
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
267 return this.openLayersMap()
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
268 .getLayer("BOTTLENECKS")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
269 .getSource()
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
270 .getFeatures()
5572
3b842e951317 change use from name of bottleneck to its id.
Thomas Junk <thomas.junk@intevation.de>
parents: 5219
diff changeset
271 .find(f => f.get("bottleneck_id") === this.selectedBottleneck);
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
272 },
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
273 waterlevel() {
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
274 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
275 ? this.refWaterlevel
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
276 : 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
277 },
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
278 refWaterlevel() {
4773
af83ff003ebf fairway_profile: fix offscreen rendering bug.
Thomas Junk <thomas.junk@intevation.de>
parents: 4750
diff changeset
279 if (!this.selectedSurvey) return 0;
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
280 return this.selectedSurvey.waterlevel_value;
4804
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
281 },
4893
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
282 waterlevelValid() {
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
283 return isNumber(this.waterlevel);
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
284 },
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
285 refWaterlevelValid() {
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
286 return isNumber(this.refWaterlevel);
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
287 },
4804
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
288 fileName() {
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
289 return this.downloadFilename(
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
290 this.$gettext("Fairwayprofile"),
5579
f54932eec5c0 Adding comments for usage of objnam
Thomas Junk <thomas.junk@intevation.de>
parents: 5572
diff changeset
291 this.bottleneck.get("objnam") //for filename objnam is okay
4804
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
292 );
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
293 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
294 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
295 watch: {
4502
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
296 depth() {
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
297 if (!this.useCustomDepth) return;
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
298 this.drawDiagram();
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
299 },
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
300 useCustomDepth() {
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
301 this.drawDiagram();
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
302 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
303 currentData() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
304 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
305 },
1382
8b85032ed3cd added loading animation to profile
Markus Kottlaender <markus@intevation.de>
parents: 1372
diff changeset
306 additionalData() {
8b85032ed3cd added loading animation to profile
Markus Kottlaender <markus@intevation.de>
parents: 1372
diff changeset
307 this.drawDiagram();
8b85032ed3cd added loading animation to profile
Markus Kottlaender <markus@intevation.de>
parents: 1372
diff changeset
308 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
309 width() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
310 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
311 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
312 height() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
313 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
314 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
315 waterLevels() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
316 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
317 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
318 selectedWaterLevel() {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
319 this.drawDiagram();
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
320 },
2264
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
321 fairwayData() {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
322 this.drawDiagram();
3149
a90091aaef67 client: fairwayprofile: close profile diagram when switching bottlenecks
Markus Kottlaender <markus@intevation.de>
parents: 3146
diff changeset
323 },
a90091aaef67 client: fairwayprofile: close profile diagram when switching bottlenecks
Markus Kottlaender <markus@intevation.de>
parents: 3146
diff changeset
324 selectedBottleneck() {
a90091aaef67 client: fairwayprofile: close profile diagram when switching bottlenecks
Markus Kottlaender <markus@intevation.de>
parents: 3146
diff changeset
325 this.$store.commit("application/paneSetup", "DEFAULT");
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
326 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
327 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
328 methods: {
4809
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
329 addLegendToCanvas(ctx, { width, height }) {
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
330 let x = width / 12,
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
331 y = height - 55;
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
332 ctx.font = "12px sans-serif";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
333 ctx.textAlign = "start";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
334
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
335 ctx.beginPath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
336 ctx.fillStyle = "#5995ff";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
337 ctx.strokeStyle = "#5995ff";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
338 ctx.arc(x, y, 8, 0, 2 * Math.PI);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
339 ctx.fill();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
340 ctx.stroke();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
341 ctx.fillStyle = "black";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
342 ctx.fillText(this.$gettext("Water"), x + 14, y + 5);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
343 ctx.closePath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
344
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
345 ctx.beginPath();
4814
ad2ad7bae4a6 client: fairwayprofile: fix legend color for image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4809
diff changeset
346 ctx.fillStyle = this.getLayerStyle(1).fillColor;
ad2ad7bae4a6 client: fairwayprofile: fix legend color for image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4809
diff changeset
347 ctx.strokeStyle = this.getLayerStyle(1).strokeColor;
4809
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
348 ctx.arc(x, (y += 20), 8, 0, 2 * Math.PI);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
349 ctx.setLineDash([0.8], 0);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
350 ctx.fill();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
351 ctx.stroke();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
352 ctx.fillStyle = "black";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
353 ctx.fillText(this.$gettext("Fairway (LOS 1)"), x + 14, y + 5);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
354 ctx.closePath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
355
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
356 ctx.beginPath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
357 ctx.fillStyle = this.getLayerStyle(2).fillColor;
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
358 ctx.strokeStyle = this.getLayerStyle(2).strokeColor;
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
359 ctx.arc(x, (y += 20), 8, 0, 2 * Math.PI);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
360 ctx.setLineDash([1.8], 0);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
361 ctx.fill();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
362 ctx.stroke();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
363 ctx.fillStyle = "black";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
364 ctx.fillText(this.$gettext("Fairway (LOS 2)"), x + 14, y + 5);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
365 ctx.closePath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
366
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
367 ctx.beginPath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
368 ctx.fillStyle = this.getLayerStyle(3).fillColor;
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
369 ctx.strokeStyle = this.getLayerStyle(3).strokeColor;
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
370 ctx.arc(x, (y += 20), 8, 0, 2 * Math.PI);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
371 ctx.setLineDash([]);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
372 ctx.fill();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
373 ctx.stroke();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
374 ctx.fillStyle = "black";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
375 ctx.fillText(this.$gettext("Fairway (LOS 3)"), x + 14, y + 5);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
376 ctx.closePath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
377
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
378 ctx.beginPath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
379 ctx.fillStyle = "#4a2e06";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
380 ctx.strokeStyle = "black";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
381 ctx.arc(x, (y += 20), 8, 0, 2 * Math.PI);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
382 ctx.setLineDash([]);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
383 ctx.fill();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
384 ctx.stroke();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
385 ctx.fillStyle = "black";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
386 ctx.fillText(this.$gettext("Sediment"), x + 14, y + 5);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
387 ctx.closePath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
388
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
389 ctx.beginPath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
390 ctx.fillStyle = "rgba(74, 47, 6, 0.6)";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
391 ctx.strokeStyle = "#943007";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
392 ctx.arc(x, (y += 20), 8, 0, 2 * Math.PI);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
393 ctx.setLineDash([]);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
394 ctx.fill();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
395 ctx.stroke();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
396 ctx.fillStyle = "black";
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
397 ctx.fillText(this.$gettext("Sediment (compare)"), x + 14, y + 5);
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
398 ctx.closePath();
b6d8570b8480 client: image-export: add diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4808
diff changeset
399 },
3146
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
400 close() {
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
401 this.$store.commit(
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
402 "application/paneSetup",
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
403 this.paneSetup === "COMPARESURVEYS_FAIRWAYPROFILE"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
404 ? "COMPARESURVEYS"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
405 : "DEFAULT"
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
406 );
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
407 this.$store.dispatch("fairwayprofile/clearCurrentProfile");
b6cc4838d2c0 client: implemented pane mechanic for diagrams
Markus Kottlaender <markus@intevation.de>
parents: 3129
diff changeset
408 },
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
409 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
410 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
411 .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
412 .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
413 // 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
414 let fillColor = style.getFill().getColor();
51aae07d5f7b fairway_profile: adjust color types for fairwaydimensions
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4137
diff changeset
415 let strokeColor = style.getStroke().getColor();
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
416 let strokeDash = style.getStroke().getLineDash();
4523
cb1f62335b00 Client: fairwayprofile: fix drawing of fairway-box
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4502
diff changeset
417 return { fillColor, strokeColor, strokeDash };
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
418 },
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
419 applyChange() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
420 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
421 this.templateData = this.defaultTemplate;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
422 return;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
423 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
424 if (this.form.template) {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
425 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
426 .then(response => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
427 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
428 values => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
429 values.forEach(v => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
430 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
431 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
432 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
433 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
434 );
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
435 })
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
436 .catch(error => {
4869
6b054b91d9b2 backend not reachable as error message etd. Login adjusted
Thomas Junk <thomas.junk@intevation.de>
parents: 4868
diff changeset
437 let message = "Backend not reachable";
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
438 if (error.response) {
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
439 const { status, data } = error.response;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
440 message = `${status}: ${data.message || data}`;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
441 }
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
442 displayError({
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
443 title: this.$gettext("Backend Error"),
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
444 message: message
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
445 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
446 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
447 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
448 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
449 downloadPDF() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
450 let fairwayInfo =
5579
f54932eec5c0 Adding comments for usage of objnam
Thomas Junk <thomas.junk@intevation.de>
parents: 5572
diff changeset
451 this.bottleneck.get("objnam") + //for Filename objnam is okay
5572
3b842e951317 change use from name of bottleneck to its id.
Thomas Junk <thomas.junk@intevation.de>
parents: 5219
diff changeset
452 " (" +
3b842e951317 change use from name of bottleneck to its id.
Thomas Junk <thomas.junk@intevation.de>
parents: 5219
diff changeset
453 this.selectedSurvey.date_info +
3b842e951317 change use from name of bottleneck to its id.
Thomas Junk <thomas.junk@intevation.de>
parents: 5219
diff changeset
454 ")";
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
455 this.generatePDF({
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
456 templateData: this.templateData,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
457 diagramTitle: fairwayInfo
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
458 });
4804
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
459 this.pdf.doc.save(this.fileName + ".pdf");
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
460 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
461
3129
136b86794453 client: improve pdf-gen code for diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3061
diff changeset
462 // Diagram legend
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
463 addDiagramLegend(position, offset, color) {
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
464 let x = offset.x,
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
465 y = offset.y;
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
466 this.pdf.doc.setFontSize(10);
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
467 let width =
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
468 (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
469 (72 / 25.6) +
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
470 4;
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
471 if (["topright", "bottomright"].indexOf(position) !== -1) {
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
472 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
473 }
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
474 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
475 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
476 }
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
477
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
478 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
479 this.pdf.doc.setDrawColor("#5995ff");
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
480 this.pdf.doc.setFillColor("#5995ff");
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
481 this.pdf.doc.circle(x, y, 2, "FD");
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
482 this.pdf.doc.text(x + 3, y + 1, this.$gettext("Water"));
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
483
4692
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
484 const toRGB = s => {
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
485 let [, r, g, b] = s.match(/.*?(\d+), (\d+), (\d+), .*/);
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
486 const toHex = n => {
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
487 let val = parseInt(n).toString(16);
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
488 if (val.length === 1) return `0${val}`;
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
489 return val;
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
490 };
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
491 return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
492 };
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
493
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
494 const los1Color = toRGB(this.getLayerStyle(1).strokeColor);
4694
e326874dd2c4 fix pdf colors legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4692
diff changeset
495 const los1Fill = toRGB(this.getLayerStyle(1).fillColor);
4692
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
496 const los2Color = toRGB(this.getLayerStyle(2).strokeColor);
4694
e326874dd2c4 fix pdf colors legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4692
diff changeset
497 const los2Fill = toRGB(this.getLayerStyle(2).fillColor);
4692
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
498 const los3Color = toRGB(this.getLayerStyle(3).strokeColor);
4694
e326874dd2c4 fix pdf colors legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4692
diff changeset
499 const los3Fill = toRGB(this.getLayerStyle(3).fillColor);
4692
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
500
3785
0c5816af79a5 client: improve pdf generation of Fairwayprofile
Bernhard Reiter <bernhard@intevation.de>
parents: 3784
diff changeset
501 this.pdf.doc.setLineDashPattern([0.8], 0);
4692
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
502 this.pdf.doc.setDrawColor(los1Color);
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
503 this.pdf.doc.setFillColor(los1Fill);
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
504 this.pdf.doc.circle(x, y + 5, 2, "FD");
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
505 this.pdf.doc.text(x + 3, y + 6, this.$gettext("Fairway (LOS 1)"));
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
506
3785
0c5816af79a5 client: improve pdf generation of Fairwayprofile
Bernhard Reiter <bernhard@intevation.de>
parents: 3784
diff changeset
507 this.pdf.doc.setLineDashPattern([1.8], 0);
4692
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
508 this.pdf.doc.setFillColor(los2Fill);
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
509 this.pdf.doc.setDrawColor(los2Color);
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
510 this.pdf.doc.circle(x, y + 10, 2, "FD");
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
511 this.pdf.doc.text(x + 3, y + 11, this.$gettext("Fairway (LOS 2)"));
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
512
3784
110436ee8ed2 Fairwayprofile: dashed patterns in PDF
Thomas Junk <thomas.junk@intevation.de>
parents: 3783
diff changeset
513 this.pdf.doc.setLineDashPattern([], 0);
4692
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
514 this.pdf.doc.setFillColor(los3Fill);
cad2b264542e adjust fill color in pdf legend
Thomas Junk <thomas.junk@intevation.de>
parents: 4682
diff changeset
515 this.pdf.doc.setDrawColor(los3Color);
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
516 this.pdf.doc.circle(x, y + 15, 2, "FD");
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
517 this.pdf.doc.text(x + 3, y + 16, this.$gettext("Fairway (LOS 3)"));
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
518
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
519 this.pdf.doc.setDrawColor("black");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
520 this.pdf.doc.setFillColor("#4a2e06");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
521 this.pdf.doc.circle(x, y + 20, 2, "FD");
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
522 this.pdf.doc.text(x + 3, y + 21, this.$gettext("Sediment"));
3590
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
523
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
524 this.pdf.doc.setDrawColor("#943007");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
525 this.pdf.doc.setFillColor("#928269");
309084558808 client: diagram-template: improve diagramlegend for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3576
diff changeset
526 this.pdf.doc.circle(x, y + 25, 2, "FD");
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
527 this.pdf.doc.text(x + 3, y + 26, this.$gettext("Sediment (Compare)"));
3240
5240f5440b62 client: implemnt pdf-template for fairwayprofile diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3149
diff changeset
528 },
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
529 getPrintLayout(svgHeight, svgWidth) {
3941
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
530 return {
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
531 main: {
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
532 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
533 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
534 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
535 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
536 }
3941
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
537 };
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
538 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
539 drawDiagram() {
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
540 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
541 this.scaleFairwayProfile();
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
542 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
543 const layout = this.getPrintLayout(this.height, this.width);
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
544 this.renderTo({
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
545 element: ".diagram-container",
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
546 dimensions: this.getDimensions({
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
547 svgWidth: this.width,
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
548 svgHeight: this.height,
3941
7b3935a8d9ee refactor addDiagram to mixin and remove code duplication
Thomas Junk <thomas.junk@intevation.de>
parents: 3936
diff changeset
549 ...layout
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
550 })
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
551 });
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
552 },
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
553 renderTo({ element, dimensions }) {
4893
b65898de11ad only accept numbers as valid data vor (ref)waterlevel
Thomas Junk <thomas.junk@intevation.de>
parents: 4890
diff changeset
554 if (!this.waterlevelValid || !this.refWaterlevelValid) return;
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
555 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
556 svg.attr("width", "100%");
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
557 svg.attr("height", "100%");
4804
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
558 svg
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
559 .append("g")
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
560 .append("rect")
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
561 .attr("width", "100%")
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
562 .attr("height", "100%")
75e6ec39a0b7 client: fairwayprofile: implement image-export
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4773
diff changeset
563 .attr("fill", "#ffffff");
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
564 const width = dimensions.width;
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
565 const height = dimensions.mainHeight;
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
566 const offsetY = 15;
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
567 const currentData = this.currentData;
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
568 const additionalData = this.additionalData;
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
569 const { xScale, yScaleRight, graph } = this.generateScalesAndGraph({
1394
b350b0b5cb6c refactored fairwayprofile cross cuts
Markus Kottlaender <markus@intevation.de>
parents: 1391
diff changeset
570 svg,
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
571 height,
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
572 width,
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
573 dimensions,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
574 offsetY
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
575 });
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
576 this.drawWaterlevel({ graph, xScale, yScaleRight, height, offsetY });
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
577 this.drawLabels({ graph, dimensions });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
578 if (currentData) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
579 this.drawProfile({
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
580 graph,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
581 xScale,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
582 yScaleRight,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
583 currentData,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
584 height,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
585 color: GROUND_COLOR,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
586 strokeColor: "black",
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
587 opacity: 1,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
588 offsetY
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
589 });
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
590 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
591 if (additionalData) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
592 this.drawProfile({
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
593 graph,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
594 xScale,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
595 yScaleRight,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
596 currentData: additionalData,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
597 height,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
598 color: GROUND_COLOR,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
599 strokeColor: "#943007",
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
600 opacity: 0.6,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
601 offsetY
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
602 });
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
603 }
4017
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
604 this.drawFairway({ graph, xScale, yScaleRight, offsetY });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
605 },
4888
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
606 /**
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
607 * Draws Fairway rectangle
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
608 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
609 * start end
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
610 * ____________
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
611 * [___________] customDepth | referenceDepth
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
612 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
613 * Starting point is the 0 line of the diagram
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
614 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
615 */
4017
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
616 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
617 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
618 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
619 }
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
620 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
621 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
622 const [startPoint, endPoint, depth] = coordinates;
4743
ac2c82719f7b fairway profile: fix box rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 4695
diff changeset
623 const referenceDepth =
ac2c82719f7b fairway profile: fix box rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 4695
diff changeset
624 this.maxAlt * 1.1 + (this.waterlevel - this.refWaterlevel) / 100;
4674
3b7de89527a3 custom fairway box limit to diagram
Thomas Junk <thomas.junk@intevation.de>
parents: 4672
diff changeset
625 let customdepth =
4743
ac2c82719f7b fairway profile: fix box rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 4695
diff changeset
626 this.depth < referenceDepth ? this.depth : referenceDepth;
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
627 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
628 .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
629 .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
630 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
631 })
9e296d686f16 client: cross profiles: support gabs in fairway and improved display in diagram and legend
Markus Kottlaender <markus@intevation.de>
parents: 3555
diff changeset
632 .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
633 .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
634 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
635 });
4750
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
636 let strokColor = this.getLayerStyle(data.los).strokeColor;
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
637 // Convert stroke value to rgb() and opacity to pass them separately
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
638 let [r, g, b, opacity] = strokColor
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
639 .substring(5, strokColor.length - 1)
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
640 .split(",");
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
641 let rgb = `rgb(${r}, ${g}, ${b})`;
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
642 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
643 .append("path")
4502
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
644 .datum([
4674
3b7de89527a3 custom fairway box limit to diagram
Thomas Junk <thomas.junk@intevation.de>
parents: 4672
diff changeset
645 { x: startPoint, y: this.useCustomDepth ? customdepth : depth },
3b7de89527a3 custom fairway box limit to diagram
Thomas Junk <thomas.junk@intevation.de>
parents: 4672
diff changeset
646 { x: endPoint, y: this.useCustomDepth ? customdepth : depth }
4502
4c3851391b6d client: fairwayprofile: implement custom depth for x-cuts
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4473
diff changeset
647 ])
4252
a5694f6d62a4 fairway_profile: use style information for painting of LOS cuts
Thomas Junk <thomas.junk@intevation.de>
parents: 4251
diff changeset
648 .attr("fill", `${this.getLayerStyle(data.los).fillColor}`)
4750
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
649 .attr("stroke", rgb)
67a5de15490b client: fix drawing of fairwaybox border in the exported pdf
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4743
diff changeset
650 .attr("stroke-opacity", opacity)
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
651 .attr("stroke-dasharray", this.getLayerStyle(data.los).strokeDash)
4017
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
652 .attr("d", fairwayArea)
639bdb17c3f2 Fixed offset for fairway box
Sascha Wilde <wilde@intevation.de>
parents: 4001
diff changeset
653 .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
654 });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
655 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
656 },
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
657 drawLabels({ graph, dimensions }) {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
658 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
659 .append("text")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
660 .attr("transform", ["rotate(-90)"])
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
661 .attr("y", dimensions.width + Math.floor(0.06 * dimensions.width))
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
662 .attr("x", -dimensions.mainHeight / 2)
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
663 .attr("fill", "black")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
664 .style("text-anchor", "middle")
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
665 .text(this.$gettext("Depth [m]"));
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
666 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
667 .append("text")
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
668 .attr("transform", ["rotate(-90)"])
4137
a41fd26c1644 fairwayprofile: set margins relative to svgheight and svgwidth
Thomas Junk <thomas.junk@intevation.de>
parents: 4017
diff changeset
669 .attr("y", -1 * Math.floor(0.065 * dimensions.width))
3936
d859ec6cf2f0 Fairwayprofile enhanced
Thomas Junk <thomas.junk@intevation.de>
parents: 3928
diff changeset
670 .attr("x", -dimensions.mainHeight / 2)
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
671 .attr("fill", "black")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
672 .style("text-anchor", "middle")
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
673 .text(this.$gettext("Waterlevel [m]"));
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
674 graph
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
675 .append("text")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
676 .attr("y", 0)
3893
9dfd225b92e8 fairwayprofile: offscreen printing
Thomas Junk <thomas.junk@intevation.de>
parents: 3819
diff changeset
677 .attr("x", 0)
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
678 .attr("dy", "1em")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
679 .attr("fill", "black")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
680 .style("text-anchor", "middle")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
681 .attr("transform", [
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
682 `translate(${dimensions.width / 2} ${dimensions.mainHeight})`,
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
683 "rotate(0)"
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
684 ])
4595
998f4d7d9626 client: mark diagram strings for translation(fairwayprofile)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4527
diff changeset
685 .text(this.$gettext("Width [m]"));
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
686 },
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
687 generateScalesAndGraph({ svg, height, width, dimensions, offsetY }) {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
688 let xScale = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
689 .scaleLinear()
3512
30a47d9fc667 client: fairway profiles: removed some old code
Markus Kottlaender <markus@intevation.de>
parents: 3408
diff changeset
690 .domain([0, this.totalLength])
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
691 .rangeRound([0, width]);
4890
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
692 // Upper limit is relevant for the extension of the y-Axis
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
693 // If there is no measure above the waterlevel we choose a cosmetic value of this.maxAlt *0.1
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
694 // to get a bit of space above the waterlevel.
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
695 // Otherwise we take the maximum measured value
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
696 const upperLimit =
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
697 this.minAlt > 0 ? this.maxAlt * 0.1 : Math.abs(this.minAlt);
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
698 // In order to draw positive values downwards, we switch both values in the
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
699 // domain definition [min, max] => [max, min] has the desired effect.
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
700 let yScaleRight = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
701 .scaleLinear()
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
702 .domain([
4672
c7dc1a6da93d fairway_profile: calculate scales
Thomas Junk <thomas.junk@intevation.de>
parents: 4671
diff changeset
703 this.maxAlt * 1.1 + (this.waterlevel - this.refWaterlevel) / 100,
4890
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
704 -upperLimit
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
705 ])
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
706 .rangeRound([height, 0]);
4890
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
707 // This definition is accordingly but uses values * 100 for the tickformatter
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
708 let yScaleLeft = d3
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
709 .scaleLinear()
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
710 .domain([
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
711 this.waterlevel -
4885
558668c32949 fairway_profile: adjusted scaling factor for left scale
Thomas Junk <thomas.junk@intevation.de>
parents: 4869
diff changeset
712 (this.maxAlt * 110 + (this.waterlevel - this.refWaterlevel)),
4890
5d9c7fcda566 Fix drawing of fairway profile.
Thomas Junk <thomas.junk@intevation.de>
parents: 4888
diff changeset
713 this.waterlevel + upperLimit * 100
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
714 ])
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
715 .rangeRound([height, 0]);
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
716
4651
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
717 let xAxis = d3
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
718 .axisBottom(xScale)
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
719 .tickSizeOuter(0)
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
720 .ticks(5);
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
721 let yAxisRight = d3
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
722 .axisRight()
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
723 .tickSizeOuter(0)
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
724 .tickSizeInner(5)
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
725 .scale(yScaleRight);
3576
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
726 let yAxisLeft = d3
4651
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
727 .axisLeft()
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
728 .tickSizeOuter(0)
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
729 .tickSizeInner(5)
e9a99e81f723 client: fairwayprofile: improve y-axes of diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4595
diff changeset
730 .scale(yScaleLeft)
3576
1109a38f7ff1 client: waterlevel format in diagrams changed from cm to m and localized
Markus Kottlaender <markus@intevation.de>
parents: 3571
diff changeset
731 .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
732
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
733 let graph = svg
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
734 .append("g")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
735 .attr(
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
736 "transform",
3942
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
737 "translate(" +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
738 dimensions.mainMargin.left +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
739 "," +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
740 dimensions.mainMargin.top +
cd8ba6599a99 fairway_profile: remove dependency on local state variable
Thomas Junk <thomas.junk@intevation.de>
parents: 3941
diff changeset
741 ")"
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
742 );
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
743 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
744 .append("g")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
745 .attr("transform", `translate(0 ${height - offsetY})`)
3512
30a47d9fc667 client: fairway profiles: removed some old code
Markus Kottlaender <markus@intevation.de>
parents: 3408
diff changeset
746 .call(xAxis)
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
747 .selectAll(".tick text")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
748 .attr("fill", "black")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
749 .select(function() {
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
750 return this.parentNode;
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
751 })
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
752 .selectAll(".tick line")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
753 .attr("stroke", "black");
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
754 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
755 .append("g")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
756 .attr("transform", `translate(${width} ${-offsetY})`)
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
757 .call(yAxisRight)
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
758 .selectAll(".tick text")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
759 .attr("fill", "black")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
760 .select(function() {
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
761 return this.parentNode;
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
762 })
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
763 .selectAll(".tick line")
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
764 .attr("stroke", "black");
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
765 graph
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
766 .append("g")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
767 .attr("transform", `translate(0 ${-offsetY})`)
3514
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
768 .call(yAxisLeft)
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
769 .selectAll(".tick text")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
770 .attr("fill", "black")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
771 .select(function() {
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
772 return this.parentNode;
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
773 })
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
774 .selectAll(".tick line")
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
775 .attr("stroke", "black");
fcb4f3fabde8 client: fairway profiles: added second y-axis (WIP)
Markus Kottlaender <markus@intevation.de>
parents: 3513
diff changeset
776
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
777 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
778 return { xScale, yScaleRight, graph };
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
779 },
4888
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
780 /**
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
781 * Draws a rectangle for the waterlevel
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
782 * (0,0) (totalLength,0)
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
783 * ____________
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
784 * [____________]
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
785 * (0,height) (totalLength, height)
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
786 */
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
787 drawWaterlevel({ graph, xScale, yScaleRight, height, offsetY }) {
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
788 let waterArea = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
789 .area()
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
790 .x(function(d) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
791 return xScale(d.x);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
792 })
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
793 .y0(height)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
794 .y1(function(d) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
795 return yScaleRight(d.y);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
796 });
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
797 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
798 .append("path")
5219
Thomas Junk <thomas.junk@intevation.de>
parents: 4893
diff changeset
799 .datum([
Thomas Junk <thomas.junk@intevation.de>
parents: 4893
diff changeset
800 { x: 0, y: 0 },
Thomas Junk <thomas.junk@intevation.de>
parents: 4893
diff changeset
801 { x: this.totalLength, y: 0 }
Thomas Junk <thomas.junk@intevation.de>
parents: 4893
diff changeset
802 ])
2264
627bfcbbf631 client: Draw fairway dimensions for all LoS and in more "cut cases".
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2154
diff changeset
803 .attr("fill-opacity", 0.65)
2854
1b5acce6120d client: added legend to cross profile diagram
Markus Kottlaender <markus@intevation.de>
parents: 2566
diff changeset
804 .attr("fill", WATER_COLOR)
3520
70cd7383325b client: fairway profiles: removed strokes for sharper edges
Markus Kottlaender <markus@intevation.de>
parents: 3514
diff changeset
805 .attr("stroke", "transparent")
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
806 .attr("d", waterArea)
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
807 .attr("transform", `translate(0 ${-offsetY})`);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
808 },
4888
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
809 /**
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
810 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
811 * Draws the ground level
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
812 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
813 * (x, y + ΔWaterlevel)
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
814 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
815 * ΔWaterlevel is the difference between the current waterlevel and the reference level
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
816 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
817 * Is the current level higher as the reference level ΔWaterlevel is positive, which in
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
818 * turn means that the distance between the surface and the ground is increased.
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
819 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
820 * Is the current level below the reference level ΔWaterlevel is negative, which in turn means
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
821 * that the distance between the surface and the ground is decreased.
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
822 *
af38a19f615a better comments on fairway profile code
Thomas Junk <thomas.junk@intevation.de>
parents: 4885
diff changeset
823 */
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
824 drawProfile({
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
825 graph,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
826 xScale,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
827 yScaleRight,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
828 currentData,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
829 height,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
830 color,
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
831 strokeColor,
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
832 opacity,
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
833 offsetY
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
834 }) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
835 for (let part of currentData) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
836 let profileLine = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
837 .line()
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
838 .x(d => {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
839 return xScale(d.x);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
840 })
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
841 .y(d =>
4671
0cc339c4c356 fairway profile line use correct delta
Thomas Junk <thomas.junk@intevation.de>
parents: 4657
diff changeset
842 yScaleRight(d.y + (this.waterlevel - this.refWaterlevel) / 100)
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
843 );
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
844 let profileArea = d3
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
845 .area()
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
846 .x(function(d) {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
847 return xScale(d.x);
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
848 })
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
849 .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
850 .y1(d =>
4657
a89e4db7980b Add delta to reference waterlevel to current depth.
Thomas Junk <thomas.junk@intevation.de>
parents: 4651
diff changeset
851 yScaleRight(d.y + (this.waterlevel - this.refWaterlevel) / 100)
3527
8a9ee18de13f client: fairway profiles: implemented selection between depth reference waterlevel and current waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3522
diff changeset
852 );
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
853 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
854 .append("path")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
855 .datum(part)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
856 .attr("fill", color)
3534
034657d6604f client: fairway profiles: improved legend
Markus Kottlaender <markus@intevation.de>
parents: 3531
diff changeset
857 .attr("stroke", "transparent")
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
858 .attr("fill-opacity", opacity)
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
859 .attr("d", profileArea)
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
860 .attr("transform", `translate(0 ${-offsetY})`);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
861 graph
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
862 .append("path")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
863 .datum(part)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
864 .attr("fill", "none")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
865 .attr("stroke", strokeColor)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
866 .attr("stroke-linejoin", "round")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
867 .attr("stroke-linecap", "round")
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
868 .attr("stroke-width", 3)
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
869 .attr("stroke-opacity", opacity)
3007
792d4476d5d5 client:implemented pdf-generation for profiles diagrams
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2860
diff changeset
870 .attr("fill-opacity", 0)
4001
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
871 .attr("d", profileLine)
bf86f9a08733 improve fairwaydiagram printing positioning
Thomas Junk <thomas.junk@intevation.de>
parents: 3992
diff changeset
872 .attr("transform", `translate(0 ${-offsetY})`);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
873 }
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
874 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
875 scaleFairwayProfile() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
876 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
877 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
878 .clientHeight;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
879 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
880 .clientWidth;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
881 if (!clientHeight || !clientWidth) return;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
882 this.height = clientHeight;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
883 this.width = clientWidth;
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
884 }
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
885 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
886 created() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
887 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
888 window.addEventListener("resize", this.resizeListenerFunction);
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
889 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
890 mounted() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
891 // 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
892 // 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
893 // 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
894 // 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
895 // 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
896 // 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
897 // screen.
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
898 setTimeout(this.drawDiagram, 150);
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
899
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
900 this.templates[0] = this.defaultTemplate;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
901 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
902 this.templateData = this.form.template;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
903 HTTP.get("/templates/diagram", {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
904 headers: {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
905 "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
906 "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
907 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
908 })
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
909 .then(response => {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
910 if (response.data.length) {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
911 this.templates = response.data;
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
912 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
913 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
914 this.applyChange();
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
915 }
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
916 })
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
917 .catch(error => {
4869
6b054b91d9b2 backend not reachable as error message etd. Login adjusted
Thomas Junk <thomas.junk@intevation.de>
parents: 4868
diff changeset
918 let message = "Backend not reachable";
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
919 if (error.response) {
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
920 const { status, data } = error.response;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
921 message = `${status}: ${data.message || data}`;
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
922 }
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
923 displayError({
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
924 title: this.$gettext("Backend Error"),
4868
008bc1ae8897 exception handling
Thomas Junk <thomas.junk@intevation.de>
parents: 4814
diff changeset
925 message: message
3992
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
926 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
927 });
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
928 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
929 updated() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
930 this.drawDiagram();
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
931 },
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
932 destroyed() {
2f024d6189ca Reverted merge with diagram-cleanup -- its not yet ready.
Sascha Wilde <wilde@intevation.de>
parents: 3968
diff changeset
933 window.removeEventListener("resize", this.resizeListenerFunction);
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
934 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
935 };
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
936 </script>