Commit 32ded042 authored by qlobbe's avatar qlobbe

add the epoch

parent d4a32540
...@@ -256,11 +256,21 @@ ...@@ -256,11 +256,21 @@
var from = yearToDate(p.from), var from = yearToDate(p.from),
to = yearToDate(p.to); to = yearToDate(p.to);
if (p.strFrom != undefined) if (p.strFrom != undefined) {
if (window.timeScale == "epoch") {
from = utcStringToDate(p.strFrom)
} else {
from = stringToDate(p.strFrom) from = stringToDate(p.strFrom)
}
}
if (p.strTo != undefined) if (p.strTo != undefined) {
if (window.timeScale == "epoch") {
to = utcStringToDate(p.strTo)
} else {
to = stringToDate(p.strTo) to = stringToDate(p.strTo)
}
}
return { from : from, return { from : from,
to : to, to : to,
...@@ -273,7 +283,9 @@ ...@@ -273,7 +283,9 @@
var groups = json.objects.filter(node => node.nodeType == "group").map(function(g){ var groups = json.objects.filter(node => node.nodeType == "group").map(function(g){
if (g.weight != undefined) console.log(g.weight)
if ((g.weight != undefined) && (g.weight != "Nothing"))
window.weighted = true; window.weighted = true;
var keys = (g.foundation.slice(1, g.foundation.length - 1)).split('|') var keys = (g.foundation.slice(1, g.foundation.length - 1)).split('|')
...@@ -298,11 +310,21 @@ ...@@ -298,11 +310,21 @@
weight = 0; weight = 0;
source = []; source = [];
if (g.strFrom != undefined) if (g.strFrom != undefined) {
if (window.timeScale == "epoch") {
from = utcStringToDate(g.strFrom)
} else {
from = stringToDate(g.strFrom) from = stringToDate(g.strFrom)
}
}
if (g.strTo != undefined) if (g.strTo != undefined) {
if (window.timeScale == "epoch") {
to = utcStringToDate(g.strTo)
} else {
to = stringToDate(g.strTo) to = stringToDate(g.strTo)
}
}
if (g.source != undefined) if (g.source != undefined)
source = intArrToArr(g.source); source = intArrToArr(g.source);
......
...@@ -22,6 +22,16 @@ function stringToDate(str) { ...@@ -22,6 +22,16 @@ function stringToDate(str) {
return d; return d;
} }
function utcStringToDate(str) {
var arr = ((str.replace('"','')).replace(' UTC','')).split(/[\s-:]+/);
var d = new Date();
d.setYear(parseInt(arr[0]));
d.setMonth(parseInt(arr[1]));
d.setDate(parseInt(arr[2]));
d.setHours(parseInt(arr[3]),parseInt(arr[4]),parseInt(arr[5]))
return d;
}
function stringArrToArr(str) { function stringArrToArr(str) {
var arr = ((str.replace('["','')).replace('"]','')).split('","'); var arr = ((str.replace('["','')).replace('"]','')).split('","');
return arr; return arr;
...@@ -163,8 +173,6 @@ function removeDays(date, days) { ...@@ -163,8 +173,6 @@ function removeDays(date, days) {
function setYDomain(labels) { function setYDomain(labels) {
console.log(labels)
var inf = (labels[0]).from, var inf = (labels[0]).from,
sup = (labels[labels.length - 1]).to; sup = (labels[labels.length - 1]).to;
...@@ -180,6 +188,9 @@ function setYDomain(labels) { ...@@ -180,6 +188,9 @@ function setYDomain(labels) {
} else if (window.timeScale == "year") { } else if (window.timeScale == "year") {
inf = removeDays(inf,365) inf = removeDays(inf,365)
sup = addDays(sup,365) sup = addDays(sup,365)
} else if (window.timeScale == "epoch") {
inf = inf
sup = sup
} else { } else {
inf = new Date((inf.getFullYear() - 1),0,0); inf = new Date((inf.getFullYear() - 1),0,0);
sup = new Date((sup.getFullYear() + 1),0,0); sup = new Date((sup.getFullYear() + 1),0,0);
...@@ -797,6 +808,8 @@ function drawPhylo(branches, periods, groups, links, aLinks, bLinks, frame) { ...@@ -797,6 +808,8 @@ function drawPhylo(branches, periods, groups, links, aLinks, bLinks, frame) {
function setGroup(g) { function setGroup(g) {
console.log(window.weighted)
if(window.weighted == true) { if(window.weighted == true) {
var radius = wScale(g.weight) var radius = wScale(g.weight)
} else { } else {
...@@ -908,7 +921,8 @@ function drawPhylo(branches, periods, groups, links, aLinks, bLinks, frame) { ...@@ -908,7 +921,8 @@ function drawPhylo(branches, periods, groups, links, aLinks, bLinks, frame) {
yAxis.call(d3.axisLeft(scale) yAxis.call(d3.axisLeft(scale)
.tickFormat(function(d){ .tickFormat(function(d){
if (d3.timeYear(d) < d) { if (d3.timeYear(d) < d) {
return d3.timeFormat('%b')(d); // '%B'
return d3.timeFormat('%B')(d);
} else { } else {
return d3.timeFormat('%Y')(d); return d3.timeFormat('%Y')(d);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment