Public
Edited
Oct 27, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hilbertChart = {
const margin = 90;

return HilbertChart()
.width(chartWidth - margin * 2)
.margin(margin)
.hilbertOrder(32 / 2)
.data(parseIpData(ianaData))
.rangePadding(0.03)
.valFormatter(ipFormatter)
.rangeTooltipContent((d) => `<b>${d.name}</b>: ${prefixFormatter(d)}`);

function parseIpData(ipData) {
const prefixes = [];

ipData
.map((row) => {
const pref = new Ip.Prefix(row.Prefix);
return {
start: pref.firstIp().toNum(),
length: pref.countIps(),
name: getName(row.Designation),
infos: [row]
};
})
.forEach((prefix) => {
let last;

if (
prefixes.length &&
(last = prefixes[prefixes.length - 1]) &&
last.name === prefix.name &&
last.start + last.length === prefix.start
) {
last.length += prefix.length;
last.infos.push(prefix.infos[0]);
} else {
prefixes.push(prefix);
}
});

return prefixes;

//

function getName(designation) {
let name = designation;

if (name.indexOf("Administered by") > -1) {
name = "Various Registries";
}

return name;
}
}

function ipFormatter(d) {
return new Ip.Addr(d).toString();
}

function prefixFormatter(d) {
const ipRange = new Ip.Range(d.start, d.start + d.length - 1);
const prefixes = ipRange.toPrefixes();

return (prefixes.length === 1 ? prefixes[0] : ipRange).toString();
}
}
Insert cell
setTimeout(
() =>
// run async to allow hilbertChart to be DOM initialized
hilbertChart.addMarker(
new Ip.Addr("128.0.0.0").toNum(),
censysHeatmapUrl,
chartWidth - 90 * 2,
chartWidth - 90 * 2,
() => ``
),
5
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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