Skip to content

Instantly share code, notes, and snippets.

@sparkofreason
Last active March 29, 2018 17:15
Show Gist options
  • Save sparkofreason/19491934f3a50f8e0297d0249059d39d to your computer and use it in GitHub Desktop.
Save sparkofreason/19491934f3a50f8e0297d0249059d39d to your computer and use it in GitHub Desktop.
{
"legends": [
{
"fill": "color",
"type": "gradient"
}
],
"config": {
"range": {
"heatmap": {
"scheme": "greenblue"
}
}
},
"axes": [
{
"scale": "x",
"grid": true,
"domain": false,
"orient": "bottom",
"title": "x"
},
{
"scale": "y",
"grid": true,
"domain": false,
"orient": "left",
"title": "y"
}
],
"width": 500,
"scales": [
{
"name": "x",
"type": "linear",
"domain": {
"data": "source",
"field": "x"
},
"range": "width"
},
{
"name": "y",
"type": "linear",
"domain": {
"data": "source",
"field": "y"
},
"range": "height"
},
{
"name": "color",
"type": "sequential",
"zero": true,
"domain": {
"data": "contours",
"field": "value"
},
"range": "heatmap"
}
],
"marks": [
{
"type": "path",
"from": {
"data": "contours"
},
"encode": {
"enter": {
"stroke": {
"value": "#888"
},
"strokeWidth": {
"value": 1
},
"fill": {
"scale": "color",
"field": "value"
},
"fillOpacity": {
"value": 0.35
}
}
},
"transform": [
{
"type": "geopath",
"field": "datum"
}
]
}
],
"$schema": "https://vega.github.io/schema/vega/v3.json",
"signals": [
{
"name": "count",
"value": 10,
"bind": {
"input": "select",
"options": [
1,
5,
10,
20
]
}
}
],
"height": 500,
"data": [
{
"name": "source",
"values": [
{
"x": -5,
"y": -5,
"z": 50
},
{
"x": -5,
"y": -4,
"z": 41
},
{
"x": -5,
"y": -3,
"z": 34
},
{
"x": -5,
"y": -2,
"z": 29
},
{
"x": -5,
"y": -1,
"z": 26
},
{
"x": -5,
"y": 0,
"z": 25
},
{
"x": -5,
"y": 1,
"z": 26
},
{
"x": -5,
"y": 2,
"z": 29
},
{
"x": -5,
"y": 3,
"z": 34
},
{
"x": -5,
"y": 4,
"z": 41
},
{
"x": -4,
"y": -5,
"z": 41
},
{
"x": -4,
"y": -4,
"z": 32
},
{
"x": -4,
"y": -3,
"z": 25
},
{
"x": -4,
"y": -2,
"z": 20
},
{
"x": -4,
"y": -1,
"z": 17
},
{
"x": -4,
"y": 0,
"z": 16
},
{
"x": -4,
"y": 1,
"z": 17
},
{
"x": -4,
"y": 2,
"z": 20
},
{
"x": -4,
"y": 3,
"z": 25
},
{
"x": -4,
"y": 4,
"z": 32
},
{
"x": -3,
"y": -5,
"z": 34
},
{
"x": -3,
"y": -4,
"z": 25
},
{
"x": -3,
"y": -3,
"z": 18
},
{
"x": -3,
"y": -2,
"z": 13
},
{
"x": -3,
"y": -1,
"z": 10
},
{
"x": -3,
"y": 0,
"z": 9
},
{
"x": -3,
"y": 1,
"z": 10
},
{
"x": -3,
"y": 2,
"z": 13
},
{
"x": -3,
"y": 3,
"z": 18
},
{
"x": -3,
"y": 4,
"z": 25
},
{
"x": -2,
"y": -5,
"z": 29
},
{
"x": -2,
"y": -4,
"z": 20
},
{
"x": -2,
"y": -3,
"z": 13
},
{
"x": -2,
"y": -2,
"z": 8
},
{
"x": -2,
"y": -1,
"z": 5
},
{
"x": -2,
"y": 0,
"z": 4
},
{
"x": -2,
"y": 1,
"z": 5
},
{
"x": -2,
"y": 2,
"z": 8
},
{
"x": -2,
"y": 3,
"z": 13
},
{
"x": -2,
"y": 4,
"z": 20
},
{
"x": -1,
"y": -5,
"z": 26
},
{
"x": -1,
"y": -4,
"z": 17
},
{
"x": -1,
"y": -3,
"z": 10
},
{
"x": -1,
"y": -2,
"z": 5
},
{
"x": -1,
"y": -1,
"z": 2
},
{
"x": -1,
"y": 0,
"z": 1
},
{
"x": -1,
"y": 1,
"z": 2
},
{
"x": -1,
"y": 2,
"z": 5
},
{
"x": -1,
"y": 3,
"z": 10
},
{
"x": -1,
"y": 4,
"z": 17
},
{
"x": 0,
"y": -5,
"z": 25
},
{
"x": 0,
"y": -4,
"z": 16
},
{
"x": 0,
"y": -3,
"z": 9
},
{
"x": 0,
"y": -2,
"z": 4
},
{
"x": 0,
"y": -1,
"z": 1
},
{
"x": 0,
"y": 0,
"z": 0
},
{
"x": 0,
"y": 1,
"z": 1
},
{
"x": 0,
"y": 2,
"z": 4
},
{
"x": 0,
"y": 3,
"z": 9
},
{
"x": 0,
"y": 4,
"z": 16
},
{
"x": 1,
"y": -5,
"z": 26
},
{
"x": 1,
"y": -4,
"z": 17
},
{
"x": 1,
"y": -3,
"z": 10
},
{
"x": 1,
"y": -2,
"z": 5
},
{
"x": 1,
"y": -1,
"z": 2
},
{
"x": 1,
"y": 0,
"z": 1
},
{
"x": 1,
"y": 1,
"z": 2
},
{
"x": 1,
"y": 2,
"z": 5
},
{
"x": 1,
"y": 3,
"z": 10
},
{
"x": 1,
"y": 4,
"z": 17
},
{
"x": 2,
"y": -5,
"z": 29
},
{
"x": 2,
"y": -4,
"z": 20
},
{
"x": 2,
"y": -3,
"z": 13
},
{
"x": 2,
"y": -2,
"z": 8
},
{
"x": 2,
"y": -1,
"z": 5
},
{
"x": 2,
"y": 0,
"z": 4
},
{
"x": 2,
"y": 1,
"z": 5
},
{
"x": 2,
"y": 2,
"z": 8
},
{
"x": 2,
"y": 3,
"z": 13
},
{
"x": 2,
"y": 4,
"z": 20
},
{
"x": 3,
"y": -5,
"z": 34
},
{
"x": 3,
"y": -4,
"z": 25
},
{
"x": 3,
"y": -3,
"z": 18
},
{
"x": 3,
"y": -2,
"z": 13
},
{
"x": 3,
"y": -1,
"z": 10
},
{
"x": 3,
"y": 0,
"z": 9
},
{
"x": 3,
"y": 1,
"z": 10
},
{
"x": 3,
"y": 2,
"z": 13
},
{
"x": 3,
"y": 3,
"z": 18
},
{
"x": 3,
"y": 4,
"z": 25
},
{
"x": 4,
"y": -5,
"z": 41
},
{
"x": 4,
"y": -4,
"z": 32
},
{
"x": 4,
"y": -3,
"z": 25
},
{
"x": 4,
"y": -2,
"z": 20
},
{
"x": 4,
"y": -1,
"z": 17
},
{
"x": 4,
"y": 0,
"z": 16
},
{
"x": 4,
"y": 1,
"z": 17
},
{
"x": 4,
"y": 2,
"z": 20
},
{
"x": 4,
"y": 3,
"z": 25
},
{
"x": 4,
"y": 4,
"z": 32
}
]
},
{
"name": "contours",
"source": "source",
"transform": [
{
"type": "contour",
"x": {
"expr": "scale('x', datum.x)"
},
"y": {
"expr": "scale('y', datum.y)"
},
"values": [
50,
32,
18,
8,
2,
0,
2,
8,
18,
32
],
"size": [
{
"signal": "width"
},
{
"signal": "height"
}
],
"count": {
"signal": "count"
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment