Vega

Diagrama de Pareto (barras + % acumulado)

Barras ordenadas de mayor a menor y curva de porcentaje acumulado en el eje derecho, calculada con window + joinaggregate — la herramienta clásica del 80/20.

Requisitos

Vega-Lite v5

Vega-Lite
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      { "cause": "Config erronée", "incidents": 38 },
      { "cause": "Déploiement raté", "incidents": 24 },
      { "cause": "Saturation disque", "incidents": 15 },
      { "cause": "Bug applicatif", "incidents": 9 },
      { "cause": "Réseau", "incidents": 6 },
      { "cause": "Certificat expiré", "incidents": 4 },
      { "cause": "Dépendance externe", "incidents": 3 },
      { "cause": "Autre", "incidents": 1 }
    ]
  },
  "transform": [
    { "window": [{ "op": "sum", "field": "incidents", "as": "cumul" }],
      "sort": [{ "field": "incidents", "order": "descending" }], "frame": [null, 0] },
    { "joinaggregate": [{ "op": "sum", "field": "incidents", "as": "total" }] },
    { "calculate": "datum.cumul / datum.total", "as": "pct_cumul" }
  ],
  "encoding": {
    "x": { "field": "cause", "type": "nominal", "sort": "-y", "title": null, "axis": { "labelAngle": -30 } }
  },
  "layer": [
    { "mark": { "type": "bar", "color": "#00f3ff" },
      "encoding": { "y": { "field": "incidents", "type": "quantitative" } } },
    { "mark": { "type": "line", "color": "#ff00ff", "point": true },
      "encoding": {
        "y": {
          "field": "pct_cumul", "type": "quantitative",
          "axis": { "format": ".0%", "orient": "right", "title": "Cumul" }
        }
      } }
  ],
  "resolve": { "scale": { "y": "independent" } }
}
Vega-LiteParetoCumulQualité

Snippets relacionados

Volver al Data Lab