Published
Edited
May 6, 2022
1 fork
Importers
Insert cell
Insert cell
wordshift = {
const div = d3.create("div");

const shift = shifterator.shifterator().debug()
.setWidth(400)
.setselection(div)
._refF(refF)
._compF(compF)
._lens(lens)
._words(words)
._stoprange(stopRange)
.stop()
// this has to be set before the shift operation
.plotdist(false)
.shifter()
.setText([
"Saturday, November 7, 2020",
"The 2020 Presidential election race called with Joe Biden the President-elect.",
"Average happiness: 5.96",
"What's making this day happier than the last seven days:",
])
.plot();

return div.node();
}
Insert cell
stopRange = [4, 6]
Insert cell
Insert cell
compF = (await d3_v7.text("https://hedonometer.org/data/storywrangler_en_all/word-vectors/2020-11-07-sum.csv").then(d => d3_v7.csvParseRows(d))).map(d => +d[0])
Insert cell
refF = (await d3_v7.text("https://hedonometer.org/data/storywrangler_en_all/word-vectors/2020-11-07-prev7.csv").then(d => d3_v7.csvParseRows(d))).map(d => +d[0])
Insert cell
words = labMT.map(d => d.word).concat(labMT.map(d => '#' + d.word))
Insert cell
lens = labMT.map(d => +d.happs).concat(labMT.map(d => +d.happs))
Insert cell
labMT = (await d3_v7.json("https://hedonometer.org/api/v1/words/?format=json&wordlist__title=labMT-en-v2&limit=100000").then(d => d.objects)).sort((a, b) => d3_v7.ascending(a.rank, b.rank))
Insert cell
d3_v7 = require("d3@7")
Insert cell
Insert cell
shifterator.functionThatDependsOnD3()
Insert cell
shifterator = import('https://unpkg.com/@andyreagan/d3-shifterator@4.0.10?module')
Insert cell
Insert cell
// shifterator = require('@andyreagan/d3-shifterator@4.0.10')
Insert cell
d3.version
Insert cell
d3 = require("d3@4.13.0")
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