Skip to content

Commit

Permalink
merging branch into master
Browse files Browse the repository at this point in the history
  • Loading branch information
cnobre committed Mar 31, 2017
2 parents 412fb9a + ef21e1a commit c5011d8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 28 deletions.
4 changes: 3 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export class App {

/** ===== PUBLIC CASE ===== */

await tableManager.loadData('TenFamiliesDescendAnon', 'TenFamiliesAttrAnon');
// await tableManager.loadData('TenFamiliesDescendAnon', 'TenFamiliesAttrAnon');
await tableManager.loadData('TwoFamiliesDescendAnon', 'TwoFamiliesAttrAnon');



/** ===== PRIVATE CASES - WORKS ONLY WITH THE RIGHT DATA LOCALLY ===== */
Expand Down
41 changes: 21 additions & 20 deletions src/attributeTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
PRIMARY_SELECTED,
COL_ORDER_CHANGED_EVENT,
POI_SELECTED,
UPDATE_TABLE_EVENT,
VIEW_CHANGED_EVENT,
TABLE_VIS_ROWS_CHANGED_EVENT
} from './tableManager';
Expand Down Expand Up @@ -125,7 +126,6 @@ class attributeTable {


public async update() {

await this.initData();
this.render();
}
Expand Down Expand Up @@ -211,7 +211,7 @@ class attributeTable {
select('#revertTreeOrder')
.attr('visibility', 'hidden')

let t2 = transition('t2').duration(600).ease(easeLinear);
let t2 = transition('test').duration(600).ease(easeLinear);

select('#columns').selectAll('.cell')
.transition(t2)
Expand Down Expand Up @@ -242,7 +242,6 @@ class attributeTable {
selectAll('.slopeLine')
.transition(t2)
.attr('d', (d: any) => {
console.log('collapsedWidth')
return this.slopeChart({y: d.y, ind: d.ind, width: Config.collapseSlopeChartWidth})
});

Expand All @@ -267,8 +266,6 @@ class attributeTable {

public async initData() {

console.log('calling initData');

// this.colOffsets = [-Config.slopeChartWidth];

this.colOffsets = [0];
Expand Down Expand Up @@ -393,12 +390,14 @@ class attributeTable {
}); //get categories from index.json def
let categories;

console.log(allCategories)

//Only need one col for binary categories
if (allCategories.length < 3) {
if (allCategories.find(d => {
return d === 'Y'
return d === 'Y';
})) {
categories = ['Y']
categories = ['Y'];
} else if (allCategories.find(d => {
return d === 'True'
})) {
Expand All @@ -415,6 +414,7 @@ class attributeTable {
categories = allCategories;
}

// console.log(categories)

if (categories.length > 2) { //Add spacing around multicolumn categories
let numColsBefore = this.colOffsets.length - 1;
Expand All @@ -439,7 +439,7 @@ class attributeTable {
people.map((person) => {
let ind = peopleIDs.indexOf(person) //find this person in the attribute data
//If there are only two categories, save both category values in this column. Else, only save the ones that match the category at hand.
if (ind > -1 && (allCategories.length < 3 || (allCategories.length > 2 && data[ind] === cat))) {
if (ind > -1 && (allCategories.length < 3 || ind > -1 && (allCategories.length > 2 && data[ind] === cat))) {
colData.push(data[ind])
} else {
colData.push(undefined);
Expand Down Expand Up @@ -541,10 +541,12 @@ class attributeTable {
let colData = [];
let people = y2personDict[row];
people.map((person) => {
// console.log(data,person)
let ind = peopleIDs.indexOf(person) //find this person in the attribute data
if (ind > -1) {
if (isUndefined(data[ind])){
console.log('problem')
console.log(name,data.size(),peopleIDs.size());
}
colData.push(data[ind].toString())
} else {
Expand Down Expand Up @@ -581,7 +583,8 @@ class attributeTable {
//renders the DOM elements
private async render() {

let t = transition('t').duration(500).ease(easeLinear);
let t = transition('t').ease(easeLinear);
// let t= this.tableManager.t;
let self = this;

let y = this.y;
Expand Down Expand Up @@ -657,7 +660,8 @@ class attributeTable {
});


colSummaries.transition(t)
colSummaries
.transition(t)
.attr('transform', (d, i) => {
let offset = this.colOffsets[i];
return 'translate(' + offset + ',0)';
Expand Down Expand Up @@ -781,7 +785,7 @@ class attributeTable {
return d.varName
});

cols.exit().transition(t).attr('opacity', 0).remove(); // should remove on col remove
cols.exit().remove(); // should remove on col remove

const colsEnter = cols.enter()
.append('g')
Expand All @@ -791,7 +795,8 @@ class attributeTable {
cols = colsEnter.merge(cols)//;

//translate columns horizontally to their position;
cols.transition(t)
cols
.transition(t)
.attr('transform', (d, i) => {
let offset = this.colOffsets[i];
return 'translate(' + offset + ',0)';
Expand All @@ -805,13 +810,12 @@ class attributeTable {
'name': d.name, 'data': d.data, 'ind': i, 'type': d.type,
'ids': d.ids, 'stats': d.stats, 'varName': d.name, 'category': d.category, 'vector': d.vector
}
console.log('out', out);
return out;
}), (d: any) => {
return d.varName
});

firstCol.exit().transition(t).attr('opacity', 0).remove(); // should remove on col remove
firstCol.exit().attr('opacity', 0).remove(); // should remove on col remove

const firstColEnter = firstCol.enter()
.append('g')
Expand Down Expand Up @@ -851,7 +855,6 @@ class attributeTable {
firstCellsEnter.attr('opacity', 0);

firstCells
.transition(t)
.attr('transform', (cell: any, i) => {
return ('translate(0, ' + y(this.rowOrder[i]) + ' )'); //the x translation is taken care of by the group this cell is nested in.
});
Expand Down Expand Up @@ -1669,10 +1672,9 @@ class attributeTable {
element.selectAll('.quant_ellipse')
.attr('cx',
(d: any) => {
if (isNaN(d.value)) {
console.log(d)
if (!isNaN(d.value)) {
return this.xScale(d.value);
}
return this.xScale(d.value);
;
})
.attr('cy', () => {
Expand Down Expand Up @@ -1979,7 +1981,6 @@ class attributeTable {

events.on(TABLE_VIS_ROWS_CHANGED_EVENT, () => {
self.update();

});

events.on(PRIMARY_SELECTED, (evt, item) => {
Expand All @@ -1991,7 +1992,7 @@ class attributeTable {
});

events.on(COL_ORDER_CHANGED_EVENT, (evt, item) => {
self.update();
// self.update();
});

}
Expand Down
23 changes: 17 additions & 6 deletions src/genealogyTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ class GenealogyTree {
//Call function that updates the position of all elements in the tree
this.update_graph();

console.log('done updating tree (within update)')

}


Expand Down Expand Up @@ -646,7 +648,7 @@ class GenealogyTree {
});

//remove extra paths
edgePaths.exit().transition().duration(400).style('opacity', 0).remove();
edgePaths.exit().remove();

let edgePathsEnter = edgePaths
.enter()
Expand All @@ -658,7 +660,7 @@ class GenealogyTree {

edgePaths
.attr('class', 'edges')
.transition(t)
// .transition(t)
.attr('d', (d: Node) => {
let maY = Math.round(d.ma.y);
let paY = Math.round(d.pa.y);
Expand All @@ -672,7 +674,7 @@ class GenealogyTree {
});

edgePaths
.transition(t.transition().ease(easeLinear))
.transition(t.transition().duration(1000).ease(easeLinear))
.attr('opacity', 1)
.attr('stroke-width', Config.glyphSize / 5);

Expand All @@ -686,7 +688,7 @@ class GenealogyTree {
});


parentEdgePaths.exit().transition().duration(400).style('opacity', 0).remove();
parentEdgePaths.exit().style('opacity', 0).remove();

let parentEdgePathsEnter = parentEdgePaths
.enter()
Expand Down Expand Up @@ -784,6 +786,7 @@ class GenealogyTree {


aggregateBars
.transition(t.transition().duration(500).ease(easeLinear))
.attr('opacity',1);


Expand Down Expand Up @@ -843,7 +846,6 @@ class GenealogyTree {
.attr('opacity', 0)

function highlightRows(d: any) {
console.log('here')

function selected(e: Node) {
let returnValue = false;
Expand Down Expand Up @@ -1026,6 +1028,8 @@ class GenealogyTree {

couplesLines = couplesLinesEnter.merge(couplesLines)

couplesLines.attr('opacity',0)

couplesLines
.attr('x1', (d:any) => {
return this.x(d.x) + Config.glyphSize*.9;
Expand All @@ -1044,6 +1048,9 @@ class GenealogyTree {
})
.attr('stroke-width', 2)


couplesLines.attr('opacity',1);

const kidGridsGroup = select('#genealogyTree').select('#kidGrids');

// Attach backgroundRects
Expand Down Expand Up @@ -1090,7 +1097,7 @@ class GenealogyTree {
return d.uniqueID;
});

allNodes.exit().transition().duration(400).style('opacity', 0).remove();
allNodes.exit().remove();

const allNodesEnter = allNodes
.enter()
Expand Down Expand Up @@ -1268,6 +1275,8 @@ class GenealogyTree {

private renderNodeGroup(element, d: Node) {

const t = transition('t').duration(500).ease(easeLinear);

element
.classed('affected', (n: any) => {
return n.affected
Expand Down Expand Up @@ -1512,11 +1521,13 @@ class GenealogyTree {
//Size hidden nodes differently
//regular nodes
element.selectAll('.male')
.transition(t)
.attr('width', glyphSize)
.attr('height', glyphSize);

//unhidden nodes
element.selectAll('.female')
.transition(t)
.attr('r', radius);

//attribute frames
Expand Down
12 changes: 11 additions & 1 deletion src/tableManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import * as range from 'phovea_core/src/range';
import * as events from 'phovea_core/src/event';
import {max, min, mean} from 'd3-array';
import {IStatistics} from 'phovea_core/src/math';
import {transition} from 'd3-transition';
import {easeLinear} from 'd3-ease';
import {__awaiter} from 'tslib';


interface IFamilyInfo {
id: number;
range: number[];
Expand Down Expand Up @@ -81,6 +84,7 @@ export const POI_SELECTED = 'affected_attribute_event';
export const FAMILY_INFO_UPDATED = 'family_stats_updated';
export const COL_ORDER_CHANGED_EVENT = 'col_ordering_changed';
export const FAMILY_SELECTED_EVENT = 'family_selected_event';
export const UPDATE_TABLE_EVENT = 'update_table'


// export const PRIMARY_COLOR = '#335b8e';
Expand Down Expand Up @@ -141,7 +145,8 @@ export default class TableManager {
// ['KindredID','PersonID', 'Asthma', 'Bipolar', 'sex', 'deceased', 'suicide', 'gen', 'Age', 'FirstBMI', 'AgeFirstBMI', 'race', 'cause_death', 'weapon']; //set of default cols to read in, minimizes load time for large files;

private defaultCols: String[] =
['KindredID', 'RelativeID', 'suicide','sex', 'deceased', 'LabID', 'Age','Depression', 'Age1D_Depression', 'Nr.Diag_Depression', 'Asthma', 'Age1D_Asthma', 'Nr.Diag_Asthma', 'Bipolar', 'MaxBMI', 'AgeMaxBMI', 'race','cause_death', 'weapon']; //set of default cols to read in, minimizes load time for large files;
['KindredID', 'RelativeID', 'sex', 'deceased', 'suicide', 'Depression', 'Age1D_Depression', 'Nr.Diag_Depression', 'Bipolar', 'Age1D_Bipolar', 'Nr.Diag_Bipolar', 'MaxBMI', 'AgeMaxBMI', 'race','cause_death', 'weapon']; //set of default cols to read in, minimizes load time for large files;



public colOrder: String[]; //array that keeps track which attributes are displayed in the panel and in the table and their correct order.
Expand All @@ -159,6 +164,8 @@ export default class TableManager {
//Keeps track of selected primary/secondary variable
private primaryAttribute: IPrimaryAttribute;

public t = transition('t').duration(600).ease(easeLinear);


/**
* Loads the graph data and the attribute data from the server and stores it in the public table variable
Expand Down Expand Up @@ -659,6 +666,7 @@ export default class TableManager {
set activeTableRows(newRows: range.Range) {
this._activeTableRows = newRows;
this.tableTable = this.table.view(range.join(this._activeTableRows, this.activeTableColumns));
console.log('firing TABLE VIS ROWS from activeTableRows')
events.fire(TABLE_VIS_ROWS_CHANGED_EVENT);
}

Expand All @@ -679,6 +687,8 @@ export default class TableManager {

this._activeGraphRows = range.list(newRange);
this.refreshActiveGraphView().then(() => {
console.log('firing update table then TABLE VIS ROWS from activeGraphRows')
// events.fire(UPDATE_TABLE_EVENT);
events.fire(TABLE_VIS_ROWS_CHANGED_EVENT);
});

Expand Down

0 comments on commit c5011d8

Please sign in to comment.