Skip to content

Commit

Permalink
begin #235
Browse files Browse the repository at this point in the history
  • Loading branch information
samussiah committed Dec 8, 2021
1 parent 92ca743 commit 377fd7a
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 160 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@
d.value.inVicinityOfFocus = d.value.distanceFromFocus < _this.settings.orbitRadius / 16; // Update coordinates once node reaches vicinity of destination or when time since
// previous state crosses some threshold.

d.value.state.transitTime++;
d.value.transitTime++;
var transitThreshold = 500 / Math.ceil(Math.sqrt(_this.settings.speeds[_this.settings.speed]));

Expand Down Expand Up @@ -4577,7 +4578,10 @@

if (!has.duration && has.start_timepoint && has.end_timepoint) {
d.duration = d.end_timepoint - d.start_timepoint + 1;
}
} // Track transit time of node during each state.


d.transitTime = 0;
}); // Define sequence

group.sort(function (a, b) {
Expand Down
3 changes: 3 additions & 0 deletions src/data/mutateData/addVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default function addVariables(has) {
if (!has.duration && has.start_timepoint && has.end_timepoint) {
d.duration = d.end_timepoint - d.start_timepoint + 1;
}

// Track transit time of node during each state.
d.transitTime = 0;
});

// Define sequence
Expand Down
28 changes: 0 additions & 28 deletions src/data/nestData/getAestheticValues.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/data/nestData/getAestheticValues/countStateChanges.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/data/nestData/getAesthetics.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/data/nestData/getAesthetics/getColor.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/data/nestData/getAesthetics/getShape.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/data/nestData/getAesthetics/getSize.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/data/nestData/getColorScale.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/data/nestData/getCoordinates.js

This file was deleted.

32 changes: 0 additions & 32 deletions src/data/nestData/getState.js

This file was deleted.

12 changes: 7 additions & 5 deletions src/data/structure.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import getState from './nestData/getState';
import getAestheticValues from './nestData/getAestheticValues';
import getCoordinates from './nestData/getCoordinates';
import getColorScale from './nestData/getColorScale';
import getAesthetics from './nestData/getAesthetics';
import getState from './structure/getState';
import getAestheticValues from './structure/getAestheticValues';
import getCoordinates from './structure/getCoordinates';
import getColorScale from './structure/getColorScale';
import getAesthetics from './structure/getAesthetics';

export default function structure(data) {
const grouped = d3
Expand All @@ -25,6 +25,8 @@ export default function structure(data) {
const colorScale = getColorScale.call(this, aestheticValues.colorValue);
const aesthetics = getAesthetics.call(this, aestheticValues, colorScale);

const queue = [state];

return {
index: this.metadata.id.findIndex((id) => id.key === state.id),
group, // array: data
Expand Down
10 changes: 5 additions & 5 deletions src/init/startInterval/reset/animation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import getNextSequence from '../runNextSequence/getNextSequence';
import getState from '../../../data/nestData/getState';
import getAestheticValues from '../../../data/nestData/getAestheticValues';
import getCoordinates from '../../../data/nestData/getCoordinates';
import getColorScale from '../../../data/nestData/getColorScale';
import getAesthetics from '../../../data/nestData/getAesthetics';
import getState from '../../../data/structure/getState';
import getAestheticValues from '../../../data/structure/getAestheticValues';
import getCoordinates from '../../../data/structure/getCoordinates';
import getColorScale from '../../../data/structure/getColorScale';
import getAesthetics from '../../../data/structure/getAesthetics';
import runModal from '../../runModal';

export default function resetAnimation(data) {
Expand Down
11 changes: 6 additions & 5 deletions src/init/startInterval/update/data/nestedData.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import getState from '../../../../data/nestData/getState';
import getAestheticValues from '../../../../data/nestData/getAestheticValues';
import getCoordinates from '../../../../data/nestData/getCoordinates';
import getColorScale from '../../../../data/nestData/getColorScale';
import getAesthetics from '../../../../data/nestData/getAesthetics';
import getState from '../../../../data/structure/getState';
import getAestheticValues from '../../../../data/structure/getAestheticValues';
import getCoordinates from '../../../../data/structure/getCoordinates';
import getColorScale from '../../../../data/structure/getColorScale';
import getAesthetics from '../../../../data/structure/getAesthetics';
import travelTime from './nestedData/travelTime';

export default function nestedData(data) {
Expand Down Expand Up @@ -32,6 +32,7 @@ export default function nestedData(data) {

// Update coordinates once node reaches vicinity of destination or when time since
// previous state crosses some threshold.
d.value.state.transitTime++;
d.value.transitTime++;
const transitThreshold =
500 / Math.ceil(Math.sqrt(this.settings.speeds[this.settings.speed]));
Expand Down
54 changes: 35 additions & 19 deletions test-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,49 @@ fetch('./data/2e4.csv')
delete d.duration;
});

const data5 = d3.nest()
.key(d => d.id)
.rollup(group => {
group.forEach((d,i) => {
d.stdy = i + 1;
d.endy = i + 1;
});

return group;
})
.entries(data)
.sort((a,b) => b.value.length - a.value.length)
.slice(0,5)
.map(d => d.value)
.flat();

const fdg = forceDirectedGraph(
data.filter(d => !/Death/.test(d.event)),
data5,
'#container',
{
individualUnit: 'patient',
individualLabel: 'Patients',
eventUnit: 'event',
eventLabel: 'HFrEF events',
timeRelative: 'since randomization',
speed: 'fast',
speedChange: [
{
timepoint: 60,
speed: 'slow',
},
{
timepoint: 75,
speed: 'medium'
}
],
eventFocusLabelChange: [
{
old_label: 'Home',
new_label: 'Away',
timepoint: 60
}
],
speed: 'medium',
//speedChange: [
// {
// timepoint: 60,
// speed: 'slow',
// },
// {
// timepoint: 75,
// speed: 'medium'
// }
//],
//eventFocusLabelChange: [
// {
// old_label: 'Home',
// new_label: 'Away',
// timepoint: 60
// }
//],
delay: 0,
minRadius: 3,
fill: true,
Expand Down

0 comments on commit 377fd7a

Please sign in to comment.