Platform
Resources
Pricing
Sign in
Get started
Observable
The end-to-end solution for building and hosting better data apps, dashboards, and reports.
Workspace
Fork
Published
Analyzing Time Series Data
By
3 authors
Edited
Oct 4, 2021
3 forks
Importers
40 stars
5
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rawdata
=
FileAttachment
(
"TexasEnergyDemandForecast@1.csv"
)
.
csv
(
{
typed
:
true
}
)
Insert cell
data
=
aq
.
from
(
rawdata
)
// https://observablehq.com/@observablehq/data-wrangler
.
rename
(
{
demand
:
"actuals"
}
)
// rename column from “demand” to “actuals”
.
objects
(
)
// return an array of objects
Insert cell
Insert cell
event
=
(
{
description
:
"Rolling Blackouts"
,
datetime
:
new
Date
(
"2021-02-15T07:25:00Z"
)
// 7:25AM UTC is 1:25AM CST
}
)
Insert cell
Insert cell
zoom
=
{
const
start
=
d3
.
isoParse
(
"2021-02-07T07:25:00Z"
)
;
const
end
=
d3
.
isoParse
(
"2021-02-16T07:25:00Z"
)
;
return
(
d
)
=>
+
d
.
date
>=
+
start
&&
+
d
.
date
<=
+
end
;
}
Insert cell
zoomed
=
data
.
filter
(
zoom
)
Insert cell
Insert cell
zoomedTicks
=
d3
.
utcDays
(
...
d3
.
extent
(
zoomed
,
d
=>
d
.
date
)
)
.
map
(
d
=>
d3
.
utcHour
.
offset
(
d
,
6
)
)
Insert cell
dataTicks
=
d3
.
utcWeeks
(
...
d3
.
extent
(
data
,
d
=>
d
.
date
)
)
.
map
(
d
=>
d3
.
utcHour
.
offset
(
d
,
6
)
)
Insert cell
Insert cell
colors
=
new
Map
(
[
[
"actuals"
,
"#5b6187"
]
,
[
"forecast"
,
"#a2a5ba"
]
,
[
"below"
,
"#89119c"
]
,
// actuals below forecast
[
"above"
,
"#ff6300"
]
,
// actuals above forecast
]
)
Insert cell
Insert cell
resp
=
{
return
width
>
500
?
1
:
2
}
Insert cell
demandBelowForecastAnnotation
=
[
Plot
.
text
(
[
{
value
:
"demand falls below forecast ➣"
}
]
,
{
text
:
"value"
,
x
:
d3
.
utcHour
.
offset
(
event
.
datetime
,
-
36
)
,
y
:
-
4000
,
textAnchor
:
"end"
,
fontSize
:
resp
*
width
/
70
,
//16,
fontStyle
:
'italic'
}
)
]
Insert cell
demandAboveForecastAnnotation
=
[
Plot
.
text
(
[
{
value
:
"demand rises above forecast ➣"
}
]
,
{
text
:
"value"
,
x
:
d3
.
utcHour
.
offset
(
event
.
datetime
,
-
134
)
,
y
:
6200
,
textAnchor
:
"end"
,
fontSize
:
resp
*
width
/
70
,
//16,
fontStyle
:
'italic'
}
)
]
Insert cell
// point out where the demand dropped below the forecast
didYouNoticeThis
=
[
Plot
.
text
(
[
{
value
:
"Did you notice demand drop below forecast here? ⇘"
}
]
,
{
text
:
"value"
,
x
:
d3
.
utcHour
.
offset
(
event
.
datetime
,
-
36
)
,
y
:
67000
,
textAnchor
:
"end"
,
fontSize
:
16
,
fontStyle
:
'italic'
}
)
]
Insert cell
// show when the rolling blackouts started on the difference chart
annotationsDeltas
=
[
Plot
.
ruleX
(
[
event
.
datetime
]
,
{
stroke
:
"gray"
,
y1
:
0
,
y2
:
maxDelta
}
)
,
// text describing the event of interest
Plot
.
text
(
[
event
]
,
{
text
:
"description"
,
x
:
"datetime"
,
y
:
maxDelta
*
1.05
,
textAnchor
:
"start"
}
)
,
]
Insert cell
Insert cell
maxDelta
=
d3
.
max
(
data
,
d
=>
d
.
actuals
-
d
.
forecast
)
Insert cell
maxValue
=
Math
.
max
(
d3
.
max
(
data
,
d
=>
d
.
actuals
)
,
d3
.
max
(
data
,
d
=>
d
.
forecast
)
)
Insert cell
Insert cell
import
{
textcolor
}
from
"@observablehq/text-color-annotations-in-markdown"
Insert cell
import
{
authorship
,
navigation
,
workshop
,
altauthorship
}
from
"@observablehq/timeseries-assets"
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
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
differenceChart
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
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
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
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
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
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
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
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
rawdata
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data
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
event
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
zoom
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
zoomed
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
zoomedTicks
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dataTicks
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
colors
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
resp
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
demandBelowForecastAnnotation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
demandAboveForecastAnnotation
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
didYouNoticeThis
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
annotationsDeltas
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
maxDelta
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maxValue
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
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