20230317 - PBI Community Help - Vega Column to Baer Chart

Created Diff never expires
34 removals
95 lines
30 additions
91 lines
{
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 400,
"width": 400,
"height": 200,
"height": 200,
"padding": 5,
"padding": 5,


"data": [
"data": [
{
{
"name": "table",
"name": "table",
"values": [
"values": [
{"category": "A", "amount": 28},
{"category": "A", "amount": 28},
{"category": "B", "amount": 55},
{"category": "B", "amount": 55},
{"category": "C", "amount": 43},
{"category": "C", "amount": 43},
{"category": "D", "amount": 91},
{"category": "D", "amount": 91},
{"category": "E", "amount": 81},
{"category": "E", "amount": 81},
{"category": "F", "amount": 53},
{"category": "F", "amount": 53},
{"category": "G", "amount": 19},
{"category": "G", "amount": 19},
{"category": "H", "amount": 87}
{"category": "H", "amount": 87}
]
]
}
}
],
],


"signals": [
"signals": [
{
{
"name": "tooltip",
"name": "tooltip",
"value": {},
"value": {},
"on": [
"on": [
{"events": "rect:mouseover", "update": "datum"},
{"events": "rect:mouseover", "update": "datum"},
{"events": "rect:mouseout", "update": "{}"}
{"events": "rect:mouseout", "update": "{}"}
]
]
}
}
],
],


"scales": [
"scales": [
{
{
"name": "yscale",
"name": "yscale",
"domain": {"data": "table", "field": "amount"},
"nice": true,
"range": "height"
},
{
"name": "xscale",
"type": "band",
"type": "band",
"domain": {"data": "table", "field": "category"},
"domain": {"data": "table", "field": "category"},
"range": "width",
"range": "height",
"padding": 0.05,
"padding": 0.05,
"round": true
"round": true
},
{
"name": "xscale",
"domain": {"data": "table", "field": "amount"},
"nice": true,
"range": "width"
}
}
],
],


"axes": [
"axes": [
{ "orient": "bottom", "scale": "xscale" },
{"orient": "bottom", "scale": "xscale"},
{ "orient": "left", "scale": "yscale" }
{"orient": "left", "scale": "yscale"}
],
],


"marks": [
"marks": [
{
{
"type": "rect",
"type": "rect",
"from": {"data":"table"},
"from": {"data": "table"},
"encode": {
"encode": {
"enter": {
"enter": {
"x": {"scale": "xscale", "field": "category"},
"x": {"scale": "xscale", "field": "amount"},
"width": {"scale": "xscale", "band": 1},
"x2": {"scale": "xscale", "value": 0},
"y": {"scale": "yscale", "field": "amount"},
"y": {"scale": "yscale", "field": "category"},
"y2": {"scale": "yscale", "value": 0}
"height": {"scale": "yscale", "band": 1}
},
},
"update": {
"update": {"fill": {"value": "steelblue"}},
"fill": {"value": "steelblue"}
"hover": {"fill": {"value": "red"}}
},
"hover": {
"fill": {"value": "red"}
}
}
}
},
},
{
{
"type": "text",
"type": "text",
"encode": {
"encode": {
"enter": {
"enter": {
"align": {"value": "center"},
"align": {"value": "left"},
"baseline": {"value": "bottom"},
"baseline": {"value": "middle"},
"fill": {"value": "#333"}
"fill": {"value": "#333"}
},
},
"update": {
"update": {
"x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},
"x": {"scale": "xscale", "signal": "tooltip.amount", "offset": 2},
"y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},
"y": {"scale": "yscale", "signal": "tooltip.category", "band": 0.5},
"text": {"signal": "tooltip.amount"},
"text": {"signal": "tooltip.amount"},
"fillOpacity": [
"fillOpacity": [
{"test": "isNaN(tooltip.amount)", "value": 0},
{"test": "isNaN(tooltip.amount)", "value": 0},
{"value": 1}
{"value": 1}
]
]
}
}
}
}
}
}
]
]
}
}