RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
chart_bars.h File Reference

chart_bars.h — grouped and stacked vertical bar charts, and the single horizontal fill row (depth ladders, utilization rows). More...

#include <stddef.h>
#include <stdint.h>
#include "fb.h"
#include "geom.h"
#include "style.h"
#include "draw_target.h"
#include "ui_context.h"

Data Structures

struct  rmgui_chart_bars_view_t
 A vertical bar chart borrowing groups * series_per group-major values. More...
struct  rmgui_chart_bar_h_view_t
 One horizontal fill row, clamped to [0, v_max] with positive v_max. More...

Functions

void rmgui_chart_bars_paint (rmgui_fb_t *fb, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_style_resolved_t *rs, const int32_t *values, size_t groups, size_t series_per, int32_t v_max, int stacked)
 Paints groups groups of series_per series each into rect; the value of series s in group g is values[g * series_per + s], painted in rs->series[s % 6].
void rmgui_chart_bar_h (rmgui_fb_t *fb, rmgui_rect_t row, rmgui_rect_t clip, const rmgui_style_resolved_t *rs, int32_t value, int32_t v_max, rmgui_color_t fill)
 Paints one horizontal fill of fill across row: width (value * row.w) / v_max rounded to the nearest pixel, from row.x rightward, the full height of row.
void rmgui_chart_bars_paint_to (rmgui_target_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_style_resolved_t *, const int32_t *, size_t, size_t, int32_t, int)
 Explicit destination bars with identical clipping and series colors.
void rmgui_chart_bar_h_to (rmgui_target_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_style_resolved_t *, int32_t, int32_t, rmgui_color_t)
 Explicit horizontal bar destination; same value clamping and rounding.
int rmgui_chart_bars_draw (const rmgui_ui_t *ui, const rmgui_chart_bars_view_t *bars, rmgui_rect_t rect)
 Draw grouped or stacked bars.
int rmgui_chart_bar_h_draw (const rmgui_ui_t *ui, const rmgui_chart_bar_h_view_t *bar, rmgui_rect_t row)
 Draw a horizontal fill row.

Detailed Description

chart_bars.h — grouped and stacked vertical bar charts, and the single horizontal fill row (depth ladders, utilization rows).

Values are raw int32 in the caller's unit; the library never scales them beyond the paint mapping. All geometry is integer pixels computed in 64 bits.

Function Documentation

◆ rmgui_chart_bars_paint()

void rmgui_chart_bars_paint ( rmgui_fb_t * fb,
rmgui_rect_t rect,
rmgui_rect_t clip,
const rmgui_style_resolved_t * rs,
const int32_t * values,
size_t groups,
size_t series_per,
int32_t v_max,
int stacked )

Paints groups groups of series_per series each into rect; the value of series s in group g is values[g * series_per + s], painted in rs->series[s % 6].

Bars grow upward from the bottom of the plot area.

Layout rule (fixed): the plot area is rect inset by rs->padding_x on the left and right and rs->padding_y on top and bottom (negative padding counts as 0). Group g occupies the column between plot.x + g*plot.w/groups and plot.x + (g+1)*plot.w/groups. Ungrouped (stacked == 0): within its group column, series s occupies the sub-column between slot.x + s*slot.w/series_per and slot.x + (s+1)*slot.w/series_per. Every bar is then inset by rs->padding_x/2 on each side, never more than half the (sub-)column minus one pixel, so a non-empty column always keeps at least one pixel of bar. A bar's height is value * plot.h / v_max with the value clamped to [0, v_max]: zero and negative values paint nothing, values above v_max reach the plot's top edge.

Stacked (stacked != 0): one bar per group spanning the group's whole (inset) column; series stack bottom-up in index order, series 0 at the bottom, each segment's height value * plot.h / v_max on the cumulative sum, clamped to the plot's top edge (overflow beyond v_max is cut).

NULL fb, rs or values, zero groups or series_per, an empty rect, or v_max <= 0 paints nothing. Pixels are written only inside clip ∩ rect.

◆ rmgui_chart_bar_h()

void rmgui_chart_bar_h ( rmgui_fb_t * fb,
rmgui_rect_t row,
rmgui_rect_t clip,
const rmgui_style_resolved_t * rs,
int32_t value,
int32_t v_max,
rmgui_color_t fill )

Paints one horizontal fill of fill across row: width (value * row.w) / v_max rounded to the nearest pixel, from row.x rightward, the full height of row.

value is clamped to [0, v_max]: a value at or below 0 paints nothing, one at or above v_max fills the row. v_max <= 0 paints nothing. rs selects nothing today; pass the chart-resolved style. NULL fb paints nothing. Pixels are written only inside clip ∩ row.

◆ rmgui_chart_bars_paint_to()

void rmgui_chart_bars_paint_to ( rmgui_target_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const rmgui_style_resolved_t * ,
const int32_t * ,
size_t ,
size_t ,
int32_t ,
int  )

Explicit destination bars with identical clipping and series colors.

RECORD uses caller-owned command storage and latches bounded failures.

◆ rmgui_chart_bar_h_to()

void rmgui_chart_bar_h_to ( rmgui_target_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const rmgui_style_resolved_t * ,
int32_t ,
int32_t ,
rmgui_color_t  )

Explicit horizontal bar destination; same value clamping and rounding.

◆ rmgui_chart_bars_draw()

int rmgui_chart_bars_draw ( const rmgui_ui_t * ui,
const rmgui_chart_bars_view_t * bars,
rmgui_rect_t rect )

Draw grouped or stacked bars.

Returns 0 or -1 for invalid arguments or style; paint errors are reported by the target.

◆ rmgui_chart_bar_h_draw()

int rmgui_chart_bar_h_draw ( const rmgui_ui_t * ui,
const rmgui_chart_bar_h_view_t * bar,
rmgui_rect_t row )

Draw a horizontal fill row.

Returns 0 or -1 for invalid arguments or style; paint errors are reported by the target.