annotate client/src/components/TimeSlider.vue @ 5062:da28a58eb10d time-sliding

client: correct showing of time in toolbar according to zoom level(selected time)
author Fadi Abbud <fadi.abbud@intevation.de>
date Mon, 09 Mar 2020 15:38:00 +0100
parents 37371727f704
children 43bebcc8961f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
1 <template>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
2 <div
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
3 id="slider"
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
4 :class="[
5037
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
5 'd-flex box ui-element rounded bg-white flex-row',
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
6 { expanded: showTimeSlider }
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
7 ]"
5058
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
8 :style="reposition"
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
9 >
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
10 <div class="d-flex mt-1 mr-1">
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
11 <input
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
12 class="form-control-sm mr-1"
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
13 type="date"
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
14 v-model="dateSelection"
5039
aec0923f9c52 icon shows now date and time
Thomas Junk <thomas.junk@intevation.de>
parents: 5038
diff changeset
15 min="2015-01-01"
5048
700758d22737 client: (minor) adjust max value for input field
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5046
diff changeset
16 :max="new Date().toISOString().split('T')[0]"
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
17 />
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
18 <input
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
19 type="time"
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
20 min="00:00"
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
21 max="23:59"
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
22 v-model="timeSelection"
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
23 class="form-control-sm"
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
24 />
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
25 </div>
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
26 <div
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
27 id="sliderContainer"
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
28 class="d-flex sliderContainer"
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
29 style="width: 98%;"
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
30 ></div>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
31 <div @click="close" class="d-flex box-control mr-0" style="width: 2%;">
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
32 <font-awesome-icon icon="times"></font-awesome-icon>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
33 </div>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
34 </div>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
35 </template>
5037
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
36 <style lang="sass" scoped>
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
37 #slider
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
38 position: absolute
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
39 bottom: 0
5057
abe3a70526a6 fix accidental deletion of current input
Thomas Junk <thomas.junk@intevation.de>
parents: 5056
diff changeset
40 min-width: 100vw
5037
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
41 &.expanded
5057
abe3a70526a6 fix accidental deletion of current input
Thomas Junk <thomas.junk@intevation.de>
parents: 5056
diff changeset
42 max-height: 100%
abe3a70526a6 fix accidental deletion of current input
Thomas Junk <thomas.junk@intevation.de>
parents: 5056
diff changeset
43 max-width: 100%
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
44 margin: 0
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
45 </style>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
46 <script>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
47 /* This is Free Software under GNU Affero General Public License v >= 3.0
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
48 * without warranty, see README.md and license for details.
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
49 *
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
50 * SPDX-License-Identifier: AGPL-3.0-or-later
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
51 * License-Filename: LICENSES/AGPL-3.0.txt
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
52 *
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
53 * Copyright (C) 2020 by via donau
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
54 * – Österreichische Wasserstraßen-Gesellschaft mbH
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
55 * Software engineering by Intevation GmbH
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
56 *
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
57 * Author(s):
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
58 * Fadi Abbud <fadiabbud@intevation.de>
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
59 */
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
60 import { mapState } from "vuex";
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
61 import * as d3 from "d3";
5043
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
62 import app from "@/main";
5044
ca5b1b5a553a client: date localization for time slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5043
diff changeset
63 import { localeDateString } from "@/lib/datelocalization";
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
64 import { format, setHours, setMinutes } from "date-fns";
5043
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
65
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
66 let zoom = null;
5061
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
67 let xScale = null;
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
68 let xAxis = null;
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
69
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
70 export default {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
71 name: "timeslider",
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
72 data() {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
73 return {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
74 newX: null
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
75 };
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
76 },
5040
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
77 watch: {
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
78 ongoingRefresh() {
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
79 if (this.ongoingRefresh) return;
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
80 this.$store.commit("application/setSelectedTime", new Date());
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
81 this.$nextTick(this.redrawSlider);
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
82 }
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
83 },
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
84 computed: {
5062
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
85 ...mapState("application", [
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
86 "showTimeSlider",
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
87 "paneSetup",
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
88 "isSelectedTimeHourly"
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
89 ]),
5040
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
90 ...mapState("map", ["ongoingRefresh"]),
5058
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
91 reposition() {
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
92 // reposition time slider in case of opened diagram
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
93 if (["DEFAULT", "COMPARESURVEYS"].indexOf(this.paneSetup) === -1) {
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
94 const height = document.getElementById("main").clientHeight + 1;
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
95 return `bottom: ${height}px`;
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
96 } else {
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
97 return "";
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
98 }
e916651d3f93 client: adjust time-slider position in case of opened diagram
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5057
diff changeset
99 },
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
100 dateSelection: {
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
101 get() {
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
102 const date = this.$store.state.application.selectedTime;
5045
a7cda81bf96f client: better formatting of time
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5044
diff changeset
103 return format(date, "YYYY-MM-DD");
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
104 },
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
105 set(value) {
5057
abe3a70526a6 fix accidental deletion of current input
Thomas Junk <thomas.junk@intevation.de>
parents: 5056
diff changeset
106 if (!value) return;
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
107 const date = new Date(value);
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
108 this.$store.commit("application/setSelectedTime", date);
5060
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
109 this.rescaleSlider(50);
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
110 }
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
111 },
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
112 timeSelection: {
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
113 get() {
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
114 const time = this.$store.state.application.selectedTime;
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
115 return format(time, "HH:mm");
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
116 },
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
117 set(value) {
5057
abe3a70526a6 fix accidental deletion of current input
Thomas Junk <thomas.junk@intevation.de>
parents: 5056
diff changeset
118 if (!value) return;
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
119 let date = this.selectedTime;
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
120 date = setHours(date, value.split(":")[0]);
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
121 date = setMinutes(date, value.split(":")[1]);
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
122 this.$store.commit("application/setSelectedTime", date);
5060
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
123 this.rescaleSlider(800);
5046
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
124 }
b5e77c43fb8b client: add Time picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5045
diff changeset
125 },
5037
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
126 selectedTime: {
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
127 get() {
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
128 return this.$store.state.application.selectedTime;
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
129 },
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
130 set(value) {
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
131 this.$store.commit("application/setSelectedTime", value);
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
132 }
9d288d9b851b client: move selectedTime to store
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5036
diff changeset
133 }
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
134 },
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
135 methods: {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
136 close() {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
137 this.$store.commit("application/showTimeSlider", false);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
138 },
5061
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
139
5060
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
140 rescaleSlider(scaleFactor) {
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
141 const tx =
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
142 -scaleFactor *
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
143 this.getScale()(d3.isoParse(this.selectedTime.toISOString())) +
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
144 document.getElementById("sliderContainer").clientWidth / 2;
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
145 var t = d3.zoomIdentity.translate(tx, 0).scale(scaleFactor);
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
146 this.getScale().domain(t.rescaleX(this.getScale()));
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
147 d3.select(".zoom").call(zoom.transform, t);
ed1d963017e7 client: improve behavior of time-slider during the use of date/time picker
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5058
diff changeset
148 },
5040
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
149 redrawSlider() {
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
150 this.createSlider();
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
151 zoom.translateTo(
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
152 d3.select(".line"),
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
153 this.newX(d3.isoParse(this.selectedTime.toISOString())),
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
154 1
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
155 );
066b76ef5e6a selected time is refreshed after reloads
Thomas Junk <thomas.junk@intevation.de>
parents: 5039
diff changeset
156 },
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
157 createSlider() {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
158 const element = document.getElementById("sliderContainer");
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
159 const svgWidth = element ? element.clientWidth : 0,
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
160 svgHeight = 40,
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
161 marginTop = 20,
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
162 marginLeft = 0;
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
163
5044
ca5b1b5a553a client: date localization for time slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5043
diff changeset
164 d3.timeFormatDefaultLocale(localeDateString);
5061
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
165 xScale = this.getScale();
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
166 this.newX = this.getScale();
5061
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
167 xAxis = this.getAxes();
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
168 d3.select(".sliderContainer svg").remove();
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
169 let svg = d3
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
170 .select(".sliderContainer")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
171 .append("svg")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
172 .attr("width", svgWidth)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
173 .attr("height", svgHeight);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
174
5038
9d26f67dd916 client: add date picker to the time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5037
diff changeset
175 zoom = d3
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
176 .zoom()
5041
abe9b75686ba client: set wheeldelta to facilitate quick changes of zoomlevel
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5040
diff changeset
177 .scaleExtent([0.8, 102000])
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
178 .translateExtent([[0, 0], [svgWidth, svgHeight]])
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
179 .extent([[0, 0], [(svgWidth, svgHeight)]])
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
180 .on("zoom", this.zoomed);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
181
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
182 svg
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
183 .append("g")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
184 .attr("class", "axis--x")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
185 .attr("transform", `translate(${marginLeft}, ${marginTop})`)
5061
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
186 .call(xAxis);
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
187
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
188 // create rectanlge on the slider area to capture mouse events
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
189 const eventRect = svg
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
190 .append("rect")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
191 .attr("id", "zoom")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
192 .attr("class", "zoom")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
193 .attr("width", svgWidth)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
194 .attr("height", svgHeight)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
195 .attr("fill", "white")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
196 .attr("opacity", 0.2)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
197 .on("mouseover", () => {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
198 svg.select(".zoom").attr("cursor", "move");
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
199 });
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
200 eventRect.call(zoom).on("click", this.onClick);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
201
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
202 const toIsoDate = d => {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
203 return d.toISOString();
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
204 };
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
205
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
206 let drag = d3
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
207 .drag()
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
208 .on("start", () => {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
209 d3.select(".line")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
210 .raise()
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
211 .classed("active", true);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
212 })
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
213 .on("drag", this.onDrag)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
214 .on("end", () => {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
215 d3.select(".line").classed("active", false);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
216 });
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
217
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
218 // Create cursor to indicate to the selected time
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
219 svg
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
220 .append("rect")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
221 .attr("class", "line")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
222 .attr("id", "scrubber")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
223 .attr("x", this.newX(d3.isoParse(toIsoDate(this.selectedTime))))
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
224 .attr("y", 0)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
225 .attr("width", 2)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
226 .attr("height", svgHeight)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
227 .attr("stroke", "#17a2b8")
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
228 .attr("stroke-width", 2)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
229 .attr("opacity", 0.6)
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
230 .on("mouseover", () => {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
231 svg.select(".line").attr("cursor", "e-resize");
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
232 })
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
233 .call(drag);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
234 },
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
235 getScale() {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
236 return d3
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
237 .scaleTime()
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
238 .range([0, document.getElementById("sliderContainer").clientWidth || 0])
5039
aec0923f9c52 icon shows now date and time
Thomas Junk <thomas.junk@intevation.de>
parents: 5038
diff changeset
239 .domain([d3.isoParse(new Date("2015-01-01")), d3.isoParse(new Date())]);
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
240 },
5043
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
241 getAxes() {
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
242 const axesFormat = date => {
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
243 return (d3.timeSecond(date) < date
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
244 ? d3.timeFormat(".%L")
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
245 : d3.timeMinute(date) < date
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
246 ? d3.timeFormat(":%S")
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
247 : d3.timeHour(date) < date
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
248 ? d3.timeFormat("%H:%M")
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
249 : d3.timeDay(date) < date
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
250 ? d3.timeFormat("%H:%M")
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
251 : d3.timeMonth(date) < date
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
252 ? d3.timeWeek(date) < date
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
253 ? d3.timeFormat(app.$gettext("%a %d"))
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
254 : d3.timeFormat(app.$gettext("%b %d"))
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
255 : d3.timeYear(date) < date
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
256 ? d3.timeFormat("%B")
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
257 : d3.timeFormat("%Y"))(date);
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
258 };
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
259 return d3
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
260 .axisBottom(this.newX)
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
261 .ticks(12)
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
262 .tickFormat(axesFormat);
bae2548dc484 client: improve the axes labeling for time-slider
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5041
diff changeset
263 },
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
264 zoomed() {
5061
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
265 this.newX = d3.event.transform.rescaleX(xScale);
5062
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
266 const currentScaleFactor = d3.event.transform.k;
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
267 const isHourly = currentScaleFactor > 400;
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
268 if (isHourly != this.isSelectedTimeHourly)
da28a58eb10d client: correct showing of time in toolbar according to zoom level(selected time)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5061
diff changeset
269 this.$store.commit("application/setSelectedTimeHourly", isHourly);
5061
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
270 xAxis.scale(this.newX);
37371727f704 client: improve time-slider code
Fadi Abbud <fadi.abbud@intevation.de>
parents: 5060
diff changeset
271 d3.select(".axis--x").call(xAxis);
5036
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
272 d3.select(".line").attr("x", this.newX(d3.isoParse(this.selectedTime)));
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
273 },
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
274 onClick() {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
275 // Extract the click location
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
276 let point = d3.mouse(document.getElementById("zoom")),
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
277 p = { x: point[0], y: point[1] };
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
278 d3.select(".line").attr("x", p.x);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
279 this.selectedTime = d3.isoParse(this.newX.invert(p.x + 2));
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
280 },
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
281 onDrag() {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
282 this.selectedTime = d3.isoParse(this.newX.invert(d3.event.x + 2));
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
283 d3.select(".line").attr("x", d3.event.x);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
284 }
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
285 },
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
286 mounted() {
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
287 setTimeout(this.createSlider, 150);
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
288 }
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
289 };
8f421cd3c746 client: Implemented first version of time-sliding
Fadi Abbud <fadi.abbud@intevation.de>
parents:
diff changeset
290 </script>