Published
Edited
Feb 16, 2022
1 fork
16 stars
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
data = FileAttachment("texasEnergyJanFeb2021@1.csv").csv({ typed: true })
Insert cell
Insert cell
Insert cell
sortOptions = (new Map([
["solar, natural gas, nuclear, coal, wind, hydro, other", ["solar","natural gas", "nuclear","coal", "wind", "hydro", "other"]],
[categories.join(", "),
categories],
["alphabetical (default)",
["coal", "hydro", "natural gas", "nuclear", "other", "wind"]],
["most to least by usage",
sortedByTotal],
["least to most by usage",
sortedByTotal.slice().reverse()]
]))
Insert cell
sortedByTotal = d3.rollups(data, v => d3.sum(v, d => d.value), d => d.type).sort((a,b) => b[1] - a[1]).map(d => d[0])
Insert cell
// set up our color scale to match EIA color schemes (semantic colors; ie - hydro is blue, solar yellow, etc)
color = ({
domain: ['solar', 'wind', 'coal', 'natural gas', 'nuclear', 'hydro', 'other'],
range: ["#FEC704","#5C9631", "#664F06","#BD7229","#A1333F","#0395D6","#ADADAD"]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more