-
Notifications
You must be signed in to change notification settings - Fork 3
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
UI hover functionality #95
base: master
Are you sure you want to change the base?
Conversation
Fixed all merge conflicts and tested, it works. |
client/src/app/app.js
Outdated
//Hovering over a representative node. | ||
|
||
|
||
//Hovering over a donation edge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unneeded comments
client/src/app/utils/d3-modules.js
Outdated
@@ -8,6 +8,8 @@ import * as scale from 'd3-scale'; | |||
import * as selection from 'd3-selection'; | |||
import * as transition from 'd3-transition'; | |||
import * as zoom from 'd3-zoom'; | |||
import * as path from 'd3-path'; | |||
import * as shape from 'd3-shape'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you import these but dont seem to use them (assign them below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
client/src/app/utils/graph.js
Outdated
|
||
class Graph { | ||
constructor(element, nodeMenu) { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unneeded spaces
client/src/app/utils/graph.js
Outdated
}); | ||
|
||
//add the representative nodes | ||
init_y = 0; | ||
Object.keys(data.representatives || {}).forEach((key) => { | ||
nodes.push({id:"r_"+data.representatives[key].id, name: data.representatives[key].name,party:data.representatives[key].party, x:600, fx: 600, y: init_y+=60}); | ||
nodes.push({id:"r_"+data.representatives[key].id, type:"representative",name: data.representatives[key].name,party:data.representatives[key].party, x:600, fx: 600, y: init_y+=60,state:data.representatives[key].state,district:data.representatives[key].district}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please be consistent in attribute order
client/src/app/utils/graph.js
Outdated
@@ -61,14 +66,16 @@ class Graph { | |||
//add the donation links between committees and representatives | |||
Object.keys(data.donations || {}).forEach((key) => { | |||
if(data.donations[key].source in data.committees && data.donations[key].destination in data.representatives){ | |||
links.push({source:"c_"+data.donations[key].source, target: "r_"+data.donations[key].destination,thickness:data.donations[key].amount, status:data.donations[key].support == "S" ? 1 : 2}); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space
client/src/app/utils/graph.js
Outdated
@@ -91,10 +100,12 @@ class Graph { | |||
.force("center", d3.forceCenter()) | |||
.force('Y', d3.forceY().y(0).strength(.001)); | |||
//Draw the edges between the nodes | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space
client/src/app/utils/hover.js
Outdated
|
||
//Mouse event when you stop hovering over a node in the visualization. | ||
//Shows the representative description of the representative on the edge. | ||
handleMouseOverNode(d,i) { // Add interactivity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javascript files use 4 tabs
client/src/style/app.css
Outdated
@@ -155,6 +155,7 @@ footer { | |||
color: lightgreen; | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space
client/src/app/utils/hover.js
Outdated
|
||
if(d.type == "representative"){ | ||
d3.select(this.parentNode).selectAll("g > rect#"+d.id) | ||
.attr("width",d.bbox.width+10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use display = "none" instead of setting width to 0 as that can cause undesired side effects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, please ignore this one
client/src/app/utils/hover.js
Outdated
if(d.type == "donation"){ | ||
//Thickness is amount.... | ||
var svg = d3.select("g"); | ||
let thickness = d.thickness; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thickness should not be used like this
Added hovering popups for representative nodes, and donation edges. allows you to find out more info about them.
Nodes: Tells you whether the rep is a senator or congressman, what state they represent, and if they have a district, which one.
Edges: for the donation edge, going from a superpac, to a representative, it gives the total dollar amount donated.