Notebooks 2.0 is here.
Read the preview announcement
Platform
Resources
Pricing
Sign in
Get started
TzuWei
Hi 👋, I'm TzuWei (uier). a computer science student from Taiwan 🇹🇼
Workspace
Fork
Public
By
TzuWei
Edited
Jun 12, 2021
Insert cell
Insert cell
{
const
svg
=
d3
.
create
(
"svg"
)
.
attr
(
"width"
,
"1000"
)
.
attr
(
"height"
,
"400"
)
.
style
(
"background"
,
"#303030"
)
.
style
(
"color"
,
"#fff"
)
;
const
x
=
d3
.
scaleLinear
(
)
.
domain
(
[
1
,
1000
]
)
.
range
(
[
0
,
800
]
)
;
const
y
=
d3
.
scaleLinear
(
)
.
domain
(
[
1
,
200
]
)
.
range
(
[
150
,
0
]
)
;
// axis in d3v4
const
xAxisInV4
=
svg
.
append
(
"g"
)
.
attr
(
"transform"
,
"translate(50, 175)"
)
.
call
(
d3v4
.
axisBottom
(
x
)
)
;
const
yAxisInV4
=
svg
.
append
(
"g"
)
.
attr
(
"transform"
,
"translate(50, 25)"
)
.
call
(
d3v4
.
axisLeft
(
y
)
)
;
// axis in d3v5
const
xAxisInV5
=
svg
.
append
(
"g"
)
.
attr
(
"transform"
,
"translate(50, 375)"
)
.
call
(
d3v5
.
axisBottom
(
x
)
)
;
const
yAxisInV5
=
svg
.
append
(
"g"
)
.
attr
(
"transform"
,
"translate(50, 225)"
)
.
call
(
d3v5
.
axisLeft
(
y
)
)
;
// uncomment the following code to change the axis color in v4
// -----------------------------------------------------------
// xAxisInV4.selectAll("path, line").attr("stroke", "#fff");
// xAxisInV4.selectAll("text").attr("fill", "#fff");
// yAxisInV4.selectAll("path, line").attr("stroke", "#fff");
// yAxisInV4.selectAll("text").attr("fill", "#fff");
// -----------------------------------------------------------
return
svg
.
node
(
)
;
}
Insert cell
Insert cell
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
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3v4
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3v5
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML