Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show cited nodes in yellow #4

Merged
merged 1 commit into from
Nov 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions source/containers/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ class Graph extends React.Component {
for (let index = this.nodes.length - 1; index >= 0; --index) {
if (this.nodes[index].keep) {
delete this.nodes[index].keep;
this.nodes[index].isCiter = nextProps.doisCitingSelected.has(this.nodes[index].doi);
this.nodes[index].isCiting = nextProps.doisCitingSelected.has(this.nodes[index].doi);
this.nodes[index].isCited = nextProps.doisCitedBySelected.has(this.nodes[index].doi);
} else {
updateRequired = true;
this.reheatSimulation = true;
Expand Down Expand Up @@ -275,9 +276,15 @@ class Graph extends React.Component {
.attr('fill', node => (
node.selected ?
this.props.colors.active
: (node.isCiter ?
: (node.isCiting ?
this.props.colors.valid
: (node.status === PUBLICATION_STATUS_IN_COLLECTION ? this.props.colors.link : this.props.colors.sideSeparator)
: (node.isCited ?
this.props.colors.warning
:(node.status === PUBLICATION_STATUS_IN_COLLECTION ?
this.props.colors.link
: this.props.colors.sideSeparator
)
)
)
))
.on('mouseover', function(node) {
Expand All @@ -286,9 +293,15 @@ class Graph extends React.Component {
.on('mouseout', function(node) {
d3.select(this).attr('fill', node.selected ?
colors.active
: (node.isCiter ?
: (node.isCiting ?
colors.valid
: (node.status === PUBLICATION_STATUS_IN_COLLECTION ? colors.link : colors.sideSeparator)
: (node.isCited ?
colors.warning
: (node.status === PUBLICATION_STATUS_IN_COLLECTION ?
colors.link
: colors.sideSeparator
)
)
)
);
})
Expand Down Expand Up @@ -412,7 +425,15 @@ export default connect(
).map(
([doi, publication]) => {return {...publication, doi}}
);
const selectedPublicationAndDoi = Array.from(state.publications.entries()).find(([doi, publication]) => publication.selected);
const selectedDoiAndPublication = Array.from(state.publications.entries()).find(([doi, publication]) => publication.selected);
const doisCitedBySelected = new Set(selectedDoiAndPublication ?
Array.from(state.publications.entries()).filter(
([doi, publication]) => publication.citers.includes(selectedDoiAndPublication[0])
).map(
([doi, publication]) => doi
)
: []
);
return {
zoom: state.graph.zoom,
xOffset: state.graph.xOffset,
Expand All @@ -428,7 +449,8 @@ export default connect(
})
)
),
doisCitingSelected: new Set(selectedPublicationAndDoi ? selectedPublicationAndDoi[1].citers : []),
doisCitingSelected: new Set(selectedDoiAndPublication ? selectedDoiAndPublication[1].citers : []),
doisCitedBySelected,
recommandedDois,
display: state.menu.display,
sticky: state.graph.sticky,
Expand Down