Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

boundary tick cleanup, remove commented out code

Taylor Gunnoe02432dc25cb5
diff --git a/web/js/date/wv.date.timeline.ticks.js b/web/js/date/wv.date.timeline.ticks.js
index 4614dc562..aaeb0052d 100644
--- a/web/js/date/wv.date.timeline.ticks.js
+++ b/web/js/date/wv.date.timeline.ticks.js
@@ -58,56 +58,54 @@ wv.date.timeline.ticks = wv.date.timeline.ticks || function(models, config, ui)
ticks.insert("svg:circle","text").attr("r","6");
ticks.each(function(){
+
var current = d3.select(this);
var currentData = current.data()[0];
var nextData = tl.zoom.current.ticks.boundary.next(currentData);
- console.log(nextData);
- //console.log(d3.select($(this).next('.tick-labeled')[0]).data()[0]);
+ var nextNormalData = tl.zoom.current.ticks.normal.next(currentData);
+ var bWidth,nWidth;
+ var subLabel;
+
+ bWidth = tl.x(nextData) - tl.x(currentData);
+
+ nWidth = tl.x(nextNormalData) - tl.x(currentData) + 1;
+
+ //subLabel = getSubLabel(boundaryTickData);
+
+ current.insert("svg:rect", "text")
+ .attr("x","0")
+ .attr("y","0")
+ .attr("width",bWidth)
+ .attr("height",tl.height)
+ .attr("class","boundarytick-background");
+
+ current.append("svg:rect")
+ .attr("x","0")
+ .attr("y","0")
+ .attr("width",bWidth)
+ .attr("height",tl.height)
+ .attr("class","boundarytick-foreground");
+
+ current.append("svg:rect")
+ .attr("class","normaltick-background")
+ .attr("height",tl.height-1)
+ .attr("y",-tl.height)
+ .attr("x",-0.5)
+ .attr("width",nWidth);
+ /*
+ if(subLabel){
+ boundaryTick.select('text').append("tspan")
+ .text(" " + subLabel)
+ .attr("class","sub-label");
+ }*/
+
});
- /*
- var nextData = getNextBoundaryTickData(boundaryTickData);
- var nextNormalTickData = getNextNormalTickData(boundaryTickData);
-
- boundaryTickWidth = x(nextBoundaryTickData) - x(boundaryTickData);
-
- normalTickWidth = x(nextNormalTickData) - x(boundaryTickData) + 1;
-
- var subLabel = getSubLabel(boundaryTickData);
-
- boundaryTick.insert("svg:rect", "text")
- .attr("x","0")
- .attr("y","0")
- .attr("width",boundaryTickWidth)
- .attr("height",height)
- .attr("class","boundarytick-background");
-
- boundaryTick.append("svg:rect")
- .attr("x","0")
- .attr("y","0")
- .attr("width",boundaryTickWidth)
- .attr("height",height)
- .attr("class","boundarytick-foreground");
-
- boundaryTick.append("svg:rect")
- .attr("class","normaltick-background")
- .attr("height",height-1)
- .attr("y",-height)
- .attr("x",-0.5)
- .attr("width",normalTickWidth);
-
- if(subLabel){
- boundaryTick.select('text').append("tspan")
- .text(" " + subLabel)
- .attr("class","sub-label");
- }
-
- });
-
- boundaryTicks.selectAll('text')
- .attr('class','tick-label')
- .attr('x',7)
- .attr('style','text-anchor:left;');
-*/
+
+ ticks.selectAll('text')
+ .attr('class','tick-label')
+ .attr('x',7)
+ .attr('style','text-anchor:left;');
+
}
};
self.compare = function(proto, end){
diff --git a/web/js/date/wv.date.timeline.zoom.js b/web/js/date/wv.date.timeline.zoom.js
index 1d2f03dbb..d1bb14cc1 100644
--- a/web/js/date/wv.date.timeline.zoom.js
+++ b/web/js/date/wv.date.timeline.zoom.js
@@ -37,88 +37,7 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
},
},
};
- /*
- self.level1 = function(){
-
- tl.ticks.normalTicks = tl.ticks.all.filter(function(d){
- return d.getUTCFullYear() % 10 !== 0;
- });
-
- tl.ticks.boundaryTicks = tl.ticks.all.filter(function(d){
- return d.getUTCFullYear() % 10 === 0;
- });
-
- tl.ticks.refresh('year','decade');
-
- };
- self.level2 = function(){
- tl.ticks.normalTicks = tl.ticks.all.filter(function(d){
- return d.getUTCMonth() !== 0;
- });
-
- tl.ticks.boundaryTicks = tl.ticks.all.filter(function(d){
- return d.getUTCMonth() === 0;
- });
-
- var protoData = new Date(Date.UTC(tl.ticks.all.data[0].getUTCFullYear(),
- tl.ticks.all.data[0].getUTCMonth()-1,
- 1));
-
- tl.ticks.refresh('month','year');
- };
- self.level3 = function(){
- var altEnd,
- fNormData,
- labelFormat = d3.time.format.utc("%b"),
- dateInterval = d3.time.day.utc,
- dateStep = 1,
- tickCount = (tl.data.end() - tl.data.start())/1000/60/60/24,
- tickCountMax,
- tickWidth = 11;
-
- tickCountMax = Math.ceil(tl.width/tickWidth);
-
- altEnd = new Date(tl.data.start().getUTCFullYear(),
- tl.data.start().getUTCMonth(),
- tl.data.start().getUTCDate() + tickCountMax);
-
- drawTicks(tickCount,
- tickCountMax,
- altEnd,
- tickWidth,
- dateInterval,
- dateStep,
- labelFormat);
-
- self.current.ticks.normal.all = function(){
- tl.ticks.normal.all = tl.ticks.all.filter(function(d){
- return d.getUTCDate() !== 1;
- });
- tl.ticks.normal.setEnds();
-
- };
-
- self.current.ticks.boundary.all = function(){
- tl.ticks.boundary.all = tl.ticks.all.filter(function(d){
- return d.getUTCDate() === 1;
- });
- };
-
- self.current.ticks.boundary.next = function(current){
- var next = new Date(current);
- return new Date(next.setUTCMonth(next.getUTCMonth()+1));
- };
-
- self.current.ticks.normal.next = function(current){
- var next = new Date(current);
- return new Date(next.setUTCDate(next.getUTCDate()+1));
- };
-
- tl.ticks.update();
-
- };
-*/
self.drawTicks = function(count, max, aEnd, w, i, s, f){
var d1 = tl.data.start(),
d2,
@@ -161,54 +80,6 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
};
-/* tl.ticks.update = function(){
- var current = self.current;
- tl.ticks.setAll();
-
- //Checks to see if all of the ticks fit onto the timeline space
- //and if so check to see that first and last major ticks are printed
- if(!tl.isCropped){
- var first = tl.ticks.firstDate;
- var last = tl.ticks.lastDate;
- var proto = new Date(Date.UTC(first.getUTCFullYear(),
- first.getUTCMonth(),
- first.getUTCDate()-1));
- var end = new Date(Date.UTC(last.getUTCFullYear(),
- last.getUTCMonth(),
- last.getUTCDate()+1));
- tl.ticks.compare(proto, end);
- }
- //set normal ticks
- self.current.ticks.normal.all();
-
- //FIXME: Section below is terrible {
- //For determining needed boundary ticks
- if($(tl.ticks.normal.firstElem).is(':nth-child(2)')){
- var first = tl.ticks.normal.firstDate;
- var proto = new Date(Date.UTC(first.getUTCFullYear(),
- first.getUTCMonth(),
- 1));
- tl.ticks.add(proto, 'g.tick');
- }
-
- //FIXME: Passing from d3 to jQuery to d3 in order to check if its the last tick elem. WAT.
- if(d3.select($(tl.ticks.normal.lastElem)
- .next()[0]).classed('domain')){
- var last = tl.ticks.normal.lastDate;
- var end = new Date(Date.UTC(last.getUTCFullYear()+1,
- last.getUTCMonth()+1,
- 1));
- tl.ticks.add(end, 'path.domain');
- }
- // } End terrible
-
- //update boundary ticks
- self.current.ticks.boundary.all();
- tl.ticks.boundary.all.classed('tick-labeled',true);
-
- tl.ticks.boundary.init(current);
-
- };*/
var init = function(){
//self.level3();
@@ -219,9 +90,12 @@ wv.date.timeline.zoom = wv.date.timeline.zoom || function(models, config, ui) {
};
/**
- * Perform timeline zooming functions
+ * Modify zoom levels here. Maybe this isnt the best way to do this.
+ * It could be called just level without the zoom part instead.
*
- * @class wv.date.timeline.zoom
+ * When the zoom level is changed, this re renders everything of the timeline.
+ *
+ * @class wv.date.timeline.zoom.lvl
*/
wv.date.timeline.zoom.lvl = wv.date.timeline.zoom.lvl || function(models, config, ui) {
var self = {};