Skip to content

Instantly share code, notes, and snippets.

@denjn5
Last active April 3, 2018 12:29
Show Gist options
  • Save denjn5/f3d0074f6bcaaafb13c144864aa68c93 to your computer and use it in GitHub Desktop.
Save denjn5/f3d0074f6bcaaafb13c144864aa68c93 to your computer and use it in GitHub Desktop.
{
"nodes": [
{"id": "Myriel", "opacity": 0.5, "size": 5},
{"id": "Napoleon", "opacity": 0.5, "size": 5},
{"id": "Mlle.Baptistine", "opacity": 0.5, "size": 5},
{"id": "Mme.Magloire", "opacity": 0.5, "size": 5},
{"id": "CountessdeLo", "opacity": 0.5, "size": 5},
{"id": "Geborand", "opacity": 0.5, "size": 5},
{"id": "Champtercier", "opacity": 0.5, "size": 5},
{"id": "Cravatte", "opacity": 0.5, "size": 5},
{"id": "Count", "opacity": 0.5, "size": 5},
{"id": "OldMan", "opacity": 0.5, "size": 5},
{"id": "Labarre", "opacity": 0.5, "size": 7},
{"id": "Valjean", "opacity": 0.5, "size": 7},
{"id": "Marguerite", "opacity": 0.5, "size": 9},
{"id": "Mme.deR", "opacity": 0.5, "size": 7},
{"id": "Isabeau", "opacity": 0.5, "size": 7},
{"id": "Gervais", "opacity": 0.5, "size": 7},
{"id": "Tholomyes", "opacity": 0.5, "size": 9},
{"id": "Listolier", "opacity": 0.5, "size": 9},
{"id": "Fameuil", "opacity": 0.5, "size": 9},
{"id": "Blacheville", "opacity": 0.5, "size": 9},
{"id": "Favourite", "opacity": 0.5, "size": 9},
{"id": "Dahlia", "opacity": 0.5, "size": 9},
{"id": "Zephine", "opacity": 0.5, "size": 9},
{"id": "Fantine", "opacity": 0.5, "size": 9},
{"id": "Mme.Thenardier", "opacity": 0.5, "size": 11},
{"id": "Thenardier", "opacity": 0.5, "size": 11},
{"id": "Cosette", "opacity": 0.5, "size": 13},
{"id": "Javert", "opacity": 0.5, "size": 11},
{"id": "Fauchelevent", "opacity": 0.5, "size": 3},
{"id": "Bamatabois", "opacity": 0.5, "size": 7},
{"id": "Perpetue", "opacity": 0.5, "size": 9},
{"id": "Simplice", "opacity": 0.5, "size": 7},
{"id": "Scaufflaire", "opacity": 0.5, "size": 7},
{"id": "Woman1", "opacity": 0.5, "size": 7},
{"id": "Judge", "opacity": 0.5, "size": 7},
{"id": "Champmathieu", "opacity": 0.5, "size": 7},
{"id": "Brevet", "opacity": 0.5, "size": 7},
{"id": "Chenildieu", "opacity": 0.5, "size": 7},
{"id": "Cochepaille", "opacity": 0.5, "size": 7},
{"id": "Pontmercy", "opacity": 0.5, "size": 11},
{"id": "Boulatruelle", "opacity": 0.5, "size": 15},
{"id": "Eponine", "opacity": 0.5, "size": 11},
{"id": "Anzelma", "opacity": 0.5, "size": 11},
{"id": "Woman2", "opacity": 0.5, "size": 13},
{"id": "MotherInnocent", "opacity": 0.5, "size": 3},
{"id": "Gribier", "opacity": 0.5, "size": 3},
{"id": "Jondrette", "opacity": 0.5, "size": 17},
{"id": "Mme.Burgon", "opacity": 0.5, "size": 17},
{"id": "Gavroche", "opacity": 0.5, "size": 19},
{"id": "Gillenormand", "opacity": 0.5, "size": 13},
{"id": "Magnon", "opacity": 0.5, "size": 13},
{"id": "Mlle.Gillenormand", "opacity": 0.5, "size": 13},
{"id": "Mme.Pontmercy", "opacity": 0.5, "size": 13},
{"id": "Mlle.Vaubois", "opacity": 0.5, "size": 13},
{"id": "Lt.Gillenormand", "opacity": 0.5, "size": 13},
{"id": "Marius", "opacity": 0.5, "size": 19},
{"id": "BaronessT", "opacity": 0.5, "size": 13},
{"id": "Mabeuf", "opacity": 0.5, "size": 19},
{"id": "Enjolras", "opacity": 0.5, "size": 19},
{"id": "Combeferre", "opacity": 0.5, "size": 19},
{"id": "Prouvaire", "opacity": 0.5, "size": 19},
{"id": "Feuilly", "opacity": 0.5, "size": 19},
{"id": "Courfeyrac", "opacity": 0.5, "size": 19},
{"id": "Bahorel", "opacity": 0.5, "size": 19},
{"id": "Bossuet", "opacity": 0.5, "size": 19},
{"id": "Joly", "opacity": 0.5, "size": 19},
{"id": "Grantaire", "opacity": 0.5, "size": 19},
{"id": "MotherPlutarch", "opacity": 0.5, "size": 21},
{"id": "Gueulemer", "opacity": 0.5, "size": 11},
{"id": "Babet", "opacity": 0.5, "size": 11},
{"id": "Claquesous", "opacity": 0.5, "size": 11},
{"id": "Montparnasse", "opacity": 0.5, "size": 11},
{"id": "Toussaint", "opacity": 0.5, "size": 13},
{"id": "Child1", "opacity": 0.5, "size": 3},
{"id": "Child2", "opacity": 0.5, "size": 3},
{"id": "Brujon", "opacity": 0.5, "size": 11},
{"id": "Mme.Hucheloup", "opacity": 0.5, "size": 19}
],
"links": [
{"source": "Napoleon", "target": "Myriel", "str": 1},
{"source": "Mlle.Baptistine", "target": "Myriel", "str": 8},
{"source": "Mme.Magloire", "target": "Myriel", "str": 10},
{"source": "Mme.Magloire", "target": "Mlle.Baptistine", "str": 6},
{"source": "CountessdeLo", "target": "Myriel", "str": 1},
{"source": "Geborand", "target": "Myriel", "str": 1},
{"source": "Champtercier", "target": "Myriel", "str": 1},
{"source": "Cravatte", "target": "Myriel", "str": 1},
{"source": "Count", "target": "Myriel", "str": 2},
{"source": "OldMan", "target": "Myriel", "str": 1},
{"source": "Valjean", "target": "Labarre", "str": 1},
{"source": "Valjean", "target": "Mme.Magloire", "str": 3},
{"source": "Valjean", "target": "Mlle.Baptistine", "str": 3},
{"source": "Valjean", "target": "Myriel", "str": 5},
{"source": "Marguerite", "target": "Valjean", "str": 1},
{"source": "Mme.deR", "target": "Valjean", "str": 1},
{"source": "Isabeau", "target": "Valjean", "str": 1},
{"source": "Gervais", "target": "Valjean", "str": 1},
{"source": "Listolier", "target": "Tholomyes", "str": 4},
{"source": "Fameuil", "target": "Tholomyes", "str": 4},
{"source": "Fameuil", "target": "Listolier", "str": 4},
{"source": "Blacheville", "target": "Tholomyes", "str": 4},
{"source": "Blacheville", "target": "Listolier", "str": 4},
{"source": "Blacheville", "target": "Fameuil", "str": 4},
{"source": "Favourite", "target": "Tholomyes", "str": 3},
{"source": "Favourite", "target": "Listolier", "str": 3},
{"source": "Favourite", "target": "Fameuil", "str": 3},
{"source": "Favourite", "target": "Blacheville", "str": 4},
{"source": "Dahlia", "target": "Tholomyes", "str": 3},
{"source": "Dahlia", "target": "Listolier", "str": 3},
{"source": "Dahlia", "target": "Fameuil", "str": 3},
{"source": "Dahlia", "target": "Blacheville", "str": 3},
{"source": "Dahlia", "target": "Favourite", "str": 5},
{"source": "Zephine", "target": "Tholomyes", "str": 3},
{"source": "Zephine", "target": "Listolier", "str": 3},
{"source": "Zephine", "target": "Fameuil", "str": 3},
{"source": "Zephine", "target": "Blacheville", "str": 3},
{"source": "Zephine", "target": "Favourite", "str": 4},
{"source": "Zephine", "target": "Dahlia", "str": 4},
{"source": "Fantine", "target": "Tholomyes", "str": 3},
{"source": "Fantine", "target": "Listolier", "str": 3},
{"source": "Fantine", "target": "Fameuil", "str": 3},
{"source": "Fantine", "target": "Blacheville", "str": 3},
{"source": "Fantine", "target": "Favourite", "str": 4},
{"source": "Fantine", "target": "Dahlia", "str": 4},
{"source": "Fantine", "target": "Zephine", "str": 4},
{"source": "Fantine", "target": "Marguerite", "str": 2},
{"source": "Fantine", "target": "Valjean", "str": 9},
{"source": "Mme.Thenardier", "target": "Fantine", "str": 2},
{"source": "Mme.Thenardier", "target": "Valjean", "str": 7},
{"source": "Thenardier", "target": "Mme.Thenardier", "str": 13},
{"source": "Thenardier", "target": "Fantine", "str": 1},
{"source": "Thenardier", "target": "Valjean", "str": 12},
{"source": "Cosette", "target": "Mme.Thenardier", "str": 4},
{"source": "Cosette", "target": "Valjean", "str": 31},
{"source": "Cosette", "target": "Tholomyes", "str": 1},
{"source": "Cosette", "target": "Thenardier", "str": 1},
{"source": "Javert", "target": "Valjean", "str": 17},
{"source": "Javert", "target": "Fantine", "str": 5},
{"source": "Javert", "target": "Thenardier", "str": 5},
{"source": "Javert", "target": "Mme.Thenardier", "str": 1},
{"source": "Javert", "target": "Cosette", "str": 1},
{"source": "Fauchelevent", "target": "Valjean", "str": 8},
{"source": "Fauchelevent", "target": "Javert", "str": 1},
{"source": "Bamatabois", "target": "Fantine", "str": 1},
{"source": "Bamatabois", "target": "Javert", "str": 1},
{"source": "Bamatabois", "target": "Valjean", "str": 2},
{"source": "Perpetue", "target": "Fantine", "str": 1},
{"source": "Simplice", "target": "Perpetue", "str": 2},
{"source": "Simplice", "target": "Valjean", "str": 3},
{"source": "Simplice", "target": "Fantine", "str": 2},
{"source": "Simplice", "target": "Javert", "str": 1},
{"source": "Scaufflaire", "target": "Valjean", "str": 1},
{"source": "Woman1", "target": "Valjean", "str": 2},
{"source": "Woman1", "target": "Javert", "str": 1},
{"source": "Judge", "target": "Valjean", "str": 3},
{"source": "Judge", "target": "Bamatabois", "str": 2},
{"source": "Champmathieu", "target": "Valjean", "str": 3},
{"source": "Champmathieu", "target": "Judge", "str": 3},
{"source": "Champmathieu", "target": "Bamatabois", "str": 2},
{"source": "Brevet", "target": "Judge", "str": 2},
{"source": "Brevet", "target": "Champmathieu", "str": 2},
{"source": "Brevet", "target": "Valjean", "str": 2},
{"source": "Brevet", "target": "Bamatabois", "str": 1},
{"source": "Chenildieu", "target": "Judge", "str": 2},
{"source": "Chenildieu", "target": "Champmathieu", "str": 2},
{"source": "Chenildieu", "target": "Brevet", "str": 2},
{"source": "Chenildieu", "target": "Valjean", "str": 2},
{"source": "Chenildieu", "target": "Bamatabois", "str": 1},
{"source": "Cochepaille", "target": "Judge", "str": 2},
{"source": "Cochepaille", "target": "Champmathieu", "str": 2},
{"source": "Cochepaille", "target": "Brevet", "str": 2},
{"source": "Cochepaille", "target": "Chenildieu", "str": 2},
{"source": "Cochepaille", "target": "Valjean", "str": 2},
{"source": "Cochepaille", "target": "Bamatabois", "str": 1},
{"source": "Pontmercy", "target": "Thenardier", "str": 1},
{"source": "Boulatruelle", "target": "Thenardier", "str": 1},
{"source": "Eponine", "target": "Mme.Thenardier", "str": 2},
{"source": "Eponine", "target": "Thenardier", "str": 3},
{"source": "Anzelma", "target": "Eponine", "str": 2},
{"source": "Anzelma", "target": "Thenardier", "str": 2},
{"source": "Anzelma", "target": "Mme.Thenardier", "str": 1},
{"source": "Woman2", "target": "Valjean", "str": 3},
{"source": "Woman2", "target": "Cosette", "str": 1},
{"source": "Woman2", "target": "Javert", "str": 1},
{"source": "MotherInnocent", "target": "Fauchelevent", "str": 3},
{"source": "MotherInnocent", "target": "Valjean", "str": 1},
{"source": "Gribier", "target": "Fauchelevent", "str": 2},
{"source": "Mme.Burgon", "target": "Jondrette", "str": 1},
{"source": "Gavroche", "target": "Mme.Burgon", "str": 2},
{"source": "Gavroche", "target": "Thenardier", "str": 1},
{"source": "Gavroche", "target": "Javert", "str": 1},
{"source": "Gavroche", "target": "Valjean", "str": 1},
{"source": "Gillenormand", "target": "Cosette", "str": 3},
{"source": "Gillenormand", "target": "Valjean", "str": 2},
{"source": "Magnon", "target": "Gillenormand", "str": 1},
{"source": "Magnon", "target": "Mme.Thenardier", "str": 1},
{"source": "Mlle.Gillenormand", "target": "Gillenormand", "str": 9},
{"source": "Mlle.Gillenormand", "target": "Cosette", "str": 2},
{"source": "Mlle.Gillenormand", "target": "Valjean", "str": 2},
{"source": "Mme.Pontmercy", "target": "Mlle.Gillenormand", "str": 1},
{"source": "Mme.Pontmercy", "target": "Pontmercy", "str": 1},
{"source": "Mlle.Vaubois", "target": "Mlle.Gillenormand", "str": 1},
{"source": "Lt.Gillenormand", "target": "Mlle.Gillenormand", "str": 2},
{"source": "Lt.Gillenormand", "target": "Gillenormand", "str": 1},
{"source": "Lt.Gillenormand", "target": "Cosette", "str": 1},
{"source": "Marius", "target": "Mlle.Gillenormand", "str": 6},
{"source": "Marius", "target": "Gillenormand", "str": 12},
{"source": "Marius", "target": "Pontmercy", "str": 1},
{"source": "Marius", "target": "Lt.Gillenormand", "str": 1},
{"source": "Marius", "target": "Cosette", "str": 21},
{"source": "Marius", "target": "Valjean", "str": 19},
{"source": "Marius", "target": "Tholomyes", "str": 1},
{"source": "Marius", "target": "Thenardier", "str": 2},
{"source": "Marius", "target": "Eponine", "str": 5},
{"source": "Marius", "target": "Gavroche", "str": 4},
{"source": "BaronessT", "target": "Gillenormand", "str": 1},
{"source": "BaronessT", "target": "Marius", "str": 1},
{"source": "Mabeuf", "target": "Marius", "str": 1},
{"source": "Mabeuf", "target": "Eponine", "str": 1},
{"source": "Mabeuf", "target": "Gavroche", "str": 1},
{"source": "Enjolras", "target": "Marius", "str": 7},
{"source": "Enjolras", "target": "Gavroche", "str": 7},
{"source": "Enjolras", "target": "Javert", "str": 6},
{"source": "Enjolras", "target": "Mabeuf", "str": 1},
{"source": "Enjolras", "target": "Valjean", "str": 4},
{"source": "Combeferre", "target": "Enjolras", "str": 15},
{"source": "Combeferre", "target": "Marius", "str": 5},
{"source": "Combeferre", "target": "Gavroche", "str": 6},
{"source": "Combeferre", "target": "Mabeuf", "str": 2},
{"source": "Prouvaire", "target": "Gavroche", "str": 1},
{"source": "Prouvaire", "target": "Enjolras", "str": 4},
{"source": "Prouvaire", "target": "Combeferre", "str": 2},
{"source": "Feuilly", "target": "Gavroche", "str": 2},
{"source": "Feuilly", "target": "Enjolras", "str": 6},
{"source": "Feuilly", "target": "Prouvaire", "str": 2},
{"source": "Feuilly", "target": "Combeferre", "str": 5},
{"source": "Feuilly", "target": "Mabeuf", "str": 1},
{"source": "Feuilly", "target": "Marius", "str": 1},
{"source": "Courfeyrac", "target": "Marius", "str": 9},
{"source": "Courfeyrac", "target": "Enjolras", "str": 17},
{"source": "Courfeyrac", "target": "Combeferre", "str": 13},
{"source": "Courfeyrac", "target": "Gavroche", "str": 7},
{"source": "Courfeyrac", "target": "Mabeuf", "str": 2},
{"source": "Courfeyrac", "target": "Eponine", "str": 1},
{"source": "Courfeyrac", "target": "Feuilly", "str": 6},
{"source": "Courfeyrac", "target": "Prouvaire", "str": 3},
{"source": "Bahorel", "target": "Combeferre", "str": 5},
{"source": "Bahorel", "target": "Gavroche", "str": 5},
{"source": "Bahorel", "target": "Courfeyrac", "str": 6},
{"source": "Bahorel", "target": "Mabeuf", "str": 2},
{"source": "Bahorel", "target": "Enjolras", "str": 4},
{"source": "Bahorel", "target": "Feuilly", "str": 3},
{"source": "Bahorel", "target": "Prouvaire", "str": 2},
{"source": "Bahorel", "target": "Marius", "str": 1},
{"source": "Bossuet", "target": "Marius", "str": 5},
{"source": "Bossuet", "target": "Courfeyrac", "str": 12},
{"source": "Bossuet", "target": "Gavroche", "str": 5},
{"source": "Bossuet", "target": "Bahorel", "str": 4},
{"source": "Bossuet", "target": "Enjolras", "str": 10},
{"source": "Bossuet", "target": "Feuilly", "str": 6},
{"source": "Bossuet", "target": "Prouvaire", "str": 2},
{"source": "Bossuet", "target": "Combeferre", "str": 9},
{"source": "Bossuet", "target": "Mabeuf", "str": 1},
{"source": "Bossuet", "target": "Valjean", "str": 1},
{"source": "Joly", "target": "Bahorel", "str": 5},
{"source": "Joly", "target": "Bossuet", "str": 7},
{"source": "Joly", "target": "Gavroche", "str": 3},
{"source": "Joly", "target": "Courfeyrac", "str": 5},
{"source": "Joly", "target": "Enjolras", "str": 5},
{"source": "Joly", "target": "Feuilly", "str": 5},
{"source": "Joly", "target": "Prouvaire", "str": 2},
{"source": "Joly", "target": "Combeferre", "str": 5},
{"source": "Joly", "target": "Mabeuf", "str": 1},
{"source": "Joly", "target": "Marius", "str": 2},
{"source": "Grantaire", "target": "Bossuet", "str": 3},
{"source": "Grantaire", "target": "Enjolras", "str": 3},
{"source": "Grantaire", "target": "Combeferre", "str": 1},
{"source": "Grantaire", "target": "Courfeyrac", "str": 2},
{"source": "Grantaire", "target": "Joly", "str": 2},
{"source": "Grantaire", "target": "Gavroche", "str": 1},
{"source": "Grantaire", "target": "Bahorel", "str": 1},
{"source": "Grantaire", "target": "Feuilly", "str": 1},
{"source": "Grantaire", "target": "Prouvaire", "str": 1},
{"source": "MotherPlutarch", "target": "Mabeuf", "str": 3},
{"source": "Gueulemer", "target": "Thenardier", "str": 5},
{"source": "Gueulemer", "target": "Valjean", "str": 1},
{"source": "Gueulemer", "target": "Mme.Thenardier", "str": 1},
{"source": "Gueulemer", "target": "Javert", "str": 1},
{"source": "Gueulemer", "target": "Gavroche", "str": 1},
{"source": "Gueulemer", "target": "Eponine", "str": 1},
{"source": "Babet", "target": "Thenardier", "str": 6},
{"source": "Babet", "target": "Gueulemer", "str": 6},
{"source": "Babet", "target": "Valjean", "str": 1},
{"source": "Babet", "target": "Mme.Thenardier", "str": 1},
{"source": "Babet", "target": "Javert", "str": 2},
{"source": "Babet", "target": "Gavroche", "str": 1},
{"source": "Babet", "target": "Eponine", "str": 1},
{"source": "Claquesous", "target": "Thenardier", "str": 4},
{"source": "Claquesous", "target": "Babet", "str": 4},
{"source": "Claquesous", "target": "Gueulemer", "str": 4},
{"source": "Claquesous", "target": "Valjean", "str": 1},
{"source": "Claquesous", "target": "Mme.Thenardier", "str": 1},
{"source": "Claquesous", "target": "Javert", "str": 1},
{"source": "Claquesous", "target": "Eponine", "str": 1},
{"source": "Claquesous", "target": "Enjolras", "str": 1},
{"source": "Montparnasse", "target": "Javert", "str": 1},
{"source": "Montparnasse", "target": "Babet", "str": 2},
{"source": "Montparnasse", "target": "Gueulemer", "str": 2},
{"source": "Montparnasse", "target": "Claquesous", "str": 2},
{"source": "Montparnasse", "target": "Valjean", "str": 1},
{"source": "Montparnasse", "target": "Gavroche", "str": 1},
{"source": "Montparnasse", "target": "Eponine", "str": 1},
{"source": "Montparnasse", "target": "Thenardier", "str": 1},
{"source": "Toussaint", "target": "Cosette", "str": 2},
{"source": "Toussaint", "target": "Javert", "str": 1},
{"source": "Toussaint", "target": "Valjean", "str": 1},
{"source": "Child1", "target": "Gavroche", "str": 2},
{"source": "Child2", "target": "Gavroche", "str": 2},
{"source": "Child2", "target": "Child1", "str": 3},
{"source": "Brujon", "target": "Babet", "str": 3},
{"source": "Brujon", "target": "Gueulemer", "str": 3},
{"source": "Brujon", "target": "Thenardier", "str": 3},
{"source": "Brujon", "target": "Gavroche", "str": 1},
{"source": "Brujon", "target": "Eponine", "str": 1},
{"source": "Brujon", "target": "Claquesous", "str": 1},
{"source": "Brujon", "target": "Montparnasse", "str": 1},
{"source": "Mme.Hucheloup", "target": "Bossuet", "str": 1},
{"source": "Mme.Hucheloup", "target": "Joly", "str": 1},
{"source": "Mme.Hucheloup", "target": "Grantaire", "str": 1},
{"source": "Mme.Hucheloup", "target": "Bahorel", "str": 1},
{"source": "Mme.Hucheloup", "target": "Courfeyrac", "str": 1},
{"source": "Mme.Hucheloup", "target": "Gavroche", "str": 1},
{"source": "Mme.Hucheloup", "target": "Enjolras", "str": 1}
]
}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.links line {
stroke: #999;
stroke-opacity: 0.6;
}
.nodes circle {
stroke: #fff;
stroke-width: 1.5px;
}
</style>
<svg width="960" height="600"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
// https://bl.ocks.org/RobinL/8174dec97312214594084755f6f65096
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var color = d3.scaleOrdinal(d3.schemeCategory20);
var simulation = d3.forceSimulation()
.force("link", d3.forceLink().id(function(d) { return d.id; }))
.force("charge", d3.forceManyBody())
.force("center", d3.forceCenter(width / 2, height / 2));
d3.json("data.json", function(error, graph) {
if (error) throw error;
var link = svg.append("g")
.attr("class", "links")
.selectAll("line")
.data(graph.links)
.enter().append("line")
.attr("stroke-width", function(d) { return Math.sqrt(d.str); });
var node = svg.append("g")
.attr("class", "nodes")
.selectAll("circle")
.data(graph.nodes)
.enter().append("circle")
.style("opacity", function(d) { return d.size / 20; })
.attr("r", 5)
.attr("fill", function(d) { return color(d.size); })
.call(d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended));
node.append("title")
.text(function(d) { return d.id; });
simulation
.nodes(graph.nodes)
.on("tick", ticked);
simulation.force("link")
.links(graph.links);
function ticked() {
link
.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
node
.attr('r', function(d) { return d.size; })
.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
}
});
function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(d) {
d.fx = d3.event.x;
d.fy = d3.event.y;
}
function dragended(d) {
if (!d3.event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment