Last active
December 15, 2015 04:38
-
-
Save deargle/5202704 to your computer and use it in GitHub Desktop.
I used DallinQ's GedcomToJson GitHub tool to convert a GEDCOM export of my PAF file to Json, then I used this script to display it with Google's OrgChart Visualization tool.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- I used DallinQ's GedcomToJson GitHub tool to convert a GEDCOM export of my PAF file to Json, then I used this script to display it with Google's OrgChart Visualization tool. --> | |
<script type='text/javascript' src='https://www.google.com/jsapi'></script> | |
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.min.js'></script> | |
<script type='text/javascript' src='famTree.js'></script><!-- this references the JSON output of my GEDCOM file. I edited the file and called the entire json "var famTree". --> | |
<script type='text/javascript'> | |
var rowData = []; | |
google.load('visualization', '1', {packages:['orgchart']}); | |
google.setOnLoadCallback(function(){ | |
drawChart(rowData); | |
}); | |
function drawChart() { | |
var data = new google.visualization.DataTable(); | |
data.addColumn('string', 'Parent'); | |
data.addColumn('string', 'Child'); | |
data.addColumn('string', 'ToolTip'); | |
data.addRows(rowData); | |
var chart = new google.visualization.OrgChart(document.getElementById('chart_div')); | |
chart.draw(data, {allowHtml:true}); | |
} | |
// I am ID I172 in my PAF | |
var rootId = "I172"; | |
var generationalDepth = 32; // a way to limit the recursion | |
drawGeneration(rootId); | |
function drawGeneration(relativeRootId) { | |
var $relativeRootPerson = getPersonById(relativeRootId); | |
try { | |
var relativeRootPersonFamilyId = $relativeRootPerson[0].famc[0].ref; | |
var relativeRootPersonFamily = getFamilyById(relativeRootPersonFamilyId); | |
var relativeRootPersonDadId = relativeRootPersonFamily[0].husbandRefs[0].ref; | |
var relativeRootPersonMomId = relativeRootPersonFamily[0].wifeRefs[0].ref; | |
} catch(e) { | |
return; // we've hit a dead-end | |
} | |
var $relativeRootPersonDad = getPersonById(relativeRootPersonDadId); | |
var $relativeRootPersonMom = getPersonById(relativeRootPersonMomId); | |
pushToRowData($relativeRootPersonMom[0].names[0].value, $relativeRootPerson[0].names[0].value, ''); | |
pushToRowData($relativeRootPersonDad[0].names[0].value, $relativeRootPerson[0].names[0].value, ''); | |
generationalDepth--; | |
if (generationalDepth > 0) { | |
drawGeneration(relativeRootPersonDadId); | |
drawGeneration(relativeRootPersonMomId); | |
} | |
} | |
function getPersonById(idSearch) { | |
return $.grep(famTree.people, function(item) { | |
return item.id === idSearch | |
}); | |
} | |
function getFamilyById(idSearch) { | |
return $.grep(famTree.families , function(item) { | |
return item.id === idSearch | |
}); | |
} | |
function pushToRowData(name, child, tooltip) { | |
rowData.push([name, child, tooltip]); | |
} | |
</script> | |
</head> | |
<body> | |
<div id='chart_div'></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment