Skip to content

Instantly share code, notes, and snippets.

@eamonnmag
Created July 26, 2017 22:32
Show Gist options
  • Save eamonnmag/e97793c08938982c2fa05d8927afb219 to your computer and use it in GitHub Desktop.
Save eamonnmag/e97793c08938982c2fa05d8927afb219 to your computer and use it in GitHub Desktop.
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"width": 700,
"height": 500,
"padding": 0,
"autosize": "none",
"signals": [
{
"name": "cx",
"update": "width / 2"
},
{
"name": "cy",
"update": "height / 2"
},
{
"name": "nodeRadius",
"value": 8,
"bind": {
"input": "range",
"min": 1,
"max": 50,
"step": 1
}
},
{
"name": "nodeCharge",
"value": -30,
"bind": {
"input": "range",
"min": -100,
"max": 10,
"step": 1
}
},
{
"name": "linkDistance",
"value": 30,
"bind": {
"input": "range",
"min": 5,
"max": 100,
"step": 1
}
},
{
"name": "static",
"value": true,
"bind": {
"input": "checkbox"
}
},
{
"description": "State variable for active node fix status.",
"name": "fix",
"value": 0,
"on": [
{
"events": "symbol:mouseout[!event.buttons], window:mouseup",
"update": "0"
},
{
"events": "symbol:mouseover",
"update": "fix || 1"
},
{
"events": "[symbol:mousedown, window:mouseup] > window:mousemove!",
"update": "2",
"force": true
}
]
},
{
"description": "Graph node most recently interacted with.",
"name": "node",
"value": null,
"on": [
{
"events": "symbol:mouseover",
"update": "fix === 1 ? item() : node"
}
]
},
{
"description": "Flag to restart Force simulation upon data changes.",
"name": "restart",
"value": false,
"on": [
{
"events": {
"signal": "fix"
},
"update": "fix > 1"
}
]
}
],
"data": [
{
"name": "node-data",
"values": [
{
"name": "Reporting guidelines",
"type": "Reporting guidelines",
"size": 116,
"index": 0
},
{
"name": "Models/formats",
"type": "Models/formats",
"size": 223,
"index": 1
},
{
"name": "Terminology artifacts",
"type": "Terminology artifacts",
"size": 343,
"index": 2
},
{
"name": "MIRIAM",
"type": "Reporting guidelines",
"size": 5,
"index": 3
},
{
"name": "MIAME/Env",
"type": "Reporting guidelines",
"size": 4,
"index": 4
},
{
"name": "MIAME",
"type": "Reporting guidelines",
"size": 5,
"index": 5
},
{
"name": "FASTA Sequence Format",
"type": "Models/formats",
"size": 252,
"index": 6
},
{
"name": "PDB Format",
"type": "Models/formats",
"size": 58,
"index": 7
},
{
"name": "GFF3",
"type": "Models/formats",
"size": 46,
"index": 8
},
{
"name": "GO",
"type": "Terminology artifacts",
"size": 140,
"index": 9
},
{
"name": "ChEBI",
"type": "Terminology artifacts",
"size": 28,
"index": 10
},
{
"name": "NCBI Taxonomy",
"type": "Terminology artifacts",
"size": 21,
"index": 11
}
],
"format": {
"type": "json"
}
},
{
"name": "link-data",
"values": [
{"source": 0, "target": 4},
{"source": 0, "target": 3},
{"source": 0, "target": 5},
{"source": 1, "target": 6},
{"source": 1, "target": 7},
{"source": 1, "target": 8},
{"source": 2, "target": 9},
{"source": 2, "target": 10},
{"source": 2, "target": 11}
],
"format": {
"type": "json"
}
}
],
"scales": [
{
"name": "color",
"type": "ordinal",
"range": {
"scheme": "category10"
}
}
],
"marks": [
{
"name": "nodes",
"type": "symbol",
"zindex": 1,
"from": {
"data": "node-data"
},
"on": [
{
"trigger": "fix",
"modify": "node",
"values": "fix === 1 ? {fx:node.x, fy:node.y} : {fx:x(), fy:y()}"
},
{
"trigger": "!fix",
"modify": "node",
"values": "{fx: null, fy: null}"
}
],
"encode": {
"enter": {
"fill": {
"scale": "color",
"field": "type"
},
"stroke": {
"value": "white"
}
},
"update": {
"size": {
"field":"size"
},
"cursor": {
"value": "pointer"
}
}
},
"transform": [
{
"type": "force",
"iterations": 300,
"restart": {
"signal": "restart"
},
"static": {
"signal": "static"
},
"forces": [
{
"force": "center",
"x": {
"signal": "cx"
},
"y": {
"signal": "cy"
}
},
{
"force": "collide",
"radius": {
"signal": "nodeRadius"
}
},
{
"force": "nbody",
"strength": {
"signal": "nodeCharge"
}
},
{
"force": "link",
"links": "link-data",
"distance": {
"signal": "linkDistance"
}
}
]
}
]
},
{
"type": "path",
"from": {
"data": "link-data"
},
"interactive": false,
"encode": {
"update": {
"stroke": {
"value": "#ccc"
},
"strokeWidth": {
"value": 0.5
}
}
},
"transform": [
{
"type": "linkpath",
"shape": "line",
"sourceX": "datum.source.x",
"sourceY": "datum.source.y",
"targetX": "datum.target.x",
"targetY": "datum.target.y"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment