Published
Edited
2 forks
Importers
35 stars
Also listed in…
Networks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
textBBoxDims = ({})
Insert cell
textSize = 5
Insert cell
getURL = node => {
if (node.type == "author") {
return `https://github.com/search?type=users&q=${node.id.replace(
" ",
"+"
)}`;
} else {
return `https://github.com/d3/${node.id}`;
}
}
Insert cell
updateGraph = {
const currentData = eg.data();
if (
currentData.nodes.length != graphData.nodes.length ||
currentData.links.length != graphData.links.length
) {
eg.changeData(graphData);
}
}
Insert cell
eg = EditableGraph({ width })
Insert cell
sim = (simulation, data, height, width) =>
simulation
.nodes(data.nodes)
.force("link", d3.forceLink(data.links).id(d => d.id))
.force("charge", d3.forceManyBody())
.force("center", d3.forceCenter(width / 2, height / 2))
.alphaDecay(0)
.restart()
Insert cell
height = 500
Insert cell
Insert cell
graphData = ({ nodes, links })
Insert cell
Insert cell
nodes = reposByDate[dateIdx].concat(authorsByDate[dateIdx])
Insert cell
connectionsByDate = {
const dateArray = [];
let cumulativeData = new Map();
dateRange.forEach(date => {
dateArray.push(cumulativeData);
cumulativeData = new Map(cumulativeData);
const currentData = dateGroupedData.get(date) || [];
currentData.forEach(datum => {
const key = datum.author + ' | ' + datum.repo;
if (!cumulativeData.has(key)) {
cumulativeData.set(key, 0);
}
cumulativeData.set(key, cumulativeData.get(key) + 1);
});
});
return dateArray.map(d => Array.from(d));
}
Insert cell
reposByDate = {
const dateArray = [];
let cumulativeData = new Map();
dateRange.forEach(date => {
dateArray.push(cumulativeData);
cumulativeData = new Map(cumulativeData);
const currentData = dateGroupedData.get(date) || [];
currentData.forEach(datum => {
const key = datum.repo;
if (!cumulativeData.has(key)) {
cumulativeData.set(key, 0);
}
cumulativeData.set(key, cumulativeData.get(key) + 1);
});
});
return dateArray.map(d =>
Array.from(d).map(t => ({ id: t[0], type: 'repo', count: t[1] }))
);
}
Insert cell
authorsByDate = {
const dateArray = [];
let cumulativeData = new Map();
dateRange.forEach(date => {
dateArray.push(cumulativeData);
cumulativeData = new Map(cumulativeData);
const currentData = dateGroupedData.get(date) || [];
currentData.forEach(datum => {
const key = datum.author;
if (!cumulativeData.has(key)) {
cumulativeData.set(key, 0);
}
cumulativeData.set(key, cumulativeData.get(key) + 1);
});
});
return dateArray.map(d =>
Array.from(d).map(t => ({ id: t[0], type: 'author', count: t[1] }))
);
}
Insert cell
dateIdx = dateRange.findIndex(d => d === date)
Insert cell
dateRange = {
const dateRange = d3.extent(cleanData, d => new Date(d.date));
let currentDate = new Date(dateRange[0]);
currentDate.setHours(0);
currentDate.setMinutes(0);
currentDate.setSeconds(0);
const dateList = [];
while (currentDate < dateRange[1]) {
dateList.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
return dateList;
}
Insert cell
dateGroupedData = d3.group(cleanData, d => d.date)
Insert cell
cleanData = combined
.map(d => {
// replace "Fil" with "Philippe Rivière"
if (d.author == "Fil") {
d.author = "Philippe Rivière";
}
// replace "Curran" and "curran" with "Curran Kelleher"
if (d.author == "Curran" || d.author == "curran") {
d.author = "Curran Kelleher";
}
// set times to the beginning of the day
// console.log(typeof d.date);
// console.log(typeof d.date);
const date = new Date(d.date.split(' ')[0]);
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
d.date = date;
return d;
})
.filter(d => d.author != "dependabot[bot]")
Insert cell
Insert cell
import { Scrubber } from '@mbostock/scrubber'
Insert cell
import { Radio } from '@observablehq/inputs'
Insert cell
import { EditableGraph, drag, EGTag } from "@rlesser/editable-force-graph@2473"
Insert cell
import { combined } from '@codingwithfire/d3-git-history-data'
Insert cell
import { setRect, getBBox } from "@rlesser/automatic-getbbox"
Insert cell
moment = require('moment')
Insert cell
d3 = require('d3')
Insert cell
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