如何更改区域标记的不透明度,或者具体来说,如何定义渐变色标的不透明度?

时间:2020-01-27 21:35:27

标签: vega-lite

this example中,如何更改区域标记的不透明度?我正在尝试将该区域的不透明度更改为1(完全不透明)。

"opacity": 1添加"fillOpacity": 1mark似乎无效。另一方面,在定义Gradient时,只能为color定义stop,而不能为opacity定义。

编辑:dominic的以下答案可用于定义渐变色标的不透明度。然而, 定义区域标记的不透明度似乎存在一个错误:https://github.com/vega/vega-lite/issues/5807

1 个答案:

答案 0 :(得分:1)

您可以将这种格式用于颜色rgba(R, G, B, A),其中A是字母。

"color": {
  "x1": 1,
  "y1": 1,
  "x2": 1,
  "y2": 0,
  "gradient": "linear",
  "stops": [
    {
      "offset": 0,
      "color": "rgba(0, 255, 0, 0)"
    },
    {
      "offset": 1,
      "color": "rgba(0, 255, 0, 1)"
    }
  ]
}

enter image description here

要将不透明度设置为1,您可以使用编码

"opacity": {
  "value": 1
}