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.jsonfile), you will know this worked because you will see thepackage.jsonfile when you runlsordir - run
npm i(ornpm installto install the dependencies listed in thepackage.jsonfile) - 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.htmlandmain.jsfiles to see what they're doing- Notice that
main.js:- loads the
d3library: 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-sankeylibrary 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.jsonfile- 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.jsoninto a format that is expected by thed3-sankeylibrary. - In
main.jsedit 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-sankeylibrary.
- leftmost node: JMU Student
- second-to-leftmost nodes: Fall, Spring
- rightmost nodes: the
student itemizedcosts from thestudent-costs
- leftmost node: Auxiliary Comprehensive Fee (or "Comprehensive Fee")
- rightmost nodes: the
Auxiliary Comprehensive Fee Componentcosts 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. Ticket 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
