Published
Edited
Oct 18, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
${ tweets.map(t => tweet(t.to_tweetid)) }
Insert cell
Insert cell
politicians = {
let all = [ ...new Set(tutotal.map(t => t.plus.concat(t.minus)).flat()) ]

let scores = all.map( a => {
let who = a
let plus = d3.sum(tutotal.map( t => t.plus.includes(who)? 1 : 0 ))
let minus = d3.sum(tutotal.map( t => t.minus.includes(who)? -1 : 0 ))
let total = plus + minus
return { who, total, plus, minus }
})
return { scores }
}
Insert cell
Insert cell
tutotal = {
return tweets.map(tweet => {
let replyTo = tweet['to_tweetid']
let plus = []
let minus = []
let text = tweet.text
let parts = text.split(' ')
let markers = ['+1', '-1']
let points = new Map()
markers.map(marker => points.set(marker, []))
let current_marker = ''
for (const part of parts) {
if(markers.includes(part)){
current_marker = part
} else {
if(markers.includes(current_marker)){
(points.get(current_marker)).push(part.toLowerCase())
}
}
}
plus = points.get('+1')
minus = points.get('-1')
return { text, replyTo, plus, minus }
})
}
Insert cell
tweets = d3.csv('https://raw.githubusercontent.com/taniki/tutotal2022/main/tutotal2022-taniki.csv')
Insert cell
import { tweet } from '@mbostock/tweet'
Insert cell
d3 = require('d3')
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