Platform
Resources
Pricing
Sign in
Get started
Frederik H.
Workspace
Fork
Public
By
Frederik H.
Edited
Jan 16, 2023
ISC
Fork of
Simple D3
Insert cell
Insert cell
xScale
=
d3
.
scaleLinear
(
)
.
domain
(
[
-
4
,
4
]
)
.
range
(
[
0
,
innerWidth
]
)
Insert cell
yScale
=
d3
.
scaleLinear
(
)
.
domain
(
[
-
2
,
14
]
)
.
range
(
[
innerHeight
,
0
]
)
Insert cell
xAxisQuadratic
=
d3
.
axisBottom
(
xScale
)
.
tickSize
(
innerHeight
+
10
)
;
Insert cell
yAxisQuadratic
=
d3
.
axisLeft
(
yScale
)
.
tickSize
(
innerWidth
+
10
)
;
Insert cell
dataQuadratic
=
[
{
x
:
-
3
,
y
:
7.5
}
,
{
x
:
-
2
,
y
:
3
}
,
{
x
:
-
1
,
y
:
0.5
}
,
{
x
:
0
,
y
:
1
}
,
{
x
:
1
,
y
:
3
}
,
{
x
:
2
,
y
:
6
}
,
{
x
:
3
,
y
:
14
}
]
Insert cell
Insert cell
quadraticRegression
=
d3
.
regressionQuad
(
)
.
x
(
d
=>
d
.
x
)
.
y
(
d
=>
d
.
y
)
.
domain
(
[
-
4
,
4
]
)
;
Insert cell
lineGenerator
=
d3
.
line
(
)
.
x
(
d
=>
xScale
(
d
[
0
]
)
)
.
y
(
d
=>
yScale
(
d
[
1
]
)
)
;
Insert cell
Plot
.
plot
(
{
width
:
640
,
marks
:
[
Plot
.
line
(
build_samples
(
(
x
)
=>
Math
.
exp
(
-
x
*
x
)
,
-
3
,
1
)
,
{
strokeWidth
:
3
,
stroke
:
"steelblue"
}
)
,
Plot
.
ruleX
(
[
0
]
)
,
Plot
.
ruleY
(
[
0
]
)
]
}
)
Insert cell
Insert cell
import
{
margin
}
from
"@harrystevens/introducing-d3-regression"
Insert cell
base
=
Math
.
min
(
width
,
400
)
;
Insert cell
import
{
innerWidth
}
from
"@harrystevens/introducing-d3-regression"
Insert cell
import
{
innerHeight
}
from
"@harrystevens/introducing-d3-regression"
Insert cell
d3
=
require
(
"d3-array@3"
,
"d3-axis@3"
,
"d3-regression@1"
,
"d3-scale@4"
,
"d3-shape@3"
,
"d3-selection@3"
)
Insert cell
import
{
build_samples
}
from
"@mcmcclur/adaptive-plotter"
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
xScale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yScale
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
xAxisQuadratic
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
yAxisQuadratic
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dataQuadratic
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
quadraticRegression
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
lineGenerator
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
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
base
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
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
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML