123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- {
- "$schema": "https://vega.github.io/schema/vega/v3.0.json",
- "description": "A simple bar chart with embedded data.",
- "autosize": "pad",
- "padding": 5,
- "height": 200,
- "style": "cell",
- "data": [
- {
- "name": "source_0",
- "values": [
- {
- "a": "A",
- "b": 28
- },
- {
- "a": "B",
- "b": 55
- },
- {
- "a": "C",
- "b": 43
- },
- {
- "a": "D",
- "b": 91
- },
- {
- "a": "E",
- "b": 81
- },
- {
- "a": "F",
- "b": 53
- },
- {
- "a": "G",
- "b": 19
- },
- {
- "a": "H",
- "b": 87
- },
- {
- "a": "I",
- "b": 52
- }
- ]
- },
- {
- "name": "data_0",
- "source": "source_0",
- "transform": [
- {
- "type": "formula",
- "expr": "toNumber(datum[\"b\"])",
- "as": "b"
- },
- {
- "type": "filter",
- "expr": "datum[\"b\"] !== null && !isNaN(datum[\"b\"])"
- }
- ]
- }
- ],
- "signals": [
- {
- "name": "x_step",
- "value": 21
- },
- {
- "name": "width",
- "update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
- }
- ],
- "marks": [
- {
- "name": "marks",
- "type": "rect",
- "style": ["bar"],
- "from": {
- "data": "data_0"
- },
- "encode": {
- "update": {
- "x": {
- "scale": "x",
- "field": "a"
- },
- "width": {
- "scale": "x",
- "band": true
- },
- "y": {
- "scale": "y",
- "field": "b"
- },
- "y2": {
- "scale": "y",
- "value": 0
- },
- "fill": {
- "value": "#4c78a8"
- }
- }
- }
- }
- ],
- "scales": [
- {
- "name": "x",
- "type": "band",
- "domain": {
- "data": "data_0",
- "field": "a",
- "sort": true
- },
- "range": {
- "step": {
- "signal": "x_step"
- }
- },
- "paddingInner": 0.1,
- "paddingOuter": 0.05
- },
- {
- "name": "y",
- "type": "linear",
- "domain": {
- "data": "data_0",
- "field": "b"
- },
- "range": [
- {
- "signal": "height"
- },
- 0
- ],
- "nice": true,
- "zero": true
- }
- ],
- "axes": [
- {
- "scale": "x",
- "orient": "bottom",
- "labelOverlap": true,
- "title": "a",
- "zindex": 1,
- "encode": {
- "labels": {
- "update": {
- "angle": {
- "value": 270
- },
- "align": {
- "value": "right"
- },
- "baseline": {
- "value": "middle"
- }
- }
- }
- }
- },
- {
- "scale": "y",
- "orient": "left",
- "labelOverlap": true,
- "tickCount": {
- "signal": "ceil(height/40)"
- },
- "title": "b",
- "zindex": 1
- },
- {
- "scale": "y",
- "orient": "left",
- "domain": false,
- "grid": true,
- "labels": false,
- "maxExtent": 0,
- "minExtent": 0,
- "tickCount": {
- "signal": "ceil(height/40)"
- },
- "ticks": false,
- "zindex": 0,
- "gridScale": "x"
- }
- ],
- "config": {
- "axisY": {
- "minExtent": 30
- }
- }
- }
|