Commit 56d84302cf1009b43fe1c486024294ace70c7686
1 parent
1185f353
Exists in
master
and in
2 other branches
Continue the great refacto and improve ticks @Vincent
Showing
2 changed files
with
42 additions
and
30 deletions
Show diff stats
web/run.py
... | ... | @@ -649,8 +649,7 @@ def get_data_for_target(target_config, input_slug, |
649 | 649 | |
650 | 650 | # Keep adding exceptions here until you can't or become mad |
651 | 651 | |
652 | - # First model has priority: ignore data from other models | |
653 | - if dkey not in all_data: | |
652 | + if dkey not in all_data: # since first model has priority | |
654 | 653 | # /!\ MUST be in the same order as PROPERTIES |
655 | 654 | all_data[dkey] = ( |
656 | 655 | dtime.strftime("%Y-%m-%dT%H:%M:%S+00:00"), | ... | ... |
web/static/js/main.js
... | ... | @@ -69,14 +69,24 @@ |
69 | 69 | this.time_series = []; |
70 | 70 | } |
71 | 71 | |
72 | + /** | |
73 | + * This is called by the inline bootstrap javascript code. | |
74 | + * This ain't in the constructor because it might return a Promise later on. | |
75 | + * (for the loader, for example) | |
76 | + * | |
77 | + * @param started_at string | |
78 | + * @param stopped_at string | |
79 | + */ | |
72 | 80 | init(started_at, stopped_at) { |
73 | 81 | // "This is called by the inline bootstrap javascript code.\nThis ain't in the constructor because it might return a Promise later on.\n(for the loader, for example)"; |
74 | 82 | const app = this; |
75 | - started_at = moment(started_at).hours(0).minutes(0).seconds(0); | |
76 | - stopped_at = moment(stopped_at).hours(0).minutes(0).seconds(0); | |
83 | + | |
84 | + started_at = moment(started_at).utc().hours(0).minutes(0).seconds(0); | |
85 | + stopped_at = moment(stopped_at).utc().hours(0).minutes(0).seconds(0); | |
77 | 86 | this.setStartAndStop(started_at, stopped_at); |
78 | 87 | this.loadAndCreatePlots(started_at, stopped_at); |
79 | 88 | window.addEventListener('resize', () => app.resize()); |
89 | + | |
80 | 90 | return this; |
81 | 91 | } |
82 | 92 | |
... | ... | @@ -86,6 +96,7 @@ |
86 | 96 | url = url.replace('<target>', target_slug); |
87 | 97 | url = url.replace('<started_at>', started_at); |
88 | 98 | url = url.replace('<stopped_at>', stopped_at); |
99 | + | |
89 | 100 | return url; |
90 | 101 | } |
91 | 102 | |
... | ... | @@ -284,8 +295,13 @@ |
284 | 295 | }); |
285 | 296 | } |
286 | 297 | |
298 | + /** | |
299 | + * | |
300 | + * @param started_at moment(.js) datetime object | |
301 | + * @param stopped_at moment(.js) datetime object | |
302 | + * @returns {SpaceWeather} | |
303 | + */ | |
287 | 304 | loadAndCreatePlots(started_at, stopped_at) { |
288 | - // "started_at: moment(.js) datetime object\nstopped_at: moment(.js) datetime object"; | |
289 | 305 | let targets; |
290 | 306 | let res$; |
291 | 307 | let k; |
... | ... | @@ -595,18 +611,6 @@ |
595 | 611 | } |
596 | 612 | |
597 | 613 | init() { |
598 | - let ref$; | |
599 | - let width; | |
600 | - let height; | |
601 | - let formatMillisecond; | |
602 | - let formatSecond; | |
603 | - let formatMinute; | |
604 | - let formatHour; | |
605 | - let formatDay; | |
606 | - let formatWeek; | |
607 | - let formatMonth; | |
608 | - let formatYear; | |
609 | - let multiFormat; | |
610 | 614 | let clipId; |
611 | 615 | let i$; |
612 | 616 | let len$; |
... | ... | @@ -621,7 +625,9 @@ |
621 | 625 | bottom: 30, |
622 | 626 | left: 80 |
623 | 627 | }; |
624 | - ref$ = this.recomputeDimensions(), width = ref$[0], height = ref$[1]; | |
628 | + let dimensions = this.recomputeDimensions(); | |
629 | + let width = dimensions[0]; | |
630 | + let height = dimensions[1]; | |
625 | 631 | this.xDataExtent = d3.extent(this.data, d => d.x); |
626 | 632 | this.yDataExtent = d3.extent(this.data, d => d.y); |
627 | 633 | if (this.options['started_at']) { |
... | ... | @@ -632,15 +638,15 @@ |
632 | 638 | } |
633 | 639 | this.xScale = d3.scaleTime().domain(this.xDataExtent); |
634 | 640 | this.yScale = d3.scaleLinear().domain(this.yDataExtent); |
635 | - formatMillisecond = d3.utcFormat(".%L"); | |
636 | - formatSecond = d3.utcFormat(":%S"); | |
637 | - formatMinute = d3.utcFormat("%H:%M"); | |
638 | - formatHour = d3.utcFormat("%H:%M"); | |
639 | - formatDay = d3.utcFormat("%a %d"); | |
640 | - formatWeek = d3.utcFormat("%b %d"); | |
641 | - formatMonth = d3.utcFormat("%B"); | |
642 | - formatYear = d3.utcFormat("%Y"); | |
643 | - multiFormat = date => { | |
641 | + const formatMillisecond = d3.utcFormat(".%L"); | |
642 | + const formatSecond = d3.utcFormat(":%S"); | |
643 | + const formatMinute = d3.utcFormat("%H:%M"); | |
644 | + const formatHour = d3.utcFormat("%H:%M"); | |
645 | + const formatDay = d3.utcFormat("%a %d"); | |
646 | + const formatWeek = d3.utcFormat("%b %d"); | |
647 | + const formatMonth = d3.utcFormat("%B"); | |
648 | + const formatYear = d3.utcFormat("%Y"); | |
649 | + const multiFormat = date => { | |
644 | 650 | if (date > d3.timeSecond(date)) { |
645 | 651 | return formatMillisecond(date); |
646 | 652 | } |
... | ... | @@ -663,8 +669,10 @@ |
663 | 669 | if (date > d3.timeYear(date)) { |
664 | 670 | return formatMonth(date); |
665 | 671 | } |
672 | + | |
666 | 673 | return formatYear(date); |
667 | 674 | }; |
675 | + // let formatScience = d3.utcFormat("%Y"); | |
668 | 676 | this.xAxis = d3.axisBottom().tickFormat(multiFormat).ticks(7); |
669 | 677 | this.yAxis = d3.axisLeft().ticks(10); |
670 | 678 | this.svg = d3.select(this.container).append('svg'); |
... | ... | @@ -681,8 +689,8 @@ |
681 | 689 | this.createCatalogLayers(); |
682 | 690 | this.horizontalLines = []; |
683 | 691 | if (this.options['horizontalLines']) { |
684 | - for (i$ = 0, len$ = (ref$ = this.options['horizontalLines']).length; i$ < len$; ++i$) { | |
685 | - line = ref$[i$]; | |
692 | + for (i$ = 0, len$ = (dimensions = this.options['horizontalLines']).length; i$ < len$; ++i$) { | |
693 | + line = dimensions[i$]; | |
686 | 694 | lineElement = this.svg.append("line").attr("class", "line horitonal-line").style("stroke", "orange").style("stroke-dasharray", "3, 2"); |
687 | 695 | this.horizontalLines.push({ |
688 | 696 | 'element': lineElement, |
... | ... | @@ -898,7 +906,12 @@ |
898 | 906 | |
899 | 907 | createCatalogLayer(started_at, stopped_at) { |
900 | 908 | let layer_rect; |
901 | - layer_rect = this.pathWrapper.append("rect").attr('y', 0).attr('height', this.plotHeight).attr('fill', '#FFFD64C2'); | |
909 | + layer_rect = this.pathWrapper.append("rect") | |
910 | + .attr('y', 0) | |
911 | + .attr('height', this.plotHeight) | |
912 | + .attr('fill', '#FFFD64C2'); | |
913 | + //won't work, possibly because of our input catcher rect. | |
914 | + //layer_rect.append('svg:title').text("!"); | |
902 | 915 | return layer_rect; |
903 | 916 | } |
904 | 917 | ... | ... |