Public
Edited
Dec 31, 2022
Insert cell
Insert cell
viewof asn = Inputs.text({label: "ASN"})
Insert cell
Insert cell
viewof granularity = Inputs.select(["day","week", "month"], {label: "Sampling granularity"})
Insert cell
Plot.plot({
marks: [Plot.cell(data, { x: "ts", y: "asn", fill: "hege" })],
color: { scheme: "blues", legend: true, reverse: false },
marginLeft: 100,
width: 490
})
Insert cell
data = {
var asn2ts = []
var current_fmt = moment( _start ).format('YYYY-MM-DD')
const end_fmt = moment( _stop ).format('YYYY-MM-DD')
while( current_fmt < end_fmt ) {
var dx = await( d3.json(`https://ihr.iijlab.net/ihr/api/hegemony/?format=json&af=4&timebin=${current_fmt}T00:00:00Z&asn=${asn}`) )
dx['results'].map( entry => {
asn2ts.push({
ts: current_fmt,
asn: `AS${entry['originasn']}`,
hege: entry['hege'] * 100.0
})
});
current_fmt = moment( current_fmt ).add(1, granularity ).format('YYYY-MM-DD')
console.log( current_fmt )
}
return asn2ts
}
Insert cell
start_m = moment( _start)
Insert cell
end_m = moment( _stop )
Insert cell
date_range = {
const range = []
let current_m = start_m
while( current_m <= end_m ) {
range.push( current_m )
current_m = current_m.add(1, granularity )
}
return range
}

Insert cell
moment = require('moment')
Insert cell
viewof _start = new Input(
new Date(
(() => {
let a = new Date();
a.setDate(a.getDate() - 365);
return a.toISOString().split("T")[0];
})()
)
)
Insert cell
viewof _stop= new Input(
new Date(
(() => {
let a = new Date();
return a.toISOString().split("T")[0];
})()
)
)
Insert cell
import {Radio, Range, Text, Input, Checkbox, Toggle, bind} from "@observablehq/inputs"
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