Platform
Resources
Pricing
Sign in
Get started
Adam Roberts
Workspace
Fork
Published
By
Adam Roberts
Edited
Jan 18, 2022
Fork of
Chart.js example
Insert cell
Insert cell
Insert cell
Insert cell
{
let
c
=
DOM
.
canvas
(
width
,
width
/
1.6
)
;
new
Chart
(
c
.
getContext
(
"2d"
)
,
{
data
:
data
,
options
:
options
(
)
}
)
;
return
c
;
}
Insert cell
data
=
(
{
labels
:
labels
,
datasets
:
[
{
type
:
"scatter"
,
label
:
'Marker 1'
,
data
:
[
{
x
:
value
,
y
:
dataSet
.
find
(
d
=>
d
.
x
===
value
)
}
]
,
backgroundColor
:
'#aef'
,
borderColor
:
'#aef'
,
pointRadius
:
8
,
showLine
:
false
}
,
{
type
:
'line'
,
// labels: labels,
label
:
'Weight curve'
,
backgroundColor
:
'#fae'
,
borderColor
:
'#fae'
,
fill
:
false
,
data
:
dataSet
,
pointRadius
:
0
}
]
}
)
Insert cell
dataSet
=
(
new
Array
(
maxSeconds
)
.
fill
(
0
)
)
.
map
(
(
e
,
i
)
=>
(
{
y
:
Math
.
round
(
Math
.
pow
(
i
/
300
+
1
,
-
2
)
*
1000
)
/
1000
,
x
:
i
}
)
)
Insert cell
labels
=
(
new
Array
(
maxSeconds
)
.
fill
(
0
)
)
.
map
(
(
e
,
i
)
=>
i
+
1
)
Insert cell
options
=
(
)
=>
(
{
responsive
:
false
,
title
:
{
display
:
true
,
text
:
'Distance-weighted scores'
}
,
scales
:
{
xAxes
:
[
{
display
:
true
,
ticks
:
{
max
:
maxSeconds
,
min
:
0
,
// autoSkip: true,
maxTicksLimit
:
18
}
,
scaleLabel
:
{
display
:
true
,
labelString
:
'Seconds'
}
}
]
,
yAxes
:
[
{
display
:
true
,
ticks
:
{
max
:
1
,
min
:
0
}
,
scaleLabel
:
{
display
:
true
,
labelString
:
'Score'
}
}
]
}
}
)
Insert cell
Insert cell
import
{
slider
}
from
"@jashkenas/inputs"
;
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
Compare fork
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
value
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maxSeconds
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dataSet
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
labels
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
options
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Chart
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML