【问题标题】:Draw funnel chart in Vega/ Vega-lite在 Vega/ Vega-lite 中绘制漏斗图
【发布时间】:2020-02-28 02:04:19
【问题描述】:

我在 kibana 中使用 vega 来可视化数据。现在我想画一个漏斗图,但它没有任何例子。 谢谢你的帮助

【问题讨论】:

    标签: elasticsearch charts kibana vega vega-lite


    【解决方案1】:

    您可以使用带有stack: "center" 的条形图在 Vega-Lite 中创建漏斗图。例如(vega editor):

    {
      "data": {
        "values": [
          {"Pipeline": "Consultation", "Count": 140000},
          {"Pipeline": "Prospect", "Count": 120000},
          {"Pipeline": "Qualified", "Count": 100000},
          {"Pipeline": "Negotiation", "Count": 80000},
          {"Pipeline": "Prototype", "Count": 60000},
          {"Pipeline": "Closing", "Count": 40000},
          {"Pipeline": "Won", "Count": 20000},
          {"Pipeline": "Finalized", "Count": 10000}
        ]
      },
      "encoding": {"y": {"field": "Pipeline", "type": "nominal", "sort": null}},
      "layer": [
        {
          "mark": "bar",
          "encoding": {
            "color": {"field": "Pipeline", "type": "nominal", "legend": null},
            "x": {"field": "Count", "type": "quantitative", "stack": "center"}
          }
        },
        {
          "mark": "text",
          "encoding": {"text": {"field": "Count", "type": "quantitative"}}
        }
      ],
      "width": 500
    }
    

    【讨论】:

    • 我在应用您的代码时使用的是 vega lite v2.6,但我的图表不在这样的中心。
    • Vega-Lite 2.6 是两个主要版本,比当前版本 (4.4) 晚了两年。我建议升级到更新的 Vega-Lite;这将解决您的问题。
    • 谢谢,不过我在kibana用vega lite,更新太难了
    • 您对此有什么想法
    • 不,我认为这在 Vega-Lite 2.6 中是不可能的——我坚持我原来的建议。
    猜你喜欢
    • 1970-01-01
    • 2020-03-19
    • 2018-09-09
    • 2020-04-22
    • 2019-06-02
    • 2021-05-28
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    相关资源
    最近更新 更多