Interactive interface for browsing global, full-resolution satellite imagery
Add timeline 3-hour boundaries and hover labels with HH:MM
ZachTRiceb0e2f1b5bc90
diff --git a/web/css/anim.widget.css b/web/css/anim.widget.cssindex 16a1f940e..4bec342f9 100644--- a/web/css/anim.widget.css+++ b/web/css/anim.widget.css@@ -149,7 +149,6 @@font-family: 'Roboto Mono', monospace;font-size: 15px;vertical-align: middle;- margin-top: 2px;margin-left: -2px;}diff --git a/web/js/date/config.js b/web/js/date/config.jsindex 2dcddc695..6a9b2deca 100644--- a/web/js/date/config.js+++ b/web/js/date/config.js@@ -576,7 +576,8 @@ export function timelineConfig(models, config, ui) {// Filters ticks for nonboundaries that have the following attributetl.zoom.current.ticks.normal.all = function () {tl.ticks.normal.all = tl.ticks.all.filter(function (d) {- return d.getUTCMinutes() !== 1;+ // This should be rewritten to be cleaner+ return d.getUTCHours() % 3 !== 0 || d.getUTCMinutes() !== 0 || d.getUTCMinutes() === 0;});tl.ticks.normal.setEnds();};@@ -584,14 +585,14 @@ export function timelineConfig(models, config, ui) {// Filters ticks for boundaries that have the following attributetl.zoom.current.ticks.boundary.all = function () {tl.ticks.boundary.all = tl.ticks.all.filter(function (d) {- return d.getUTCMinutes() === 1;+ return d.getUTCHours() % 3 === 0 && d.getUTCMinutes() === 0;});};// Calculated next boundary tick by datetl.zoom.current.ticks.boundary.next = function (current) {var next = new Date(current);- return new Date(next.setUTCMinutes(next.getUTCMinutes() + 10));+ return new Date(next.setUTCHours(next.getUTCHours() + 3));};// Calculated next normal tick by date@@ -658,12 +659,12 @@ export function timelineConfig(models, config, ui) {// Displayed default labeltl.zoom.current.ticks.boundary.label = function (d) {- return d.getUTCHours();+ return null;};// Displayed default sub-label (if any)tl.zoom.current.ticks.boundary.subLabel = function (d) {- return d.getUTCDate();+ return null;};// Value for clicked boundary tickdiff --git a/web/js/date/timeline-ticks.js b/web/js/date/timeline-ticks.jsindex 92dae7b1f..a280fb75d 100644--- a/web/js/date/timeline-ticks.js+++ b/web/js/date/timeline-ticks.js@@ -388,7 +388,7 @@ export function timelineTicks(models, config, ui) {var $boundaryTick;var tick = this.parentNode;var boundaryTick, boundaryTickWidth;- var hoverDay = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());+ var hoverDay = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes());// Using jquery to precise select as it's easier than d3if (d3.select(tick)@@ -417,16 +417,31 @@ export function timelineTicks(models, config, ui) {// trigger hover stateboundaryTick.select('rect.boundarytick-background').classed('bg-hover', true);- boundaryTick.append('svg:text')- .attr('class', 'hover-tick-label')- .attr('y', '15')- .attr('x', boundaryTickWidth / 2)- .attr('style', 'text-anchor:middle')- .attr('width', boundaryTickWidth)- .text(d.getUTCFullYear() ++ if (models.date.selectedZoom >= 4) {+ boundaryTick.append('svg:text')+ .attr('class', 'hover-tick-label')+ .attr('y', '15')+ .attr('x', boundaryTickWidth / 2)+ .attr('style', 'text-anchor:middle')+ .attr('width', boundaryTickWidth)+ .text(d.getUTCFullYear() +' ' + model.monthAbbr[d.getUTCMonth()] +' ' + d.getUTCDate() +- ' (' + util.daysInYear(hoverDay) + ')'); // Add hover Label+ ' ' + util.pad(d.getUTCHours(), 2, '0') ++ ':' + util.pad(d.getUTCMinutes(), 2, '0') ++ ' (' + util.daysInYear(hoverDay) + ')');+ } else {+ boundaryTick.append('svg:text')+ .attr('class', 'hover-tick-label')+ .attr('y', '15')+ .attr('x', boundaryTickWidth / 2)+ .attr('style', 'text-anchor:middle')+ .attr('width', boundaryTickWidth)+ .text(d.getUTCFullYear() ++ ' ' + model.monthAbbr[d.getUTCMonth()] ++ ' ' + d.getUTCDate() ++ ' (' + util.daysInYear(hoverDay) + ')'); // Add hover Label+ }},remove: function () { // TODO: updatetl.boundary.selectAll('.tick-label, .sub-label')