Unlisted
Edited
Apr 20, 2023
Insert cell
Insert cell
Insert cell
Insert cell
download_button = DOM.download(() => rasterize(graph), "graph", "Save as PNG")
Insert cell
import { rasterize } from "@mbostock/saving-svg"
Insert cell
Insert cell
kings_board_statement = {
if (kings_board_selector.name != "---") {
return md`How many ways are there to place non-attacking Kings on a chessboard of dimensions ${tex`${kings_board_selector.m} \times ${kings_board_selector.n}`}?`;
} else {
return md``;
}
}
Insert cell
names = [
{ name: "---" },
{ name: "Alyson", seed: 22 },
{ name: "Andrew", seed: 1 },
{ name: "Audrey", seed: 23 },
{ name: "Brian", seed: 2 },
{ name: "Chris", seed: 3 },
{ name: "Christopher", seed: 4 },
{ name: "Elliot", seed: 5 },
{ name: "Ethan", seed: 6 },
{ name: "Gavin", seed: 7 },
{ name: "Haley", seed: 8 },
{ name: "Hunter", seed: 9 },
{ name: "Jacob B", seed: 10 },
{ name: "Jacob T", seed: 11 },
{ name: "Jahfari", seed: 12 },
{ name: "Jasmine", seed: 13 },
{ name: "Joel", seed: 14 },
{ name: "Jonathan", seed: 15 },
{ name: "Matthew", seed: 16 },
{ name: "Nadia", seed: 17 },
{ name: "Patrick", seed: 18 },
{ name: "Seth", seed: 19 },
{ name: "Taylor", seed: 20 },
{ name: "William", seed: 21 }
]
Insert cell
Insert cell
source = d3.randomLcg((name.seed + 1) / 42)
Insert cell
d3.randomUniform.source(source)(0, 1)()
Insert cell
Insert cell
dot_source = `digraph {
A [pos = "0,2!"]
B [pos = "2,2!"]
C [pos = "2,0!"]
D [pos = "0,0!"]
${links}
}`
Insert cell
dot`${dot_source}`
Insert cell
d3 = require("d3@7", "d3-graphviz@2")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more