ccharts 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,483 @@
1
+ /* Generated by scripts/sync_sources.py from abi/ccharts_abi.h — do not edit.
2
+ * Change the original and re-run the script. */
3
+ /*
4
+ * ccharts_abi.h — flat C ABI for the ccharts single-header library.
5
+ *
6
+ * ccharts turns financial OHLC data into a string; this layer is what lets a
7
+ * language other than C ask it to.
8
+ *
9
+ * WHY THIS EXISTS
10
+ * ---------------
11
+ * ccharts.h exports nothing: CC_INLINE makes every function `static inline`,
12
+ * so the implementation is compiled into whichever translation unit defines
13
+ * CCHARTS_IMPLEMENTATION. `struct cc_ohlc` is likewise private to that block.
14
+ * Neither is reachable from a foreign function interface. This layer defines
15
+ * CCHARTS_IMPLEMENTATION once, and re-exports a stable, cdecl, opaque-handle
16
+ * API that Go (cgo), Rust, C#, Java and WebAssembly can all bind to without
17
+ * repeating the same marshalling and ownership logic five times.
18
+ *
19
+ * CONTRACT
20
+ * --------
21
+ * - Every entry point returns a ccharts_status; CCHARTS_OK is 0.
22
+ * - Data handles are opaque, immutable once built, and thread-safe to share
23
+ * (ccharts.h holds no mutable global state). Release with
24
+ * ccharts_data_free.
25
+ * - Rendered strings are heap-allocated by the library and released with
26
+ * ccharts_string_free. The expected binding pattern is: render, copy into
27
+ * a native string, free immediately.
28
+ * - Invalid dimensions are an error here, not the empty string ccharts.h
29
+ * returns, so the "empty means invalid" convention never reaches a
30
+ * binding's users.
31
+ * - NaN and inf are rejected at the boundary: cc_pixel() feeds values to
32
+ * lround(), which is undefined for non-finite input.
33
+ *
34
+ * All structs are fixed-layout, no bitfields, and nothing is passed by value,
35
+ * which keeps the ABI describable in every foreign-function tool.
36
+ */
37
+
38
+ #ifndef CCHARTS_ABI_H
39
+ #define CCHARTS_ABI_H
40
+
41
+ #include <stddef.h>
42
+ #include <stdint.h>
43
+
44
+ #define CCHARTS_VERSION "3.0.0"
45
+
46
+ #if defined(_WIN32)
47
+ # if defined(CCHARTS_ABI_BUILD_SHARED)
48
+ # define CCHARTS_API __declspec(dllexport)
49
+ # elif defined(CCHARTS_ABI_USE_SHARED)
50
+ # define CCHARTS_API __declspec(dllimport)
51
+ # else
52
+ # define CCHARTS_API
53
+ # endif
54
+ #elif defined(__GNUC__)
55
+ # define CCHARTS_API __attribute__((visibility("default")))
56
+ #else
57
+ # define CCHARTS_API
58
+ #endif
59
+
60
+ #ifdef __cplusplus
61
+ extern "C" {
62
+ #endif
63
+
64
+ /* An opaque, immutable OHLC dataset. */
65
+ typedef struct ccharts_data ccharts_data;
66
+
67
+ /* Status codes. Functions return int32_t rather than this enum: an enum's
68
+ * underlying type is implementation-defined, and every foreign function
69
+ * interface would have to guess it. */
70
+ typedef enum ccharts_status {
71
+ CCHARTS_OK = 0,
72
+ CCHARTS_ERR_INVALID_ARG = 1, /* NULL pointer, n <= 0, ... */
73
+ CCHARTS_ERR_PARSE = 2, /* malformed or empty JSON/CSV */
74
+ CCHARTS_ERR_NOMEM = 3,
75
+ CCHARTS_ERR_NON_FINITE = 4, /* NaN or inf among the prices */
76
+ CCHARTS_ERR_DIMENSIONS = 5 /* width/height <= 0 or over the limits */
77
+ } ccharts_status;
78
+
79
+ /* Indices for ccharts_color(). Bindings name these in their own enums instead
80
+ * of copying the ANSI escape sequences. */
81
+ typedef enum ccharts_color_index {
82
+ CCHARTS_COLOR_BLACK = 0, CCHARTS_COLOR_RED, CCHARTS_COLOR_GREEN,
83
+ CCHARTS_COLOR_YELLOW, CCHARTS_COLOR_BLUE, CCHARTS_COLOR_MAGENTA,
84
+ CCHARTS_COLOR_CYAN, CCHARTS_COLOR_WHITE,
85
+ CCHARTS_COLOR_BRIGHT_BLACK, CCHARTS_COLOR_BRIGHT_RED,
86
+ CCHARTS_COLOR_BRIGHT_GREEN, CCHARTS_COLOR_BRIGHT_YELLOW,
87
+ CCHARTS_COLOR_BRIGHT_BLUE, CCHARTS_COLOR_BRIGHT_MAGENTA,
88
+ CCHARTS_COLOR_BRIGHT_CYAN, CCHARTS_COLOR_BRIGHT_WHITE,
89
+ CCHARTS_COLOR_RESET,
90
+ CCHARTS_COLOR_COUNT
91
+ } ccharts_color_index;
92
+
93
+ /* Rendering options. Every color is a NUL-terminated ANSI escape string or
94
+ * NULL for the library default, exactly like cc_settings_t; pass NULL for the
95
+ * whole struct to take every default. Arbitrary escapes (256-color,
96
+ * truecolor) are accepted — the strings are not interpreted here. */
97
+ typedef struct ccharts_settings {
98
+ const char* rise_color;
99
+ const char* fall_color;
100
+ const char* bg_color;
101
+ const char* area_color;
102
+ int32_t single_color;
103
+ int32_t show_prices;
104
+ int32_t show_times;
105
+ } ccharts_settings;
106
+
107
+ /* ---------------------------- Building data ---------------------------- */
108
+
109
+ /* Builds a dataset from four equal-length price columns. `ts` holds epoch
110
+ * seconds and may be NULL (all timestamps unknown). The arrays are copied
111
+ * immediately and never retained, which keeps cgo's pointer-passing rules and
112
+ * every GC's object lifetime out of the picture. */
113
+ CCHARTS_API int32_t ccharts_from_arrays(const double* open,
114
+ const double* high,
115
+ const double* low,
116
+ const double* close,
117
+ const int64_t* ts,
118
+ int32_t n,
119
+ ccharts_data** out);
120
+
121
+ /* Builds a dataset from the fixed-schema JSON accepted by cc_json_to_ohlc. */
122
+ CCHARTS_API int32_t ccharts_parse_json(const char* json,
123
+ ccharts_data** out);
124
+
125
+ /* Builds a dataset from CSV: open,high,low,close[,timestamp] per line.
126
+ * Unlike cc_str_to_ohlc, which fills a caller-sized array and never reports
127
+ * how many rows it actually parsed, this counts the parseable lines first, so
128
+ * the dataset never carries trailing zero-filled candles. */
129
+ CCHARTS_API int32_t ccharts_parse_csv(const char* csv,
130
+ char value_separator,
131
+ char line_separator,
132
+ ccharts_data** out);
133
+
134
+ /* Number of candles, or 0 for NULL. */
135
+ CCHARTS_API int32_t ccharts_data_len(const ccharts_data* data);
136
+
137
+ /* Releases a dataset. NULL is a no-op. */
138
+ CCHARTS_API void ccharts_data_free(ccharts_data* data);
139
+
140
+ /* ------------------------------ Rendering ------------------------------ */
141
+
142
+ /* Renders a line chart. On CCHARTS_OK, *out points to a NUL-terminated UTF-8
143
+ * string owned by the caller (release with ccharts_string_free) and *out_len,
144
+ * when not NULL, receives its length in bytes. On error *out is set to NULL. */
145
+ CCHARTS_API int32_t ccharts_line(const ccharts_data* data,
146
+ int32_t width, int32_t height,
147
+ const ccharts_settings* settings,
148
+ char** out, size_t* out_len);
149
+
150
+ /* Renders a candlestick chart; same contract as ccharts_line. */
151
+ CCHARTS_API int32_t ccharts_candle(const ccharts_data* data,
152
+ int32_t width, int32_t height,
153
+ const ccharts_settings* settings,
154
+ char** out, size_t* out_len);
155
+
156
+ /* Releases a string returned by ccharts_line / ccharts_candle /
157
+ * ccharts_pie_from_slices. */
158
+ CCHARTS_API void ccharts_string_free(char* s);
159
+
160
+ /* -------------------------------- Pie -------------------------------- */
161
+
162
+ /* One pie slice: a label (may be NULL or empty) and a positive amount. The
163
+ * renderer turns the values into percentages, so they are amounts, not
164
+ * fractions. Mirrors cc_pie_slice_t in ccharts.h (the two structs stay
165
+ * separate: the header channels are internally linked, this one is the FFI
166
+ * surface, and layout is documented here rather than shared). */
167
+ typedef struct ccharts_pie_slice {
168
+ const char* label;
169
+ double value;
170
+ } ccharts_pie_slice;
171
+
172
+ /* Renders a pie/donut chart of `count` slices and returns it in *out (a
173
+ * NUL-terminated UTF-8 string the caller releases with ccharts_string_free;
174
+ * *out_len, when not NULL, receives its length in bytes). `donut` hollows
175
+ * the center; `colors` is an array of `color_count` ANSI escape strings used
176
+ * per slice (index mod color_count), or NULL for the fixed default palette;
177
+ * `show_legend` appends one "label value (pct%)" line per slice below the
178
+ * disk when `show_pct` is set, otherwise without the percentage.
179
+ *
180
+ * The remaining arguments are the optional Fas 3 pie settings, all of which
181
+ * default to the original behavior when left at their sentinel/zero values:
182
+ * - slice_gap : angular gap between slices, radians; 0 = adjacent
183
+ * - inner_radius_ratio : donut thickness in [0,1]; 0 = disk; NEGATIVE
184
+ * (e.g. -1) = unspecified, so `donut` decides (0.5
185
+ * for a donut, 0 for a disk); >1 clamped to 1
186
+ * - legend_format : ccharts_pie_legend_format enum; 0 = original
187
+ * - start_angle : radians where slice 0 begins; NEGATIVE =
188
+ * unspecified (CC_PI/2 = 12 o'clock)
189
+ * - counter_clockwise : 0 = original counter-clockwise sweep; nonzero =
190
+ * mirrored (clockwise) sweep
191
+ * - center_text : text drawn in the hollow center (only when there is
192
+ * a hollow); NULL or "" disables it
193
+ *
194
+ * Non-finite slice_gap / inner_radius_ratio / start_angle are rejected.
195
+ *
196
+ * Same contract as ccharts_line: CCHARTS_OK with *out set to a string on
197
+ * success (including the empty string the header returns when every slice
198
+ * value is <= 0), CCHARTS_ERR_INVALID_ARG for NULL slices / count <= 0,
199
+ * CCHARTS_ERR_NON_FINITE for NaN/inf values, CCHARTS_ERR_DIMENSIONS for
200
+ * width/height outside cc_dim_ok, CCHARTS_ERR_NOMEM on allocation failure.
201
+ * On error *out is set to NULL. */
202
+ CCHARTS_API int32_t ccharts_pie_from_slices(
203
+ const ccharts_pie_slice* slices, int32_t count,
204
+ int32_t width, int32_t height,
205
+ int32_t donut,
206
+ const char* const* colors, int32_t color_count,
207
+ int32_t show_legend, int32_t show_pct,
208
+ double slice_gap, double inner_radius_ratio, int32_t legend_format,
209
+ double start_angle, int32_t counter_clockwise, const char* center_text,
210
+ char** out, size_t* out_len);
211
+
212
+ /* legend_format values for ccharts_pie_from_slices, mirroring the header's
213
+ * CC_PIE_LEGEND_* constants. Unknown values fall back to VALUE (original). */
214
+ #define CCHARTS_PIE_LEGEND_VALUE 0 /* "label value" (+ "(NN%)" when show_pct) */
215
+ #define CCHARTS_PIE_LEGEND_LABEL_PCT 1 /* "label NN%" */
216
+ #define CCHARTS_PIE_LEGEND_VALUE_PCT 2 /* "value (NN%)" */
217
+ #define CCHARTS_PIE_LEGEND_LABEL 3 /* "label" only */
218
+
219
+ /* ------------------------------ Histogram ------------------------------ */
220
+
221
+ /* Histogram rendering options. Every color is a NUL-terminated ANSI escape
222
+ * string or NULL for the library default, exactly like ccharts_settings;
223
+ * pass NULL for the whole struct to take every default. `bin_count` <= 0
224
+ * auto-selects (20 bins for >= 40 samples, else 10, trimmed to the width).
225
+ * `min_value`/`max_value` are the value window for the histogram: NaN means
226
+ * auto-select that endpoint from the data range (so NaN is allowed, unlike
227
+ * the samples). `show_bins` appends a value-axis footer row (window min
228
+ * left, window max right); `show_prices` prepends an 8-column left margin
229
+ * with the max-count / min-count labels. Mirrors cc_hist_settings_t in
230
+ * ccharts.h (the two structs stay separate: the header channels are
231
+ * internally linked, this one is the FFI surface). */
232
+ typedef struct ccharts_hist_settings {
233
+ const char* rise_color;
234
+ const char* bg_color;
235
+ int32_t bin_count;
236
+ double min_value;
237
+ double max_value;
238
+ int32_t show_bins;
239
+ int32_t show_prices;
240
+ } ccharts_hist_settings;
241
+
242
+ /* Renders a histogram of `count` scalar samples (a 1-D sequence, not OHLC
243
+ * rows) into a `width` x `height` grid. Same contract as ccharts_line:
244
+ * CCHARTS_OK with *out (NUL-terminated UTF-8, release with
245
+ * ccharts_string_free) on success, CCHARTS_ERR_INVALID_ARG for NULL
246
+ * samples / count <= 0 / NULL out, CCHARTS_ERR_NON_FINITE for NaN/inf
247
+ * samples or +-inf min_value/max_value (NaN min/max is the "auto" sentinel
248
+ * and is allowed), CCHARTS_ERR_DIMENSIONS for width/height outside
249
+ * cc_dim_ok, CCHARTS_ERR_NOMEM on allocation failure. On error *out is set
250
+ * to NULL. */
251
+ CCHARTS_API int32_t ccharts_hist(const double* samples, int32_t count,
252
+ int32_t width, int32_t height,
253
+ const ccharts_hist_settings* settings,
254
+ char** out, size_t* out_len);
255
+
256
+ /* ------------------------------ Sparkline ------------------------------ */
257
+
258
+ /* Sparkline rendering options. Mirrors cc_spark_settings_t in ccharts.h (the
259
+ * two structs stay separate: the header channels are internally linked, this
260
+ * one is the FFI surface, and layout is documented here rather than shared).
261
+ * Every color is a NUL-terminated ANSI escape string or NULL for the library
262
+ * default; pass NULL for the whole struct to take every default. `min_above`
263
+ * / `min_below` reserve that many sub-pixels at the top/bottom edge so the
264
+ * line does not clip; both are plain ints defaulting to 0, so a partial {0}
265
+ * initializer means the same as NULL (no sentinel ambiguity). */
266
+ typedef struct ccharts_spark_settings {
267
+ const char* rise_color;
268
+ const char* area_color;
269
+ int32_t min_above;
270
+ int32_t min_below;
271
+ } ccharts_spark_settings;
272
+
273
+ /* Renders a sparkline of `count` scalar samples (a 1-D sequence of
274
+ * close-like values, not OHLC rows) into a `width` x `height` grid. Same
275
+ * contract as ccharts_line: CCHARTS_OK with *out (NUL-terminated UTF-8,
276
+ * release with ccharts_string_free) on success, CCHARTS_ERR_INVALID_ARG for
277
+ * NULL samples / count <= 0 / NULL out, CCHARTS_ERR_NON_FINITE for NaN/inf
278
+ * samples, CCHARTS_ERR_DIMENSIONS for width/height outside cc_dim_ok,
279
+ * CCHARTS_ERR_NOMEM on allocation failure. On error *out is set to NULL. */
280
+ CCHARTS_API int32_t ccharts_spark(const double* samples, int32_t count,
281
+ int32_t width, int32_t height,
282
+ const ccharts_spark_settings* settings,
283
+ char** out, size_t* out_len);
284
+
285
+ /* ------------------------------ Bar chart ------------------------------ */
286
+
287
+ /* One bar: a categorical label (may be NULL or empty) and a non-negative
288
+ * height. Values are clamped to zero by the renderer (a negative value draws
289
+ * that bar at zero height rather than below the axis), so only non-finite
290
+ * values are an error. Mirrors cc_bar_item_t in ccharts.h (the two structs
291
+ * stay separate: the header channels are internally linked, this one is the
292
+ * FFI surface, and layout is documented here rather than shared). */
293
+ typedef struct ccharts_bar_slice {
294
+ const char* label;
295
+ double value;
296
+ } ccharts_bar_slice;
297
+
298
+ /* Bar chart rendering options. Mirrors cc_bar_settings_t in ccharts.h (the
299
+ * two structs stay separate: the header channels are internally linked, this
300
+ * one is the FFI surface). Every color is a NUL-terminated ANSI escape string
301
+ * or NULL for the library default; pass NULL for the whole struct to take
302
+ * every default. `show_labels` appends a footer row with each column's label
303
+ * (truncated to the column width); `show_prices` prepends an 8-column value
304
+ * axis with the max bar value at the top and 0 (the baseline) at the bottom.
305
+ * All fields are pointers or plain ints, so a partial {0} initializer means
306
+ * the same as NULL (no sentinel ambiguity). */
307
+ typedef struct ccharts_bar_settings {
308
+ const char* rise_color;
309
+ const char* bg_color;
310
+ int32_t show_labels;
311
+ int32_t show_prices;
312
+ } ccharts_bar_settings;
313
+
314
+ /* Renders a categorical bar chart of `count` (label, value) pairs into a
315
+ * `width` x `height` grid. Each bar grows up from a zero baseline scaled to
316
+ * the largest value, drawn with 8 sub-pixel rows (cc_lower_eighth tops). Same
317
+ * contract as ccharts_line: CCHARTS_OK with *out (NUL-terminated UTF-8,
318
+ * release with ccharts_string_free) on success, CCHARTS_ERR_INVALID_ARG for
319
+ * NULL items / count <= 0 / NULL out, CCHARTS_ERR_NON_FINITE for NaN/inf
320
+ * values, CCHARTS_ERR_DIMENSIONS for width/height outside cc_dim_ok,
321
+ * CCHARTS_ERR_NOMEM on allocation failure. Negative values are clamped to
322
+ * zero (not an error). On error *out is set to NULL. */
323
+ CCHARTS_API int32_t ccharts_bar(const ccharts_bar_slice* items, int32_t count,
324
+ int32_t width, int32_t height,
325
+ const ccharts_bar_settings* settings,
326
+ char** out, size_t* out_len);
327
+
328
+ /* ---------------------------- Stacked bar chart -------------------------- */
329
+
330
+ /* One stacked-bar series: a name (may be NULL/empty; the per-series color
331
+ * comes from the palette) and a `values` array with one entry per category.
332
+ * All series must share the same category count (settings->cats). Values are
333
+ * clamped to zero by the renderer (a negative entry draws at zero height
334
+ * rather than below the axis), so only non-finite values are an error.
335
+ * Mirrors cc_stack_series_t in ccharts.h (the two structs stay separate: the
336
+ * header channels are internally linked, this one is the FFI surface, and
337
+ * layout is documented here rather than shared). */
338
+ typedef struct ccharts_stack_series {
339
+ const char* name;
340
+ const double* values;
341
+ } ccharts_stack_series;
342
+
343
+ /* Stacked bar rendering options. Mirrors cc_stack_settings_t in ccharts.h.
344
+ * `colors` is a NULL-terminated per-series palette override (or NULL for the
345
+ * fixed default palette); `cat_labels` is an optional array of `cats` category
346
+ * names used for the label footer; `series` repeats series_count and `cats` is
347
+ * the number of categories (the length of every series' values array) and is
348
+ * REQUIRED. `show_labels` appends a footer row with each column's category
349
+ * label (truncated to the column width); `show_prices` prepends an 8-column
350
+ * value axis with the tallest stack total at the top and 0 (the baseline) at
351
+ * the bottom. All fields are pointers or plain ints, so a partial {0}
352
+ * initializer means the same as NULL (no sentinel ambiguity). */
353
+ typedef struct ccharts_stack_settings {
354
+ const char* const* colors;
355
+ const char* bg_color;
356
+ const char* const* cat_labels;
357
+ int32_t series;
358
+ int32_t cats;
359
+ int32_t show_labels;
360
+ int32_t show_prices;
361
+ } ccharts_stack_settings;
362
+
363
+ /* Renders a stacked bar chart of `series_count` series (the 2-D matrix: each
364
+ * series carries its own `values` array of settings->cats entries) into a
365
+ * `width` x `height` grid. Each category's bar is the vertical SUM of its
366
+ * series' values, drawn as stacked segments (one per series) with 8 sub-pixel
367
+ * rows, colored via a deterministic palette or the settings override. Same
368
+ * contract as ccharts_line: CCHARTS_OK with *out (NUL-terminated UTF-8,
369
+ * release with ccharts_string_free) on success, CCHARTS_ERR_INVALID_ARG for
370
+ * NULL series / series_count <= 0 / NULL settings / NULL out,
371
+ * CCHARTS_ERR_NON_FINITE for NaN/inf values, CCHARTS_ERR_DIMENSIONS for
372
+ * width/height outside cc_dim_ok, CCHARTS_ERR_NOMEM on allocation failure.
373
+ * Negative values are clamped to zero (not an error). On error *out is set to
374
+ * NULL. */
375
+ CCHARTS_API int32_t ccharts_stack(const ccharts_stack_series* series,
376
+ int32_t series_count,
377
+ int32_t width, int32_t height,
378
+ const ccharts_stack_settings* settings,
379
+ char** out, size_t* out_len);
380
+
381
+ /* ------------------------------ Heatmap chart ---------------------------- */
382
+
383
+ /* Heatmap rendering options. Mirrors cc_heat_settings_t in ccharts.h.
384
+ * `low_color` is the ANSI color for the minimum value (default bright-black),
385
+ * `high_color` for the maximum (default bright-white), and `mid_color` is an
386
+ * optional ANSI color that replaces the ladder's middle entry (index 5) for a
387
+ * 3-stop ramp (NULL = 2-stop). `bg_color` colors the grid cells the matrix
388
+ * does not cover (matrix smaller than width/height). `row_labels` /
389
+ * `col_labels` are optional `rows` / `cols` label arrays printed around the
390
+ * grid when `show_labels` is set. All fields are pointers or plain ints, so a
391
+ * partial {0} initializer means the same as NULL (no sentinel ambiguity). */
392
+ typedef struct ccharts_heat_settings {
393
+ const char* low_color;
394
+ const char* high_color;
395
+ const char* mid_color;
396
+ const char* bg_color;
397
+ const char* const* row_labels;
398
+ const char* const* col_labels;
399
+ int32_t show_labels;
400
+ } ccharts_heat_settings;
401
+
402
+ /* Renders a heatmap of a `rows` x `cols` row-major `values` matrix into a
403
+ * `width` x `height` grid. Matrix elements map to the fixed deterministic
404
+ * colormap ladder by their value's position between the matrix min/max; a
405
+ * matrix larger than the grid is downsampled by block-average, and one
406
+ * smaller than the grid occupies the top-left with background padding. Same
407
+ * contract as ccharts_line: CCHARTS_OK with *out (NUL-terminated UTF-8,
408
+ * release with ccharts_string_free) on success, CCHARTS_ERR_INVALID_ARG for
409
+ * NULL values / rows <= 0 / cols <= 0 / NULL out, CCHARTS_ERR_NON_FINITE for
410
+ * NaN/inf values, CCHARTS_ERR_DIMENSIONS for width/height outside cc_dim_ok,
411
+ * CCHARTS_ERR_NOMEM on allocation failure. On error *out is set to NULL. */
412
+ CCHARTS_API int32_t ccharts_heat(const double* values, int32_t rows,
413
+ int32_t cols,
414
+ int32_t width, int32_t height,
415
+ const ccharts_heat_settings* settings,
416
+ char** out, size_t* out_len);
417
+
418
+ /* ------------------------------- Box plot ------------------------------- */
419
+
420
+ /* One box-plot category: a name (may be NULL/empty; the core does not print
421
+ * it — bindings may add their own footer) and its `samples` array of `n`
422
+ * values. A category with n <= 0 or a NULL samples array is a marshalling
423
+ * error (the renderer cannot build a five-number summary from no samples).
424
+ * Mirrors cc_box_category_t in ccharts.h (the two structs stay separate:
425
+ * the header channels are internally linked, this one is the FFI surface,
426
+ * and layout is documented here rather than shared). */
427
+ typedef struct ccharts_box_category {
428
+ const char* name;
429
+ const double* samples;
430
+ int32_t n;
431
+ } ccharts_box_category;
432
+
433
+ /* Box plot rendering options. Mirrors cc_box_settings_t in ccharts.h.
434
+ * `rise_color` is the ANSI color for the box and median (default green);
435
+ * `area_color` for the whiskers (NULL/empty = share rise_color); `bg_color`
436
+ * for the empty cells above/below each box (NULL = none); `show_prices`
437
+ * prepends an 8-column value axis with the global max on the top row and the
438
+ * global min on the bottom row. All fields are pointers or plain ints, so a
439
+ * partial {0} initializer means the same as NULL (no sentinel ambiguity). */
440
+ typedef struct ccharts_box_settings {
441
+ const char* rise_color;
442
+ const char* area_color;
443
+ const char* bg_color;
444
+ int32_t show_prices;
445
+ } ccharts_box_settings;
446
+
447
+ /* Renders a box plot of `cat_count` categories into a `width` x `height`
448
+ * grid. Each category's samples yield a nearest-rank five-number summary
449
+ * (min, Q1, median, Q3, max); every box, its whiskers and its median are
450
+ * placed on 8-sub-pixel rows over the global min/max value span (the exact
451
+ * quartile and glyph conventions are documented in cc_box_create in
452
+ * ccharts.h). Same contract as ccharts_line: CCHARTS_OK with *out
453
+ * (NUL-terminated UTF-8, release with ccharts_string_free) on success,
454
+ * CCHARTS_ERR_INVALID_ARG for NULL cats / cat_count <= 0 / any category with
455
+ * NULL samples or n <= 0 / NULL out, CCHARTS_ERR_NON_FINITE for NaN/inf
456
+ * samples, CCHARTS_ERR_DIMENSIONS for width/height outside cc_dim_ok,
457
+ * CCHARTS_ERR_NOMEM on allocation failure. On error *out is set to NULL. */
458
+ CCHARTS_API int32_t ccharts_box(const ccharts_box_category* cats,
459
+ int32_t cat_count,
460
+ int32_t width, int32_t height,
461
+ const ccharts_box_settings* settings,
462
+ char** out, size_t* out_len);
463
+
464
+ /* ---------------------------- Introspection ---------------------------- */
465
+
466
+ /* ANSI escape for a ccharts_color_index, or NULL when out of range. */
467
+ CCHARTS_API const char* ccharts_color(int32_t index);
468
+
469
+ /* Human-readable message for a status code; never NULL. */
470
+ CCHARTS_API const char* ccharts_error_message(int32_t status);
471
+
472
+ /* Library version ("3.0.0"), shared by every binding. */
473
+ CCHARTS_API const char* ccharts_version(void);
474
+
475
+ /* CC_MAX_DIM / CC_MAX_CELLS, so bindings do not duplicate the limits. */
476
+ CCHARTS_API int32_t ccharts_max_dim(void);
477
+ CCHARTS_API int32_t ccharts_max_cells(void);
478
+
479
+ #ifdef __cplusplus
480
+ }
481
+ #endif
482
+
483
+ #endif /* CCHARTS_ABI_H */