Published
Edited
Jun 17, 2020
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Insert cell
data = FileAttachment("results_v2_L2_pureSelenium_alltogether.json").json();
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
views = {
var views = [];
data.nodes.forEach( d => {
if(views.indexOf(d.views) == -1){
views.push(d.views)
}});
return views.sort();
}
Insert cell
video_by_date = {
var video_date = [];
data.nodes.forEach( d => {
if(d.date != ""){
video_date.push({
key: d.id,
value: d.date
});
}
});
// var video_date_sorted = Object.keys(video_date).sort(function(a, b) {
// console.log(Math.abs(Date.parse(video_date[b].value) - Date.parse(video_date[a].value)));
// return Date.parse(video_date[b].value) - Date.parse(video_date[a].value);
// })
return video_date;
}
Insert cell
durations = {
var durs = [];
data.nodes.forEach( d => {
if(durs.indexOf(d.views) == -1){
var dur = d.duration.replace("PT", ":");
dur = dur.replace("H",":");
dur = dur.replace("M",":");
dur = dur.replace("S","");
var dur_arr = dur.split(':');
var mins = (+dur_arr[0]) * 60 + (+dur_arr[1]) + (+dur_arr[2]) / 60;
durs.push(mins)
}});
return durs.sort();
}
Insert cell
Insert cell
count_tokens = d3.nest()
.key(function(d) { return d.top_tokens; })
.rollup(function(leaves) { return leaves.length; }).entries(data.nodes)
Insert cell
count_categories = d3.nest()
.key(function(d) { return d.genre; })
.rollup(function(leaves) { return leaves.length; }).entries(data.nodes)
Insert cell
Insert cell
Insert cell
Insert cell
tokens_sorted = {
var token = [];
count_tokens.forEach( d => {
if(d.key != "undefined"){
token.push(d.key)
}
});
return token;
}
Insert cell
categories_sorted = {
var category = [];
count_categories.forEach( d => {
if(d.key != ""){
category.push(d.key)
}
});
return category;
}
Insert cell
Insert cell
color_scale_channel = d3.scaleOrdinal(channel, d3.schemeCategory10);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {Scrubber} from "@mbostock/scrubber"
Insert cell
Insert cell
Insert cell
moment = require("moment")
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