Adds TableInput.column_specs sidecar field enabling apps to declare Badge,
Progress, Duration and Icon renderers per column without writing ImGui inline.
Back-compat: apps without column_specs compile and behave identically.
- data_table_types.h: CellRenderer enum, BadgeRule, IconMapEntry, ColumnSpec types
- data_table.cpp: hex_to_imcolor helper, icon_name_to_glyph static map (~30 Tabler icons),
draw_cell_custom dispatcher, integration in Stage-0 and Stage-N cell loops and draw_extra_panel
- Bump version 1.0.0 -> 1.1.0 with capability growth log
- cpp/tests/test_column_specs.cpp: 5 smoke/linker tests (back-compat + 4 renderer types)
- cpp/tests/CMakeLists.txt: register test_column_specs target linked against fn_table_viz
- types/core/{cell_renderer,badge_rule,icon_map_entry,column_spec}.md: registry type mds
- docs/capabilities/data_table_renderers.md: canonical doc with end-to-end examples
- docs/capabilities/INDEX.md: added data-table-renderers group
All tests green: test_column_specs 5/5, test_fn_table_viz_smoke 8/8,
tql_emit 41/41, tql_apply 88/88, Wave-1 tests 8/8.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6.7 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, params, output
| 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 | params | output | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| data_table | function | cpp | viz | 1.1.0 | impure | void data_table::render(const char* id, const std::vector<TableInput>& tables, State& st, bool show_chrome = true) | Render UI completa de tabla TQL: chips bar, tabla, viz panels, column-stats inline, drill, color rules, joins, TQL editor, Ask AI. Entry-point publica del stack data_table. Muta State segun interaccion del usuario. |
|
|
|
false | error_go_core |
|
true |
|
cpp/tests/test_column_specs.cpp | cpp/functions/viz/data_table.cpp |
|
void. Muta st en respuesta a la interaccion del usuario (filtros, breakouts, sorts, drill, joins, viz mode). Los cambios son visibles en st al retornar. |
Ejemplo
#include "viz/data_table.h"
#include "core/data_table_types.h"
// --- Setup (una vez) ---
data_table::TableInput t;
t.name = "orders";
t.rows = num_rows;
t.cols = num_cols;
t.cells = cells_ptr; // row-major flat array, owner externo
t.headers = {"id", "amount", "status"};
t.types = {data_table::ColumnType::Int,
data_table::ColumnType::Float,
data_table::ColumnType::String};
data_table::State st; // persiste entre frames
// --- Render (cada frame) ---
ImGui::Begin("Orders");
ImGui::BeginChild("##tbl", ImVec2(-1, -1));
data_table::render("##orders", {t}, st);
ImGui::EndChild();
ImGui::End();
Cuando usarla
Cuando una app necesita tabla con filtros + agregaciones + viz + joins sobre datos en memoria. Reemplaza ImGui::BeginTable inline + toda la logica TQL manual. Sustituye directamente el include del playground (tables/data_table.h) cambiando solo el path a viz/data_table.h.
Gotchas
- ImGui + ImPlot context activos:
render()llama a APIs de ambas librerias. Llamar fuera de un frame activo causa UB. - State no stack-local:
Statecontiene el historial de drill, pipeline de stages, cache de stats y buffers de UI. Declarar en el stack del frame reset todo el estado del usuario en cada frame. - Drill-down propaga en State:
st.active_stageyst.stagesse mutan por click en charts. El caller puede leersttrasrender()para reaccionar. - Thread-safety:
render()usastatic thread_localpara buffers intermedios. Llamar solo desde el main thread de ImGui. - TableInput owner externo:
cellses un puntero raw al array del caller. Los datos deben sobrevivir durante toda la llamada arender(). No pasar puntero a vector que puede reallocarse. - Ask AI modal (llm_anthropic): el boton "Ask AI" usa un stub interno de
llm_anthropicque retorna error por defecto. Para activar la feature real, compilar con-DFN_LLM_ANTHROPIC=1y proveerinfra/llm_anthropic.hen el include path. Pendiente Wave 4: promover al registry. - FN_TQL_DUCKDB: modo SQL del Ask AI requiere compilar con
-DFN_TQL_DUCKDB=1y la libreria DuckDB disponible.
Notas
No hay tests unitarios directos: render() requiere ImGui + ImPlot context activos (imposible sin ventana GL). Cobertura via:
cpp/apps/primitives_gallery/playground/tables/— playground original con self_test.cpp y e2e_run.sh.- Wave 4: migration self-tests en las apps que migren desde el playground.
Estado Wave 3.5 (issue 0081-I):
- Todos los includes del playground (
data_table_logic.h,tql.h,tql_to_sql.h) eliminados.data_table.cppcompila sin el playground en el include path. tql::applyfirma extendida ya entql_apply_cpp_core(wave anterior). Resuelto.tql_to_sqlpromovido acore/tql_to_sql.h. Resuelto.data_table_logichelpers (row_to_tsv, drill, view_mode, etc.) declarados comostaticendata_table.cpp. No son API pública.State::ensure_stage0/raw/activeimplementados encompute_stage.cpp.ColStatsstruct: usa el decompute_column_stats_cpp_core. Unificado.
Deuda tecnica restante (Wave 4):
llm_anthropic(Ask AI modal, issue 0080): stub interno activo. Promover acpp/functions/infra/llm_anthropicpara activar feature real.FN_TQL_DUCKDB: modo SQL del Ask AI sin soporte en stub. Requiere DuckDB + flag de compilacion.column_specsTQL roundtrip (Phase 2): actualmente caller-managed. No persisten en TQL emit/apply. Planificado en issue 0081-O.
Capability growth log
v1.1.0 (2026-05-15) — declarative CellRenderer (Badge/Progress/Duration/Icon) via TableInput.column_specs sidecar. Back-compat preservado: apps existentes sin column_specs siguen funcionando sin cambios.
Promovido desde cpp/apps/primitives_gallery/playground/tables/data_table.{h,cpp} — issue 0081-H.