vega / vega-lite

A concise grammar of interactive graphics, built on Vega.
https://vega.github.io/vega-lite/
BSD 3-Clause "New" or "Revised" License
4.66k stars 607 forks source link

Opacity behavior changes when encoding switches from aggregates to datum #6893

Open salivian opened 4 years ago

salivian commented 4 years ago

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}
      }
    }
  ]
}```
eugmes commented 6 months ago

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 commented 6 months ago

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.