vega-lite
vega-lite copied to clipboard
LabelAngle expr in config can break the code
This code breaks:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A simple bar chart with embedded data.",
"data": {
"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}
]
},
"transform": [
{"calculate": "datum.a + datum.a", "as": "a"},
{"calculate": "datum.a + datum.a", "as": "a"}
],
"width": "container",
"mark": "bar",
"encoding": {
"x": {
"field": "a",
"type": "nominal"
},
"y": {"field": "b", "type": "quantitative"}
},
"config": {
"signals": [{
"name": "labelRotateThreshold",
"value": "30"
}],
"axisX": {
"labelAlign": {"expr": "bandwidth('x') > labelRotateThreshold ? 'center' : 'right'"},
"labelAngle": {"expr": "bandwidth('x') > labelRotateThreshold ? 0 : -90"},
"labelLimit": {"expr": "bandwidth('x') > labelRotateThreshold ? bandwidth('x') : 200"}
}
}
}
Temporary fix is to add
"labelBaseline": {"expr": "bandwidth('x') > labelRotateThreshold ? 'top' : 'middle'"},
But the main culprit is that the defaultLabelBaseline
logic doesn't check for signal from config yet.