code wiki / _hdl_build / nx_chart.nx

nx_chart.nx

buildroot/runtime/_hdl_build/nx_chart.nx

9771 B202 linesdepth 5pulls 6 transitivereach 2 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_chart.nx -- IMS Thrust D R2: a SOVEREIGN, REUSABLE native-SVG bar-chart renderer. THE GAP IT FILLS: nx_viz_chart.nx is a whole-PAGE main() that reads a fixed TSV and writes an HTML file -- not a reusable function. nx_wiki_graph emits SVG but only a circular link-graph. So the gap is a clean LIBRARY function chart_svg(labels[], values[], n, title) -> <svg>...</svg> that any organ can call to drop a bar chart inline into a page. Pure + deterministic (no I/O, no wall-clock). REUSE (zero geometry reinvented): imports nx_viz_axis -> which transitively gives the proven viz primitives the d3-equivalent suite already KAT-grades: vs_linear (nx_viz_scale) -- map a data value -> a pixel height (the bar scaling). va_axis_left(nx_viz_axis) -- the y-axis: baseline + tick marks + numeric labels. vsh_lit / vsh_n (nx_viz_shape) -- append a literal / an integer into the SVG buffer. We add ONLY the bar-chart composition (the bars, the x-labels, the title) -- the part that did not exist as a reusable call. SVG is static (no <script>) -> sovereign, renders identically everywhere. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_viz_axis.nx nx_syscalls.nx nx_chart.nx nx_figure_gate.nx nx_figures_page.nx

imports: nx_viz_axis.nxnx_syscalls.nx

imported by: nx_figure_gate.nxnx_figures_page.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ chart_svg ch_maxv ch_nice_top sys_mmap ↻

structs

none

consts

19const CH_MAGIC_8192: i64 = 8192
22const CH_OK: i64 = 0
23const CH_BAD_INPUT: i64 = 2900
24const CH_OVERFLOW: i64 = 2901
27const CH_M_L: i64 = 56 // left margin (room for the y-axis labels)
28const CH_TITLE_MAX: i64 = 200 // title chars copied into the <text> element (the cap the title loop used to write into its own cursor)
29const CH_M_T: i64 = 40 // top margin (room for the title)
30const CH_PLOT_H: i64 = 300 // plot area height in px (data range maps into this)
31const CH_BW: i64 = 64 // bar width
32const CH_GAP: i64 = 34 // gap between bars
33const CH_M_B: i64 = 44 // bottom margin (room for the x-axis labels)
34const CH_TICKS: i64 = 6 // y-axis tick target
35const CH_LBLCAP: i64 = 64 // per-label byte cap (defensive)

functions

38func ch_maxv(values: *i64, n: i64) -> i64
called by 1: chart_svg
50func ch_nice_top(v: i64) -> i64
called by 2: chart_svgmain
76func chart_svg(labels_ptr: *i64, labels_len: *i64, values: *i64, n: i64,
189func main() -> i64