Public
Edited
Apr 12, 2022
2 forks
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {powerplants_2019} from "@emfielduva/dvlib_sampledata"
Insert cell
Insert cell
sortedData = d3.sort(powerplants_2019, (a,b)=>d3.ascending(a[sortField],b[sortField]))
Insert cell
Insert cell
import {layoutChildren} from "@emfielduva/dvlib_layout"
Insert cell
dataLayout = layoutChildren("powerplants", sortedData);
Insert cell
Insert cell
pcElem = d3.select(svgContainer).select("#layer1")
Insert cell
pc = dvPackCircles(pcElem,dataLayout,800,600,"Plant annual net generation (MWh)",options);
Insert cell
options = ({
transitionMS: 1000,
padding: 1,
classField: "Plant primary fuel generation category",
textLabelField: "Plant name"
})
Insert cell
the `options` object contains a series of properties that control the layout and visual encoding.
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rollupData = d3.rollups(powerplants_2019, v => d3.sum(v, d => toNum(d["Plant annual net generation (MWh)"])), d => d["Plant primary fuel generation category"]).sort((a,b) => d3.descending(a[1],b[1]))
Insert cell
viewof tableRollup = Inputs.table(rollupData)
Insert cell
dataLayoutFullSum = layoutChildren("powerplants", rollupData);
Insert cell
pc2Elem = d3.select(svgContainer2).select("#layer1")
Insert cell
pc2 = dvPackCircles(pc2Elem,dataLayoutFullSum,800,600,'',options)
Insert cell
<svg id="base" width="1000" height="650">
<g id="layer1"></g>
</svg>
Insert cell
Insert cell
Insert cell
Insert cell
rollupDataByState = d3.rollups(powerplants_2019, v => d3.sum(v, d => toNum(d["Plant annual net generation (MWh)"])), d => d["Plant state abbreviation"], d => d["Plant primary fuel generation category"]);
Insert cell
dataLayoutByState = layoutChildren("powerplants", rollupDataByState);
Insert cell
pc3Elem = d3.select(svgContainer3).select("#bystate")
Insert cell
pc3 = dvPackCircles(pc3Elem,dataLayoutByState,800,600,'',options)
Insert cell
<svg id="base" width="1000" height="650">
<g id="bystate"></g>
<style>
#bystate circle {stroke: #ccc}
</style>
</svg>
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