|
91 | 91 | it.dRevert.innerHTML='Revert zoom'; |
92 | 92 | it.dRevert.style.position = "absolute"; |
93 | 93 | it.dRevert.style.zIndex = 1000; |
94 | | - it.dRevert.style.top = '10px'; |
| 94 | + it.dRevert.style.bottom = '15px'; |
95 | 95 | it.dRevert.style.right = '10px'; |
96 | 96 | it.dRevert.style.borderRadius = '0.25rem'; |
97 | 97 | it.dRevert.style.border = it.context.theme == 'dark' ? '1px solid #758591' : '1px solid black'; |
|
101 | 101 | it.dRevert.addEventListener('click', function(e){ |
102 | 102 | it.hasInnerRequest = true; |
103 | 103 | // last |
104 | | - it.context.query.request(_.first(it.historyRequests), function (data, his) { |
| 104 | + let firstHistoryRequest = _.first(it.historyRequests); |
| 105 | + it.context.query.request({from: firstHistoryRequest.from, till: firstHistoryRequest.till}, function (data, his) { |
105 | 106 | it.hasInnerRequest = true; |
106 | 107 | // it.historyRequests.pop(); |
107 | 108 | it.historyRequests = []; |
|
133 | 134 | "</select>"; |
134 | 135 | it.dFormat.style.position = "absolute"; |
135 | 136 | it.dFormat.style.zIndex = 1000; |
136 | | - it.dFormat.style.top = '10px'; |
137 | | - it.dFormat.style.left = '10px'; |
| 137 | + it.dFormat.style.bottom = '15px'; |
| 138 | + it.dFormat.style.left = '0'; |
| 139 | + it.dFormat.style.width = '100%'; |
| 140 | + it.dFormat.style.textAlign = 'center'; |
138 | 141 | it.$el.appendChild(it.dFormat); |
139 | 142 | it.dFormat.querySelector('select').addEventListener('change', function(e){ |
140 | | - if (Array.isArray(it.historyRequests)){ |
141 | | - it.historyRequests.push(it.context.query.variables); |
142 | | - }else{ |
143 | | - it.historyRequests = [it.context.query.variables]; |
144 | | - } |
| 143 | + // if (Array.isArray(it.historyRequests)){ |
| 144 | + // it.historyRequests.push(it.context.query.variables); |
| 145 | + // }else{ |
| 146 | + // it.historyRequests = [it.context.query.variables]; |
| 147 | + // } |
145 | 148 | it.hasInnerRequest = true; |
146 | 149 | it.context.query.request({dateFormat: e.target.value}, function (data, his) { |
147 | 150 | it.hasInnerRequest = true; |
|
180 | 183 | case 'datetime': |
181 | 184 | // ISO 8601 — 2014-12-06T10:30:00-0800 |
182 | 185 | // tmp_data = moment(tmp_data); |
183 | | - tmp_data = {v: new Date(tmp_data), f: it.setPattern(tmp_data, it.context.query.variables.dateFormat)}; |
| 186 | + tmp_data = it.setPattern(tmp_data, it.context.query.variables.dateFormat); |
184 | 187 | break; |
185 | 188 | case 'timeofday': |
186 | 189 | // 8:30am would be: [8, 30, 0, 0] |
|
200 | 203 | setPattern: function(date, dateFormat){ |
201 | 204 | switch(dateFormat){ |
202 | 205 | case '%Y': |
203 | | - return moment(date).format('YYYY'); |
| 206 | + return {v: moment(date).toDate(), f: moment.utc(date).format('YYYY')}; |
204 | 207 | break; |
205 | 208 | case '%Y-%m': |
206 | | - return moment(date).format('MMM YYYY'); |
| 209 | + return {v: moment(date).toDate(), f: moment.utc(date).format('MMM YYYY')}; |
207 | 210 | break; |
208 | 211 | case '%Y-%m-%d': |
209 | 212 | default: |
210 | | - return moment(date).format('MMM DD, YYYY'); |
| 213 | + return {v: moment(date).toDate(), f: moment(date).format('MMM DD, YYYY')}; |
211 | 214 | } |
212 | 215 | }, |
213 | 216 | setTill: function(till, dateFormat){ |
|
228 | 231 | case '%Y': |
229 | 232 | return { |
230 | 233 | hAxis:{ |
231 | | - title: 'Years', |
| 234 | + // title: 'Years', |
232 | 235 | format: 'yyyy', |
233 | 236 | gridlines: { |
234 | | - interval: [1], |
| 237 | + // interval: [1], |
235 | 238 | units: { |
236 | 239 | years: {format: ['yyyy']}, |
237 | 240 | // months: {format: ['MM/yy']}, |
|
244 | 247 | months: {format: [' ']}, |
245 | 248 | days: {format: [' ']}, |
246 | 249 | }, |
247 | | - color: 'grey', |
| 250 | + color: 'transparent', |
248 | 251 | } |
249 | 252 | } |
250 | 253 | }; |
251 | 254 | break; |
252 | 255 | case '%Y-%m-%d': |
253 | 256 | return { |
254 | 257 | hAxis:{ |
255 | | - title: 'Days', |
| 258 | + // title: 'Days', |
256 | 259 | format: 'dd/MM/yy', |
257 | 260 | gridlines: { |
258 | 261 | units: { |
259 | 262 | years: {format: ['yyyy']}, |
260 | 263 | months: {format: ['MM/yy']}, |
261 | | - days: {format: ['dd']}, |
| 264 | + days: {format: ['dd/MM/yy']}, |
262 | 265 | }, |
263 | 266 | }, |
264 | 267 | minorGridlines: { |
265 | 268 | units: { |
266 | | - years: {format: ['yyyy']}, |
267 | | - months: {format: ['MM']}, |
268 | | - days: {format: ['dd']}, |
| 269 | + years: {format: [' ']}, |
| 270 | + months: {format: [' ']}, |
| 271 | + days: {format: [' ']}, |
269 | 272 | }, |
270 | | - color: 'grey', |
| 273 | + color: 'transparent', |
271 | 274 | } |
272 | 275 | } |
273 | 276 | }; |
274 | 277 | break; |
275 | 278 | case '%Y-%m-%dT%H': |
276 | 279 | return { |
277 | 280 | hAxis:{ |
278 | | - title: 'Hours' |
| 281 | + // title: 'Hours' |
279 | 282 | } |
280 | 283 | }; |
281 | 284 | break; |
282 | 285 | case '%Y-%m': |
283 | 286 | default: |
284 | 287 | return { |
285 | 288 | hAxis:{ |
286 | | - title: 'Months', |
287 | | - format: 'dd/MM/yy', |
| 289 | + // title: 'Months', |
| 290 | + format: 'MM/yy', |
288 | 291 | gridlines: { |
289 | 292 | units: { |
290 | 293 | years: {format: ['yyyy']}, |
291 | 294 | months: {format: ['MM/yy']}, |
292 | | - days: {format: ['dd']}, |
| 295 | + days: {format: [' ']}, |
293 | 296 | }, |
294 | 297 | }, |
295 | 298 | minorGridlines: { |
296 | 299 | units: { |
297 | | - years: {format: ['yyyy']}, |
298 | | - months: {format: ['MM']}, |
299 | | - days: {format: ['dd']}, |
| 300 | + years: {format: [' ']}, |
| 301 | + months: {format: [' ']}, |
| 302 | + days: {format: [' ']}, |
300 | 303 | }, |
301 | | - color: 'grey', |
| 304 | + color: 'transparent', |
302 | 305 | } |
303 | 306 | } |
304 | 307 | }; |
|
0 commit comments