Commit a8ce269bda5df4dc83ef6e29456f086e774b917c

Authored by Goutte
1 parent 696037b4

Force time display to be UTC (whatever the user's locale is)

Showing 2 changed files with 22 additions and 22 deletions   Show diff stats
web/static/js/swapp.js
@@ -183,7 +183,7 @@ @@ -183,7 +183,7 @@
183 return d3.csv(url, function(csv){ 183 return d3.csv(url, function(csv){
184 var timeFormat, data; 184 var timeFormat, data;
185 console.debug("Requested CSV for " + target_slug + "…", csv); 185 console.debug("Requested CSV for " + target_slug + "…", csv);
186 - timeFormat = d3.timeParse('%Y-%m-%dT%H:%M:%S%Z'); 186 + timeFormat = d3.utcParse('%Y-%m-%dT%H:%M:%S%Z');
187 data = { 187 data = {
188 'hee': [] 188 'hee': []
189 }; 189 };
@@ -497,16 +497,16 @@ @@ -497,16 +497,16 @@
497 bottom: 30, 497 bottom: 30,
498 left: 80 498 left: 80
499 }; 499 };
500 - this.xScale = d3.scaleTime().domain(this.xDataExtent); 500 + this.xScale = d3.scaleUtc().domain(this.xDataExtent);
501 this.yScale = d3.scaleLinear().domain(this.yDataExtent); 501 this.yScale = d3.scaleLinear().domain(this.yDataExtent);
502 - formatMillisecond = d3.timeFormat(".%L");  
503 - formatSecond = d3.timeFormat(":%S");  
504 - formatMinute = d3.timeFormat("%H:%M");  
505 - formatHour = d3.timeFormat("%H:%M");  
506 - formatDay = d3.timeFormat("%a %d");  
507 - formatWeek = d3.timeFormat("%b %d");  
508 - formatMonth = d3.timeFormat("%B");  
509 - formatYear = d3.timeFormat("%Y"); 502 + formatMillisecond = d3.utcFormat(".%L");
  503 + formatSecond = d3.utcFormat(":%S");
  504 + formatMinute = d3.utcFormat("%H:%M");
  505 + formatHour = d3.utcFormat("%H:%M");
  506 + formatDay = d3.utcFormat("%a %d");
  507 + formatWeek = d3.utcFormat("%b %d");
  508 + formatMonth = d3.utcFormat("%B");
  509 + formatYear = d3.utcFormat("%Y");
510 multiFormat = function(date){ 510 multiFormat = function(date){
511 if (date > d3.timeSecond(date)) { 511 if (date > d3.timeSecond(date)) {
512 return formatMillisecond(date); 512 return formatMillisecond(date);
@@ -721,7 +721,7 @@ @@ -721,7 +721,7 @@
721 TimeSeries.prototype.bisectDate = d3.bisector(function(d){ 721 TimeSeries.prototype.bisectDate = d3.bisector(function(d){
722 return d.x; 722 return d.x;
723 }).left; 723 }).left;
724 - TimeSeries.prototype.timeFormat = d3.timeFormat("%Y-%m-%d %H:%M"); 724 + TimeSeries.prototype.timeFormat = d3.utcFormat("%Y-%m-%d %H:%M");
725 TimeSeries.prototype.moveCursor = function(x0){ 725 TimeSeries.prototype.moveCursor = function(x0){
726 var i, d0, d1, d, xx, yy, mirrored, dx, transform; 726 var i, d0, d1, d, xx, yy, mirrored, dx, transform;
727 i = this.bisectDate(this.data, x0, 1); 727 i = this.bisectDate(this.data, x0, 1);
web/static/js/swapp.ls
@@ -159,7 +159,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE @@ -159,7 +159,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE
159 url = sw.buildDataUrlForTarget(target_slug, started_at, stopped_at) 159 url = sw.buildDataUrlForTarget(target_slug, started_at, stopped_at)
160 d3.csv(url, (csv) -> 160 d3.csv(url, (csv) ->
161 console.debug("Requested CSV for #{target_slug}…", csv) 161 console.debug("Requested CSV for #{target_slug}…", csv)
162 - timeFormat = d3.timeParse('%Y-%m-%dT%H:%M:%S%Z') 162 + timeFormat = d3.utcParse('%Y-%m-%dT%H:%M:%S%Z')
163 data = { 'hee': [] } 163 data = { 'hee': [] }
164 configuration['parameters'].forEach((parameter) -> 164 configuration['parameters'].forEach((parameter) ->
165 data[parameter['id']] = [] 165 data[parameter['id']] = []
@@ -384,19 +384,19 @@ export class TimeSeries @@ -384,19 +384,19 @@ export class TimeSeries
384 left: 80 384 left: 80
385 } 385 }
386 386
387 - @xScale = d3.scaleTime().domain(@xDataExtent) 387 + @xScale = d3.scaleUtc().domain(@xDataExtent)
388 @yScale = d3.scaleLinear().domain(@yDataExtent) 388 @yScale = d3.scaleLinear().domain(@yDataExtent)
389 # Domain on a log scale MUST NOT cross zero 389 # Domain on a log scale MUST NOT cross zero
390 # @yScale = d3.scaleLog().domain(@yDataExtent) 390 # @yScale = d3.scaleLog().domain(@yDataExtent)
391 391
392 - formatMillisecond = d3.timeFormat(".%L")  
393 - formatSecond = d3.timeFormat(":%S")  
394 - formatMinute = d3.timeFormat("%H:%M")  
395 - formatHour = d3.timeFormat("%H:%M")  
396 - formatDay = d3.timeFormat("%a %d")  
397 - formatWeek = d3.timeFormat("%b %d")  
398 - formatMonth = d3.timeFormat("%B")  
399 - formatYear = d3.timeFormat("%Y") 392 + formatMillisecond = d3.utcFormat(".%L")
  393 + formatSecond = d3.utcFormat(":%S")
  394 + formatMinute = d3.utcFormat("%H:%M")
  395 + formatHour = d3.utcFormat("%H:%M")
  396 + formatDay = d3.utcFormat("%a %d")
  397 + formatWeek = d3.utcFormat("%b %d")
  398 + formatMonth = d3.utcFormat("%B")
  399 + formatYear = d3.utcFormat("%Y")
400 400
401 multiFormat = (date) -> 401 multiFormat = (date) ->
402 if date > d3.timeSecond(date) then return formatMillisecond(date) 402 if date > d3.timeSecond(date) then return formatMillisecond(date)
@@ -645,7 +645,7 @@ export class TimeSeries @@ -645,7 +645,7 @@ export class TimeSeries
645 @focus.style("display", "none") 645 @focus.style("display", "none")
646 646
647 bisectDate: d3.bisector((d) -> d.x).left # /!\ complex 647 bisectDate: d3.bisector((d) -> d.x).left # /!\ complex
648 - timeFormat: d3.timeFormat("%Y-%m-%d %H:%M") 648 + timeFormat: d3.utcFormat("%Y-%m-%d %H:%M")
649 649
650 moveCursor: (x0) -> 650 moveCursor: (x0) ->
651 i = @bisectDate(@data, x0, 1) 651 i = @bisectDate(@data, x0, 1)