Platform
Resources
Pricing
Sign in
Get started
Fabian Iwand
Web developer and autodidact with an interest in creative coding.
Workspace
Fork
Unlisted
Widgets and helpers
By
Fabian Iwand
Edited
Mar 19, 2023
Insert cell
Insert cell
options
=
Object
.
entries
(
{
one
:
"Label one"
,
two
:
"Label two"
,
three
:
"Label three"
}
)
Insert cell
// Accessor functions that we'll use for all our widgets.
widgetOptions
=
(
{
valueof
:
d
=>
d
[
0
]
,
format
:
d
=>
d
[
1
]
}
)
Insert cell
Insert cell
Insert cell
Insert cell
singleSelection
Insert cell
viewof
singleSelection
=
select
(
options
,
{
...
widgetOptions
,
value
:
"two"
}
)
Insert cell
Inputs
.
bind
(
Inputs
.
radio
(
options
,
widgetOptions
)
,
viewof
singleSelection
)
Insert cell
Insert cell
multiSelection
Insert cell
viewof
multiSelection
=
select
(
options
,
{
...
widgetOptions
,
multiple
:
true
,
value
:
[
"two"
,
"three"
]
}
)
Insert cell
Inputs
.
bind
(
Inputs
.
checkbox
(
options
,
widgetOptions
)
,
viewof
multiSelection
)
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
options
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
widgetOptions
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
select
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
singleSelection
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
multiSelection
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML