Public
Edited
Nov 19
Paused
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.cell(
links
.filter((d) => d.source !== "NA" && d.target !== "Want NA")
.map((d) => ((d.stay = d.source == d.target.replace("Want ", "")), d)),
{
x: (d) => d.source,
y: (d) => d.target,
fill: "pct"
}
)
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fromVar = `${variable}HaveWorkedWith`
Insert cell
toVar = `${variable}WantToWorkWith`
Insert cell
color = {
const concatScale = d3.schemeTableau10.concat(d3.schemeAccent);
// .concat(d3.schemeCategory10);
return d3.scaleOrdinal(
selectedLanguages.length > concatScale.length
? d3.quantize(d3.interpolateSpectral, selectedLanguages.length)
: concatScale
);
}
Insert cell
Insert cell
viewof unrolledResultsAll = aq
.from(results)
.select("ResponseId", fromVar, toVar)
.derive({
fromList: aq.escape((d) => op.split(d[fromVar], ";")),
toList: aq.escape((d) => op.split(d[toVar], ";"))
})
.unroll("fromList")
.unroll("toList")
.view()
Insert cell
Insert cell
viewof unrolledResults = unrolledResultsAll
.filter(
aq.escape(
(d) =>
selectedLanguages.includes(d.fromList) &&
selectedLanguages.includes(d.toList)
)
)
.sample(+sampleSize)
.view()
Insert cell
viewof nodesFrom = unrolledResultsAll
.groupby("fromList")
.count()
.rename({
fromList: "id",
count: "value"
}).view()
Insert cell
viewof nodes = nodesFrom
.union(
unrolledResultsAll.groupby("toList").count()
.derive({
toList: d => `Want ${d.toList}`
})
.rename({
toList: "id",
count: "value"
})
)
.view()
Insert cell
Insert cell
viewof joinedResults = unrolledResults
.join(unrolledResults, (s, t, $) => op.equal(s.ResponseId, t.ResponseId))
.groupby([`fromList_1`, `toList_2`])
.rollup({
fullCount: op.count(),
value: op.distinct("ResponseId_1")
})
.groupby(["fromList_1"])
.derive({
pct: d => d.value/op.sum(d.value),
sum: d => op.sum(d.value),
source: d => d.fromList_1,
target: d => `Want ${d.toList_2}`
})
.orderby("fromList_1")
.view()
Insert cell
Insert cell
// // My library seems too slow for this 🤷🏼
// network = tableToNetwork(unrolledResults.objects().slice(0, 100), {
// matchBy: "ResponseId",
// nodesBy: fromVar,
// linkFrom: fromVar,
// linkTo: toVar,
// selfLinks: true,
// directed: true
// })

Insert cell
vars = Object.keys(results[0])
.filter((d) => d.endsWith("HaveWorkedWith"))
.map((d) => d.replace("HaveWorkedWith", ""))
Insert cell
languages = nodesFrom
.orderby(aq.desc("value"))
.objects()
.map((d) => d.id)
// languages = [
// "JavaScript",
// "SQL",
// "HTML/CSS",
// "Python",
// "Bash/Shell (all shells)",
// "TypeScript",
// "Java",
// "C++",
// "C#",
// "C",
// "PHP",
// "PowerShell",
// "Rust",
// "Go",
// "Kotlin",
// "Dart",
// "Ruby",
// "Assembly",
// "Visual Basic (.Net)",
// "Swift",
// "VBA",
// "MATLAB",
// "Lua",
// "Haskell",
// "Elixir",
// "R",
// "MicroPython",
// "Delphi",
// "Groovy",
// "Perl",
// "Scala",
// "Solidity",
// "F#",
// "Fortran",
// "Erlang",
// "NA",
// "Apex",
// "Clojure",
// "Objective-C",
// "GDScript",
// "OCaml",
// "Zig",
// "Lisp",
// "Crystal",
// "Julia",
// "Cobol",
// "Prolog",
// "Nim",
// "Zephyr"
// ]
Insert cell
results = zip.file("survey_results_public.csv").csv({typed: true})
Insert cell
viewof selectAttrb = searchCheckbox(Object.keys(results[0]))
Insert cell
navio(results, {attribs: selectAttrb})
Insert cell
fmtPct = (f => d => `${f(d)}`)(d3.format(",.1%"))
Insert cell
// schema = zip.file("survey_results_schema.csv").csv({typed: true})
Insert cell
import {aq, op} from "@uwdata/arquero"
Insert cell
import {navio} from "@john-guerra/navio"
Insert cell
import { SankeyChart } from "@john-guerra/sankey-diagram-component"
Insert cell
zip = FileAttachment("stack-overflow-developer-survey-2024.zip").zip()
Insert cell
import {PersistInput} from "@john-guerra/persist-input"
Insert cell
import {searchCheckbox} from "@john-guerra/search-checkbox"
Insert cell
import {vl} from "@vega/vega-lite-api-v5"
Insert cell
links
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