I’m doing some form of data visualization learning for 180 days because I need to #JFDI.

See post explaining how and why I’m doing this.

Code Learning:

Three Takeways

Chapter Six Network Visualization

  • Example of function for adding new nodes and edges to make sure they’re connected to new network (note seems inefficient, why not just add it to data?  Good code practice/explanation tho)
    • function addNodesAndEdges() {
      • force.stop();
      • var oldEdges = force.links()
      • var oldNodes = force.nodes()
      • var newNode1 = {id: “raj”, followers: 100, following: 67};
      • var newNode2= {id: “wu”, followers: 50, following: 30};
      • var newEdge1 = {source: oldNodes[0], target: newNode1, weight 5};
      • var newEdge2 = {source: oldNodes[0], target newNode2, weight: 5};
      • oldEdges.push(newEdge1, newEdge2);
      • oldNodes.push(newNode1, newNode2);
      • force.links(oldEdges).nodes(oldNodes);
    • d3.select(“svg”).selectAll(“line.link”)
      • .data(oldEdges, function(d) {
      • return d.source.id + “-” + d.target.id
      • })
    • .enter()
    • .insert(“line”, “g.node”)
    • .attr(“class”, “link”)
    • .style(“stroke”, “red”)
    • .style(“stroke-width”,  5)
    • .attr(“marker-end”, “url(#Triangle)”);
  • var nodeEnter = d3.select(“svg”).selectAll(“g.node”)
    • .data(oldNodes, function(id) {
      • return d.id
      • }).enter()
      • .append(“g”)
      • .attr(“class”, “node”)
      • call(force.drag());
  • nodeEnter.append(“circle”)
    • .attr(“r”, 5)
    • .style(“fill”, “red”)
    • .style(“stroke”, “darkred”)
    • .style(“stroke-width”, “2px”)
  • nodeEnter.append(“text”)
    • .style(“text-anchor”, “middle”)
    • .attr(“y”, 15)
    • .text(function(d) { return d.id;});
    • force.start();
    • };
  • Force layouts are extremely resource intensive.  You can optimize by limiting the nodes on your network. p 202
  • Another way to optimize is use force.chargeDistance() to set max distance – the lower the charge distance, the less structured the layout will be, but the faster it will run. p 203

Reading and Learning Data Visualization Theoretically/Critically:

Edward Tufte Visual Display of Quantitative Information

Chapter Two Graphical Integrity
Three Takeaways
  • “At the core of the preoccupation with deceptive graphics was the assumption that data graphics were mainly devices for showing the obvious to the ignorant.  It is hard to imagine any doctrine more likely to stifle intellectual progress in a field” p 53
  • “Show data variation, not design variation” p 61
  • “In time-series display of money, deflated and standardized units of monetary measurement are nearly always better than nominal units” p 68
Posted in , , ,

Leave a Reply