Platform
Resources
Pricing
Sign in
Contact us
Xiaoji Chen
Designer. Geek. Beer addict. Data queen.
Workspace
Fork
Published
By
Xiaoji Chen
Edited
Jul 8, 2022
9 forks
17 stars
Insert cell
Insert cell
Insert cell
container
=
html
`<div style="height:300px"></div>`
Insert cell
Insert cell
deckgl
=
{
const
props
=
{
container
,
map
:
mapboxgl
,
mapStyle
:
'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'
,
initialViewState
:
{
longitude
:
-
122.402
,
latitude
:
37.79
,
zoom
:
12
,
pitch
:
0
,
bearing
:
0
}
,
controller
:
true
,
layers
:
[
scatterplotLayer
,
textLayer
]
}
;
// Avoid creating multiple instances
const
prevDeckInstance
=
this
;
if
(
prevDeckInstance
)
{
prevDeckInstance
.
setProps
(
props
)
;
return
prevDeckInstance
;
}
return
new
deck
.
DeckGL
(
props
)
;
}
Insert cell
Insert cell
scatterplotLayer
=
{
return
new
deck
.
ScatterplotLayer
(
{
data
:
[
{
position
:
[
-
122.402
,
37.79
]
,
color
:
[
255
,
0
,
0
]
,
radius
:
1000
}
]
,
getPosition
:
d
=>
d
.
position
,
getColor
:
d
=>
d
.
color
,
getRadius
:
d
=>
d
.
radius
,
opacity
:
0.3
}
)
;
}
Insert cell
textLayer
=
{
return
new
deck
.
TextLayer
(
{
data
:
[
{
position
:
[
-
122.402
,
37.79
]
,
text
:
'Hello World'
}
]
,
getPosition
:
d
=>
d
.
position
,
getText
:
d
=>
d
.
text
}
)
;
}
Insert cell
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
container
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
deckgl
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
scatterplotLayer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
textLayer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mapboxgl
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
deck
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