【问题标题】:Vega-Lite : stroke color value from data?Vega-Lite:数据中的笔触颜色值?
【发布时间】:2019-01-30 17:35:48
【问题描述】:

在 Vega 中,可以从数据中获取颜色值,如下所示:example in Vega

有没有办法用 Vega-Lite 做到这一点? example in Vega-Lite

【问题讨论】:

    标签: javascript html json vega-lite


    【解决方案1】:

    是的,您需要在颜色属性中将scale 设置为null

    "encoding": {
          "x": ...,
          "y": ...,
          "color": {
            "field": "color",
            "legend": null,
            "type":"nominal",
            "scale": null
          }
        }
    

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

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

    希望对你有帮助!!

    【讨论】:

    • @DrWoodMan 很棒!
    猜你喜欢
    • 2020-03-14
    • 2019-01-28
    • 2020-04-16
    • 2016-05-18
    • 2021-08-22
    • 2021-03-02
    • 2020-03-19
    • 1970-01-01
    • 2019-06-13
    相关资源
    最近更新 更多