Published
Edited
May 10, 2022
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
Insert cell
Insert cell
Insert cell
gX = {
const svg = d3.select(xAxisSvg);
return svg.selectAll("g")
.data([x])
.join("g")
.call(xAxis)
.attr("transform", "translate(0,30)");
}
Insert cell
Insert cell
// nodes = tweets.map(n => {
// n.date = new Date(n.created_at);
// return n;
// })
Insert cell
Insert cell
// links = {
// let links=[];
// links = nodes.filter( t=> t.retweeted_status).map(t => ({
// target:t.retweeted_status.id_str,
// target_id:t.retweeted_status.id_str,
// source:t.id_str,
// type: "retweet"
// }));
// links = links.concat(nodes.filter(t=> t.in_reply_to_status_id).map(t=> ( {
// source:t.id_str,
// target:t.in_reply_to_status_id,
// target_id:t.in_reply_to_status_id,
// type: "reply"
// })));
// links = links.concat(nodes.filter(t=> t. quoted_status).map(t=> ( {
// source:t.id_str,
// target:t.quoted_status.id_str,
// target_id: t.quoted_status.id_str,
// type: "quote"
// })));

// return links;
// }
Insert cell
md`Filters for nodes and links`
Insert cell
Insert cell
simulationNodes= nodes.filter(t =>
searchHandle!=="" ? t.user.screen_name === searchHandle : true &&
includeRts ? true : t.retweeted_status===undefined
)
Insert cell
dNodes = {
const dNodes = {};
// Add rts and quotes
for (let n of simulationNodes) {
n.retweeted_status && (dNodes[n.retweeted_status.id_str]=n.retweeted_status, n.degree=0);
n.quoted_status && (dNodes[n.quoted_status.id_str]=n.quoted_status, n.degree=0);
};
for (let n of simulationNodes) {
n.degree=0;
dNodes[n.id_str]=n;
};
return dNodes;
}
Insert cell
Insert cell
Insert cell
# Network Data
Insert cell
network = FileAttachment("chi2022_rt_network_small@3.json").json()
Insert cell
// For computing from the tweets
// nodes = tweets.map(n => {
// n.date = new Date(n.created_at);
// return n;
// })
nodes = network.nodes.map((n) => {
n.date = new Date(n.created_at);
return n;
})
Insert cell
nodes[0]
Insert cell
Insert cell
x.domain()
Insert cell
Insert cell
Insert cell
import {dataInput} from "@john-guerra/file-input-with-default-value"
Insert cell
import {tweet} from "@mbostock/tweet"
Insert cell
d3 = require("d3@5", "https://rawgit.com/john-guerra/b484776070920239d6acea09682de0f8/raw/192a59258a8dae54798b8b832dce63db8f15e3a5/forceInABox.js")
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