Published
Edited
May 19, 2020
Fork of Word cloud
2 forks
Importers
1 star
Insert cell
Insert cell
Insert cell
height = width*divider
Insert cell
divider = 0.6
Insert cell
//data = ({a: 9, b: 20, c:30, d:8, e:12, f:3, g:7, h:14})
dataSource = FileAttachment("concepts.json").json()
Insert cell
Insert cell
Insert cell
fontFamily = "sans-serif"
Insert cell
fontScale = width/40
Insert cell
rotate = () => 0 // () => (~~(Math.random() * 6) - 3) * 30
Insert cell
padding = 1
Insert cell
// words = source.split(/[\s.]+/g)
// .map(w => w.replace(/^[“‘"\-—()\[\]{}]+/g, ""))
// .map(w => w.replace(/[;:.!?()\[\]{},"'’”\-—]+$/g, ""))
// .map(w => w.replace(/['’]s$/g, ""))
// .map(w => w.substring(0, 30))
// .map(w => w.toLowerCase())
// .filter(w => w && !stopwords.has(w))
words = {
const words = []
for (let key in dataSource) {
for (let i = 0; i < dataSource[key]; i++) {
words.push(key)
}
}
return words
}
Insert cell
words.filter(w => /\W/.test(w))
Insert cell
data = d3.rollups(words, group => group.length, w => w)
.sort(([, a], [, b]) => d3.descending(a, b))
.slice(0, 250)
.map(([text, value]) => ({text, value}))
Insert cell
stopwords = new Set("i,me,my,myself,we,us,our,ours,ourselves,you,your,yours,yourself,yourselves,he,him,his,himself,she,her,hers,herself,it,its,itself,they,them,their,theirs,themselves,what,which,who,whom,whose,this,that,these,those,am,is,are,was,were,be,been,being,have,has,had,having,do,does,did,doing,will,would,should,can,could,ought,i'm,you're,he's,she's,it's,we're,they're,i've,you've,we've,they've,i'd,you'd,he'd,she'd,we'd,they'd,i'll,you'll,he'll,she'll,we'll,they'll,isn't,aren't,wasn't,weren't,hasn't,haven't,hadn't,doesn't,don't,didn't,won't,wouldn't,shan't,shouldn't,can't,cannot,couldn't,mustn't,let's,that's,who's,what's,here's,there's,when's,where's,why's,how's,a,an,the,and,but,if,or,because,as,until,while,of,at,by,for,with,about,against,between,into,through,during,before,after,above,below,to,from,up,upon,down,in,out,on,off,over,under,again,further,then,once,here,there,when,where,why,how,all,any,both,each,few,more,most,other,some,such,no,nor,not,only,own,same,so,than,too,very,say,says,said,shall".split(","))
Insert cell
color = d3.scaleOrdinal(d3.schemeCategory10);

Insert cell
d3 = {
const d3 = await require("d3@5", "d3-array@2");
d3.cloud = await require("d3-cloud@1");
return d3;
}
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