Public
Edited
May 7, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof dataAggregationSelected = Inputs.radio(new Map([["All Passwords", allDataSorted], ["Group by Password Type", rollupData], ["Count by Crack Difficulty", rollupDataByDifficulty]]), {value: allDataSorted, label: "Select one:"})

// Is there a way to make
Insert cell
viewof sortField = Inputs.select(["length", "password_type", "crack_difficulty"], {label: "Sort By:", value: "password_type"})
Insert cell
Insert cell
UvaPasswords = FileAttachment("pass1000@2.csv").csv()
Insert cell
// UvaPasswords.forEach(d => {
// if (d.alphabet_size == "10") {d.password_type = "numeric"}
// else if (d.alphabet_size == "26") {d.password_type = "alphabetic"}
// else if (d.alphabet_size == "36") {d.password_type = "alphanumeric"}
// else if (d.alphabet_size == "43") {d.password_type = "numeric-symbolic"}
// else if (d.alphabet_size == "59") {d.password_type = "alphabetic-symbolic"}
// else if (d.alphabet_size == "69") {d.password_type = "alphanumeric-symbolic"}
// })
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
allDataSorted = d3.sort(UvaPasswords, (a,b)=>d3.ascending(a[sortField], b[sortField]))
Insert cell
Insert cell
rollupData = d3.rollups(UvaPasswords, v => d3.count(v, d => toNum(d["search_space_count"])), d => d["password_type"]).sort((a,b) => d3.ascending(a[1],b[1]))
Insert cell
Insert cell
rollupDataByDifficulty = d3.rollups(UvaPasswords, v => d3.count(v, d => toNum(d["search_space_count"])), d => d["crack_difficulty"], d => ["password_type"]);
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,600,600,"alphabet_size",options); // alphabet_size works fine
Insert cell
//pc = dvPackCircles(pcElem,dataLayout,600,600,"search_space_count",options); // for some reason doesn't like search_space_count
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
rollupData2 = d3.rollups(UvaPasswords, v => d3.count(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,600,600,'',options)
Insert cell
Insert cell
dataLayoutByDifficulty = layoutChildren("passwords", rollupDataByDifficulty);
Insert cell
pc3Elem = d3.select(svgContainer3).select("#bydifficulty")
Insert cell
pc3 = dvPackCircles(pc3Elem,dataLayoutByDifficulty,800,800,'',options)
Insert cell
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