Files
egutierrez 0487180ac2 feat(viz): treemap squarified (Bruls et al.) — layout puro + render DrawList
treemap_layout devuelve TreemapRect{min, max, item} con coords absolutas
dentro de la region. La suma de areas == area total (verificado via test
standalone, ratio=1.000000). El render usa AddRectFilled + AddText cuando
labels y valores caben dentro de la cell.

Limitaciones MVP: jerarquia plana (no recursivo), sin interaccion.
2026-04-25 21:52:33 +02:00

33 lines
976 B
C++

#pragma once
// Squarified treemap (Bruls, Huijbrechts, van Wijk 2000).
//
// Layout puro (treemap_layout) separado del render (treemap) — la layout
// no toca ImGui y es testeable.
#include "imgui.h"
#include <string>
#include <vector>
struct TreemapItem {
std::string label;
float value;
ImU32 color;
};
struct TreemapRect {
ImVec2 min;
ImVec2 max;
const TreemapItem* item;
};
// Layout puro. Devuelve un rect por item con coords absolutas dentro de [0,0]-region.
// Items con value <= 0 se ignoran.
std::vector<TreemapRect> treemap_layout(const std::vector<TreemapItem>& items,
ImVec2 region);
// Render. Si size.x <= 0 usa el ancho disponible. Reserva size en el layout ImGui.
void treemap(const char* id,
const std::vector<TreemapItem>& items,
ImVec2 size = ImVec2(-1.0f, 300.0f));