我在kibana中使用vega可视化数据。现在,我想绘制一个漏斗图,但是没有任何示例。 elasticsearch - 在Vega/Vega-lite中绘制漏斗图-LMLPHP
谢谢您的帮助

最佳答案

您可以使用带有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
}

elasticsearch - 在Vega/Vega-lite中绘制漏斗图-LMLPHP

10-06 07:20