Vega

Waterfall: descomposición del P&L mensual

Cada barra flota entre un inicio y un fin precalculados (y/y2), coloreada como subida, bajada o total — el clásico puente contable entre dos saldos.

Requisitos

Vega-Lite v5

Vega-Lite
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      { "etape": "Capital initial", "debut": 0, "fin": 25000, "type": "total" },
      { "etape": "Janvier", "debut": 25000, "fin": 26200, "type": "hausse" },
      { "etape": "Février", "debut": 26200, "fin": 25400, "type": "baisse" },
      { "etape": "Mars", "debut": 25400, "fin": 27100, "type": "hausse" },
      { "etape": "Avril", "debut": 27100, "fin": 26500, "type": "baisse" },
      { "etape": "Mai", "debut": 26500, "fin": 28300, "type": "hausse" },
      { "etape": "Juin", "debut": 28300, "fin": 29150, "type": "hausse" },
      { "etape": "Solde final", "debut": 0, "fin": 29150, "type": "total" }
    ]
  },
  "mark": { "type": "bar", "tooltip": true },
  "encoding": {
    "x": { "field": "etape", "type": "nominal", "sort": null, "title": null, "axis": { "labelAngle": -30 } },
    "y": { "field": "debut", "type": "quantitative", "title": "Solde ($)" },
    "y2": { "field": "fin" },
    "color": {
      "field": "type", "type": "nominal",
      "scale": { "domain": ["hausse", "baisse", "total"], "range": ["#27c93f", "#ff5f56", "#4a90d9"] },
      "legend": null
    }
  }
}
Vega-LiteWaterfally2Finance

Snippets relacionados

Volver al Data Lab