Let's learn more about our institution while learning more about javascript and interactive information visualization (a.k.a. "infovis" or "dataviz").
- Fork this repository
- Clone your fork
Note: this not about using 3p code in your own app (final project)
- come to have the code (e.g. clone repo, as in preceding section)
- open a terminal in that directory (i.e. the one that has the
package.json
file), you will know this worked because you will see thepackage.json
file when you runls
ordir
- run
npm i
(ornpm install
to install the dependencies listed in thepackage.json
file) - you're ready to roll, so in the case of this project which is built with vite, you could now do like
npm run dev
- Go to the URL listed in the output of the previous step (e.g. http://localhost:5173/ )
- What do you see?
- Review the
index.html
andmain.js
files to see what they're doing- Notice that
main.js
:- loads the
d3
library: https://d3js.org/what-is-d3 - fetches some json data from
data/data_sankey.json
- take a look at this file:
- what javascript data structures are used in this file?
- what general data structure (for those of you have taken Dat Structures) might best represent the data that is in this file?
- take a look at this file:
- uses the
d3-sankey
library to create a sankey diagram
- loads the
- Notice that
We will make 4 Sankey diagrams (more details follow) using data from JMU which you can find in the data
directory.
- Inspect the
data/jmu.json
file- What javascript structure(s) is(are) used in this file?
- how does the structure of the data in this file compare to the structure of the data in
data/data_sankey.json
?
- Create the new sankey diagram per specs below.
- When working conducting data analysis, including infovis, it is often necessary to wrangle the data into a format that is more amenable to the task at hand.
- often this just means in to a format expected by our own existing code, our (or third-party, a.k.a. "3p") libraries, tools, apps, etc.
- In this case, we will need to wrangle the data in
data/jmu.json
into a format that is expected by thed3-sankey
library. - In
main.js
edit the code where the current json data is loaded to instead load the correct data file, and before proceeding to the next parts of the code, construct data in the format expected by thed3-sankey
library.
- leftmost node: JMU Student
- second-to-leftmost nodes: Fall, Spring
- rightmost nodes: the
student itemized
costs from thestudent-costs
- leftmost node: Auxiliary Comprehensive Fee (or "Comprehensive Fee")
- rightmost nodes: the
Auxiliary Comprehensive Fee Component
costs from thestudent-costs
- leftmost nodes: JMU (positive) Revenue items
- second-to-leftmost nodes: JMU Revenue Categories (e.g. operating revenues, non-operating revenues, etc.)
- center node: JMU
- second-to-rightmost nodes: JMU Expense (negative revenue) Categories (e.g. operating expenses)
- rightmost nodes: JMU Expense items (e.g. Instruction, Research, etc.)
- leftmost nodes: football, men's basketball, women's basketball, other sports, non-program specific
- second-to-leftmost nodes: JMU Athletics (positive) Revenue items (e.g. Ticker sales, etc.)
- center node: JMU Athletics
- second-to-rightmost nodes: JMU Athletics Expense categories (negative revenue) (e.g. Athletic student aid, etc.)
- rightmost nodes: football, men's basketball, women's basketball, other sports, non-program specific
- https://d3-graph-gallery.com/graph/sankey_basic.html
- https://github.com/d3/d3-sankey
- https://observablehq.com/@d3/sankey/2
- https://observablehq.com/@d3/sankey-component