Platform
Resources
Pricing
Sign in
Get started
深度碎片
as simple as possible
Workspace
Fork
Published
D3 documentation
By
深度碎片
Edited
Nov 16, 2019
Fork of
d3.selection.attr
Insert cell
md
`# d3.selection.style`
// opt+cmd+j to inspect element for detail
Insert cell
set_h1_style_color
=
d3
.
select
(
"h1"
)
.
style
(
"color"
,
"cyan"
)
Insert cell
access_h1_style_color
=
d3
.
select
(
"h1"
)
.
style
(
"color"
)
Insert cell
set_h1_style_with_func
=
d3
.
select
(
"h1"
)
.
style
(
"transform"
,
function
(
d
,
i
,
nodes
)
{
return
`translate(100px, 0px)`
;
}
)
Insert cell
set_all_p_style_with_func
=
d3
.
selectAll
(
"p"
)
.
style
(
"transform"
,
function
(
d
,
i
,
nodes
)
{
return
(
i
%
2
===
0
)
?
`translate(100px, 0px)`
:
`translate(200px, 0px)`
}
)
Insert cell
set_all_p_fontSize_with_func
=
d3
.
selectAll
(
"p"
)
.
style
(
"font-size"
,
function
(
d
,
i
,
nodes
)
{
return
(
i
%
2
===
0
)
?
`12px`
:
`18px`
;
}
)
Insert cell
d3
=
require
(
"https://cdn.jsdelivr.net/npm/d3@5.12.0/dist/d3.js"
)
;
Insert cell
import
{
anchorLink
}
from
"@embracelife/tutorial-utilities"
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
Compare fork
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
set_h1_style_color
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
access_h1_style_color
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
set_h1_style_with_func
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
set_all_p_style_with_func
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
set_all_p_fontSize_with_func
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML