Skip to content

Commit

Permalink
Merge pull request #1153 from nextstrain/transmission-perf
Browse files Browse the repository at this point in the history
Improve performance when transmission lines are not drawn
  • Loading branch information
jameshadfield authored Jun 3, 2020
2 parents 748ec8a + a9ef44b commit 55208f6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/components/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class Map extends React.Component {
this.props.pieChart,
this.props.legendValues,
this.props.colorBy,
this.props.showTransmissionLines,
this.props.dispatch
);

Expand Down Expand Up @@ -385,6 +386,7 @@ class Map extends React.Component {
nextProps.pieChart,
nextProps.legendValues,
nextProps.colorBy,
nextProps.showTransmissionLines,
nextProps.dispatch
);
const d3elems = drawDemesAndTransmissions(
Expand All @@ -397,8 +399,7 @@ class Map extends React.Component {
nextProps.dateMaxNumeric,
nextProps.pieChart,
nextProps.geoResolution,
nextProps.dispatch,
nextProps.showTransmissionLines
nextProps.dispatch
);
this.setState({
d3elems,
Expand Down
5 changes: 2 additions & 3 deletions src/components/map/mapHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ export const drawDemesAndTransmissions = (
numDateMax,
pieChart, /* bool */
geoResolution,
dispatch,
showTransmissionLines
dispatch
) => {

// add transmission lines
Expand All @@ -165,7 +164,7 @@ export const drawDemesAndTransmissions = (
.attr("stroke-opacity", 0.6)
.attr("stroke-linecap", "round")
.attr("stroke", (d) => { return d.color; })
.attr("stroke-width", showTransmissionLines ? 1 : 0);
.attr("stroke-width", 1);

const visibleTips = nodes[0].tipCount;
const demeMultiplier =
Expand Down
26 changes: 16 additions & 10 deletions src/components/map/mapHelpersLatLong.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ export const createDemeAndTransmissionData = (
pieChart,
legendValues,
colorBy,
showTransmissionLines,
dispatch
) => {
/*
Expand All @@ -414,16 +415,21 @@ export const createDemeAndTransmissionData = (
demeIndices
} = setupDemeData(nodes, visibility, geoResolution, nodeColors, triplicate, metadata, map, pieChart, legendValues, colorBy);

/* second time so that we can get Bezier */
const { transmissionData, transmissionIndices, demesMissingLatLongs } = setupTransmissionData(
nodes,
visibility,
geoResolution,
nodeColors,
triplicate,
metadata,
map
);
let transmissionData = [];
let transmissionIndices = {};
let demesMissingLatLongs = new Set(); // TODO: this won't be filled in if we're not showing transmission lines...
if (showTransmissionLines) {
/* second time so that we can get Bezier */
({ transmissionData, transmissionIndices, demesMissingLatLongs } = setupTransmissionData(
nodes,
visibility,
geoResolution,
nodeColors,
triplicate,
metadata,
map
));
}

const filteredDemesMissingLatLongs = [...demesMissingLatLongs].filter((value) => {
return value.toLowerCase() !== "unknown";
Expand Down

0 comments on commit 55208f6

Please sign in to comment.