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

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