Commit 7b5642aef428cd0ec598497637ddbe162dfa5f9c
1 parent
58bfe281
Exists in
master
and in
2 other branches
Normalize time interval for time series.
Showing
3 changed files
with
27 additions
and
19 deletions
Show diff stats
CHANGELOG.md
... | ... | @@ -6,11 +6,9 @@ |
6 | 6 | - [ ] Set the log level to _error_ in production (see `web/run.py`) |
7 | 7 | - [ ] CRON statements to call the cache cleanup and warmup |
8 | 8 | - [ ] Cache warmup (generate for today's default interval) `/cache/warmup` |
9 | -- [ ] Normalize time interval for time series | |
10 | 9 | - [ ] Give the future data another color |
11 | 10 | - [ ] Sort times series by closeness to the sun |
12 | 11 | - [ ] Generate a CDF file (not NetCDF) |
13 | -- [ ] Move the link to the source in the footer | |
14 | 12 | |
15 | 13 | An heliospheric propagation 1D MHD model for solar wind prediction at planets, probes and comets. |
16 | 14 | |
... | ... | @@ -18,6 +16,7 @@ An heliospheric propagation 1D MHD model for solar wind prediction at planets, p |
18 | 16 | |
19 | 17 | ## 1.0.0-rc4 |
20 | 18 | |
19 | +- [x] Normalize time interval for time series | |
21 | 20 | - [x] Make the footer images clickable |
22 | 21 | - [x] Highlight the visits counter |
23 | 22 | - [x] Use a default interval up to 3 weeks in the future | ... | ... |
web/static/js/swapp.js
... | ... | @@ -299,7 +299,10 @@ |
299 | 299 | if (!(id in data)) { |
300 | 300 | console.error("No data for id '" + id + "'.", data); |
301 | 301 | } |
302 | - return this$.time_series.push(new TimeSeries(id, title, target, data[id], this$.parameters[id].active, container)); | |
302 | + return this$.time_series.push(new TimeSeries(id, title, target, data[id], this$.parameters[id].active, container, { | |
303 | + 'started_at': this$.started_at, | |
304 | + 'stopped_at': this$.stopped_at | |
305 | + })); | |
303 | 306 | }); |
304 | 307 | this.time_series.forEach(function(ts){ |
305 | 308 | ts.options['onMouseOver'] = function(){ |
... | ... | @@ -445,6 +448,7 @@ |
445 | 448 | this.parameter = parameter; |
446 | 449 | this.title = title; |
447 | 450 | this.target = target; |
451 | + this.data = data; | |
448 | 452 | this.visible = visible; |
449 | 453 | this.container = container; |
450 | 454 | this.options = options != null |
... | ... | @@ -455,24 +459,26 @@ |
455 | 459 | this.onMouseOut = bind$(this, 'onMouseOut', prototype); |
456 | 460 | this.onMouseOver = bind$(this, 'onMouseOver', prototype); |
457 | 461 | this.onMouseMove = bind$(this, 'onMouseMove', prototype); |
458 | - this.setData(data); | |
459 | 462 | this.init(); |
460 | 463 | } |
461 | 464 | TimeSeries.prototype.toString = function(){ |
462 | 465 | return this.title + " of " + this.target.name; |
463 | 466 | }; |
464 | - TimeSeries.prototype.setData = function(data){ | |
465 | - this.data = data; | |
467 | + TimeSeries.prototype.init = function(){ | |
468 | + var formatMillisecond, formatSecond, formatMinute, formatHour, formatDay, formatWeek, formatMonth, formatYear, multiFormat, clipId, dx, this$ = this; | |
469 | + console.info("Initializing plot of " + this + "…"); | |
466 | 470 | this.xDataExtent = d3.extent(this.data, function(d){ |
467 | 471 | return d.x; |
468 | 472 | }); |
469 | - return this.yDataExtent = d3.extent(this.data, function(d){ | |
473 | + this.yDataExtent = d3.extent(this.data, function(d){ | |
470 | 474 | return d.y; |
471 | 475 | }); |
472 | - }; | |
473 | - TimeSeries.prototype.init = function(){ | |
474 | - var formatMillisecond, formatSecond, formatMinute, formatHour, formatDay, formatWeek, formatMonth, formatYear, multiFormat, clipId, dx, this$ = this; | |
475 | - console.info("Initializing plot of " + this + "…"); | |
476 | + if (this.options['started_at']) { | |
477 | + this.xDataExtent[0] = this.options['started_at']; | |
478 | + } | |
479 | + if (this.options['stopped_at']) { | |
480 | + this.xDataExtent[1] = this.options['stopped_at']; | |
481 | + } | |
476 | 482 | this.margin = { |
477 | 483 | top: 30, |
478 | 484 | right: 20, | ... | ... |
web/static/js/swapp.ls
... | ... | @@ -251,7 +251,10 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE |
251 | 251 | id = parameter['id'] ; title = parameter['title'] |
252 | 252 | if id not of data then console.error("No data for id '#{id}'.", data) |
253 | 253 | @time_series.push(new TimeSeries( |
254 | - id, title, target, data[id], @parameters[id].active, container | |
254 | + id, title, target, data[id], @parameters[id].active, container, { | |
255 | + 'started_at': @started_at, | |
256 | + 'stopped_at': @stopped_at, | |
257 | + } | |
255 | 258 | )) |
256 | 259 | ) |
257 | 260 | @time_series.forEach((ts) ~> # returning true may be faster |
... | ... | @@ -347,24 +350,24 @@ export class TimeSeries |
347 | 350 | # Time in x-axis |
348 | 351 | # Data in y-axis |
349 | 352 | |
350 | - (@parameter, @title, @target, data, @visible, @container, @options = {}) -> | |
353 | + (@parameter, @title, @target, @data, @visible, @container, @options = {}) -> | |
351 | 354 | # parameter : slug of the parameter to observe, like btan or pdyn |
352 | 355 | # title : string, more descriptive, shown on the left of the Y axis |
353 | 356 | # target : target object, like described in configuration |
354 | 357 | # data : list of {x: <datetime>, y: <float>} |
355 | - @setData(data) | |
356 | 358 | @init() |
357 | 359 | |
358 | 360 | toString: -> "#{@title} of #{@target.name}" |
359 | 361 | |
360 | - setData: (data) -> | |
361 | - @data = data # and pre-compute extents for performance when zooming | |
362 | - @xDataExtent = d3.extent(@data, (d) -> d.x) | |
363 | - @yDataExtent = d3.extent(@data, (d) -> d.y) | |
364 | - | |
365 | 362 | init: -> |
366 | 363 | console.info "Initializing plot of #{@}…" |
367 | 364 | |
365 | + # pre-compute extents for performance when zooming | |
366 | + @xDataExtent = d3.extent(@data, (d) -> d.x) | |
367 | + @yDataExtent = d3.extent(@data, (d) -> d.y) | |
368 | + if @options['started_at'] then @xDataExtent[0] = @options['started_at'] | |
369 | + if @options['stopped_at'] then @xDataExtent[1] = @options['stopped_at'] | |
370 | + | |
368 | 371 | @margin = { |
369 | 372 | top: 30, |
370 | 373 | right: 20, | ... | ... |