【问题标题】:How to change mark properties with selections [vega-lite]如何使用选择更改标记属性 [vega-lite]
【发布时间】:2020-07-23 15:32:00
【问题描述】:

如何使用 vega-lite 选择更改标记属性(不是字段编码或值)?

例如,用图层标记{type:bar,fill:none,stroke,black}突出显示选定的条。

【问题讨论】:

    标签: visualization vega-lite altair


    【解决方案1】:

    我想我在interactive bar select highlight example找到了答案

    可能无法通过选择直接更改标记属性,但可以通过选择有条件地设置fillOpacitystrockWidth 编码通道。

    相关的代码是:

     "fillOpacity": {
          "condition": {"selection": "select", "value": 1},
          "value": 0.3
        },
        "strokeWidth": {
          "condition": [
            {
              "test": {
                "and": [
                  {"selection": "select"},
                  "length(data(\"select_store\"))"
                ]
              },
              "value": 2
            },
            {"selection": "highlight", "value": 1}
          ],
          "value": 0
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      • 2013-12-22
      相关资源
      最近更新 更多