Skip to content

Commit

Permalink
Merge 542e0f7 into 054e37b
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke-Sikina committed Apr 15, 2020
2 parents 054e37b + 542e0f7 commit 20b6a65
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 464 deletions.
44 changes: 22 additions & 22 deletions index.html
@@ -1,10 +1,10 @@
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="js/lib/jquery.dataTables.min.js"></script>
<script src="js/lib/jquery.qtip.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="js/lib/underscore-min.js"></script>
<script>
/**
Expand All @@ -25,11 +25,11 @@
*/
Object.setPrototypeOf = Object.setPrototypeOf || function(obj, proto) {
obj.__proto__ = proto;
return obj;
return obj;
}
</script>
<script src="http://cdn.rawgit.com/MrRio/jsPDF/v1.3.5/dist/jspdf.min.js"></script>
<script src="http://html2canvas.hertzen.com/build/html2canvas.js"></script>
<script src="//cdn.rawgit.com/MrRio/jsPDF/v1.3.5/dist/jspdf.min.js"></script>
<script src="//html2canvas.hertzen.com/build/html2canvas.js"></script>
<script src="js/lib/d3-timeline.js"></script>
<script src="js/plugins/util.js"></script>
<script src="js/plugins/pluginPrototype.js"></script>
Expand All @@ -43,8 +43,8 @@
<script src="js/clinicalTimeline.js"></script>
<script src="js/sanity.js"></script>
<script src="js/parser.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="css/lib/jquery.qtip.min.css" type="text/css" rel="stylesheet" />
<link href="css/lib/dataTables.tableTools.min.css" type="text/css" rel="stylesheet" />
<style type="text/css">
Expand Down Expand Up @@ -173,7 +173,7 @@
var testData = getURLParameterByName("test");
var dataFed = "data1";
var waitForParse = false;

if (jsonURL !== "") {
if (jsonURL.indexOf("?view=") > -1) {
jsonURL = jsonURL.substring(0, jsonURL.indexOf("?view="));
Expand Down Expand Up @@ -225,42 +225,42 @@
.enableTrackTooltips(true)
.plugins([
{
obj: new trimClinicalTimeline("Trim Timeline"),
obj: new trimClinicalTimeline("Trim Timeline"),
enabled: trimmingForSceenshotTest
},
},
{
obj: new clinicalTimelineHelperLines("Helper Lines"),
obj: new clinicalTimelineHelperLines("Helper Lines"),
enabled: false
},
},
{
obj: new clinicalTimelineZoom("Zoom"),
obj: new clinicalTimelineZoom("Zoom"),
enabled: !trimmingForSceenshotTest
},
{
obj: new clinicalTimelineOverviewAxis("Overview Axis"),
obj: new clinicalTimelineOverviewAxis("Overview Axis"),
enabled:!trimmingForSceenshotTest
},
{
obj: new clinicalTimelineVerticalLine("Vertical Timeline",
obj: new clinicalTimelineVerticalLine("Vertical Timeline",
{
tooltipControllerId: "#tooltip-controller",
hoverBegin: 200,
tooltipControllerId: "#tooltip-controller",
hoverBegin: 200,
hoverEnd: 770
}),
enabled: false
},
{
obj: new configCheckManager(null,
obj: new configCheckManager(null,
{
configUlId: "#timeline-wrapper #config-div #config-dropdown"
}),
}),
enabled: true
},
{
obj: new clinicalTimelineExporter("Export",
obj: new clinicalTimelineExporter("Export",
{
exportDivId : "#export-div",
}),
}),
enabled: true
}
])
Expand All @@ -287,7 +287,7 @@ <h3>clinical timeline</h3>
<span class="caret"></span></button>
<ul class="dropdown-menu">
<script type="text/javascript">
var exporter = (new clinicalTimelineExporter()).run(null, {exportDivId : "#export-div", timelineDiv : "#timeline"});
var exporter = (new clinicalTimelineExporter()).run(null, {exportDivId : "#export-div", timelineDiv : "#timeline"});
</script>
<li><a href='javascript:exporter.generateSVG()'>SVG Image</a></li>
<li><a href='javascript:exporter.generatePNG(true)'>PNG Image</a></li>
Expand Down
223 changes: 48 additions & 175 deletions js/clinicalTimeline.js
Expand Up @@ -2,53 +2,6 @@
/* start-test-code-not-included-in-build */
d3 = require('d3');
/* end-test-code-not-included-in-build */

formatDayMonthYear = function(time) {
if (Math.abs(time.m) === 12) {
time.y = time.y + time.m / 12;
time.m = 0;
}

if (time.y !== 0) {
if (time.m !== 0) {
if (time.d !== 0) {
return time.y + "y" + Math.abs(time.m) + "m" + Math.abs(time.d) + "d";
} else {
return time.y + "y" + Math.abs(time.m) + "m";
}
} else if (time.d !== 0) {
return time.y + "y" + Math.abs(time.d) + "d";
} else {
return time.y + "y";
}
} else if (time.m !== 0) {
if (time.d !== 0) {
return time.m + "m" + Math.abs(time.d) + "d";
} else {
return time.m + "m";
}
} else {
return time.d + "d";
}
}

formatMonthYear = function(time) {
if (Math.abs(time.m) === 12) {
time.y = time.y + time.m / 12;
time.m = 0;
}

if (time.y !== 0) {
if (time.m !== 0) {
return time.y + "y" + Math.abs(time.m) + "m";
} else {
return time.y + "y";
}
} else {
return time.m + "m";
}
}

