Public
Edited
Dec 9, 2022
2 forks
Insert cell
Insert cell
viewof experimentId = Inputs.text({
type: "string",
label: html`Type here the <b>experimentId</b>`,
})
Insert cell
url = `https://tiktok.tracking.exposed/api/v2/metadata?experimentId=${experimentId ? experimentId : "warwickworkshop" }&format=json`
Insert cell
response = fetch(url);
Insert cell
jsondata = response.json();
Insert cell
_.countBy(jsondata.data, 'type');
Insert cell
searchdata = _.filter(jsondata.data, {type: 'search'});
Insert cell
contributors = _.countBy(searchdata, 'supporter')
Insert cell
researchers = _.countBy(searchdata, 'researchTag')
Insert cell
Insert cell
data = _.reduce(searchdata, function(memo, entry) {
_.each(entry.results, function(answer) {
const csventry = {
...entry.geoip,
..._.pick(entry, ['id', 'supporter', 'creatorName', 'savingTime', 'experimentId', 'timelineId', 'href', 'researchTag']),
...answer.video,
..._.pick(answer, ['order', 'textdesc']),
};
memo.push(csventry);
});
return memo;
}, []);

Insert cell
DOM.download(new Blob([data], {type:'text/csv'}), `tktrex-${experimentId}-${data.length}.csv`, "Download CSV")
Insert cell
Insert cell
Inputs.table(search, {
format: {
Year: d3.format("d") // format as "1960" rather than "1,960"
}
})
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