vega-lite icon indicating copy to clipboard operation
vega-lite copied to clipboard

Opacity behavior changes when encoding switches from aggregates to datum

Open salivian opened this issue 4 years ago • 2 comments

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}
      }
    }
  ]
}```

salivian avatar Sep 23 '20 08:09 salivian

The opacity is somewhat respected, but it looks like it is scaled some way. Changing the value to 0.007 produces the following output: image

When playing with sequence generator example, I discovered that the actual opacity there depends on number of points in the sequence.

eugmes avatar Apr 03 '24 20:04 eugmes

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.

eugmes avatar Apr 03 '24 20:04 eugmes