vega-lite
vega-lite copied to clipboard
Opacity behavior changes when encoding switches from aggregates to datum
If I change the encoding of a rect from aggregate to fixed datum boundaries, the opacity parameter is no longer respected.
am I missing something here ?
Thanks!
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "A scatterplot showing horsepower and miles per gallons for various cars.",
"data": {"url": "data/cars.json"},
"layer": [
{
"mark": "point",
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative"},
"y": {
"field": "Miles_per_Gallon",
"type": "quantitative",
"title": "Miles per Gallon"
}
}
},
{
"mark": "rule",
"encoding": {"y": {"aggregate": "min", "field": "Miles_per_Gallon"}}
},
{
"mark": "rule",
"encoding": {"y": {"aggregate": "max", "field": "Miles_per_Gallon"}}
},
{
"mark": "rect",
"encoding": {
"y": {"datum":20},
"y2": {"datum":10},
"opacity": {"value": 0.2}
}
}
]
}```
The opacity is somewhat respected, but it looks like it is scaled some way. Changing the value to 0.007 produces the following output:
When playing with sequence generator example, I discovered that the actual opacity there depends on number of points in the sequence.
This is a duplicate of https://github.com/vega/vega-lite/issues/6858. The solution (workaround?) is to add "data": {"values": [{}]}
to the mark layer.