Skip to content

Instantly share code, notes, and snippets.

@willium
Created December 24, 2015 06:12
Show Gist options
  • Save willium/f3ffa817ac87f40c2e54 to your computer and use it in GitHub Desktop.
Save willium/f3ffa817ac87f40c2e54 to your computer and use it in GitHub Desktop.
"labels" on bars
{
"width": 400,
"height": 400,
"padding": {"top": 10, "left": 30, "bottom": 20, "right": 10},
"data": [
{
"name": "table",
"values": [
{"category":"A", "amount":28},
{"category":"B", "amount":55},
{"category":"C", "amount":43},
{"category":"D", "amount":91},
{"category":"E", "amount":81},
{"category":"F", "amount":53},
{"category":"G", "amount":19},
{"category":"H", "amount":87},
{"category":"I", "amount":52}
]
}
],
"scales": [
{
"name": "xscale",
"type": "ordinal",
"range": "width",
"domain": {
"data": "table",
"field": "category"
}
},
{
"name": "yscale",
"range": "height",
"nice": true,
"domain": {
"data": "table",
"field": "amount"
}
}
],
"axes": [
{
"type": "x",
"scale": "xscale"
},
{
"type": "y",
"scale": "yscale"
}
],
"marks": [
{
"type": "rect",
"from": {
"data":"table"
},
"properties": {
"update": {
"fill": {
"value": "steelblue"
},
"x": {
"scale": "xscale",
"field": "category"
},
"width": {
"scale": "xscale",
"band": true,
"offset": -1
},
"y": {
"scale": "yscale",
"field": "amount"
},
"y2": {
"scale": "yscale",
"value": 0
}
}
}
},
{
"type": "text",
"from": {
"data":"table"
},
"properties": {
"update": {
"fill": {
"value": "#333"
},
"align": {
"value": "center"
},
"x": {
"scale": "xscale",
"field": "category"
},
"dx": {
"scale": "xscale",
"band": true,
"mult": 0.5
},
"y": {
"scale": "yscale",
"field": "amount",
"offset": -5
},
"text": {
"field": "amount"
}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment