Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created February 9, 2015 20:40
Show Gist options
  • Save tmcw/052151d6977d858df7c0 to your computer and use it in GitHub Desktop.
Save tmcw/052151d6977d858df7c0 to your computer and use it in GitHub Desktop.
{
"width": 1190,
"height": 200,
"padding": {
"top": 10,
"left": 40,
"bottom": 15,
"right": 10
},
"data": [
{
"name": "table",
"format": {
"type": "json",
"parse": {
"x": "date"
}
},
"values": [
{
"x": "2014-12-23T05:00:00.000Z",
"y": 1,
"c": "count"
},
{
"x": "2014-12-23T05:00:00.000Z",
"y": 1,
"c": "count"
}
]
},
{
"name": "stats",
"source": "table",
"transform": [
{
"type": "facet",
"keys": [
"data.x"
]
},
{
"type": "stats",
"value": "data.y"
}
]
}
],
"scales": [
{
"name": "x",
"type": "time",
"clamp": true,
"range": "width",
"domain": {
"data": "table",
"field": "data.x"
}
},
{
"name": "y",
"type": "linear",
"range": "height",
"nice": true,
"domain": {
"data": "stats",
"field": "sum"
}
},
{
"name": "color",
"type": "ordinal",
"domain": {
"data": "table",
"field": "data.c"
},
"range": [
"#56b881",
"#3887be",
"#8a8acb",
"#ee8a65"
]
}
],
"axes": [
{
"type": "x",
"scale": "x",
"format": "%x",
"ticks": 11,
"tickSize": 0,
"properties": {
"labels": {
"fill": {
"value": "#b3b3b1"
}
},
"axis": {
"stroke": {
"value": "#b3b3b1"
}
}
}
},
{
"type": "y",
"tickSize": 0,
"format": ",s",
"scale": "y",
"properties": {
"labels": {
"fill": {
"value": "#b3b3b1"
}
},
"axis": {
"stroke": {
"value": "#b3b3b1"
}
}
}
}
],
"marks": [
{
"type": "group",
"from": {
"data": "table",
"transform": [
{
"type": "facet",
"keys": [
"data.c"
]
},
{
"type": "stack",
"point": "data.x",
"height": "data.y"
}
]
},
"marks": [
{
"type": "rect",
"properties": {
"enter": {
"x": {
"scale": "x",
"field": "data.x"
},
"width": {
"value": null
},
"y": {
"scale": "y",
"field": "y"
},
"y2": {
"scale": "y",
"field": "y2"
},
"fill": {
"scale": "color",
"field": "data.c"
}
},
"update": {
"fillOpacity": {
"value": 1
}
},
"hover": {
"fillOpacity": {
"value": 0.5
}
}
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment