Platform
Resources
Pricing
Sign in
Get started
Observable
The end-to-end solution for building and hosting better data apps, dashboards, and reports.
Workspace
Fork
Published
By
Shan Carter
Edited
Apr 29, 2021
1 fork
5 stars
Insert cell
Insert cell
test
=
html
`<svg>
<path d="M0,0 L10,10"
</svg>`
Insert cell
path
=
test
.
querySelector
(
"path"
)
Insert cell
pathLength
=
path
.
getTotalLength
(
)
Insert cell
numSamples
=
10
Insert cell
step
=
Math
.
ceil
(
pathLength
/
numSamples
)
Insert cell
points
=
{
let
points
=
[
]
;
for
(
let
i
=
0
;
i
<
numSamples
;
i
++
)
{
let
point
=
path
.
getPointAtLength
(
i
*
step
)
;
points
.
push
(
{
x
:
point
.
x
,
y
:
point
.
y
}
)
;
}
return
points
;
}
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
test
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
path
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
pathLength
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
numSamples
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
step
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
points
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML