Published
Edited
Jun 17, 2020
1 star
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_AvaazFreq_15_05_2020@1.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

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more