Vega lite - Cannot use datum expr in scale padding
nhannt201 opened this issue · comments
Nguyễn Trung Nhẫn commented
I'm having trouble utilizing "datum" within "expr" in vega-lite scale padding. I'm attempting to calculate the padding adjustment value but keep encountering the error "datum is not defined." I'm currently using vega-lite v5, and encountering this issue when applying the JSON code.
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"x": 1, "y": 10},
{"x": 2, "y": 5},
{"x": 3, "y": -3},
{"x": 4, "y": 8}
]
},
"mark": "point",
"encoding": {
"x": {
"field": "x",
"type": "quantitative",
"scale": {"padding": {"expr": "datum.y < 3 ? 20 : 0"}}
},
"y": {"field": "y", "type": "quantitative"}
}
}
The document below describes how I can use expr, but in fact, it does not fully support the expr syntax in the above case, specifically does not support "datum".
Is there any solution to solve the above problem?