Platform
Resources
Pricing
Sign in
Get started
Lincoln Mullen
Religious history, digital history, and nineteenth-century US history.
Workspace
Fork
Published
Teaching
By
Lincoln Mullen
Edited
Apr 21, 2021
1 star
3
Insert cell
Insert cell
Insert cell
Insert cell
course
=
"HIST 390"
// A string
Insert cell
year
=
2021
// A number
Insert cell
message
=
`Hello, ${
course
} students from ${
year
}`
// Another string, which uses earlier variables
Insert cell
courseObject
=
(
{
title
:
"The Digital Past"
,
catalog
:
"HIST 390"
,
instructor
:
"Lincoln Mullen"
,
students
:
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
]
// An array of students
}
)
Insert cell
courseObject
.
catalog
Insert cell
`${
courseObject
.
title
} (${
courseObject
.
catalog
})`
Insert cell
Insert cell
bookPrices
=
[
12.40
,
19.99
,
15.00
,
45.00
,
9.00
]
Insert cell
function
sum
(
x
)
{
let
total
=
0
;
for
(
let
i
=
0
;
i
<
x
.
length
;
i
++
)
{
total
+=
x
[
i
]
;
}
return
total
;
}
Insert cell
sum
(
bookPrices
)
Insert cell
function
average
(
x
)
{
return
sum
(
x
)
/
x
.
length
;
}
Insert cell
average
(
bookPrices
)
Insert cell
Insert cell
function
geocode
(
address
,
city
,
state
,
zip
)
{
let
place
=
encodeURI
(
`${
address
}, ${
city
}, ${
state
} ${
zip
}`
)
;
// let url = `https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address=${place}&benchmark=2020&format=json`;
let
url
=
`https://geocode.xyz/${
place
}?json=1&auth=408344306725209919059x89261`
;
let
response
=
d3
.
json
(
url
)
;
return
response
;
}
Insert cell
location
=
geocode
(
"3211 Providence Drive"
,
"Anchorage"
,
"AK"
,
"99508"
)
Insert cell
gmuLocation
=
FileAttachment
(
"location.json"
)
.
json
(
)
Insert cell
function
getStation
(
location
)
{
let
lat
=
location
.
latt
;
let
lon
=
location
.
longt
;
let
station
=
d3
.
json
(
`https://api.weather.gov/points/${
lat
},${
lon
}`
)
;
return
station
;
}
Insert cell
station
=
getStation
(
gmuLocation
)
Insert cell
gmuStation
=
FileAttachment
(
"station.json"
)
.
json
(
)
Insert cell
getForecast
=
function
(
station
)
{
let
forecast
=
d3
.
json
(
station
.
properties
.
forecast
)
;
return
forecast
;
}
Insert cell
forecast
=
getForecast
(
gmuStation
)
Insert cell
gmuForecast
=
FileAttachment
(
"forecast.json"
)
.
json
(
)
Insert cell
d3
.
json
(
"https://api.weather.gov/gridpoints/OKX/33,37/forecast"
)
Insert cell
gmuForecast
.
properties
.
periods
[
0
]
Insert cell
md
`### Weather in ${
gmuLocation
.
standard
.
city
}`
Insert cell
weatherChart
Insert cell
md
`## Imports`
Insert cell
d3
=
require
(
"d3@v6"
)
Insert cell
import
{
weatherChart
}
from
"@kerryrodden/simple-custom-weather-chart-in-d3"
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
course
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
year
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
message
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
courseObject
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
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
bookPrices
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sum
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
average
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
geocode
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
location
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gmuLocation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getStation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
station
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gmuStation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getForecast
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
forecast
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gmuForecast
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
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