Public
Edited
Aug 24, 2023
Paused
Fork of Radar Plot
9 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
async function createData() {
// const d = new Date();
// const t0 = d.getTime();

const ids = ["Atlas", "RIS", "RouteViews", "RIS&RouteViews"]; // Array of ids
let bias = {};
const responses = await Promise.all(
ids.map(async id => {
bias[id] = await get_imp_bias(id); // Send request for each id
})
);

let dataNew = [];
for (let i=0; i<Object.keys(bias_dimension_labels_new).length; i++) {
dataNew.push(Object(
{
'tag': Object.keys(bias_dimension_labels_new)[i],
'RIPE RIS': parseFloat(bias["RIS"][Object.values(bias_dimension_labels_new)[i]]),
'RIPE Atlas': parseFloat(bias["Atlas"][Object.values(bias_dimension_labels_new)[i]]),
'RouteViews': parseFloat(bias["RouteViews"][Object.values(bias_dimension_labels_new)[i]]),
'RIS&RouteViews': parseFloat(bias["RIS&RouteViews"][Object.values(bias_dimension_labels_new)[i]]),
'My 1st Custom Set': 0.001,
'My 2nd Custom Set': 0.001,
'My 3rd Custom Set': 0.001
}
)
)
}

// const d1 = new Date();
// const t1 = d1.getTime();
// console.log(t1-t0)
return dataNew;
}
Insert cell
Insert cell
function get_custom_bias(arg_custom_set, arg_set_numbers_type) {
let custom_data;
if (arg_custom_set.length > 0){
let mtype = (arg_set_numbers_type === "ASNs") ? "asn" : "probe";
custom_data = fetch("https://ai4netmon.csd.auth.gr/api/bias/"+mtype+"/?"+mtype+"="+arg_custom_set.replaceAll(",","&"+mtype+"=")).then((response) => response.json());
}
return custom_data
}
Insert cell
Insert cell
formattedData = selected_monitor_sets.map(m => (data_custom_new.filter(e => bias_dimensions.includes(e.tag)).map(e => ({axis:e.tag, value:e[m]}))))
Insert cell
data_custom_new = {
let x = JSON.parse(JSON.stringify(data_fetched));

const custom_sets_dict = {"My 1st Custom Set": custom_set,
"My 2nd Custom Set": custom_set1,
"My 3rd Custom Set": custom_set2
};
const ids = ["My 1st Custom Set", "My 2nd Custom Set", "My 3rd Custom Set"];
let bias = {};
const responses = await Promise.all(
ids.map(async id => {
bias[id] = await get_custom_bias(custom_sets_dict[id], set_numbers_type); // Send request for each id
})
);

for (let id=0; id<ids.length; id++) {
const current_custom_set = ids[id]
if (custom_sets_dict[current_custom_set].length > 0){
for (var i = 0; i < data_fetched.length; i++) {
let tt = data_fetched[i]["tag"];
let tk = bias_dimension_labels_new[tt];
let bias_dict;
bias_dict = bias[current_custom_set]["bias"]
x[i][current_custom_set] = bias_dict[tk]
}
}
}
return x;
}
Insert cell
Insert cell
monitor_sets = ["RIPE RIS", "RIPE Atlas", "RouteViews", "RIS&RouteViews", "My 1st Custom Set", "My 2nd Custom Set", "My 3rd Custom Set"]//data.columns.slice(1)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// radarLine = d3.lineRadial()
// .curve(d3["curveLinear"])
// .radius(d => rScale(d))
// .angle((d, i) => -angleSlice*i)
Insert cell
// rScale = d3.scaleLinear()
// .domain([0, maxValue])
// .range([0, radius])
Insert cell
Insert cell
Insert cell
Insert cell
// axisLabelFactor = 1.12
Insert cell
// wrapWidth = 60
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// dotRadius = 4
Insert cell
// radius = (height-(margin*2)) / 2
Insert cell
// height = 600
Insert cell
// margin = 30
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof monitor_set_selection = {
const select = Inputs.select(monitor_sets, {label: "Monitor Set", value: monitor_sets});

select.style.width = "100%";
return select;
}
Insert cell
viewof searched_data = {
const search_field = Inputs.search(data_monitor_set_formatted, {label: 'Filter by: Bias Dimension, Value or Difference'});

search_field.style.width = "100%";
return search_field;
}
// viewof searched_data = Inputs.search(data_monitor_set_formatted, {label: 'Filter by: Bias Dimension, Value or Difference'});
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
diff_only_arr = data_monitor_set_formatted.map(el => el['Difference']);
Insert cell
smallest_diff_widget = {
if (diff_only_arr.length !== 0) {
return html`
<p><strong>${Math.min(...diff_only_arr)}</strong> for <strong>${data_monitor_set_formatted.map(el => el['Difference'] == Math.min(...diff_only_arr) ? el['Bias Dimension'] : '')}</strong> with value: <strong>${data_monitor_set_formatted.map(el => el['Difference'] == Math.min(...diff_only_arr) ? el['Value'] : '')}</strong></p>
`
} else {
return html`
<p><em>No results</em></p>
`
}
}
Insert cell
largest_diff_widget = {
if (diff_only_arr.length !== 0) {
return html`
<p><strong>${Math.max(...diff_only_arr)}</strong> for <strong>${data_monitor_set_formatted.map(el => el['Difference'] == Math.max(...diff_only_arr) ? el['Bias Dimension'] : '')}</strong> with value: <strong>${data_monitor_set_formatted.map(el => el['Difference'] == Math.max(...diff_only_arr) ? el['Value'] : '')}</strong></p>
`
} else {
return html`
<p><em>No results</em></p>
`
}
}
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