Last active
March 28, 2018 11:49
-
-
Save IIIEII/aaa1bdfd949c018df671c8f44b143098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega/v3.json", | |
"width": 400, | |
"height": 200, | |
"padding": 5, | |
"data": [ | |
{ | |
"name": "source_0", | |
"values": [ | |
{"issue": "IS-01", "open": 1521918031121, "close": 1522004478764}, | |
{"issue": "IS-02", "open": 1522090866461, "close": null}, | |
{"issue": "IS-03", "open": 1522090866461, "close": 1522177314788}, | |
{"issue": "IS-04", "open": 1522090866461, "close": 1522177314788}, | |
{"issue": "IS-05", "open": 1522004478764, "close": null}, | |
{"issue": "IS-06", "open": 1522004478764, "close": 1522090866461}, | |
{"issue": "IS-07", "open": 1522004478764, "close": 1522090866461}, | |
{"issue": "IS-08", "open": 1521918031121, "close": null} | |
], | |
"transform": [ | |
{ | |
"type": "formula", | |
"expr": "sequence(floor(datum.open/86400000)*86400000 - 86400000, datum.close || now(), 86400000)", | |
"as": "dates" | |
}, | |
{ | |
"type": "flatten", | |
"fields": ["dates"] | |
}, | |
{ | |
"type": "aggregate", | |
"groupby": ["dates"], | |
"as": ["count"] | |
} | |
] | |
} | |
], | |
"scales": [ | |
{ | |
"name": "xscale", | |
"type": "band", | |
"domain": {"data": "source_0", "field": "dates"}, | |
"range": "width", | |
"padding": 0.05, | |
"round": true | |
}, | |
{ | |
"name": "yscale", | |
"domain": {"data": "source_0", "field": "count"}, | |
"nice": true, | |
"range": "height" | |
} | |
], | |
"axes": [ | |
{ | |
"orient": "bottom", | |
"scale": "xscale", | |
"encode": { | |
"labels": { | |
"update": { | |
"text": { | |
"signal": "timeFormat(datum.value, '%b %d, %H:00')" | |
}, | |
"angle": {"value": 270}, | |
"align": {"value": "right"}, | |
"baseline": {"value": "middle"}, | |
"fontSize": {"value": 12} | |
} | |
} | |
} | |
}, | |
{ "orient": "left", "scale": "yscale" } | |
], | |
"marks": [ | |
{ | |
"type": "rect", | |
"from": {"data":"source_0"}, | |
"encode": { | |
"enter": { | |
"x": {"scale": "xscale", "field": "dates"}, | |
"width": {"scale": "xscale", "band": 1}, | |
"y": {"scale": "yscale", "field": "count"}, | |
"y2": {"scale": "yscale", "value": 0} | |
}, | |
"update": { | |
"fill": {"value": "steelblue"} | |
}, | |
"hover": { | |
"fill": {"value": "red"} | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment