Vega

Waffle 5 × 8: distribución de los resultados de los trades

Cuarenta cuadrados, uno por trade: los transforms calculate (módulo y división entera) construyen la cuadrícula, y el color semántico cuenta ganadores, perdedores y break-even.

Requisitos

Vega-Lite v5

Vega-Lite
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "values": [
      { "i": 0, "s": "Gagnant" }, { "i": 1, "s": "Gagnant" }, { "i": 2, "s": "Gagnant" }, { "i": 3, "s": "Gagnant" },
      { "i": 4, "s": "Gagnant" }, { "i": 5, "s": "Gagnant" }, { "i": 6, "s": "Gagnant" }, { "i": 7, "s": "Gagnant" },
      { "i": 8, "s": "Gagnant" }, { "i": 9, "s": "Gagnant" }, { "i": 10, "s": "Gagnant" }, { "i": 11, "s": "Gagnant" },
      { "i": 12, "s": "Gagnant" }, { "i": 13, "s": "Gagnant" }, { "i": 14, "s": "Gagnant" }, { "i": 15, "s": "Gagnant" },
      { "i": 16, "s": "Gagnant" }, { "i": 17, "s": "Gagnant" }, { "i": 18, "s": "Gagnant" }, { "i": 19, "s": "Gagnant" },
      { "i": 20, "s": "Gagnant" }, { "i": 21, "s": "Gagnant" }, { "i": 22, "s": "Gagnant" }, { "i": 23, "s": "Gagnant" },
      { "i": 24, "s": "Gagnant" }, { "i": 25, "s": "Perdant" }, { "i": 26, "s": "Perdant" }, { "i": 27, "s": "Perdant" },
      { "i": 28, "s": "Perdant" }, { "i": 29, "s": "Perdant" }, { "i": 30, "s": "Perdant" }, { "i": 31, "s": "Perdant" },
      { "i": 32, "s": "Perdant" }, { "i": 33, "s": "Perdant" }, { "i": 34, "s": "Perdant" }, { "i": 35, "s": "Perdant" },
      { "i": 36, "s": "Perdant" }, { "i": 37, "s": "Break-even" }, { "i": 38, "s": "Break-even" }, { "i": 39, "s": "Break-even" }
    ]
  },
  "transform": [
    { "calculate": "datum.i % 8", "as": "col" },
    { "calculate": "floor(datum.i / 8)", "as": "lig" }
  ],
  "height": 240,
  "mark": { "type": "rect", "stroke": "#0b0e14", "strokeWidth": 3, "tooltip": true },
  "encoding": {
    "x": { "field": "col", "type": "ordinal", "axis": null },
    "y": { "field": "lig", "type": "ordinal", "axis": null },
    "color": {
      "field": "s", "type": "nominal", "title": null,
      "scale": { "domain": ["Gagnant", "Perdant", "Break-even"], "range": ["#27c93f", "#ff5f56", "#ffbd2e"] },
      "legend": { "orient": "top" }
    },
    "tooltip": [
      { "field": "i", "title": "Trade #" },
      { "field": "s", "title": "Résultat" }
    ]
  }
}
TradingWafflecalculateGrille

Snippets relacionados

Volver al Data Lab