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

UI hover functionality #95

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

UI hover functionality #95

wants to merge 9 commits into from

Conversation

luciencd
Copy link
Collaborator

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.

@luciencd luciencd requested a review from SaswatB April 20, 2017 01:58
@luciencd
Copy link
Collaborator Author

Fixed all merge conflicts and tested, it works.

//Hovering over a representative node.


//Hovering over a donation edge.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unneeded comments

@@ -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';
Copy link
Collaborator

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


class Graph {
constructor(element, nodeMenu) {


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded spaces

});

//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});
Copy link
Collaborator

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

@@ -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});

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

@@ -91,10 +100,12 @@ class Graph {
.force("center", d3.forceCenter())
.force('Y', d3.forceY().y(0).strength(.001));
//Draw the edges between the nodes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space


//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
Copy link
Collaborator

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

@@ -155,6 +155,7 @@ footer {
color: lightgreen;
}


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space


if(d.type == "representative"){
d3.select(this.parentNode).selectAll("g > rect#"+d.id)
.attr("width",d.bbox.width+10);
Copy link
Collaborator

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

Copy link
Collaborator

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

if(d.type == "donation"){
//Thickness is amount....
var svg = d3.select("g");
let thickness = d.thickness;
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants