Skip to content

Instantly share code, notes, and snippets.

@janecakemaster
Created April 18, 2014 06:10
Show Gist options
  • Save janecakemaster/11027050 to your computer and use it in GitHub Desktop.
Save janecakemaster/11027050 to your computer and use it in GitHub Desktop.
raw json data looks like this:
{
"name":"flare.analytics.cluster.AgglomerativeCluster",
"size":3938,
"imports":[
"flare.animate.Transitioner",
"flare.vis.data.DataList",
"flare.util.math.IMatrix",
"flare.analytics.cluster.MergeEdge",
"flare.analytics.cluster.HierarchicalCluster",
"flare.vis.data.Data"
]
},
{
"name":"flare.analytics.cluster.CommunityStructure",
"size":3812,
"imports":[
"flare.analytics.cluster.HierarchicalCluster",
"flare.animate.Transitioner",
"flare.vis.data.DataList",
"flare.analytics.cluster.MergeEdge",
"flare.util.math.IMatrix"
]
},
The code for the diagram example converts the json into maps by creating two maps (one for index by name, other for name by index) and using the maps, counts the number of imports for each package and creates a square matrix out of them.
Each row represents a package and each column is the number of time it uses another package. For example, [0,3] is 2 so that means the first package uses the 4th package 2 times. d3 contains a chord.matrix method that converts this matrix into chords.
[5][0][0][2][0][0][0][0][0][0][0][0][0][3][0][2][0][0][0][8][0][0][0][0][0][0][1][0][0][0]
[0][1][0][5][0][0][0][0][0][0][0][0][0][5][2][0][0][0][0][14][0][0][0][0][0][0][6][0][0][1]
[0][0][0][1][0][0][0][0][0][0][0][0][1][2][0][0][0][1][0][1][0][0][0][0][0][0][1][0][0][1]
[0][0][0][30][1][0][0][0][0][0][0][0][0][9][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][16][0][0][0][0][0][0][0][0][2][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][7][17][0][0][0][0][0][0][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][2][7][0][0][0][0][0][0][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][3][0][0][0][0][0][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][1][1][0][0][0][0][0][0][0][0][0][2][0][1][0][0][0][0][0][0][0][0][0][1]
[0][0][0][0][0][0][0][0][0][22][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][61][0][0][6][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][32][39][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][0][0][19][14][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][0][0][0][23][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][0][0][0][0][2][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][2][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][0][0][0][2][0][0][3][0][0][0][0][0][0][0][0][0][0][0][0][0]
[0][0][0][3][0][0][0][5][0][0][0][0][4][3][0][0][0][7][0][0][0][0][0][0][0][0][0][0][0][2]
[0][0][0][2][0][0][0][1][0][0][0][0][0][3][0][0][0][0][12][2][0][4][0][0][0][0][0][0][1][3]
[0][0][0][2][0][0][3][1][0][0][0][0][9][17][2][2][0][0][0][26][4][4][0][0][0][0][0][0][0][0]
[0][0][0][0][0][0][0][0][0][0][0][0][0][3][0][0][0][0][0][5][3][0][0][0][0][0][0][0][0][0]
[0][0][0][1][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][6][0][1][0][0][0][0][0][0][0][0]
[0][0][0][1][0][0][0][6][0][0][0][0][4][6][0][0][5][0][0][1][0][0][4][0][0][0][0][0][0][0]
[0][0][0][1][0][0][0][0][0][0][0][0][0][0][0][0][0][2][0][2][0][1][0][2][0][0][0][0][1][0]
[0][0][0][3][0][0][0][0][0][0][0][0][3][3][0][0][7][0][0][8][0][0][0][0][4][0][2][0][0][0]
[0][0][0][3][0][0][0][0][0][0][0][0][0][1][0][0][0][0][0][10][0][0][0][0][0][0][3][0][0][0]
[0][0][0][7][0][0][0][0][0][0][0][0][0][5][0][0][0][0][0][1][0][0][0][0][0][0][11][0][0][3]
[0][0][0][1][0][0][0][3][0][0][0][0][0][5][0][0][0][0][0][6][0][0][0][0][0][0][1][2][0][0]
[0][0][0][6][0][0][0][0][0][3][0][0][6][20][0][0][0][4][0][34][1][0][0][0][0][0][2][0][14][1]
[0][0][0][3][0][0][0][0][0][0][0][0][0][1][0][0][0][2][1][2][0][2][0][0][0][0][2][0][0][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment