1{2 "$schema": "https://vega.github.io/schema/vega/v5.json",3 "width": 400,4 "height": 200,5 "padding": 5,67 "data": [8 {9 "name": "table",10 "values": [11 {"category": "A", "amount": 28},12 {"category": "B", "amount": 55},13 {"category": "C", "amount": 43},14 {"category": "D", "amount": 91},15 {"category": "E", "amount": 81},16 {"category": "F", "amount": 53},17 {"category": "G", "amount": 19},18 {"category": "H", "amount": 87}19 ]20 }21 ],2223 "signals": [24 {25 "name": "tooltip",26 "value": {},27 "on": [28 {"events": "rect:mouseover", "update": "datum"},29 {"events": "rect:mouseout", "update": "{}"}30 ]31 }32 ],3334 "scales": [35 {36 "name": "xscale",37 "type": "band",38 "domain": {"data": "table", "field": "category"},39 "range": "width",40 "padding": 0.05,41 "round": true42 },43 {44 "name": "yscale",45 "domain": {"data": "table", "field": "amount"},46 "nice": true,47 "range": "height"48 }49 ],5051 "axes": [52 { "orient": "bottom", "scale": "xscale" },53 { "orient": "left", "scale": "yscale" }54 ],5556 "marks": [57 {58 "type": "rect",59 "from": {"data":"table"},60 "encode": {61 "enter": {62 "x": {"scale": "xscale", "field": "category"},63 "width": {"scale": "xscale", "band": 1},64 "y": {"scale": "yscale", "field": "amount"},65 "y2": {"scale": "yscale", "value": 0}66 },67 "update": {68 "fill": {"value": "steelblue"}69 },70 "hover": {71 "fill": {"value": "red"}72 }73 }74 },75 {76 "type": "text",77 "encode": {78 "enter": {79 "align": {"value": "center"},80 "baseline": {"value": "bottom"},81 "fill": {"value": "#333"}82 },83 "update": {84 "x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},85 "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},86 "text": {"signal": "tooltip.amount"},87 "fillOpacity": [88 {"test": "datum === tooltip", "value": 0},89 {"value": 1}90 ]91 }92 }93 }94 ]95}