Skip to main content
100%

D3 SVG Tutorial

✓ Published0🌍 Public
JJamestiberiuseanes
Last edited Feb 3, 2016
Created on Feb 3, 2016

This example shows a static bar chart of a 20-point dataset rendered as an SVG, with each bar’s height and color intensity tied to its value. The code uses D3.js version 3.5.5, applying the `d3.select` and `data().enter()` pattern to append rectangles and text labels. Bars are positioned with arithmetic on the dataset length and fixed width/height variables, while fill colors are generated as RGB values scaled by data. The chart demonstrates basic SVG shape binding and data-driven styling without axes or interaction.

AI-generated description

VI2 - James Eanes

Part 1 - Tableau:

  • Bar chart of passing yards per player (best displayed as a horizontal bar chart), with conference mapped to color
    • Insight: this is incredibly easy to do with an off-the-shelf tool (i.e., a few mouse clicks) versus the hours it took to learn enough about R to make this same graph!

tableau_barchart_passingyds_confcolor

  • Scatterplot of 2 interesting variables, with conference mapped to color
    • Insight: I chose to plot pass attempts and interceptions to determine what correlation might exist between them and what outliers might exist; as one might expect, those with the most interceptions also had relatively high pass attempts; however, there is one passer who clear surpasses everyone in interceptions (22, with about 440 passes), and there is one with a remarkable 8 interceptions with 550 passes. Good plot for finding standouts.

tableau_scatterplot_passattempts_vs_interceptions

  • One other interesting graph that uses a derived variable
    • Insight: I chose to plot the sum of passing and rushing yards per passer; this gives a quick view of the most capable “threats” in terms of both their arms and legs, with about 7 real stand-outs.

sumrushingpassing

Comments on using Tableau:

  1. It's very easy to use for simple charts, but takes some time to get used to the layout.
  2. I had to search around to figure out how to get the sum of two measures; turned out I needed to right-click on one of the measures and create a "Calculated Field", which wasn't the most obvious of ways to get there.

What I learned in this part of the D3 tutorial:

  1. Internet Explorer 8+ doesn't support SVG...seems bad...
  2. SVG syntax is apparently based on (or at least very similar to) XML
  3. There are multiple ways to represent just about everything, but the "chaining" approach really helps when adding lots of attributes (instead of typing in values as attributes on a DOM element).

Similar vizzes