Mercurial > gemma
annotate client/src/components/fairway/AvailableFairwayDepth.vue @ 3441:d7ec52232702
afd: improve legend coloring
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 24 May 2019 11:31:43 +0200 |
parents | 6a044d6c2cdc |
children | 9be91acbe49a |
rev | line source |
---|---|
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 <template> |
3184
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
2 <div class="d-flex flex-column flex-fill"> |
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
3 <UIBoxHeader icon="chart-area" :title="title" :closeCallback="close" /> |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
4 <UISpinnerOverlay v-if="loading" /> |
3279
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
5 <div class="d-flex flex-fill"> |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
6 <DiagramLegend> |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
7 <div v-for="(entry, index) in legend" :key="index" class="legend"> |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
8 <span |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
9 :style=" |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
10 `${legendStyle( |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
11 index |
3280
8fb81b45085f
available_fairway_depth: use rounded border for legend
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3279
diff
changeset
|
12 )}; border-radius: 0.25rem; width: 40px; height: 20px;` |
3279
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
13 " |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
14 ></span> |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
15 {{ entry }} |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
16 </div> |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
17 <div> |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
18 <select |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
19 @change="applyChange" |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
20 v-model="form.template" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
21 class="form-control d-block custom-select-sm w-100 mt-1" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
22 > |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
23 <option |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
24 v-for="template in templates" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
25 :value="template" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
26 :key="template.name" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
27 > |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
28 {{ template.name }} |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
29 </option> |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
30 </select> |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
31 <button |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
32 @click="downloadPDF" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
33 type="button" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
34 class="btn btn-sm btn-info d-block w-100 mt-1" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
35 > |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
36 <translate>Export to PDF</translate> |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
37 </button> |
3437 | 38 <a |
39 :href="dataLink" | |
40 :download="csvFileName" | |
41 class="mt-1 btn btn-sm btn-info" | |
42 >Download CSV</a | |
43 > | |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
44 </div> |
3279
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
45 </DiagramLegend> |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
46 <div |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
47 ref="diagramContainer" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
48 :id="containerId" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
49 class="mx-auto my-auto diagram-container" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
50 ></div> |
3135 | 51 </div> |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
52 </div> |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
53 </template> |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
54 |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
55 <style></style> |
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
56 |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
57 <script> |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
58 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
59 * without warranty, see README.md and license for details. |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
60 * |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
61 * SPDX-License-Identifier: AGPL-3.0-or-later |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
62 * License-Filename: LICENSES/AGPL-3.0.txt |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
63 * |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
64 * Copyright (C) 2018 by via donau |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
65 * – Österreichische Wasserstraßen-Gesellschaft mbH |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
66 * Software engineering by Intevation GmbH |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
67 * |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
68 * Author(s): |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
69 * Thomas Junk <thomas.junk@intevation.de> |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
70 * 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:
3282
diff
changeset
|
71 * Fadi Abbud <fadi.abbud@intevation.de> |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
72 */ |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
73 import * as d3 from "d3"; |
3135 | 74 import app from "@/main"; |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
75 import debounce from "debounce"; |
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
76 import { diagram } from "@/lib/mixins"; |
3184
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
77 import { mapState } from "vuex"; |
3191
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
78 import filters from "@/lib/filters.js"; |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
79 import jsPDF from "jspdf"; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
80 import canvg from "canvg"; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
81 import { pdfgen } from "@/lib/mixins"; |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
82 import { HTTP } from "@/lib/http"; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
83 import { displayError } from "@/lib/errors"; |
3327
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
84 import { FREQUENCIES } from "@/store/fairwayavailability"; |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
85 |
3213
b3a1ecdda797
available_fairway_depth: hours in days
Thomas Junk <thomas.junk@intevation.de>
parents:
3210
diff
changeset
|
86 const hoursInDays = x => x / 24; |
b3a1ecdda797
available_fairway_depth: hours in days
Thomas Junk <thomas.junk@intevation.de>
parents:
3210
diff
changeset
|
87 |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
88 export default { |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
89 mixins: [diagram, pdfgen], |
3279
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
90 components: { |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
91 DiagramLegend: () => import("@/components/DiagramLegend") |
215173f62900
available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3273
diff
changeset
|
92 }, |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 data() { |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
94 return { |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
95 containerId: "availablefairwaydepth", |
3134
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
3131
diff
changeset
|
96 loading: false, |
3135 | 97 width: 1000, |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
98 height: 600, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
99 paddingRight: 100, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
100 spaceBetween: 80, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
101 labelPaddingTop: 15, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
102 scalePaddingLeft: 50, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
103 paddingTop: 10, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
104 diagram: null, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
105 yScale: null, |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
106 barsWidth: 60, |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
107 dimensions: null, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
108 pdf: { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
109 doc: null, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
110 width: null, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
111 height: null |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
112 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
113 form: { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
114 template: null |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
115 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
116 templateData: null, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
117 templates: [], |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
118 defaultTemplate: { |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
119 name: "Default", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
120 properties: { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
121 paperSize: "a4" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
122 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
123 elements: [ |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
124 { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
125 type: "diagram", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
126 position: "topleft", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
127 offset: { x: 20, y: 60 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
128 width: 290, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
129 height: 100 |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
130 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
131 { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
132 type: "diagramtitle", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
133 position: "topleft", |
3285
aac1ca73e92a
client: diagram-template:(cleanup) move reusable pdf-functions to mixins.js
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3282
diff
changeset
|
134 offset: { x: 70, y: 20 }, |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
135 fontsize: 20, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
136 color: "steelblue" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
137 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
138 { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
139 type: "diagramlegend", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
140 position: "topleft", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
141 offset: { x: 30, y: 160 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
142 color: "black" |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
143 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
144 ] |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
145 } |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
146 }; |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
147 }, |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
148 created() { |
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
149 window.addEventListener("resize", debounce(this.drawDiagram), 100); |
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
150 }, |
3134
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
3131
diff
changeset
|
151 mounted() { |
3191
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
152 this.drawDiagram(); |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
153 this.templates[0] = this.defaultTemplate; |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
154 this.form.template = this.templates[0]; |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
155 this.templateData = this.form.template; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
156 HTTP.get("/templates/diagram", { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
157 headers: { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
158 "X-Gemma-Auth": localStorage.getItem("token"), |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
159 "Content-type": "text/xml; charset=UTF-8" |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
160 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
161 }) |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
162 .then(response => { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
163 if (response.data.length) { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
164 this.templates = response.data; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
165 this.form.template = this.templates[0]; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
166 this.templates[this.templates.length] = this.defaultTemplate; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
167 this.applyChange(); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
168 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
169 }) |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
170 .catch(e => { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
171 const { status, data } = e.response; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
172 displayError({ |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
173 title: this.$gettext("Backend Error"), |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
174 message: `${status}: ${data.message || data}` |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
175 }); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
176 }); |
3134
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
3131
diff
changeset
|
177 }, |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
178 computed: { |
3210
66e90b48387a
available_fairway-depth: store refactored
Thomas Junk <thomas.junk@intevation.de>
parents:
3192
diff
changeset
|
179 ...mapState("fairwayavailability", [ |
3191
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
180 "selectedFairwayAvailabilityFeature", |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
181 "fwData", |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
182 "from", |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
183 "to", |
3216
ee6a4e8af766
available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents:
3213
diff
changeset
|
184 "frequency", |
3437 | 185 "legend", |
186 "csv" | |
3191
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
187 ]), |
3437 | 188 dataLink() { |
189 return `data:text/csv;charset=utf-8, ${encodeURIComponent(this.csv)}`; | |
190 }, | |
191 csvFileName() { | |
192 return `${this.$gettext("fairwayavailability")}-${ | |
193 this.selectedFairwayAvailabilityFeature.properties.name | |
194 }-${filters.surveyDate(this.fromDate)}-${filters.surveyDate( | |
195 this.toDate | |
196 )}-${this.$gettext(this.frequency)}-.csv`; | |
197 }, | |
3327
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
198 frequencyToRange() { |
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
199 const frequencies = { |
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
200 [FREQUENCIES.MONTHLY]: [-33, 33], |
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
201 [FREQUENCIES.QUARTERLY]: [-93, 93], |
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
202 [FREQUENCIES.YEARLY]: [-370, 370] |
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
203 }; |
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
204 return frequencies[this.frequency]; |
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
205 }, |
3191
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
206 fromDate() { |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
207 return this.from; |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
208 }, |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
209 toDate() { |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
210 return this.to; |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
211 }, |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
212 availability() { |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
213 return this.plainAvailability; |
3184
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
214 }, |
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
215 title() { |
3191
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
216 return `Available Fairway Depth: ${ |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
217 this.featureName |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
218 } (${filters.surveyDate(this.fromDate)} - ${filters.surveyDate( |
c0cd5dfec153
statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents:
3185
diff
changeset
|
219 this.toDate |
3268
1a97a079ef1b
client: diagram-template: fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3267
diff
changeset
|
220 )}) ${this.$gettext(this.frequency)}`; |
3184
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
221 }, |
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
222 featureName() { |
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
223 return this.selectedFairwayAvailabilityFeature.properties.name; |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
224 } |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
225 }, |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
226 methods: { |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
227 applyChange() { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
228 if (this.form.template.hasOwnProperty("properties")) { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
229 this.templateData = this.defaultTemplate; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
230 return; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
231 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
232 if (this.form.template) { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
233 HTTP.get("/templates/diagram/" + this.form.template.name, { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
234 headers: { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
235 "X-Gemma-Auth": localStorage.getItem("token"), |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
236 "Content-type": "text/xml; charset=UTF-8" |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
237 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
238 }) |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
239 .then(response => { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
240 this.templateData = response.data.template_data; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
241 }) |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
242 .catch(e => { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
243 const { status, data } = e.response; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
244 displayError({ |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
245 title: this.$gettext("Backend Error"), |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
246 message: `${status}: ${data.message || data}` |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
247 }); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
248 }); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
249 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
250 }, |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
251 downloadPDF() { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
252 this.pdf.doc = new jsPDF( |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
253 "l", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
254 "mm", |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
255 this.templateData.properties.paperSize |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
256 ); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
257 // pdf width and height in millimeter (landscape) |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
258 this.pdf.width = |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
259 this.templateData.properties.paperSize === "a3" ? 420 : 297; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
260 this.pdf.height = |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
261 this.templateData.properties.paperSize === "a3" ? 297 : 210; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
262 if (this.templateData) { |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
263 // default values if some are missing in template |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
264 let defaultFontSize = 11, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
265 defaultColor = "black", |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
266 defaultWidth = 70, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
267 defaultTextColor = "black", |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
268 defaultBorderColor = "white", |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
269 defaultBgColor = "white", |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
270 defaultRounding = 2, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
271 defaultPadding = 2, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
272 defaultOffset = { x: 0, y: 0 }; |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
273 this.templateData.elements.forEach(e => { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
274 switch (e.type) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
275 case "diagram": { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
276 this.addDiagram( |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
277 e.position, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
278 e.offset || defaultOffset, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
279 e.width, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
280 e.height |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
281 ); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
282 break; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
283 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
284 case "diagramtitle": { |
3285
aac1ca73e92a
client: diagram-template:(cleanup) move reusable pdf-functions to mixins.js
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3282
diff
changeset
|
285 let title = `Available Fairway Depth: ${this.featureName}`; |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
286 this.addDiagramTitle( |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
287 e.position, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
288 e.offset || defaultOffset, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
289 e.fontsize || defaultFontSize, |
3285
aac1ca73e92a
client: diagram-template:(cleanup) move reusable pdf-functions to mixins.js
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3282
diff
changeset
|
290 e.color || defaultColor, |
aac1ca73e92a
client: diagram-template:(cleanup) move reusable pdf-functions to mixins.js
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3282
diff
changeset
|
291 title |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
292 ); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
293 break; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
294 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
295 case "diagramlegend": { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
296 this.addDiagramLegend( |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
297 e.position, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
298 e.offset || defaultOffset, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
299 e.color || defaultColor |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
300 ); |
3273
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
301 break; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
302 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
303 case "text": { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
304 this.addText( |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
305 e.position, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
306 e.offset || defaultOffset, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
307 e.width || defaultWidth, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
308 e.fontsize || defaultFontSize, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
309 e.color || defaultTextColor, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
310 e.text |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
311 ); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
312 break; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
313 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
314 case "image": { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
315 this.addImage( |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
316 e.url, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
317 e.format, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
318 e.position, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
319 e.offset || defaultOffset, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
320 e.width, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
321 e.height |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
322 ); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
323 break; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
324 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
325 case "box": { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
326 this.addBox( |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
327 e.position, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
328 e.offset, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
329 e.width, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
330 e.height, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
331 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
332 e.color || defaultBgColor, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
333 e.brcolor || defaultBorderColor |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
334 ); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
335 break; |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
336 } |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
337 case "textbox": { |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
338 this.addTextBox( |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
339 e.position, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
340 e.offset || defaultOffset, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
341 e.width, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
342 e.height, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
343 e.rounding === 0 || e.rounding ? e.rounding : defaultRounding, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
344 e.padding || defaultPadding, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
345 e.fontsize || defaultFontSize, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
346 e.color || defaultTextColor, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
347 e.background || defaultBgColor, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
348 e.text, |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
349 e.brcolor || defaultBorderColor |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
350 ); |
050e72ce5cf7
client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3268
diff
changeset
|
351 break; |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
352 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
353 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
354 }); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
355 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
356 this.pdf.doc.save(`Available Fairway Depth: ${this.featureName}`); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
357 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
358 addDiagram(position, offset, width, height) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
359 let x = offset.x, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
360 y = offset.y; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
361 var svg = this.$refs.diagramContainer.innerHTML; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
362 if (svg) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
363 svg = svg.replace(/\r?\n|\r/g, "").trim(); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
364 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
365 if (!width) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
366 width = this.templateData.properties.paperSize === "a3" ? 380 : 290; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
367 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
368 if (!height) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
369 height = this.templateData.properties.paperSize === "a3" ? 130 : 100; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
370 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
371 if (["topright", "bottomright"].indexOf(position) !== -1) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
372 x = this.pdf.width - offset.x - width; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
373 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
374 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
375 y = this.pdf.height - offset.y - height; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
376 } |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
377 var canvas = document.createElement("canvas"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
378 canvas.width = window.innerWidth; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
379 canvas.height = window.innerHeight / 2; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
380 canvg(canvas, svg, { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
381 ignoreMouse: true, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
382 ignoreAnimation: true, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
383 ignoreDimensions: true |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
384 }); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
385 var imgData = canvas.toDataURL("image/png"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
386 this.pdf.doc.addImage(imgData, "PNG", x, y, width, height); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
387 }, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
388 addDiagramLegend(position, offset, color) { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
389 let x = offset.x, |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
390 y = offset.y; |
3333
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
391 this.pdf.doc.setFontSize(10); |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
392 let width = |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
393 (this.pdf.doc.getStringUnitWidth(">= LDC [h]") * 10) / (72 / 25.6) + 15; |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
394 // if position is on the right, x needs to be calculate with pdf width and |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
395 // the size of the element |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
396 if (["topright", "bottomright"].indexOf(position) !== -1) { |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
397 x = this.pdf.width - offset.x - width; |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
398 } |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
399 if (["bottomright", "bottomleft"].indexOf(position) !== -1) { |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
400 y = this.pdf.height - offset.y - this.getTextHeight(7); |
d5dbfba9faae
clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3330
diff
changeset
|
401 } |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
402 |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
403 this.pdf.doc.setTextColor(color); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
404 this.pdf.doc.setDrawColor("rgb(255, 133, 94)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
405 this.pdf.doc.setFillColor("rgb(255, 133, 94)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
406 this.pdf.doc.rect(x, y, 8, 4, "FD"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
407 this.pdf.doc.text(">= LDC [h]", x + 10, y + 3); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
408 |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
409 this.pdf.doc.setDrawColor("rgb(255, 66, 79)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
410 this.pdf.doc.setFillColor("rgb(255, 66, 79)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
411 this.pdf.doc.rect(x, y + 5, 8, 4, "FD"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
412 this.pdf.doc.text("< 200.00 [h]", x + 10, y + 8); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
413 |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
414 this.pdf.doc.setDrawColor("rgb(255, 115, 124)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
415 this.pdf.doc.setFillColor("rgb(255, 115, 124)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
416 this.pdf.doc.rect(x, y + 10, 8, 4, "FD"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
417 this.pdf.doc.text(">= 200.00 [h]", x + 10, y + 13); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
418 |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
419 this.pdf.doc.setDrawColor("rgb(255, 153, 160)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
420 this.pdf.doc.setFillColor("rgb(255, 153, 160)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
421 this.pdf.doc.rect(x, y + 15, 8, 4, "FD"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
422 this.pdf.doc.text(">= 230.00 [h]", x + 10, y + 18); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
423 |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
424 this.pdf.doc.setDrawColor("rgb(45, 132, 179)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
425 this.pdf.doc.setFillColor("rgb(45, 132, 179)"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
426 this.pdf.doc.rect(x, y + 20, 8, 4, "FD"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
427 this.pdf.doc.text(">= 250.00 [h]", x + 10, y + 23); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
428 }, |
3239
a7d44d1ae57d
available_fairway_depth: legend
Thomas Junk <thomas.junk@intevation.de>
parents:
3235
diff
changeset
|
429 legendStyle(index) { |
3441
d7ec52232702
afd: improve legend coloring
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
430 const style = { |
d7ec52232702
afd: improve legend coloring
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
431 0: `background-color: ${this.$options.COLORS.LDC};`, |
d7ec52232702
afd: improve legend coloring
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
432 1: `background-color: ${this.$options.COLORS.REST[0]};`, |
d7ec52232702
afd: improve legend coloring
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
433 2: `background-color: ${this.$options.COLORS.REST[1]};`, |
d7ec52232702
afd: improve legend coloring
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
434 3: `background-color: ${this.$options.COLORS.HIGHEST};` |
d7ec52232702
afd: improve legend coloring
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
435 }; |
d7ec52232702
afd: improve legend coloring
Thomas Junk <thomas.junk@intevation.de>
parents:
3437
diff
changeset
|
436 return style[index]; |
3239
a7d44d1ae57d
available_fairway_depth: legend
Thomas Junk <thomas.junk@intevation.de>
parents:
3235
diff
changeset
|
437 }, |
3184
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
438 close() { |
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
439 this.$store.commit("application/paneSetup", "DEFAULT"); |
1ba2a7d22fbb
available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents:
3180
diff
changeset
|
440 }, |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
441 drawDiagram() { |
3235
0c5a28ffe9ee
available_fairway_depth: flexible layouting options
Thomas Junk <thomas.junk@intevation.de>
parents:
3216
diff
changeset
|
442 this.dimensions = this.getDimensions({ |
0c5a28ffe9ee
available_fairway_depth: flexible layouting options
Thomas Junk <thomas.junk@intevation.de>
parents:
3216
diff
changeset
|
443 main: { top: 20, right: 20, bottom: 110, left: 200 } |
0c5a28ffe9ee
available_fairway_depth: flexible layouting options
Thomas Junk <thomas.junk@intevation.de>
parents:
3216
diff
changeset
|
444 }); |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
445 this.yScale = d3 |
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
446 .scaleLinear() |
3327
7ab8a176db92
available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents:
3291
diff
changeset
|
447 .domain(this.frequencyToRange) |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
448 .range([this.dimensions.mainHeight - 30, 0]); |
3134
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
3131
diff
changeset
|
449 d3.select(".diagram-container svg").remove(); |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
450 this.generateDiagramContainer(); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
451 this.drawBars(); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
452 this.drawScaleLabel(); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
453 this.drawScale(); |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
454 this.drawTooltip(); |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
455 }, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
456 generateDiagramContainer() { |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
457 const diagram = d3 |
3134
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
3131
diff
changeset
|
458 .select(".diagram-container") |
ab00165540fe
available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents:
3131
diff
changeset
|
459 .append("svg") |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
460 .attr("width", this.dimensions.width) |
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
461 .attr("height", this.dimensions.mainHeight); |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
462 this.diagram = diagram |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
463 .append("g") |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
464 .attr("transform", `translate(0 ${this.paddingTop})`); |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
465 }, |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
466 drawTooltip() { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
467 this.diagram |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
468 .append("text") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
469 .text("banane") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
470 .attr("font-size", "0.8em") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
471 .attr("opacity", 0) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
472 .attr("id", "tooltip"); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
473 }, |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
474 drawBars() { |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
475 const everyBar = this.diagram |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
476 .selectAll("g") |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
477 .data(this.fwData) |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
478 .enter() |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
479 .append("g") |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
480 .attr("transform", (d, i) => { |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
481 const dx = this.paddingRight + i * this.spaceBetween; |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
482 return `translate(${dx})`; |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
483 }); |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
484 this.drawSingleBars(everyBar); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
485 this.drawLabelPerBar(everyBar); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
486 }, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
487 drawSingleBars(everyBar) { |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
488 this.drawLDC(everyBar); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
489 this.drawHighestLevel(everyBar); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
490 this.drawLowerLevels(everyBar); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
491 }, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
492 drawLowerLevels(everyBar) { |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
493 everyBar |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
494 .selectAll("g") |
3330
0e442b547f6d
mocking fairway_availability
Thomas Junk <thomas.junk@intevation.de>
parents:
3327
diff
changeset
|
495 .data(d => d.lowerLevels) |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
496 .enter() |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
497 .append("rect") |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
498 .on("mouseover", function() { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
499 d3.select(this).attr("opacity", "0.8"); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
500 d3.select("#tooltip").attr("opacity", 1); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
501 }) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
502 .on("mouseout", function() { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
503 d3.select(this).attr("opacity", 1); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
504 d3.select("#tooltip").attr("opacity", 0); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
505 }) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
506 .on("mousemove", function(d) { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
507 let y = d3.mouse(this)[1]; |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
508 const dy = document |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
509 .querySelector(".diagram-container") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
510 .getBoundingClientRect().left; |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
511 const value = Number.parseFloat(hoursInDays(d.height)).toFixed(2); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
512 d3.select("#tooltip") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
513 .text(value) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
514 .attr("y", y - 10) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
515 .attr("x", d3.event.pageX - dy); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
516 //d3.event.pageX gives coordinates relative to SVG |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
517 //dy gives offset of svg on page |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
518 }) |
3347
cd745be63f71
available_fairway_depth: draw lower levels refactored
Thomas Junk <thomas.junk@intevation.de>
parents:
3333
diff
changeset
|
519 .attr("y", d => { |
cd745be63f71
available_fairway_depth: draw lower levels refactored
Thomas Junk <thomas.junk@intevation.de>
parents:
3333
diff
changeset
|
520 return 2 * this.yScale(0) - this.yScale(hoursInDays(d.translateY)); |
cd745be63f71
available_fairway_depth: draw lower levels refactored
Thomas Junk <thomas.junk@intevation.de>
parents:
3333
diff
changeset
|
521 }) |
3128
1610d3042bbb
fairway_availability: generative code fixed
Thomas Junk <thomas.junk@intevation.de>
parents:
3125
diff
changeset
|
522 .attr("height", d => { |
3347
cd745be63f71
available_fairway_depth: draw lower levels refactored
Thomas Junk <thomas.junk@intevation.de>
parents:
3333
diff
changeset
|
523 return this.yScale(0) - this.yScale(hoursInDays(d.height)); |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
524 }) |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
525 .attr("width", this.barsWidth) |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
526 .attr("fill", (d, i) => { |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
527 return this.$options.COLORS.REST[i]; |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
528 }); |
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
529 }, |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
530 fnheight(name) { |
3213
b3a1ecdda797
available_fairway_depth: hours in days
Thomas Junk <thomas.junk@intevation.de>
parents:
3210
diff
changeset
|
531 return d => this.yScale(0) - this.yScale(hoursInDays(d[name])); |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
532 }, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
533 drawLDC(everyBar) { |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
534 const height = this.fnheight("ldc"); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
535 everyBar |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
536 .append("rect") |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
537 .on("mouseover", function() { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
538 d3.select(this).attr("opacity", "0.8"); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
539 d3.select("#tooltip").attr("opacity", 1); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
540 }) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
541 .on("mouseout", function() { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
542 d3.select(this).attr("opacity", 1); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
543 d3.select("#tooltip").attr("opacity", 0); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
544 }) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
545 .on("mousemove", function(d) { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
546 let y = d3.mouse(this)[1]; |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
547 const dy = document |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
548 .querySelector(".diagram-container") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
549 .getBoundingClientRect().left; |
3371
f76a694f7f7b
available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents:
3360
diff
changeset
|
550 const value = Number.parseFloat(hoursInDays(d.ldc)).toFixed(2); |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
551 d3.select("#tooltip") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
552 .text(value) |
3410 | 553 .attr("y", y - 50) |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
554 .attr("x", d3.event.pageX - dy); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
555 //d3.event.pageX gives coordinates relative to SVG |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
556 //dy gives offset of svg on page |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
557 }) |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
558 .attr("y", this.yScale(0)) |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
559 .attr("height", height) |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
560 .attr("width", this.barsWidth) |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
561 .attr("transform", d => `translate(0 ${-1 * height(d)})`) |
3216
ee6a4e8af766
available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents:
3213
diff
changeset
|
562 .attr("fill", this.$options.COLORS.LDC) |
ee6a4e8af766
available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents:
3213
diff
changeset
|
563 .attr("id", "ldc"); |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
564 }, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
565 drawHighestLevel(everyBar) { |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
566 const height = this.fnheight("highestLevel"); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
567 everyBar |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
568 .append("rect") |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
569 .on("mouseover", function() { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
570 d3.select(this).attr("opacity", "0.8"); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
571 d3.select("#tooltip").attr("opacity", 1); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
572 }) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
573 .on("mouseout", function() { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
574 d3.select(this).attr("opacity", 1); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
575 d3.select("#tooltip").attr("opacity", 0); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
576 }) |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
577 .on("mousemove", function(d) { |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
578 let y = d3.mouse(this)[1]; |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
579 const dy = document |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
580 .querySelector(".diagram-container") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
581 .getBoundingClientRect().left; |
3371
f76a694f7f7b
available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents:
3360
diff
changeset
|
582 const value = Number.parseFloat(hoursInDays(d.highestLevel)).toFixed( |
f76a694f7f7b
available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents:
3360
diff
changeset
|
583 2 |
f76a694f7f7b
available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents:
3360
diff
changeset
|
584 ); |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
585 d3.select("#tooltip") |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
586 .text(value) |
3410 | 587 .attr("y", y - 50) |
3360
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
588 .attr("x", d3.event.pageX - dy); |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
589 //d3.event.pageX gives coordinates relative to SVG |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
590 //dy gives offset of svg on page |
b2ccfebd5616
available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents:
3349
diff
changeset
|
591 }) |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
592 .attr("y", this.yScale(0)) |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
593 .attr("height", height) |
3216
ee6a4e8af766
available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents:
3213
diff
changeset
|
594 .attr("width", this.barsWidth - 5) |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
595 .attr("transform", d => `translate(0 ${-1 * height(d)})`) |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
596 .attr("fill", this.$options.COLORS.HIGHEST); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
597 }, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
598 drawLabelPerBar(everyBar) { |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
599 everyBar |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
600 .append("text") |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
601 .text(d => d.label) |
3349
ac0006f675c0
available-fairway_depth: labels above
Thomas Junk <thomas.junk@intevation.de>
parents:
3347
diff
changeset
|
602 .attr("y", this.labelPaddingTop); |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
603 }, |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
604 drawScaleLabel() { |
3180
429e28295902
available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents:
3153
diff
changeset
|
605 const center = this.dimensions.mainHeight / 2; |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
606 this.diagram |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
607 .append("text") |
3135 | 608 .text(this.$options.LEGEND) |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
609 .attr("text-anchor", "middle") |
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
610 .attr("x", 0) |
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
611 .attr("y", 0) |
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
612 .attr("dy", "1em") |
3135 | 613 .attr("transform", `translate(0, ${center}), rotate(-90)`); |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
614 }, |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
615 drawScale() { |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
616 const yAxis = d3.axisLeft().scale(this.yScale); |
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
617 this.diagram |
3125
383720d8d98e
fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents:
3033
diff
changeset
|
618 .append("g") |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
619 .attr("transform", `translate(${this.scalePaddingLeft})`) |
3267
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
620 .call(yAxis) |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
621 .selectAll(".tick text") |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
622 .attr("fill", "black") |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
623 .select(function() { |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
624 return this.parentNode; |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
625 }) |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
626 .selectAll(".tick line") |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
627 .attr("stroke", "black"); |
b07b4cca5e34
client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents:
3239
diff
changeset
|
628 this.diagram.selectAll(".domain").attr("stroke", "black"); |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
629 } |
3135 | 630 }, |
3282
707d4435aff3
redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents:
3280
diff
changeset
|
631 watch: { |
707d4435aff3
redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents:
3280
diff
changeset
|
632 fwData() { |
707d4435aff3
redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents:
3280
diff
changeset
|
633 this.drawDiagram(); |
707d4435aff3
redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents:
3280
diff
changeset
|
634 } |
707d4435aff3
redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents:
3280
diff
changeset
|
635 }, |
3216
ee6a4e8af766
available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents:
3213
diff
changeset
|
636 LEGEND: app.$gettext("Sum of days"), |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
637 COLORS: { |
3288
c2d753ef5aa1
fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents:
3287
diff
changeset
|
638 LDC: "#cdcdcd", |
c2d753ef5aa1
fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents:
3287
diff
changeset
|
639 HIGHEST: "#3675ff", |
3291
6996aa1d2df9
available_fairway_depth: switched colors
Thomas Junk <thomas.junk@intevation.de>
parents:
3288
diff
changeset
|
640 REST: ["#782121", "#ff6c6c", "#ffaaaa"] |
3153
8159bd2aaf93
fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents:
3135
diff
changeset
|
641 } |
3033
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
642 }; |
c2c1e3e3af1c
Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
643 </script> |