var clinicalTimeline = (function(){
"use strict";

Expand All @@ -75,16 +28,8 @@ var clinicalTimeline = (function(){
enableTrackTooltips,
overviewX = margin.overviewAxis.left,
chart = null,
zoomStartId = null,
zoomEndId = null,
zoomStart = null,
firstElementId = null,
lastElementId = null,
trimmed = false,
trimmingDidNothing = false,
clinicalTimelinePlugins,
clinicalTimelineReadOnlyVars,
fractionTimelineShown = 1.0;
clinicalTimelineReadOnlyVars;

function getTrack(data, track) {
return data.filter(function(x) {
Expand Down Expand Up @@ -115,14 +60,13 @@ var clinicalTimeline = (function(){
}

minDays = Math.min(getMinStartingTime(allData), 0);
var zoomLevel = timeline.computeZoomLevel(minDays, maxDays, width * zoomFactor, timeline.fractionTimelineShown()),
var zoomLevel = timeline.computeZoomLevel(minDays, maxDays, width * zoomFactor),
tickValues = timeline.getTickValues(minDays, maxDays, zoomLevel);

beginning = tickValues[0];
ending = tickValues[tickValues.length-1];
overviewAxisWidth = width - 200;


var chart = d3.timeline()
.stack()
.margin(margin)
Expand Down Expand Up @@ -466,6 +410,52 @@ var clinicalTimeline = (function(){
}
}

function formatDayMonthYear(time) {
if (Math.abs(time.m) === 12) {
time.y = time.y + time.m / 12;
time.m = 0;
}

if (time.y !== 0) {
if (time.m !== 0) {
if (time.d !== 0) {
return time.y + "y" + Math.abs(time.m) + "m" + Math.abs(time.d) + "d";
} else {
return time.y + "y" + Math.abs(time.m) + "m";
}
} else if (time.d !== 0) {
return time.y + "y" + Math.abs(time.d) + "d";
} else {
return time.y + "y";
}
} else if (time.m !== 0) {
if (time.d !== 0) {
return time.m + "m" + Math.abs(time.d) + "d";
} else {
return time.m + "m";
}
} else {
return time.d + "d";
}
}

function formatMonthYear(time) {
if (Math.abs(time.m) === 12) {
time.y = time.y + time.m / 12;
time.m = 0;
}

if (time.y !== 0) {
if (time.m !== 0) {
return time.y + "y" + Math.abs(time.m) + "m";
} else {
return time.y + "y";
}
} else {
return time.m + "m";
}
}

timeline.addDataPointTooltip = function addDataPointTooltip(elem) {
function createDataTable(tooltip_table) {
var dataTable = {
Expand Down Expand Up @@ -849,28 +839,6 @@ var clinicalTimeline = (function(){
}
}

timeline.approximateTickToDayValue = function approximateTickToDayValue(tick) {
var dayRegex = /(-?)((\d+)(?:y))?((\d+)(?:m))?((\d+)(?:d))/
var monthRegex = /(-?)((\d+)(?:y))?((\d+)(?:m))/
var yearRegex = /(-?)((\d+)(?:y))/

var uParse = function (num) { return num === undefined ? 0 : parseInt(num); };

var match = tick.match(dayRegex);
if (match) {
return uParse(match[1] + "1") * (uParse(match[3]) * 365 + uParse(match[5]) * 30.5 + uParse(match[7]))
}
match = tick.match(monthRegex);
if (match) {
return uParse(match[1] + "1") * (uParse(match[3]) * 365 + uParse(match[5]) * 30.5)
}
match = tick.match(yearRegex);
if (match) {
return uParse(match[1] + "1") * (uParse(match[3]) * 365)
}
return 0;
}

/**
* Return zoomFactor by specifying what kind of zoomLevel on the x axis
* (e.g. years, days) is desired
Expand Down Expand Up @@ -1009,101 +977,6 @@ var clinicalTimeline = (function(){
return timeline;
};

timeline.fractionTimelineShown = function (update) {
if (!arguments.length) {
return fractionTimelineShown
}
fractionTimelineShown = update;
return timeline;
}

/**
* Has the timeline been trimmed yet?
* Used to avoid render loops when trimmed and zoomed
*
* @param {boolean} update
* @returns {object} clinicalTimeline object | boolean
*/
timeline.trimmed = function (update) {
if (!arguments.length) {
return trimmed
}
trimmed = update;
return timeline;
}

timeline.trimmingDidNothing = function (update) {
if (!arguments.length) {
return trimmingDidNothing
}
trimmingDidNothing = update;
return timeline;
}

/**
* The position in days of the start of the zoom region
* @param {number} update
* @returns {object} clinicalTimeline object | number
*/
timeline.zoomStart = function (update) {
if (!arguments.length) {
return zoomStart
}
zoomStart = update;
return timeline;
}

/**
* The id of the first timeline element inside the zoom region
* @param {number} update
* @returns {object} clinicalTimeline object | number
*/
timeline.zoomStartId = function (update) {
if (!arguments.length) {
return zoomStartId;
}
zoomStartId = update;
return timeline;
}
/**
* The id of the last timeline element inside the zoom region
* @param {number} update
* @returns {object} clinicalTimeline object | number
*/
timeline.zoomEndId = function (update) {
if (!arguments.length) {
return zoomEndId;
}
zoomEndId = update;
return timeline;
}

/**
* The id of the last timeline element
* @param {number} update
* @returns {object} clinicalTimeline object | number
*/
timeline.lastElementId = function (update) {
if (!arguments.length) {
return lastElementId;
}
lastElementId = update;
return timeline;
}

/**
* The id of the first element on the timeline
* @param {number} update
* @returns {object} clinicalTimeline object | number
*/
timeline.firstElementId = function (update) {
if (!arguments.length) {
return firstElementId;
}
firstElementId = update;
return timeline;
}

/**
* Change the value of the variable allData of clinicalTimeline
* if argument data is provided, else return the existing value
Expand Down

0 comments on commit 20b6a65

Please sign in to comment.