我如何在vegalite中分割滚动条中x轴的值

问题描述 投票:0回答:1

我想在 Vega lite 中创建图表,但在 x 轴标签重叠时遇到问题。我希望 x 轴标签不重叠,如果超出矩形框大小,它必须中断,并且仅显示在其下方并将该值也映射到滚动条中,即(concat1)。 编辑链接

我想要这样的x轴标签----

                 AEROPLANE
                 FLY
                 DAILY

我尝试使用列表数据类型,但在滚动器中使用字符串值列表时遇到问题..

visualization vega-lite vega vega-embed vega-lite-api
1个回答
0
投票

{
  "data": {
    "values": [
      {"Key_data": "a", "description": "AEROPLANE"},
      {"Key_data": "b", "description": "AEROPLANE FLY DAILY"},
      {"Key_data": "c", "description": "FLY DAILY"},
      {"Key_data": "d", "description": "HELICOPTER"},
      {"Key_data": "d", "description": "HIGH BLOOD PRESSURE"}
    ]
  },
  "columns": 1,
  "concat": [
    {
      "width": 700,
      "height": 350,
      "transform": [{"filter": {"param": "brush"}}],
      "layer": [
        {
          "mark": {"type": "rect"},
          "encoding": {
            "y": {"field": "Key_data", "type": "nominal"},
            "x": {
              "field": "description",
              "type": "nominal",
              "axis": {
                "orient": "top",
                "labelAngle": 0,
                "labelExpr": "split(datum.label,' ')",
                "labelPadding": 25
              }
            }
          }
        }
      ]
    },
    {
      "width": 700,
      "height": 30,
      "mark": "area",
      "encoding": {
        "x": {"field": "description", "type": "nominal", "axis": null},
        "y": {"field": "Key_data", "type": "nominal", "axis": null}
      },
      "params": [
        {
          "name": "brush",
          "value": [
            "AEROPLANE",
            "AEROPLANE FLY DAILY",
            "FLY DAILY",
            "HELICOPTER",
            "HIGH BLOOD PRESSURE"
          ],
          "select": {"type": "interval", "encodings": ["x"]}
        }
      ]
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.