code wiki / _hdl_build / nx_chart.nx

nx_chart.nx

buildroot/runtime/_hdl_build/nx_chart.nx

9325 B197 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 chart_svg ch_maxv ch_nice_top vsh_lit vsh_n sys_mmap ↻ sys_mmap ↻ va_axis_left sys_mmap ↻ vs_ticks vs_linear vsh_lit ↻ vsh_n ↻ vs_linear ↻

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_M_T: i64 = 40 // top margin (room for the title)
29const CH_PLOT_H: i64 = 300 // plot area height in px (data range maps into this)
30const CH_BW: i64 = 64 // bar width
31const CH_GAP: i64 = 34 // gap between bars
32const CH_M_B: i64 = 44 // bottom margin (room for the x-axis labels)
33const CH_TICKS: i64 = 6 // y-axis tick target
34const CH_LBLCAP: i64 = 64 // per-label byte cap (defensive)

functions

37func ch_maxv(values: *i64, n: i64) -> i64
called by 1: chart_svg
49func ch_nice_top(v: i64) -> i64
called by 2: chart_svgmain
75func chart_svg(labels_ptr: *i64, labels_len: *i64, values: *i64, n: i64,
184func main() -> i64