The final project will provide hands-on experience designing, implementing, and deploying interactive visualizations for the web. For this project, you will select a topic of interest and author a narrative article and accompanying visualizations to educate and inform a general audience. Think of your project as contributing to our own class newspaper or scientific magazine. The final deliverable will take the form of an explanatory narrative, deployed as an interactive web page using GitHub Pages. You will leverage the template and style provided here.
Your project must visualize one or more publicly accessible datasets of social or scientific importance. You are free to choose a specific domain of personal interest; for example, you might explore data relevant to your UW major. Example topics include transportation, economic development, humanitarian aid, legislative voting records, and communicating scientific research, among many others. Talk to the course staff if you have any questions regarding the project theme.
This template was created with Idyll, which is a markup language for creating beautiful interactive webpages. For your own webpage, you can customize the particular components and layouts that are used, but the style of the overall page is predefined by our course theme.
Keep reading for examples of how to embed visualizations and modify the format.
We can easily embed images inline by including a short code snippet referencing an image file: 
First, we specify the data that will be used in the visualization with a short code snippet: [data name:"sunshine" source:"sunshine.json" /]
. We will reference this dataset with the name sunshine
when creating visualizations in Vega-Lite or D3.
Idyll has support for embedding Vega-Lite visualizations to the page using a similar approach to the standard image. To get started, we need to first install Vega-Lite by running the command: npm i --save idyll-vega-lite
. We can then embed a visualization as follows (see the index.idyll
file for the actual code):
The main Vega-Lite component uses the JSON syntax, but you can also create Vega-Lite visualizations using the API as follows:
The main thing to note when using the API is that you must call .toSpec()
at the end of your code in order to make the IdyllVegaLite
component behave normally.
.toSpec()
function is an easy way to port visualizations from Observable to your final webpage. Develop your designs in Observable as normal, then copy the JSON specification as follows: JSON.stringify(myVis.toSpec())
, where myVis
is the name of the variable containing your visualization. The JSON.stringify
function allows you to copy the text (string) version of the JSON object. Note that you may have to adjust the JSON spec slightly when adding it to the IdyllVegaLite
component in order to import your data appropriately.Idyll has a pre-supported component for rendering D3 visualizations; to create a visualization, you can write a new component that extends this custom class. To see how this work, take a look at the file d3-sunshine
in the components
directory. In essence, you will create a seperate custom D3 component for each visualization that you would like to create in D3 for your page.
If you look at the index.idyll
, this is how you can embed Tableau visualizations:
TableauEmbed
is a custom component defined in the file tableau-embed.js
. You can similarly create your own custom components for other types of embeddings.
You can embed Observable visualizations as follows:
The original visualization is on the larger side, so we can display it using a FullWidth
component so that the visualization spans the whole width of our browser window. While you can customize the size of the embeded window, the size of the visualizations will be the same as the original Observable document.
Similar to the other embedded visualizations, you can embed interactive Plotly visualizations using the custom component PlotlyEmbed
:
Note that the width
and height
parameters control the size of the iframe
that is embedded in the page, not the visualization, so you will need to design your visualizations with Plotly accordingly, and test the page layout.
The most straightforward (and default) style for a page is basic text like what we have used so far. Visualizations are embedded in place and are scrolled like a standard webpage. But with Idyll, we can do a lot more!
Take the Vega-Lite visualization from earlier, we can display it in the margin alongside the text by wrapping the code with the command [Aside] ... [/Aside]
.
Perhaps you would like to try including a large image in the background, with text that scrolls by on top of it? With Idyll, that’s easy! Keep scrolling for an example...
To create this scrolling segment of the document, we first specify a Scroller
component, which can just be done with [Scroller] ... [/Scroller]
. The text and visualizations seen here are specified within this component.
The background is that same Tableau map visualization from earlier, but displayed at a larger size.
To set the background, you can use a Graphic
component to wrap the TableauEmbed
component from earlier.
The contents for these text boxes are described with the Step
component, and can even include other components like the visualizations from before!
Take a look in the index.idyll
file to see exactly how this works in the code, and keep scrolling for more examples.
Idyll allows you to mix and match components throughout the document to create dynamic visualizations and compelling narrative layouts. Some other layout options include FullWidth, Inline, and Stepper, among others. Details are included on Idyll’s documentation page for built-in components.
This page also describes a variety of the other built-in components for controlling the dynamic behavior of the document, such as dynamic variables and input widgets like (buttons, range sliders, and dropdowns).
Let’s take a look at some dynamic visualization updates with another scrollytelling example. In this case, we will use a fixed visualization alongside the text and update the visualization as we go. Keep scrolling to see the example...
This Scroller
uses some custom CSS to set the background color to ”#33333f”
It also uses custom CSS to style the Graphic
(which is a custom D3 component) so that it appears as a fixed visualization next to the scrolling text.
What’s cool about this CustomD3Component
is that it updates as we scroll. It does this by leveraging the update
function to animate the point as it moves to a new position.
To keep track of where we are in the Scroller
, we first defined a dynamic Idyll variable named myLocation
using the following code: [var name:"myLocation" value:0 /]
Each time we scroll to a new Step
, the Graphic
updates it state based on this dynamic variable, which can be used to parameterize the visualization.
Right now, the value of myLocation
is 0.00. Cool huh?
Step
and the previous one, notice how the value that is displayed changes based on when the new Step
is triggered.You can really put anything in these dynamic variables. For example, the Vega-Lite visualization we keep using could have been in a variable.
There’s a better way, though. What if we create our own new custom component? This way we can seperate out our visualizations into different files. See components/my-viz.js
for the following example.
You can also use the Vega-Lite API like in the following example, found in components/my-api-viz.js
.
This template is a starting place for your project. Update the header information to include the relevant details for your project, and then feel free to mix and match the visualization and layout techniques introduced here for your own narrative. Use this template and especially the Idyll documentation as a reference for what you can do.
Think about how the narrative structure draws readers into the story you are telling and how the visualizations interact with the text (and with each other). The narrative should help ensure that the page as a whole is greater than just the sum of its parts. When designing your page, decide on particular layouts that enhance the reader’s experience and understanding of the topic.
You must have Node.js installed. You can get it directly from https://nodejs.org/en/.
idyll
installed (npm i -g idyll
).npm install
to install project-specific dependencies.
npm is the node package manager. If you’re curious how this works and what the project dependencies are, open up package.json
to see where these are listed.
You can install custom dependencies by running npm install <package-name> --save
. Note that any collaborators will also need to download the package locally by running npm install
after pulling the changes.
Run idyll
from the command line. Your post will appear at http://localhost:3000/. When the server is running, any local change that you make will be deteched and your webpage will auto-update with the new changes. Your local changes will not be visible to your team members until you push the changes to your repository. These changes will not be reflected in the final website unless you run the build script and push the updated docs folder (see below).
Run idyll build
. The output will appear in the top-level build
folder. To change the output location, change the output
option in package.json
, such as to docs
.
Make sure your post has been built, then commit the docs
folder to your project repository. It will be available at cse412-21sp.github.io/your-repo-name/. For example, you can view the sample embedded Tableau, vega-lite, and d3 charts at https://jhoffswell.github.io/cse412-project-template-idyll/.
This template was adapted from the initial Scrollytelling template for Idyll. The code and visualization examples were adapted from the final project template created for a previous offering of CSE 412.