Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

branch merge

Taylor Gunnoe11be2d646da7
diff --cc src/js/date/wv.date.timeline.js
index 8490d7199,c7c93e99a..de092abb4
--- a/src/js/date/wv.date.timeline.js
+++ b/src/js/date/wv.date.timeline.js
@@@ -76,9 -95,8 +76,10 @@@ wv.date.timeline = wv.date.timeline ||
var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
var self = {};
-
+
+ var incrementBtn = $("#right-arrow-group");
+ var decrementBtn = $("#left-arrow-group");
+
var x = d3.time.scale()
.domain([
d3.min(data, function(d) { return d.date; }),
@@@ -146,27 -142,21 +147,27 @@@
svg.select(".line2")
.attr("class", "line2")
.attr("d", line);
+
+ updateTimeline();
+
+ if(($("svg#now-line").offset().left) < ($("#timeline footer").offset().left)){
+ $("svg#now-line").css("visibility","hidden");
- var makeFill = d3.select('.line2').attr("d");
- d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
- var makeFillPos = $(".line2").offset();
- $("svg#now-line").css("left", (makeFillPos.left-3) + "px");
+ }
+ else{
+ $("svg#now-line").css("visibility","visible");
+ }
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
-
+
+
};
-
+
var zoom = d3.behavior.zoom()
.x(x)
- .scaleExtent([1, 1500])
+ .scaleExtent([1, 100])
.on("zoom", zoomed);
-
+
var make_x_axis = function (x) {
return d3.svg.axis()
.scale(x)
@@@ -178,9 -175,14 +179,9 @@@
.scale(x)
.orient("bottom")
.ticks(10);
-
- var yAxis = d3.svg.axis()
- .scale(y)
- .orient("left")
- .ticks(5);
-
+
var init = function() {
-
+
svg = d3.select('#timeline footer')
.append("svg:svg")
.attr('width', width + margin.left + margin.right)
@@@ -229,12 -232,14 +230,12 @@@
.datum(data2)
.attr("class", "line2")
.attr("d", line);
- var makeFill = d3.select('.line2').attr("d");
- d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
- var makeFillPos = $(".line2").offset();
- $("svg#now-line").css("left", (makeFillPos.left-3) + "px");
-
+
+ updateTimeline();
+
d3.selectAll('.x.axis .tick text').attr('x',5).attr('style','text-anchor:left;');
-
- // Hover line.
+
+ // Hover line.
var hoverLineGroup = svg.append("g")
.attr("class", "hover-line");
var hoverLine = hoverLineGroup
@@@ -245,36 -250,40 +246,36 @@@
var hoverDate = hoverLineGroup.append('text')
.attr("class", "hover-text")
.attr('y', height-40);
-
+
// Hide hover line by default.
hoverLineGroup.style("opacity", 1e-6);
-
-
- updateTime();
-
-
- // Add mouseover events.
-
- d3.select("#timeline footer").on("mouseenter", function() {
- $("#timeline-text").show();
- hoverLineGroup.style("opacity", 1);
- }).on("mousemove", function() {
-
- var mouse_x = d3.mouse(this)[0];
- var mouse_y = d3.mouse(this)[1];
- var graph_y = y.invert(mouse_y);
- var graph_x = x.invert(mouse_x);
- var format = d3.time.format('%e %b');
- //format.parse(graph_x)
- var stringDate = String(graph_x).split(' ');
- $("#timeline-text").text(stringDate[3] + " " + stringDate[1] + " " + stringDate[2]);
- hoverLine.attr("x1", mouse_x).attr("x2", mouse_x);
- if ((mouse_x > (x(data2[0].date)- 3)) && (mouse_x < (x(data2[0].date) + 6))){
- hoverLineGroup.style("opacity", 1e-6);
- $("#timeline-text").hide();
- $(".line2").css("stroke","#fff");
- }else {
+
+ /****************************** TIMELINE LINES ************************************/
+
+ d3.select("#timeline footer").on("mouseenter", function() {
$("#timeline-text").show();
hoverLineGroup.style("opacity", 1);
- $(".line2").css("stroke","transparent");
- }
- $("#timeline-text").css({"left": d3.event.pageX});
+ }).on("mousemove", function() {
+
+ var mouse_x = d3.mouse(this)[0];
+ var mouse_y = d3.mouse(this)[1];
+ var graph_y = y.invert(mouse_y);
+ var graph_x = x.invert(mouse_x);
+ var format = d3.time.format('%e %b');
+ //format.parse(graph_x)
+ var stringDate = String(graph_x).split(' ');
+ $("#timeline-text").text(stringDate[3] + " " + stringDate[1] + " " + stringDate[2]);
+ hoverLine.attr("x1", mouse_x).attr("x2", mouse_x);
+ if ((mouse_x > (x(data2[0].date)- 3)) && (mouse_x < (x(data2[0].date) + 6))){
+ hoverLineGroup.style("opacity", 1e-6);
+ $("#timeline-text").hide();
+ $(".line2").css("stroke","#fff");
+ }else {
+ $("#timeline-text").show();
+ hoverLineGroup.style("opacity", 1);
+ $(".line2").css("stroke","transparent");
+ }
+ $("#timeline-text").css({"left": d3.event.pageX});
}).on("mouseleave", function() {
hoverLineGroup.style("opacity", 1e-6);
$("#timeline-text").hide();
@@@ -285,59 -294,58 +286,61 @@@
data2[1].date = Date.parse(x.invert(mouse_x));
svg.select(".line2")
.attr("d", line);
- var makeFill = d3.select('.line2').attr("d");
- d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
- var makeFillPos = $(".line2").offset();
- $("svg#now-line").css("left", (makeFillPos.left-3) + "px");
+ updateTimeline();
currentDate = new Date(data2[0].date);
updateTime();
-
-
- });
+
+
+ })/*.on("mousedown",function(){
+ mouse_x_start = d3.mouse(this)[0];
+ var mouse_x_jump = mouse_x_start + timelineJump;
+ console.log("$$$$$$$$$$$$ ");
+ })*/;
++
$("svg#now-line").mousedown(function(e){
- console.log("mousedown");
e.preventDefault();
+
d3.select("#timeline footer").on("mousemove", function(){
var mouse_x = d3.mouse(this)[0];
data2[0].date = Date.parse(x.invert(mouse_x));
data2[1].date = Date.parse(x.invert(mouse_x));
svg.select(".line2")
.attr("d", line);
- var makeFill = d3.select('.line2').attr("d");
- d3.select(".line2").attr("d", makeFill + "l3,0l0,60z");
- var makeFillPos = $(".line2").offset();
- $("svg#now-line").css("left", (makeFillPos.left-3) + "px");
+ updateTimeline();
currentDate = new Date(data2[0].date);
updateTime();
+
+
});
- }).mouseup(function(){
+ }).mouseup(function(){
d3.select("#timeline footer").on("mousemove", null);
d3.select("#timeline footer").on("mousemove", function() {
+
- var mouse_x = d3.mouse(this)[0];
- var mouse_y = d3.mouse(this)[1];
- var graph_y = y.invert(mouse_y);
- var graph_x = x.invert(mouse_x);
- var format = d3.time.format('%e %b');
- //format.parse(graph_x)
- var stringDate = String(graph_x).split(' ');
- $("#timeline-text").text(stringDate[3] + " " + stringDate[1] + " " + stringDate[2]);
- hoverLine.attr("x1", mouse_x).attr("x2", mouse_x);
- if ((mouse_x > (x(data2[0].date)- 3)) && (mouse_x < (x(data2[0].date) + 6))){
- hoverLineGroup.style("opacity", 1e-6);
- $("#timeline-text").hide();
- $(".line2").css("stroke","#fff");
- }else {
- $("#timeline-text").show();
- hoverLineGroup.style("opacity", 1);
- $(".line2").css("stroke","transparent");
- }
- $("#timeline-text").css({"left": d3.event.pageX});
- });
-
+
+ var mouse_x = d3.mouse(this)[0];
+ var mouse_y = d3.mouse(this)[1];
+ var graph_y = y.invert(mouse_y);
+ var graph_x = x.invert(mouse_x);
+ var format = d3.time.format('%e %b');
+ //format.parse(graph_x)
+ var stringDate = String(graph_x).split(' ');
+ $("#timeline-text").text(stringDate[3] + " " + stringDate[1] + " " + stringDate[2]);
+ hoverLine.attr("x1", mouse_x).attr("x2", mouse_x);
+ if ((mouse_x > (x(data2[0].date)- 3)) && (mouse_x < (x(data2[0].date) + 6))){
+ hoverLineGroup.style("opacity", 1e-6);
+ $("#timeline-text").hide();
+ $(".line2").css("stroke","#fff");
+ }else {
+ $("#timeline-text").show();
+ hoverLineGroup.style("opacity", 1);
+ $(".line2").css("stroke","transparent");
+ }
+ $("#timeline-text").css({"left": d3.event.pageX});
+ });
+
});
-
+ /**************************END TIMELINE LINES****************************/
+
//bind click action to interval radio buttons
var buttons = $('.button-input-group');
buttons.click(function(e){