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

Draw funnel chart in Vega/ Vega-lite

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

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