Vega-Lite:来自数据的笔触颜色值?

DrW*_*Man 4 html javascript json vega-lite

在 Vega 中,可以从数据中获取颜色值,例如:Vega 中的示例

有没有办法用 Vega-Lite 做到这一点?Vega-Lite 中的示例

Nim*_*mal 5

是的,您需要在颜色属性中设置scaleto null。

"encoding": {
      "x": ...,
      "y": ...,
      "color": {
        "field": "color",
        "legend": null,
        "type":"nominal",
        "scale": null
      }
    }
Run Code Online (Sandbox Code Playgroud)

要直接对数据值进行编码,可以将 scale 属性设置为 null。

https://vega.github.io/vega-lite/docs/scale.html#disable

希望能帮助到你!!