Platform
Resources
Pricing
Sign in
Get started
Luke Murray
MIT Ph.D. Candidate in HCI
Workspace
Fork
Published
By
Luke Murray
Edited
Feb 8, 2021
1 fork
Importers
1
Insert cell
Insert cell
chart
Insert cell
import
{
chart
}
with
{
data
,
partition
,
color
}
from
"966f4cd6ed3d1e45"
Insert cell
color
=
d3
.
scaleOrdinal
(
d3
.
quantize
(
d3
.
interpolateRainbow
,
alphabet
.
length
+
1
)
)
.
domain
(
// set color domain to alphabet
alphabet
.
map
(
(
c
,
i
)
=>
{
let
node
=
data
.
children
.
find
(
d
=>
d
.
name
.
startsWith
(
c
)
)
;
// colors set based on inner ring
if
(
node
)
{
// if inner ring has a multi letter prefix use that prefix
return
node
.
name
;
// happens often with qu
}
return
c
;
}
)
)
Insert cell
alphabet
=
[
...
'abcdefghijklmnopqrstuvwxyz'
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
randomWords
=
getRandomSubarray
(
words
,
10000
)
Insert cell
Insert cell
words
=
FileAttachment
(
"scrabble-words.txt"
)
.
text
(
)
.
then
(
text
=>
text
.
split
(
/\n/
)
.
map
(
word
=>
word
.
toLocaleLowerCase
(
)
)
)
Insert cell
algos
=
require
(
'typescript-algos'
)
Insert cell
d3
=
require
(
"d3@6"
)
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
color
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
alphabet
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
partition
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
convertTrieNodeToSunburstNode
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
trie
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randomWords
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getRandomSubarray
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
words
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
algos
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML