Published unlisted
Edited
Aug 19, 2020
Insert cell
Insert cell
Insert cell
Insert cell
String(months[0].month)
Insert cell
/* months = Array.from({length: (2020-2000)*12}, (_, i) => {
const date = new Date("2000-01-01");
date.setMonth(i+11);
return date;
}) */
Insert cell
renewable_totals = {
let solar_data = plant_data.filter(data => data['label'].includes('solar'));
let solar_sum = Math.round(d3.sum(solar_data, data => data['capacity'])).toLocaleString() + ' MW';
let wind_data = plant_data.filter(data => data['label'].includes('wind'));
let wind_sum = Math.round(d3.sum(wind_data, data => data['capacity'])).toLocaleString() + ' MW';
return [solar_sum, wind_sum]
}
Insert cell
function circle_size(capacity) {
const scale = d3.scaleLinear()
.domain([0, 750])
.range([4, 12]);
return scale(capacity)
}
Insert cell
plant_data = {
let month_plants = capacities_by_month.filter(data => data['month'].getTime() == month.getTime());
return month_plants.map( d =>
({loc: proj(get_plant_location(d['full_plant_id'])),
capacity: d['Nameplate Capacity (MW)'],
label: d['full_plant_id']
}))
}
Insert cell
plant_data2 = []
Insert cell
{
let month_plants = capacities_by_month.filter(data => data['month'].getTime() == month.getTime());
// remove plants that no longer exist
plant_data2.push(8)
}
Insert cell
function get_plant_location(plant_id) {
plant_id = plant_id.slice(0,plant_id.search('_'));
let plant_data = plant_locations[plant_locations.findIndex(d => d['full_plant_id_notech'] == plant_id)];
return [plant_data.Longitude, plant_data.Latitude]
}
Insert cell
function plantcolor(planttype){
if (planttype.includes("wind")) {
return '#b8d2f5' }
else {
return '#f5e2ae'
}}
Insert cell
path = d3.geoPath()
Insert cell
Insert cell
states = new Map(us.objects.states.geometries.map(d => [d.id, d.properties]))
Insert cell
us = FileAttachment("counties-albers-10m.json").json()
Insert cell
proj = d3.geoAlbersUsa().scale(1300).translate([487.5, 305])
Insert cell
capacities_by_month = d3.csvParse(await FileAttachment("capacities_by_month@5.csv").text(), d3.autoType).sort((a,b) => parseInt(b.full_plant_id.slice(0,b.full_plant_id.search('0')) - a.full_plant_id.slice(0,a.full_plant_id.search('-'))))
Insert cell
months = d3.csvParse(await FileAttachment("months.csv").text(), d3.autoType)
Insert cell
plant_locations = d3.csvParse(await FileAttachment("plant_locations.csv").text(), d3.autoType)
Insert cell
topojson = require("topojson-client@3")
Insert cell
import {Scrubber} from "@mbostock/scrubber"
Insert cell
d3 = require("d3@5")
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.
Learn more