Published
Edited
Sep 27, 2022
26 stars
Insert cell
Insert cell
Insert cell
htl.svg`<svg class="chart" width="300" height="200">
<path d="M 10 190 66 175 122 130 178 160 234 10 290 50" stroke="black" fill="none">
</svg>`
Insert cell
d3.selectAll("svg.chart").style("border", "2px solid green")
Insert cell
Insert cell
import {chart} from "507f2e71a0ffc623"
Insert cell
chart
Insert cell
Insert cell
Insert cell
chart1 = htl.svg`<svg width="300" height="200">
<path d="M 10 190 66 175 122 130 178 160 234 10 290 50" stroke="black" fill="none">
</svg>`
Insert cell
d3.select(chart1).style("border", "2px solid green")
Insert cell
d3.select(chart1).select("path").style("stroke-width", "2")
Insert cell
Insert cell
[1, 2, 3]
Insert cell
// d3.selectAll("path").attr("fill", "red")
Insert cell
Insert cell
{
return htl.html`<table>
<tr><th>Country</th><th>Population</th></tr>
<tr><td>United States</td><td>330 million</td></tr>
</table>`
}
Insert cell
Insert cell
{
htl.html`<table>
<tr><th>Country</th><th>Population</th></tr>
<tr><td>United States</td><td>329.5 million</td></tr>
</table>`
}
Insert cell
Insert cell
{
const node = htl.html`<table>
<tr><th>Country</th><th>Population</th></tr>
<tr><td class="highlight">United States</td><td>330 million</td></tr>
</table>`;
d3.selectAll("td.highlight").style("color", "red");
return node;
}
Insert cell
Insert cell
{
const node = htl.html`<table>
<tr><th>Country</th><th>Population</th></tr>
<tr><td class="highlight">United States</td><td>330 million</td></tr>
</table>`;
d3.select(node).selectAll("td.highlight").style("color", "red");
return node;
}
Insert cell
Insert cell
viewof country = Inputs.radio(["United States", "China"], {label: "Country", value: "United States"})
Insert cell
htl.html`<table class="table-picker">
<tr><th>Country</th><th>Population</th></tr>
<tr><td class=${country === "United States" && "highlight"}>United States</td><td>330 million</td></tr>
<tr><td class=${country === "China" && "highlight"}>China</td><td>1,402 million</td></tr>
</table>`
Insert cell
d3.selectAll(".table-picker").select(".highlight").style("color", "red")
Insert cell
Insert cell
Insert cell
table = htl.html`<table class="table-picker">
<tr><th>Country</th><th>Population</th></tr>
<tr><td class=${country === "United States" && "highlight"}>United States</td><td>330 million</td></tr>
<tr><td class=${country === "China" && "highlight"}>China</td><td>1,402 million</td></tr>
</table>`
Insert cell
d3.select(table).select(".highlight").style("color", "red")
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more