Public
Edited
Jul 11, 2024
Fork of Hello Clingo
6 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
result = run(program, 1)
Insert cell
color = {
const fills = d3.schemePastel1;
const colors = new Map();

if (!result.Call[0].Witnesses) return "#888";

result.Call[0].Witnesses[0].Value.forEach((r) => {
const [, i, c] = r.match(/(\d+),(\d+)/);
colors.set(+i, +c);
});
return Object.assign(
(_, i) => (colors.has(i) ? color(colors.get(i)) : "#eee"),
{ map: colors }
);

function color(c) {
return colorType === "textures"
? `url(#diverging-12541021-${c})`
: fills[c % fills.length];
}
}
Insert cell
Insert cell
geometries = (
world.objects.countries ??
world.objects.counties ??
world.objects.states
).geometries.filter((d) => d.id !== "010") // removes Antarctica
Insert cell
edges = topojson.neighbors(geometries)
Insert cell
world = d3.json(topo)
Insert cell
d3 = require("d3@7", "d3-geo-projection@3")
Insert cell
Insert cell
Insert cell
Insert cell
run = {
const clingo = await require(`clingo-wasm@${version}`)
await clingo.init(`https://cdn.jsdelivr.net/npm/clingo-wasm@${version}/dist/clingo.wasm`)
return clingo.run
}
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