Platform
Resources
Pricing
Sign in
Get started
Michael Cooper
Developer @Observable
Workspace
Fork
Published
By
Michael Cooper
Edited
Aug 29, 2022
14 stars
6
Insert cell
Insert cell
1
Insert cell
Insert cell
Insert cell
Insert cell
2
Insert cell
Insert cell
Insert cell
dataset
=
{
let
start
=
performance
.
now
(
)
;
let
rv
=
Float64Array
.
from
(
{
length
:
maxMillions
*
1e6
}
,
d3
.
randomNormal
(
0
)
)
;
mutable
timeSpent
=
{
...
mutable
timeSpent
,
dataset
:
performance
.
now
(
)
-
start
}
;
return
rv
;
}
Insert cell
data
=
dataset
.
subarray
(
0
,
numPoints
)
Insert cell
numPoints
=
1e6
*
millions
Insert cell
maxMillions
=
50
Insert cell
mutable
timeSpent
=
{
}
Insert cell
results
=
{
let
start
=
performance
.
now
(
)
;
let
rv
=
density1d
(
data
,
xBins
)
;
mutable
timeSpent
=
{
...
mutable
timeSpent
,
bin
:
performance
.
now
(
)
-
start
}
;
return
rv
;
}
Insert cell
density1d
=
{
let
module
=
await
import
(
URL
.
createObjectURL
(
await
FileAttachment
(
"density_bins@7.js"
)
.
blob
(
)
)
)
;
await
module
.
default
(
await
FileAttachment
(
"density_bins_bg@11.wasm"
)
.
url
(
)
)
;
return
module
.
density_1d_core
;
}
Insert cell
kb
=
{
let
f
=
d3
.
format
(
".3s"
)
;
return
(
d
)
=>
f
(
d
/
1024
)
+
"kb"
;
}
Insert cell
wasmSize
=
(
await
FileAttachment
(
"density_bins_bg@11.wasm"
)
.
arrayBuffer
(
)
)
.
byteLength
Insert cell
jsSize
=
(
await
FileAttachment
(
"density_bins@7.js"
)
.
arrayBuffer
(
)
)
.
byteLength
Insert cell
import
{
comma
,
details
}
from
"@yurivish/zig-density-plot-prototype"
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
millions
Edit
Show 1 comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
xBins
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Show 2 comments
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dataset
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
numPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maxMillions
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
timeSpent
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
results
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
density1d
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
kb
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
wasmSize
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
jsSize
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