Files
fn_registry/cpp/functions/viz/treemap.md
T
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

2.3 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, framework, params, output, notes
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path framework params output notes
treemap component cpp viz 1.0.0 pure void treemap(const char* id, const std::vector<TreemapItem>& items, ImVec2 size) Squarified treemap (Bruls, Huijbrechts, van Wijk) para jerarquias planas con valores. Layout puro separado del render.
imgui
drawlist
chart
visualization
treemap
hierarchy
squarified
pendiente-usar
false
imgui
false
cpp/functions/viz/treemap.cpp imgui
name desc
id Identificador unico para PushID (evita colisiones entre treemaps)
name desc
items Vector de TreemapItem {label, value, color}. Items con value <= 0 se ignoran
name desc
size Tamano del rect del treemap. x <= 0 usa el ancho disponible
Renderiza el treemap en el frame ImGui actual usando AddRectFilled + AddText sobre el WindowDrawList scaffolding/demo en primitives_gallery

treemap

Treemap squarified: dado un vector de items con valor numerico, divide el rect dado en cells cuya area es proporcional al valor del item. El algoritmo de Bruls et al. minimiza el aspect ratio (cells lo mas cuadradas posibles).

API

struct TreemapItem { std::string label; float value; ImU32 color; };
struct TreemapRect { ImVec2 min, max; const TreemapItem* item; };

std::vector<TreemapRect> treemap_layout(const std::vector<TreemapItem>&, ImVec2 region); // pure
void treemap(const char* id, const std::vector<TreemapItem>&, ImVec2 size = {-1, 300});

treemap_layout es pura — devuelve rects en coords [0..region]. treemap invoca el layout y renderiza con AddRectFilled + label + valor cuando caben.

Conservacion del area

La suma de areas de los rects es igual al area de la region (modulo errores de redondeo). Util para tests.

Limitaciones MVP

  • Solo jerarquia plana (no recursivo). Para jerarquias anidadas, llamar treemap_layout recursivamente sobre cada cell.
  • Sin interaccion (click, zoom).

Ejemplo

std::vector<TreemapItem> items = {
    {"vivienda",   950, IM_COL32(180,120,200,255)},
    {"comida",     320, IM_COL32(120,180,200,255)},
    {"transporte", 180, IM_COL32(200,180,120,255)},
};
treemap("##gastos", items, ImVec2(-1, 300));