Public
Edited
May 6, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof sortField = Inputs.select(["length", "password_type"], {label: "Sort By:", value: "password_type"})
Insert cell
Insert cell
UvaPasswords = FileAttachment("pass1000@3.csv").csv()
Insert cell
//passwords = UvaPasswords.drop({index: [0], inplace: true});
Insert cell
pass1000@3.csv
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
pass1000@3.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
//slicedData = d3.shuffle(UvaPasswords).slice(0,1000)
Insert cell
sortedData = d3.sort(UvaPasswords, (a,b) => d3.ascending(a[sortField],b[sortField]))
Insert cell
Insert cell
import {layoutChildren} from "@emfielduva/dvlib_layout"
Insert cell
dataLayout = layoutChildren("passwords", sortedData);
Insert cell
Insert cell
Insert cell
import {dvPackCircles} from "@emfielduva/dvlib_layout"
Insert cell
Insert cell
pcElem = d3.select(svgContainer).select('#layer1')
Insert cell
pc = dvPackCircles(pcElem,dataLayout,800,600,"search_space_count",options);
Insert cell
Insert cell
options = ({
transitionMS: 1000,
padding: 1,
classField: "password_type",
textLabelField: "password"
})
Insert cell
Insert cell
import {toNum} from "@emfielduva/dvlib_layout"
Insert cell
rollupData = d3.rollups(UvaPasswords, v => d3.sum(v, d => toNum(d["search_space_count"])), d => d["password_type"]).sort((a,b) => d3.ascending(a[1],b[1])) //use d3.count to count how many of each type of password
//.sort(a,b) --> compares each a and b value and sorts them
//a[1] --> sorts by column 1 (numeric value)
Insert cell
// rollupData = d3.rollups(UvaPasswords, v=> d3.sum(v,
// d => d["password"]),
// d => d["length"]),
// d => d["alphabet_size"]),
// d => d["search_space_count"]).sort((a,b,c,d) => d3.ascending(a[1],b[1]),c[1],d[1])
Insert cell
Insert cell
viewof tableRollup = Inputs.table(rollupData)
Insert cell
dataLayoutFullSum = layoutChildren("passwords",rollupData);
Insert cell
pc2Elem = d3.select(svgContainer2).select("#layer1")
Insert cell
pc2 = dvPackCircles(pc2Elem,dataLayoutFullSum,800,600,'',options)
Insert cell
dvPackCircles
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