comparison client/src/store/gauges.js @ 2751:5da81634bdc4

client: waterlevel diagram: implemented nash-sutcliffe Since there is no real data available currently, I left a commented block of demo data in client/src/store/gauges.js:L139. Uncomment that block to see the coefficients in the diagram.
author Markus Kottlaender <markus@intevation.de>
date Thu, 21 Mar 2019 12:33:43 +0100
parents 7dcca9649a61
children 71e7237110ba
comparison
equal deleted inserted replaced
2750:6446bf6d2a89 2751:5da81634bdc4
20 const init = () => { 20 const init = () => {
21 return { 21 return {
22 gauges: [], 22 gauges: [],
23 selectedGaugeISRS: null, 23 selectedGaugeISRS: null,
24 waterlevels: [], 24 waterlevels: [],
25 nashSutcliffe: null,
25 dateFrom: dateFrom, 26 dateFrom: dateFrom,
26 dateTo: new Date() 27 dateTo: new Date()
27 }; 28 };
28 }; 29 };
29 30
45 selectedGaugeISRS: (state, isrs) => { 46 selectedGaugeISRS: (state, isrs) => {
46 state.selectedGaugeISRS = isrs; 47 state.selectedGaugeISRS = isrs;
47 }, 48 },
48 waterlevels: (state, data) => { 49 waterlevels: (state, data) => {
49 state.waterlevels = data; 50 state.waterlevels = data;
51 },
52 nashSutcliffe: (state, data) => {
53 state.nashSutcliffe = data;
50 }, 54 },
51 dateFrom: (state, dateFrom) => { 55 dateFrom: (state, dateFrom) => {
52 state.dateFrom = dateFrom; 56 state.dateFrom = dateFrom;
53 }, 57 },
54 dateTo: (state, dateTo) => { 58 dateTo: (state, dateTo) => {
122 .catch(error => { 126 .catch(error => {
123 commit("waterlevels", []); 127 commit("waterlevels", []);
124 reject(error); 128 reject(error);
125 }); 129 });
126 }); 130 });
131 },
132 loadNashSutcliffe({ state, commit }) {
133 return new Promise((resolve, reject) => {
134 HTTP.get(`/data/nash-sutcliffe/${state.selectedGaugeISRS}`, {
135 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
136 })
137 .then(response => {
138 commit("nashSutcliffe", response.data);
139 // dest data
140 // commit("nashSutcliffe", {
141 // when: "2019-03-20T10:38:05.687",
142 // coeffs: [
143 // {
144 // value: 0.814,
145 // samples: 18,
146 // hours: 24
147 // },
148 // {
149 // value: 0.319,
150 // samples: 36,
151 // hours: 48
152 // },
153 // {
154 // value: -0.20546757,
155 // samples: 54,
156 // hours: 72
157 // }
158 // ]
159 // });
160 resolve(response.data);
161 })
162 .catch(error => {
163 commit("nashSutcliffe", null);
164 reject(error);
165 });
166 });
127 } 167 }
128 } 168 }
129 }; 169 };