【问题标题】:vega-lite: is it possible to render only the legend without the reference chart?vega-lite:是否可以只渲染没有参考图表的图例?
【发布时间】:2021-05-14 11:03:35
【问题描述】:

我正在构建一个 HTML 页面的线框,其中有一些 vega-lite 图表。

有没有办法只渲染图表的图例?如果是,怎么做?

【问题讨论】:

    标签: vega-lite


    【解决方案1】:

    我不知道仅显示图例的内置方法,但您可以通过删除所有位置编码、将标记不透明度设置为零以及将视图宽度/高度设置为 0 来破解它。例如,这是一种仅从this Vega-Lite example 生成图例的方法:

    {
      "data": {
        "url": "data/penguins.json"
      },
      "mark": {"type": "point", "opacity": 0},
      "encoding": {
        "color": {"field": "Species", "type": "nominal"},
        "shape": {"field": "Species", "type": "nominal"}
      },
      "config": {"view": {"width": 0, "height": 0}}
    }
    

    【讨论】:

      猜你喜欢
      • 2020-10-10
      • 2018-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 1970-01-01
      相关资源
      最近更新 更多