annotate client/src/components/fairway/AvailableFairwayDepth.vue @ 3939:f9de2ea2706e

available_fairway_depth: leverage mixin
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 12 Jul 2019 10:17:09 +0200
parents 03f37e64701c
children 7b3935a8d9ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
3466
dfa97aad1134 client: unify the buttons style for diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3464
diff changeset
34 class="btn btn-sm btn-info d-block w-100 mt-2"
3267
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
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
38 <a
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
39 :href="dataLink"
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
40 :download="csvFileName"
3466
dfa97aad1134 client: unify the buttons style for diagram legend
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3464
diff changeset
41 class="mt-2 btn btn-sm btn-info w-100"
3437
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
42 >Download CSV</a
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
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"
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
49 class="diagram-container flex-fill"
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
50 ></div>
3135
Thomas Junk <thomas.junk@intevation.de>
parents: 3134
diff changeset
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 *
3800
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
64 * Copyright (C) 2018, 2019 by via donau
3033
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):
3800
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
69 * * Thomas Junk <thomas.junk@intevation.de>
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
70 * * Markus Kottländer <markus.kottlaender@intevation.de>
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
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
Thomas Junk <thomas.junk@intevation.de>
parents: 3134
diff changeset
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";
3184
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
76 import { mapState } from "vuex";
3191
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
77 import filters from "@/lib/filters.js";
3811
37e896990c99 client: improve pdf generation towards vector diagrams
Bernhard Reiter <bernhard@intevation.de>
parents: 3806
diff changeset
78 import svg2pdf from "svg2pdf.js";
3939
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
79 import { diagram, pdfgen, templateLoader } 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
80 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
81 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
82 import { FREQUENCIES } from "@/store/fairwayavailability";
3927
03f37e64701c Factored out default template for diagrams in a single file.
Sascha Wilde <wilde@intevation.de>
parents: 3922
diff changeset
83 import { defaultDiagramTemplate } from "@/lib/DefaultDiagramTemplate";
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
84
3213
b3a1ecdda797 available_fairway_depth: hours in days
Thomas Junk <thomas.junk@intevation.de>
parents: 3210
diff changeset
85 const hoursInDays = x => x / 24;
b3a1ecdda797 available_fairway_depth: hours in days
Thomas Junk <thomas.junk@intevation.de>
parents: 3210
diff changeset
86
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
87 export default {
3939
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
88 mixins: [diagram, pdfgen, templateLoader],
3279
215173f62900 available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3273
diff changeset
89 components: {
215173f62900 available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3273
diff changeset
90 DiagramLegend: () => import("@/components/DiagramLegend")
215173f62900 available_fairway_depth: improve legend layout
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3273
diff changeset
91 },
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
92 data() {
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
93 return {
3918
1e837d86bead available_fairway_lnwl: fixed containerID
Thomas Junk <thomas.junk@intevation.de>
parents: 3917
diff changeset
94 containerId: "availablefairwaydepth-diagram-container",
3682
c086f5176ef2 client: diagrams: fixed removal of resize listener
Markus Kottlaender <markus@intevation.de>
parents: 3544
diff changeset
95 resizeListenerFunction: null,
3134
ab00165540fe available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents: 3131
diff changeset
96 loading: false,
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
97 scalePaddingLeft: 60,
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
98 scalePaddingRight: 0,
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
99 paddingTop: 25,
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
100 pdf: {
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
101 doc: null,
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
102 width: null,
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
103 height: null
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
104 },
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
105 form: {
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
106 template: null
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
107 },
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
108 templateData: null,
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
109 templates: [],
3927
03f37e64701c Factored out default template for diagrams in a single file.
Sascha Wilde <wilde@intevation.de>
parents: 3922
diff changeset
110 defaultTemplate: defaultDiagramTemplate
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
111 };
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
112 },
3180
429e28295902 available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents: 3153
diff changeset
113 created() {
3682
c086f5176ef2 client: diagrams: fixed removal of resize listener
Markus Kottlaender <markus@intevation.de>
parents: 3544
diff changeset
114 this.resizeListenerFunction = debounce(this.drawDiagram, 100);
c086f5176ef2 client: diagrams: fixed removal of resize listener
Markus Kottlaender <markus@intevation.de>
parents: 3544
diff changeset
115 window.addEventListener("resize", this.resizeListenerFunction);
c086f5176ef2 client: diagrams: fixed removal of resize listener
Markus Kottlaender <markus@intevation.de>
parents: 3544
diff changeset
116 },
c086f5176ef2 client: diagrams: fixed removal of resize listener
Markus Kottlaender <markus@intevation.de>
parents: 3544
diff changeset
117 destroyed() {
c086f5176ef2 client: diagrams: fixed removal of resize listener
Markus Kottlaender <markus@intevation.de>
parents: 3544
diff changeset
118 window.removeEventListener("resize", this.resizeListenerFunction);
3180
429e28295902 available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents: 3153
diff changeset
119 },
3134
ab00165540fe available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents: 3131
diff changeset
120 mounted() {
3688
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
121 // Nasty but necessary if we don't want to use the updated hook to re-draw
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
122 // the diagram because this would re-draw it also for irrelevant reasons.
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
123 // In this case we need to wait for the child component (DiagramLegend) to
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
124 // render. According to the docs (https://vuejs.org/v2/api/#mounted) this
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
125 // should be possible with $nextTick() but it doesn't work because it does
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
126 // not guarantee that the DOM is not only updated but also re-painted on the
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
127 // screen.
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
128 setTimeout(this.drawDiagram, 150);
af06045e87c9 client: diagrams: wait (longer) for legend child component to render before rendering diagram (see comments for explanation)
Markus Kottlaender <markus@intevation.de>
parents: 3682
diff changeset
129
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
130 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
131 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
132 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
133 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
134 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
135 "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
136 "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
137 }
050e72ce5cf7 client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3268
diff changeset
138 })
050e72ce5cf7 client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3268
diff changeset
139 .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
140 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
141 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
142 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
143 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
144 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
145 }
050e72ce5cf7 client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3268
diff changeset
146 })
050e72ce5cf7 client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3268
diff changeset
147 .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
148 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
149 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
150 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
151 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
152 });
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 });
3134
ab00165540fe available_fairway_depths: Component made visible
Thomas Junk <thomas.junk@intevation.de>
parents: 3131
diff changeset
154 },
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
155 computed: {
3210
66e90b48387a available_fairway-depth: store refactored
Thomas Junk <thomas.junk@intevation.de>
parents: 3192
diff changeset
156 ...mapState("fairwayavailability", [
3191
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
157 "selectedFairwayAvailabilityFeature",
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
158 "fwData",
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
159 "from",
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
160 "to",
3216
ee6a4e8af766 available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents: 3213
diff changeset
161 "frequency",
3476
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
162 "csv",
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
163 "depthlimit1",
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
164 "depthlimit2",
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
165 "widthlimit1",
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
166 "widthlimit2"
3191
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
167 ]),
3476
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
168 legend() {
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
169 const d = [this.depthlimit1, this.depthlimit2].sort();
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
170 const w = [this.widthlimit1, this.widthlimit2].sort();
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
171 const lowerBound = [d[0], w[0]].filter(x => x).join(", ");
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
172 const upperBound = [d[1], w[1]].filter(x => x).join(", ");
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
173 return [
3493
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
174 `> LDC`,
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
175 `>= ${upperBound}`,
3476
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
176 `< ${upperBound}`,
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
177 `< ${lowerBound}`
3476
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
178 ];
cc11f207e060 afd: omit legend generation from CSV. Legend is generated from known inputs
Thomas Junk <thomas.junk@intevation.de>
parents: 3466
diff changeset
179 },
3437
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
180 dataLink() {
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
181 return `data:text/csv;charset=utf-8, ${encodeURIComponent(this.csv)}`;
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
182 },
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
183 csvFileName() {
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
184 return `${this.$gettext("fairwayavailability")}-${
3481
ba26adce0ce8 afd: robust legend name
Thomas Junk <thomas.junk@intevation.de>
parents: 3476
diff changeset
185 this.featureName
3437
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
186 }-${filters.surveyDate(this.fromDate)}-${filters.surveyDate(
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
187 this.toDate
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
188 )}-${this.$gettext(this.frequency)}-.csv`;
6a044d6c2cdc afd: csv download
Thomas Junk <thomas.junk@intevation.de>
parents: 3410
diff changeset
189 },
3327
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
190 frequencyToRange() {
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
191 const frequencies = {
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
192 [FREQUENCIES.MONTHLY]: [-33, 33],
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
193 [FREQUENCIES.QUARTERLY]: [-93, 93],
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
194 [FREQUENCIES.YEARLY]: [-370, 370]
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
195 };
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
196 return frequencies[this.frequency];
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
197 },
3191
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
198 fromDate() {
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
199 return this.from;
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
200 },
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
201 toDate() {
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
202 return this.to;
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
203 },
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
204 availability() {
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
205 return this.plainAvailability;
3184
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
206 },
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
207 title() {
3191
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
208 return `Available Fairway Depth: ${
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
209 this.featureName
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
210 } (${filters.surveyDate(this.fromDate)} - ${filters.surveyDate(
c0cd5dfec153 statistics: persist fields to vuex
Thomas Junk <thomas.junk@intevation.de>
parents: 3185
diff changeset
211 this.toDate
3268
1a97a079ef1b client: diagram-template: fix typo
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3267
diff changeset
212 )}) ${this.$gettext(this.frequency)}`;
3184
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
213 },
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
214 featureName() {
3481
ba26adce0ce8 afd: robust legend name
Thomas Junk <thomas.junk@intevation.de>
parents: 3476
diff changeset
215 if (this.selectedFairwayAvailabilityFeature == null) return "";
3184
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
216 return this.selectedFairwayAvailabilityFeature.properties.name;
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
217 }
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
218 },
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
219 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
220 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
221 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
222 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
223 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
224 }
050e72ce5cf7 client: diagram-template: add template elements and get templates from backend(fairway avalibilty)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3268
diff changeset
225 if (this.form.template) {
3806
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
226 this.loadTemplates("/templates/diagram/" + this.form.template.name)
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 .then(response => {
3806
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
228 this.prepareImages(response.data.template_data.elements).then(
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
229 values => {
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
230 values.forEach(v => {
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
231 response.data.template_data.elements[v.index].url = v.url;
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
232 });
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
233 this.templateData = response.data.template_data;
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
234 }
cc80a37173f8 Available-fairway-depth(both): use mixin for template loading and image processing
Thomas Junk <thomas.junk@intevation.de>
parents: 3800
diff changeset
235 );
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
236 })
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 .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
238 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
239 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
240 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
241 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
242 });
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 });
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 }
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 },
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
246 downloadPDF() {
3800
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
247 let title = `Available Fairway Depth: ${this.featureName}`;
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
248 this.generatePDF({
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
249 templateData: this.templateData,
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
250 diagramTitle: title
26325370ba18 client: improve pdf generation
Bernhard Reiter <bernhard@intevation.de>
parents: 3780
diff changeset
251 });
3267
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.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
253 },
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
254 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
255 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
256 y = offset.y;
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
257 const svgWidth = this.millimeter2pixels(width, 80);
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
258 const svgHeight = this.millimeter2pixels(height, 80);
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
259 // draw the diagram in a separated html element to get the full size
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
260 const offScreen = document.querySelector("#offScreen");
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
261 offScreen.style.width = `${svgWidth}px`;
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
262 offScreen.style.height = `${svgHeight}px`;
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
263 this.renderTo({
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
264 element: offScreen,
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
265 dimensions: this.getDimensions({
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
266 svgWidth: svgWidth,
3939
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
267 svgHeight: svgHeight,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
268 main: { top: 0, right: 20, bottom: 50, left: 20 },
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
269 nav: {
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
270 top: svgHeight - 65,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
271 right: 20,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
272 bottom: 30,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
273 left: 80
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
274 }
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
275 })
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
276 });
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
277 var svg = offScreen.querySelector("svg");
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
278 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
279 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
280 }
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
281 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
282 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
283 }
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
284 svg2pdf(svg, this.pdf.doc, {
3811
37e896990c99 client: improve pdf generation towards vector diagrams
Bernhard Reiter <bernhard@intevation.de>
parents: 3806
diff changeset
285 xOffset: x,
37e896990c99 client: improve pdf generation towards vector diagrams
Bernhard Reiter <bernhard@intevation.de>
parents: 3806
diff changeset
286 yOffset: y,
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
287 scale: 0.354
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
288 });
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
289 offScreen.removeChild(svg);
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
290 },
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
291 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
292 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
293 y = offset.y;
3333
d5dbfba9faae clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3330
diff changeset
294 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
295 let width =
3493
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
296 (this.pdf.doc.getStringUnitWidth(">= LDC") * 10) / (72 / 25.6) + 15;
3333
d5dbfba9faae clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3330
diff changeset
297 // 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
298 // 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
299 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
300 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
301 }
d5dbfba9faae clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3330
diff changeset
302 if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
3493
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
303 y = this.pdf.height - offset.y - this.getTextHeight(6);
3333
d5dbfba9faae clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3330
diff changeset
304 }
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
305
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
306 this.pdf.doc.setTextColor(color);
3493
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
307 this.pdf.doc.setDrawColor(this.$options.COLORS.LDC);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
308 this.pdf.doc.setFillColor(this.$options.COLORS.LDC);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
309 this.pdf.doc.roundedRect(x, y, 10, 4, 1.5, 1.5, "FD");
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
310 this.pdf.doc.text(this.legend[0], x + 12, y + 3);
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
311
3493
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
312 this.pdf.doc.setDrawColor(this.$options.COLORS.REST[0]);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
313 this.pdf.doc.setFillColor(this.$options.COLORS.REST[0]);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
314 this.pdf.doc.roundedRect(x, y + 5, 10, 4, 1.5, 1.5, "FD");
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
315 this.pdf.doc.text(this.legend[1], x + 12, y + 8);
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
316
3493
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
317 this.pdf.doc.setDrawColor(this.$options.COLORS.REST[1]);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
318 this.pdf.doc.setFillColor(this.$options.COLORS.REST[1]);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
319 this.pdf.doc.roundedRect(x, y + 10, 10, 4, 1.5, 1.5, "FD");
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
320 this.pdf.doc.text(this.legend[2], x + 12, y + 13);
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
321
3493
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
322 this.pdf.doc.setDrawColor(this.$options.COLORS.HIGHEST);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
323 this.pdf.doc.setFillColor(this.$options.COLORS.HIGHEST);
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
324 this.pdf.doc.roundedRect(x, y + 15, 10, 4, 1.5, 1.5, "FD");
da58cf951342 client: diagram-template: improve diagramlegend element (AvailableFairwayDepth)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3484
diff changeset
325 this.pdf.doc.text(this.legend[3], x + 12, y + 18);
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
326 },
3239
a7d44d1ae57d available_fairway_depth: legend
Thomas Junk <thomas.junk@intevation.de>
parents: 3235
diff changeset
327 legendStyle(index) {
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
328 return [
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
329 `background-color: ${this.$options.COLORS.LDC};`,
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
330 `background-color: ${this.$options.COLORS.HIGHEST};`,
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
331 `background-color: ${this.$options.COLORS.REST[1]};`,
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
332 `background-color: ${this.$options.COLORS.REST[0]};`
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
333 ][index];
3239
a7d44d1ae57d available_fairway_depth: legend
Thomas Junk <thomas.junk@intevation.de>
parents: 3235
diff changeset
334 },
3184
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
335 close() {
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
336 this.$store.commit("application/paneSetup", "DEFAULT");
1ba2a7d22fbb available_fairway_depth: display selected feature
Thomas Junk <thomas.junk@intevation.de>
parents: 3180
diff changeset
337 },
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
338 drawDiagram() {
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
339 const elem = document.querySelector("#" + this.containerId);
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
340 const svgWidth = elem != null ? elem.clientWidth : 0;
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
341 const svgHeight = elem != null ? elem.clientHeight : 0;
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
342 const dimensions = this.getDimensions({
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
343 svgHeight,
3939
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
344 svgWidth,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
345 main: { top: 0, right: 20, bottom: 50, left: 20 },
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
346 nav: {
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
347 top: svgHeight - 65,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
348 right: 20,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
349 bottom: 30,
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
350 left: 80
f9de2ea2706e available_fairway_depth: leverage mixin
Thomas Junk <thomas.junk@intevation.de>
parents: 3927
diff changeset
351 }
3235
0c5a28ffe9ee available_fairway_depth: flexible layouting options
Thomas Junk <thomas.junk@intevation.de>
parents: 3216
diff changeset
352 });
3911
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
353 d3.select(".diagram-container svg").remove();
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
354 this.renderTo({ element: ".diagram-container", dimensions });
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
355 },
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
356 renderTo({ element, dimensions }) {
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
357 const diagram = d3
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
358 .select(element)
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
359 .append("svg")
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
360 .attr("width", "100%")
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
361 .attr("height", "100%");
e4e496ae7974 fairway_availability: rendering to offscreen element
Thomas Junk <thomas.junk@intevation.de>
parents: 3909
diff changeset
362 diagram.append("g");
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
363 const yScale = d3
3180
429e28295902 available_fairway_depth: implement reactivity
Thomas Junk <thomas.junk@intevation.de>
parents: 3153
diff changeset
364 .scaleLinear()
3327
7ab8a176db92 available_fairway_depth: adjust scale according to selected timerange
Thomas Junk <thomas.junk@intevation.de>
parents: 3291
diff changeset
365 .domain(this.frequencyToRange)
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
366 .range([dimensions.mainHeight - 30, 0]);
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
367 this.drawScaleLabel({ diagram, dimensions });
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
368 this.drawScale({ diagram, dimensions, yScale });
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
369 this.drawBars({ diagram, yScale, dimensions });
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
370 this.drawTooltip(diagram);
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
371 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
372 drawTooltip(diagram) {
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
373 diagram
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
374 .append("text")
3874
7b6a74919051 client: available fairway depth diagram: rounding day numbers
Markus Kottlaender <markus@intevation.de>
parents: 3717
diff changeset
375 .text("")
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
376 .attr("font-size", "0.8em")
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
377 .attr("opacity", 0)
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
378 .attr("id", "tooltip");
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
379 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
380 drawBars({ diagram, yScale, dimensions }) {
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
381 const widthPerItem = Math.min(
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
382 (dimensions.width - this.scalePaddingLeft - this.scalePaddingRight) /
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
383 this.fwData.length,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
384 180
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
385 );
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
386 const spaceBetween = widthPerItem * 0.2;
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
387 const ldcOffset = widthPerItem * 0.1;
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
388 const everyBar = diagram
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
389 .selectAll("g.bars")
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
390 .data(this.fwData)
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
391 .enter()
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
392 .append("g")
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
393 .attr("class", "bars")
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
394 .attr("transform", (d, i) => {
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
395 const dx = this.scalePaddingLeft + i * widthPerItem;
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
396 return `translate(${dx})`;
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
397 });
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
398 this.drawSingleBars({
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
399 everyBar,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
400 yScale,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
401 dimensions,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
402 widthPerItem,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
403 spaceBetween,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
404 ldcOffset
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
405 });
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
406 this.drawLabelPerBar({ everyBar, dimensions, widthPerItem });
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
407 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
408 drawSingleBars({
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
409 everyBar,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
410 yScale,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
411 widthPerItem,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
412 spaceBetween,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
413 ldcOffset
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
414 }) {
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
415 this.drawLDC({ everyBar, yScale, widthPerItem, spaceBetween, ldcOffset });
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
416 this.drawHighestLevel({
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
417 everyBar,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
418 yScale,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
419 widthPerItem,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
420 spaceBetween,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
421 ldcOffset
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
422 });
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
423 this.drawLowerLevels({
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
424 everyBar,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
425 yScale,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
426 widthPerItem,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
427 spaceBetween,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
428 ldcOffset
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
429 });
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
430 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
431 drawLowerLevels({
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
432 everyBar,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
433 yScale,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
434 widthPerItem,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
435 spaceBetween,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
436 ldcOffset
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
437 }) {
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
438 everyBar
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
439 .selectAll("g.bars")
3330
0e442b547f6d mocking fairway_availability
Thomas Junk <thomas.junk@intevation.de>
parents: 3327
diff changeset
440 .data(d => d.lowerLevels)
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
441 .enter()
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
442 .append("rect")
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
443 .on("mouseover", function() {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
444 d3.select(this).attr("opacity", "0.8");
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
445 d3.select("#tooltip").attr("opacity", 1);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
446 })
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
447 .on("mouseout", function() {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
448 d3.select(this).attr("opacity", 1);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
449 d3.select("#tooltip").attr("opacity", 0);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
450 })
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
451 .on("mousemove", function(d) {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
452 let y = d3.mouse(this)[1];
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
453 const dy = document
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
454 .querySelector(".diagram-container")
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
455 .getBoundingClientRect().left;
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
456 const value = Number.parseFloat(hoursInDays(d.height)).toFixed(2);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
457 d3.select("#tooltip")
3874
7b6a74919051 client: available fairway depth diagram: rounding day numbers
Markus Kottlaender <markus@intevation.de>
parents: 3717
diff changeset
458 .text(Math.round(value))
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
459 .attr("y", y - 10)
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
460 .attr("x", d3.event.pageX - dy);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
461 //d3.event.pageX gives coordinates relative to SVG
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
462 //dy gives offset of svg on page
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
463 })
3347
cd745be63f71 available_fairway_depth: draw lower levels refactored
Thomas Junk <thomas.junk@intevation.de>
parents: 3333
diff changeset
464 .attr("y", d => {
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
465 return (
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
466 2 * yScale(0) - yScale(hoursInDays(d.translateY)) + this.paddingTop
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
467 );
3347
cd745be63f71 available_fairway_depth: draw lower levels refactored
Thomas Junk <thomas.junk@intevation.de>
parents: 3333
diff changeset
468 })
3128
1610d3042bbb fairway_availability: generative code fixed
Thomas Junk <thomas.junk@intevation.de>
parents: 3125
diff changeset
469 .attr("height", d => {
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
470 return yScale(0) - yScale(hoursInDays(d.height));
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
471 })
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
472 .attr("x", ldcOffset + spaceBetween / 2)
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
473 .attr("width", widthPerItem - ldcOffset - spaceBetween)
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
474 .attr("fill", (d, i) => {
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
475 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
476 });
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
477 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
478 fnheight({ name, yScale }) {
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
479 return d => yScale(0) - yScale(hoursInDays(d[name]));
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
480 },
3914
9440d2922097 client: available fairwaydepth diagram: adjust width of ldc bar, draw 0-tick line as solid line
Markus Kottlaender <markus@intevation.de>
parents: 3911
diff changeset
481 drawLDC({ everyBar, yScale, widthPerItem, spaceBetween, ldcOffset }) {
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
482 const height = this.fnheight({ name: "ldc", yScale });
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
483 everyBar
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
484 .append("rect")
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
485 .on("mouseover", function() {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
486 d3.select(this).attr("opacity", "0.8");
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
487 d3.select("#tooltip").attr("opacity", 1);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
488 })
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
489 .on("mouseout", function() {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
490 d3.select(this).attr("opacity", 1);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
491 d3.select("#tooltip").attr("opacity", 0);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
492 })
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
493 .on("mousemove", function(d) {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
494 let y = d3.mouse(this)[1];
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
495 const dy = document
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
496 .querySelector(".diagram-container")
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
497 .getBoundingClientRect().left;
3371
f76a694f7f7b available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents: 3360
diff changeset
498 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
499 d3.select("#tooltip")
3874
7b6a74919051 client: available fairway depth diagram: rounding day numbers
Markus Kottlaender <markus@intevation.de>
parents: 3717
diff changeset
500 .text(Math.round(value))
3410
e5bc8f4924cb afd: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3408
diff changeset
501 .attr("y", y - 50)
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
502 .attr("x", d3.event.pageX - dy);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
503 //d3.event.pageX gives coordinates relative to SVG
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
504 //dy gives offset of svg on page
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
505 })
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
506 .attr("y", yScale(0))
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
507 .attr("height", height)
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
508 .attr("x", spaceBetween / 2)
3914
9440d2922097 client: available fairwaydepth diagram: adjust width of ldc bar, draw 0-tick line as solid line
Markus Kottlaender <markus@intevation.de>
parents: 3911
diff changeset
509 .attr("width", widthPerItem - ldcOffset - spaceBetween)
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
510 .attr(
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
511 "transform",
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
512 d => `translate(0 ${this.paddingTop + -1 * height(d)})`
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
513 )
3216
ee6a4e8af766 available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents: 3213
diff changeset
514 .attr("fill", this.$options.COLORS.LDC)
ee6a4e8af766 available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents: 3213
diff changeset
515 .attr("id", "ldc");
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
516 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
517 drawHighestLevel({
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
518 everyBar,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
519 yScale,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
520 widthPerItem,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
521 spaceBetween,
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
522 ldcOffset
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
523 }) {
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
524 const height = this.fnheight({ name: "highestLevel", yScale });
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
525 everyBar
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
526 .append("rect")
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
527 .on("mouseover", function() {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
528 d3.select(this).attr("opacity", "0.8");
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
529 d3.select("#tooltip").attr("opacity", 1);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
530 })
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
531 .on("mouseout", function() {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
532 d3.select(this).attr("opacity", 1);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
533 d3.select("#tooltip").attr("opacity", 0);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
534 })
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
535 .on("mousemove", function(d) {
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
536 let y = d3.mouse(this)[1];
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
537 const dy = document
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
538 .querySelector(".diagram-container")
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
539 .getBoundingClientRect().left;
3371
f76a694f7f7b available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents: 3360
diff changeset
540 const value = Number.parseFloat(hoursInDays(d.highestLevel)).toFixed(
f76a694f7f7b available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents: 3360
diff changeset
541 2
f76a694f7f7b available_fairway_depth: fix tooltip
Thomas Junk <thomas.junk@intevation.de>
parents: 3360
diff changeset
542 );
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
543 d3.select("#tooltip")
3874
7b6a74919051 client: available fairway depth diagram: rounding day numbers
Markus Kottlaender <markus@intevation.de>
parents: 3717
diff changeset
544 .text(Math.round(value))
3410
e5bc8f4924cb afd: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3408
diff changeset
545 .attr("y", y - 50)
3360
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
546 .attr("x", d3.event.pageX - dy);
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
547 //d3.event.pageX gives coordinates relative to SVG
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
548 //dy gives offset of svg on page
b2ccfebd5616 available_fairway_depth: tooltips
Thomas Junk <thomas.junk@intevation.de>
parents: 3349
diff changeset
549 })
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
550 .attr("y", yScale(0))
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
551 .attr("height", height)
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
552 .attr("x", ldcOffset + spaceBetween / 2)
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
553 .attr("width", widthPerItem - ldcOffset - spaceBetween)
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
554 .attr(
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
555 "transform",
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
556 d => `translate(0 ${this.paddingTop + -1 * height(d)})`
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
557 )
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
558 .attr("fill", this.$options.COLORS.HIGHEST);
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
559 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
560 drawLabelPerBar({ everyBar, dimensions, widthPerItem }) {
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
561 everyBar
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
562 .append("text")
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
563 .text(d => d.label)
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
564 .attr("y", dimensions.mainHeight + this.paddingTop - 5)
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
565 .attr("x", widthPerItem / 2)
3717
eab5e934c37d client: available fairway depth diagram: decreased label font-size to avoid overlapping at least a little bit better
Markus Kottlaender <markus@intevation.de>
parents: 3716
diff changeset
566 .attr("text-anchor", "middle")
3922
32b656e77e2f client: fwa diagrams: better alignment of tick labels in pdf
Markus Kottlaender <markus@intevation.de>
parents: 3920
diff changeset
567 .attr("font-size", 10);
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
568 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
569 drawScaleLabel({ diagram, dimensions }) {
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
570 diagram
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
571 .append("text")
3135
Thomas Junk <thomas.junk@intevation.de>
parents: 3134
diff changeset
572 .text(this.$options.LEGEND)
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
573 .attr("text-anchor", "middle")
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
574 .attr("x", 0)
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
575 .attr("y", 0)
3903
7e519a11de4e client: available fairway depth diagram: adjusted position of y axis label
Markus Kottlaender <markus@intevation.de>
parents: 3891
diff changeset
576 .attr("dy", "20")
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
577 .attr(
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
578 "transform",
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
579 `translate(2, ${(dimensions.mainHeight + this.paddingTop) /
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
580 2}), rotate(-90)`
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
581 );
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
582 },
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
583 drawScale({ diagram, dimensions, yScale }) {
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
584 const yAxisLeft = d3
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
585 .axisLeft()
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
586 .tickSizeInner(
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
587 dimensions.width - this.scalePaddingLeft - this.scalePaddingRight
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
588 )
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
589 .tickSizeOuter(0)
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
590 .scale(yScale);
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
591 const yAxisRight = d3
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
592 .axisRight()
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
593 .tickSizeInner(
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
594 dimensions.width - this.scalePaddingLeft - this.scalePaddingRight
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
595 )
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
596 .tickSizeOuter(0)
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
597 .scale(yScale);
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
598
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
599 diagram
3125
383720d8d98e fairway_availability: generative code for diagram added
Thomas Junk <thomas.junk@intevation.de>
parents: 3033
diff changeset
600 .append("g")
3876
0c6ef9e655fc client: available fairway depth diagrams: added second y-axis on the right
Markus Kottlaender <markus@intevation.de>
parents: 3874
diff changeset
601 .attr(
0c6ef9e655fc client: available fairway depth diagrams: added second y-axis on the right
Markus Kottlaender <markus@intevation.de>
parents: 3874
diff changeset
602 "transform",
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
603 `translate(${dimensions.width - this.scalePaddingRight} ${
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
604 this.paddingTop
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
605 })`
3876
0c6ef9e655fc client: available fairway depth diagrams: added second y-axis on the right
Markus Kottlaender <markus@intevation.de>
parents: 3874
diff changeset
606 )
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
607 .call(yAxisLeft)
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
608 .selectAll(".tick text")
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
609 .attr("fill", "black")
3922
32b656e77e2f client: fwa diagrams: better alignment of tick labels in pdf
Markus Kottlaender <markus@intevation.de>
parents: 3920
diff changeset
610 .attr("font-size", 10)
32b656e77e2f client: fwa diagrams: better alignment of tick labels in pdf
Markus Kottlaender <markus@intevation.de>
parents: 3920
diff changeset
611 .attr("dy", 3)
3878
1ff97bb72a24 client: available fairway depth diagrams: made more space for tick labels
Markus Kottlaender <markus@intevation.de>
parents: 3877
diff changeset
612 .attr("dx", -3)
3267
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
613 .select(function() {
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
614 return this.parentNode;
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
615 })
b07b4cca5e34 client: diagram-template: implement pdf-template for fairway availability diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 3239
diff changeset
616 .selectAll(".tick line")
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
617 .attr("stroke-dasharray", 5)
3905
3c095749efb2 client: available fairwaydepth diagrams: emphasize 0-ticks
Markus Kottlaender <markus@intevation.de>
parents: 3903
diff changeset
618 .attr("stroke", "#ccc")
3c095749efb2 client: available fairwaydepth diagrams: emphasize 0-ticks
Markus Kottlaender <markus@intevation.de>
parents: 3903
diff changeset
619 .select(function() {
3c095749efb2 client: available fairwaydepth diagrams: emphasize 0-ticks
Markus Kottlaender <markus@intevation.de>
parents: 3903
diff changeset
620 return this.parentNode;
3c095749efb2 client: available fairwaydepth diagrams: emphasize 0-ticks
Markus Kottlaender <markus@intevation.de>
parents: 3903
diff changeset
621 })
3c095749efb2 client: available fairwaydepth diagrams: emphasize 0-ticks
Markus Kottlaender <markus@intevation.de>
parents: 3903
diff changeset
622 .filter(d => d === 0)
3c095749efb2 client: available fairwaydepth diagrams: emphasize 0-ticks
Markus Kottlaender <markus@intevation.de>
parents: 3903
diff changeset
623 .selectAll(".tick line")
3914
9440d2922097 client: available fairwaydepth diagram: adjust width of ldc bar, draw 0-tick line as solid line
Markus Kottlaender <markus@intevation.de>
parents: 3911
diff changeset
624 .attr("stroke-dasharray", "none")
3905
3c095749efb2 client: available fairwaydepth diagrams: emphasize 0-ticks
Markus Kottlaender <markus@intevation.de>
parents: 3903
diff changeset
625 .attr("stroke", "#333");
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
626 diagram
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
627 .append("g")
3879
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
628 .attr(
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
629 "transform",
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
630 `translate(${this.scalePaddingLeft} ${this.paddingTop})`
20be498adaf7 client: available fairway depth diagram: use available space
Markus Kottlaender <markus@intevation.de>
parents: 3878
diff changeset
631 )
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
632 .call(yAxisRight)
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
633 .selectAll(".tick text")
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
634 .attr("fill", "black")
3922
32b656e77e2f client: fwa diagrams: better alignment of tick labels in pdf
Markus Kottlaender <markus@intevation.de>
parents: 3920
diff changeset
635 .attr("font-size", 10)
32b656e77e2f client: fwa diagrams: better alignment of tick labels in pdf
Markus Kottlaender <markus@intevation.de>
parents: 3920
diff changeset
636 .attr("dy", 3)
3878
1ff97bb72a24 client: available fairway depth diagrams: made more space for tick labels
Markus Kottlaender <markus@intevation.de>
parents: 3877
diff changeset
637 .attr("dx", 3)
3877
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
638 .select(function() {
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
639 return this.parentNode;
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
640 })
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
641 .selectAll(".tick line")
d82b5e5868e3 client: available fairway depth diagrams: draw horizontal scale lines for better readability
Markus Kottlaender <markus@intevation.de>
parents: 3876
diff changeset
642 .attr("stroke", "transparent");
3909
2e7f191bba27 available_fairwaydepth: factor out side-effects from diagram rendering
Thomas Junk <thomas.junk@intevation.de>
parents: 3905
diff changeset
643 diagram.selectAll(".domain").attr("stroke", "black");
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
644 }
3135
Thomas Junk <thomas.junk@intevation.de>
parents: 3134
diff changeset
645 },
3282
707d4435aff3 redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents: 3280
diff changeset
646 watch: {
707d4435aff3 redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents: 3280
diff changeset
647 fwData() {
707d4435aff3 redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents: 3280
diff changeset
648 this.drawDiagram();
707d4435aff3 redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents: 3280
diff changeset
649 }
707d4435aff3 redraw diagram on change of data
Thomas Junk <thomas.junk@intevation.de>
parents: 3280
diff changeset
650 },
3216
ee6a4e8af766 available_fairway_depth: legend POC
Thomas Junk <thomas.junk@intevation.de>
parents: 3213
diff changeset
651 LEGEND: app.$gettext("Sum of days"),
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
652 COLORS: {
3288
c2d753ef5aa1 fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents: 3287
diff changeset
653 LDC: "#cdcdcd",
c2d753ef5aa1 fairway_availability: sane defaults and ISC colors for diagram
Thomas Junk <thomas.junk@intevation.de>
parents: 3287
diff changeset
654 HIGHEST: "#3675ff",
3291
6996aa1d2df9 available_fairway_depth: switched colors
Thomas Junk <thomas.junk@intevation.de>
parents: 3288
diff changeset
655 REST: ["#782121", "#ff6c6c", "#ffaaaa"]
3153
8159bd2aaf93 fairway_depth_diagram: display of mockdata
Thomas Junk <thomas.junk@intevation.de>
parents: 3135
diff changeset
656 }
3033
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
657 };
c2c1e3e3af1c Available fairway depth: rudimentary thoughts / prototype. Tbd;
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
658 </script>