PlottingSVG::SVGAxisRenderer
PlottingSVG::SVGAxisRenderer
Renders a simple linear axis (uniform tick spacing) as SVG fragments in pixel space. More…
#include <SVGAxisRenderer.hpp>
Inherits from PlottingSVG::SVGDecoration
Public Functions
| Name | |
|---|---|
| SVGAxisRenderer(float range_min, float range_max, float tick_interval, std::string axis_title) Construct an axis decoration with fixed domain, tick step, and title text. |
|
| void | setPosition(AxisPosition position) Select bottom (horizontal) or left (vertical) axis layout. |
| void | setMargin(int pixels) Set the inset from each canvas edge to the inner plot box (pixels). |
| void | setFontSize(int pixels) Set the font size for tick labels (SVG font-size). |
| void | setTickLength(int pixels) Set the length of tick marks extending from the spine (pixels). |
| void | setAxisColor(std::string stroke_hex) Set the stroke color for the spine and tick segments (SVG stroke attribute). |
| void | setLabelColor(std::string fill_hex) Set the fill color for tick labels and title text (SVG fill attribute). |
| virtual std::vector< std::string > | render(int canvas_width, int canvas_height) const override Emit <line> and <text> elements for the configured axis. |
Additional inherited members
Public Functions inherited from PlottingSVG::SVGDecoration
| Name | |
|---|---|
| virtual | ~SVGDecoration() =default |
Detailed Description
class PlottingSVG::SVGAxisRenderer;Renders a simple linear axis (uniform tick spacing) as SVG fragments in pixel space.
Data coordinates from range_min through range_max map linearly to the inner rectangle inset by margin from the canvas border. Tick positions are multiples of tick_interval starting at the first tick at or above range_min.
Public Functions Documentation
function SVGAxisRenderer
SVGAxisRenderer(
float range_min,
float range_max,
float tick_interval,
std::string axis_title
)Construct an axis decoration with fixed domain, tick step, and title text.
Parameters:
- range_min Data value at the left (vertical axis) or bottom (horizontal axis) end.
- range_max Data value at the opposite end; must exceed
range_minfor[render()](/api_generated/Classes/classPlottingSVG_1_1SVGAxisRenderer.md#function-render)to emit geometry when the canvas and margins are valid. - tick_interval Distance between tick marks in data units; if
<= 0, only the spine (and optional title) are drawn. - axis_title Shown as the axis title when non-empty;
&,<,>are escaped for SVG text.
Precondition:
range_max > range_minand both endpoints are finite if callers expect non-empty output from[render()](/api_generated/Classes/classPlottingSVG_1_1SVGAxisRenderer.md#function-render)under valid canvas and margin settings (enforcement: none) [IMPORTANT]tick_intervalis finite whenever tick marks are desired (tick_interval > 0) (enforcement: none) [LOW]
function setPosition
void setPosition(
AxisPosition position
)Select bottom (horizontal) or left (vertical) axis layout.
Parameters:
- position Edge used for the spine and tick direction.
function setMargin
void setMargin(
int pixels
)Set the inset from each canvas edge to the inner plot box (pixels).
Parameters:
- pixels Margin on all sides; used for spine placement and tick mapping.
Precondition: pixels >= 0 so inset arithmetic matches the intended “inner rectangle” model (enforcement: none) [IMPORTANT]
function setFontSize
void setFontSize(
int pixels
)Set the font size for tick labels (SVG font-size).
Parameters:
- pixels Font size in pixels.
Precondition: pixels > 0 for readable output (enforcement: none) [LOW]
function setTickLength
void setTickLength(
int pixels
)Set the length of tick marks extending from the spine (pixels).
Parameters:
- pixels Tick length; non-positive values invert or collapse ticks visually (enforcement: none) [LOW]
function setAxisColor
void setAxisColor(
std::string stroke_hex
)Set the stroke color for the spine and tick segments (SVG stroke attribute).
Parameters:
- stroke_hex Color string (e.g.
#000000); invalid SVG paint values produce invalid SVG fragments (enforcement: none) [LOW]
function setLabelColor
void setLabelColor(
std::string fill_hex
)Set the fill color for tick labels and title text (SVG fill attribute).
Parameters:
- fill_hex Color string (e.g.
#000000); invalid SVG paint values produce invalid SVG fragments (enforcement: none) [LOW]
function render
virtual std::vector< std::string > render(
int canvas_width,
int canvas_height
) const overrideEmit <line> and <text> elements for the configured axis.
Parameters:
- canvas_width SVG viewport width in pixels.
- canvas_height SVG viewport height in pixels.
Precondition:
canvas_width > 0andcanvas_height > 0are required for any non-empty output (enforcement: runtime_check)- Let
span = range_max - range_min.spanmust be finite andspan > 0for spine/ticks to be emitted (enforcement: runtime_check) 2 * margin < canvas_widthand2 * margin < canvas_heightso the inner box has positive size (enforcement: runtime_check)- If
tick_interval > 0, it must be finite so tick positions are well-defined (enforcement: none) [LOW] — non-finite interval is not guarded and may yield undefined tick placement
Postcondition:
- Return value is empty if any runtime-checked precondition above fails.
- Otherwise returns a sequence of SVG element strings (spine; optional ticks and labels; optional title) with
&,<,>escaped in text nodes. - Does not throw.
Reimplements: PlottingSVG::SVGDecoration::render
Updated on 2026-11-13 at 20:25:41 +0000