Нарисуйте воронкообразную диаграмму в Vega / Vega-lite - PullRequest
1 голос
/ 28 февраля 2020

Я использую Vega в кибане для визуализации данных. Теперь я хочу нарисовать воронкообразную диаграмму, но у нее нет примеров этого. enter image description here Спасибо за вашу помощь

1 Ответ

1 голос
/ 28 февраля 2020

Вы можете создать воронкообразную диаграмму в Vega-Lite, используя гистограмму с stack: "center". Например ( 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
}

enter image description here

...