

Defines the content: headings, text, buttons, images, and containers.

Controls presentation: color, typography, spacing, and layout.

Responds to events and changes the page programmatically.

For interactive visualization: HTML provides a place for the chart, CSS styles it, and JavaScript creates and updates it.

Key idea: interactive charts are small programs running in or alongside a webpage.
<div> containers.id and class.You do not need to become a web developer: recognize the roles of HTML and CSS so generated interactive graphics are less mysterious.
The Document Object Model (DOM) is the browser’s object representation of the HTML page.
JavaScript can use the DOM to:
Mental model: HTML creates the tree; JavaScript can edit the tree.
<svg width="220" height="100">
<circle cx="60" cy="50" r="30" fill="steelblue"></circle>
<rect x="120" y="25" width="70" height="50" fill="orange"></rect>
</svg>JavaScript is the programming language that makes browser content dynamic.
For data visualization, it commonly handles:
You mainly need to recognize familiar programming ideas: variables, arrays/objects, functions, loops, and function calls.
<p id="message">Waiting...</p>
<button onclick="updateMessage()">Click me</button>
<script>
function updateMessage() {
const element = document.getElementById("message");
element.textContent = "The page changed without reloading.";
}
</script>What happened?
id.This same pattern powers filters, tooltips, linked charts, and dashboards.
The raw JavaScript can also perform computation based on user input.
function f(x) { return 3*x*x + 4*x; }
function integrate(A, B, N) {
const dx = (B - A) / N;
let sum = 0;
for (let i = 0; i < N; i++) {
const x = A + (i + 0.5) * dx; // midpoint
sum += f(x) * dx;
}
return sum;
}
const estimate = integrate(0, 2, 100);
document.getElementById("output").textContent = estimate;Takeaway: browser JavaScript can combine inputs + computation + DOM updates into an interactive app.
The complete example is included in HTML-JS-D3-examples.zip (INTEGRATE.html).
You could manually create and update every SVG element—but visualization libraries package common patterns for us.
Examples: Plotly.js, Vega-Lite
Example: D3.js
Choose the highest-level tool that gives you the control you need.
Plotly.js is a browser-based graphing library that provides many chart types and common interactions out of the box.
<div id="myPlot"></div>
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script>
<script>
const data = [{
x: [1, 2, 3, 4, 5],
y: [1, 2, 4, 8, 16],
mode: "lines+markers",
type: "scatter"
}];
Plotly.newPlot("myPlot", data);
</script>The code has the same basic ingredients we just learned:
<div id="myPlot"> — a container for the chart.Plotly.newPlot(...).This is the motivation for learning the web stack: you can use high-level libraries without treating them as a black box.
D3 = Data-Driven Documents
d3.select("#chart")
.append("circle")
.attr("cx", 60)
.attr("cy", 60)
.attr("r", 30)
.style("fill", "steelblue");For this course, the important point is the model, not memorizing the D3 API.
Interactivity is most useful when it helps the viewer answer a question that would be difficult with one fixed view.
DATA
↓
JavaScript / visualization library
↓
HTML + SVG elements in the DOM
↓
CSS + browser rendering
↓
INTERACTIVE GRAPHIC
↕
user events: hover • click • filter • zoomRemember the roles:
You do not need to build everything from scratch—you need enough of the foundation to understand and customize the tools you use.
Useful files to inspect after class: - INTEGRATE.html — raw JavaScript + user input + computation - JS-Plotting/ — JavaScript plotting examples - EX-D3/ — progressively more detailed D3/SVG examples - html-cheatsheet.zip — HTML reference material
These are optional extensions, not material you need to memorize for the introductory lecture.