Commit 56d84302cf1009b43fe1c486024294ace70c7686

Authored by Goutte
1 parent 1185f353

Continue the great refacto and improve ticks @Vincent

Showing 2 changed files with 42 additions and 30 deletions   Show diff stats
@@ -649,8 +649,7 @@ def get_data_for_target(target_config, input_slug, @@ -649,8 +649,7 @@ def get_data_for_target(target_config, input_slug,
649 649
650 # Keep adding exceptions here until you can't or become mad 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 # /!\ MUST be in the same order as PROPERTIES 653 # /!\ MUST be in the same order as PROPERTIES
655 all_data[dkey] = ( 654 all_data[dkey] = (
656 dtime.strftime("%Y-%m-%dT%H:%M:%S+00:00"), 655 dtime.strftime("%Y-%m-%dT%H:%M:%S+00:00"),
web/static/js/main.js
@@ -69,14 +69,24 @@ @@ -69,14 +69,24 @@
69 this.time_series = []; 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 init(started_at, stopped_at) { 80 init(started_at, stopped_at) {
73 // "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)"; 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 const app = this; 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 this.setStartAndStop(started_at, stopped_at); 86 this.setStartAndStop(started_at, stopped_at);
78 this.loadAndCreatePlots(started_at, stopped_at); 87 this.loadAndCreatePlots(started_at, stopped_at);
79 window.addEventListener('resize', () => app.resize()); 88 window.addEventListener('resize', () => app.resize());
  89 +
80 return this; 90 return this;
81 } 91 }
82 92
@@ -86,6 +96,7 @@ @@ -86,6 +96,7 @@
86 url = url.replace('<target>', target_slug); 96 url = url.replace('<target>', target_slug);
87 url = url.replace('<started_at>', started_at); 97 url = url.replace('<started_at>', started_at);
88 url = url.replace('<stopped_at>', stopped_at); 98 url = url.replace('<stopped_at>', stopped_at);
  99 +
89 return url; 100 return url;
90 } 101 }
91 102
@@ -284,8 +295,13 @@ @@ -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 loadAndCreatePlots(started_at, stopped_at) { 304 loadAndCreatePlots(started_at, stopped_at) {
288 - // "started_at: moment(.js) datetime object\nstopped_at: moment(.js) datetime object";  
289 let targets; 305 let targets;
290 let res$; 306 let res$;
291 let k; 307 let k;
@@ -595,18 +611,6 @@ @@ -595,18 +611,6 @@
595 } 611 }
596 612
597 init() { 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 let clipId; 614 let clipId;
611 let i$; 615 let i$;
612 let len$; 616 let len$;
@@ -621,7 +625,9 @@ @@ -621,7 +625,9 @@
621 bottom: 30, 625 bottom: 30,
622 left: 80 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 this.xDataExtent = d3.extent(this.data, d => d.x); 631 this.xDataExtent = d3.extent(this.data, d => d.x);
626 this.yDataExtent = d3.extent(this.data, d => d.y); 632 this.yDataExtent = d3.extent(this.data, d => d.y);
627 if (this.options['started_at']) { 633 if (this.options['started_at']) {
@@ -632,15 +638,15 @@ @@ -632,15 +638,15 @@
632 } 638 }
633 this.xScale = d3.scaleTime().domain(this.xDataExtent); 639 this.xScale = d3.scaleTime().domain(this.xDataExtent);
634 this.yScale = d3.scaleLinear().domain(this.yDataExtent); 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 if (date > d3.timeSecond(date)) { 650 if (date > d3.timeSecond(date)) {
645 return formatMillisecond(date); 651 return formatMillisecond(date);
646 } 652 }
@@ -663,8 +669,10 @@ @@ -663,8 +669,10 @@
663 if (date > d3.timeYear(date)) { 669 if (date > d3.timeYear(date)) {
664 return formatMonth(date); 670 return formatMonth(date);
665 } 671 }
  672 +
666 return formatYear(date); 673 return formatYear(date);
667 }; 674 };
  675 + // let formatScience = d3.utcFormat("%Y");
668 this.xAxis = d3.axisBottom().tickFormat(multiFormat).ticks(7); 676 this.xAxis = d3.axisBottom().tickFormat(multiFormat).ticks(7);
669 this.yAxis = d3.axisLeft().ticks(10); 677 this.yAxis = d3.axisLeft().ticks(10);
670 this.svg = d3.select(this.container).append('svg'); 678 this.svg = d3.select(this.container).append('svg');
@@ -681,8 +689,8 @@ @@ -681,8 +689,8 @@
681 this.createCatalogLayers(); 689 this.createCatalogLayers();
682 this.horizontalLines = []; 690 this.horizontalLines = [];
683 if (this.options['horizontalLines']) { 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 lineElement = this.svg.append("line").attr("class", "line horitonal-line").style("stroke", "orange").style("stroke-dasharray", "3, 2"); 694 lineElement = this.svg.append("line").attr("class", "line horitonal-line").style("stroke", "orange").style("stroke-dasharray", "3, 2");
687 this.horizontalLines.push({ 695 this.horizontalLines.push({
688 'element': lineElement, 696 'element': lineElement,
@@ -898,7 +906,12 @@ @@ -898,7 +906,12 @@
898 906
899 createCatalogLayer(started_at, stopped_at) { 907 createCatalogLayer(started_at, stopped_at) {
900 let layer_rect; 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 return layer_rect; 915 return layer_rect;
903 } 916 }
904 917