hilbertChart = {
const margin = 50;
const hilbertChart = HilbertChart()
.width(chartWidth - margin * 2)
.margin(margin)
.hilbertOrder(20 / 2)
.data(parseAsnData(ianaData))
.rangePadding(0.03);
setTimeout(() => hilbertChart.focusOn(0, 2 ** 16), 100);
return hilbertChart;
function parseAsnData(asnData) {
const asns = [];
const ignoreNames = ['see sub-registry 16-bit as numbers'];
asnData.map(asn => {
const asRange = asn.Number.split('-');
return {
start: +asRange[0],
length: asRange.length > 1 ? +asRange[1] - asRange[0] + 1 : 1,
name: asn.Description.replace('Assigned by', ''),
infos: [asn]
};
}).filter(asn =>
ignoreNames.indexOf(asn.name.toLowerCase()) === -1
).filter(asn =>
asn.name.toLowerCase() !== 'unallocated' && (asn.start + asn.length) <= Math.pow(2, 24)
).forEach(asn => {
let last;
if (asns.length
&& (last = asns[asns.length - 1])
&& last.name === asn.name
&& (last.start + last.length === asn.start)) {
last.length += asn.length;
last.infos.push(asn.infos[0]);
} else {
asns.push(asn);
}
});
return asns;
}
}