16#ifndef izzi_SVG_GRAPHS_LINE_H
17#define izzi_SVG_GRAPHS_LINE_H 1
89 for (
uint i = 0; i < points.size(); i++)
91 auto [ vx, vy ] = points[i];
92 auto [ cx, cy ] = cpoints[i];
95 string tipstr(gstate.
title);
97 tipstr += std::to_string(
static_cast<uint>(vy));
101 tipstr += std::to_string(
static_cast<uint>(vx));
105 const bool roundp = linecap ==
"round" || linecap ==
"circle";
106 const bool squarep = linecap ==
"square";
107 const bool trianglep = linecap ==
"triangle";
138 2 * radius, 2 * radius };
160 if (!roundp && !squarep && !trianglep)
162 string m(
"make_line_graph_markers_tips:: ");
163 m +=
"linecap value invalid or missing, currently set to: ";
166 throw std::runtime_error(
m);
180 const double xscalein = 1,
const double yscalein = 1,
187 auto [ pwidth, pheight ] = aplate;
188 double gwidth = pwidth - (2 * gstate.
marginx);
189 double gheight = pheight - (2 * gstate.
marginy);
190 const double chartyo = pheight - gstate.
marginy;
191 const double chartxo = gstate.
marginx;
192 const double chartxe = pwidth - gstate.
marginx;
205 point_2t xlabelp = make_tuple(pwidth / 2, chartyo + (gstate.
marginy / 2));
208 point_2t ylabelp = make_tuple(chartxo / 2, pheight / 2);
232 const double xrange(maxx - minx);
233 const double xscale(gwidth / xrange);
234 const double yrange(maxy - miny);
235 const double yscale(gheight / yrange);
241 double xtickn(xrange * 2);
248 double xdelta = std::max(xrange / xtickn, 0.1);
254 const double ydelta = yrange / gstate.
yticdigits;
262 for (
double x = minx; x < maxx; x += xdelta)
264 const double xto = chartxo + (x * xscale);
266 oss << fixed << setprecision(gstate.
xticdigits) << x;
267 const string sxui = oss.str() + gstate.
xticu;
276 const double xgol = gstate.
marginx - yticspacer;
277 const double xgor = gstate.
marginx + gwidth + yticspacer;
278 const double starty = miny != 0 ? miny : miny + ydelta;
279 for (
double y = starty; y < maxy + ydelta; y += ydelta)
281 const double yto = chartyo - (y * yscale);
282 const string syui = std::to_string(
static_cast<uint>(y)) + gstate.
yticu;
300 for (
double y = miny + ydelta; y < maxy + ydelta; y += ydelta)
303 const double yto = chartyo - (y * yscale);
312 for (
double x = minx + xdelta; x < maxx - xdelta; x += xdelta)
314 const double xto = chartxo + (x * xscale);
315 const string syui = std::to_string(
static_cast<uint>(y)) + gstate.
yticu;
338 auto [ minx, maxx ] = xrange;
339 auto [ miny, maxy ] = yrange;
345 auto [ pwidth, pheight ] = aplate;
346 double gwidth = pwidth - (2 * gstate.
marginx);
347 double gheight = pheight - (2 * gstate.
marginy);
348 const double chartyo = pheight - gstate.
marginy;
352 for (
uint i = 0; i < points.size(); i++)
355 auto [ vx, vy ] =
pt;
359 double x = gstate.
marginx + xlen;
363 double y = chartyo - ylen;
365 cpoints.push_back(make_tuple(x, y));
constexpr svg::ushort line_2_polyline_tooltips(200)
constexpr svg::ushort line_1_polyline(100)
Polyline/line creation options. 1: use one line with css dasharray and markers mid,...
void add_data(const data &d)
Either serialize immediately (as below), or create data structure that adds data to data_vec and then...
void add_style(const style &sty)
void add_data(const data &d, string trans="")
static constexpr const char * pair_finish_tag
static string finish_group()
void add_title(const string &t)
static string start_group(const string name="")
static constexpr const char * pair_finish_tag
static constexpr const char * pair_finish_tag
void add_raw(const string &raw)
void add_element(const element_base &e)
static constexpr string finish_tag_hard
line_element make_line(const point_2t origin, const point_2t end, style s, const string dasharray="")
Line primitive.
string make_line_graph_markers_tips(const vrange &points, const vrange &cpoints, const graph_rstate &gstate, const double radius)
Return set of paths corresponding to marker shapes with tooltips.
@ pt
Point where 1 pixel x 1/72 dpi x 96 PPI = .26 mm.
unsigned short ushort
Base integer type: positive and negative, signed integral value.
svg_element make_line_graph_annotations(const area<> aplate, const vrange &points, const graph_rstate &gstate, const double xscalein=1, const double yscalein=1, const typography typo=k::apercu_typo)
Axis Labels Axis X/Y Ticmarks X line increments.
double scale_value_on_range(const ssize_type value, const ssize_type min, const ssize_type max, const ssize_type nfloor, const ssize_type nceil)
Scale value from min to max on range (nfloor, nceil).
void styled_text(svg_element &obj, const string text, const point_2t origin, const typography typo)
Text at.
@ alt
alternate use specified in situ
@ vector
svg path, circle, rectangle, etc.
@ echo
b & w outline version of vector
svg_element make_line_graph(const svg::area<> aplate, const vrange &points, const graph_rstate &gstate, const point_2t xrange, const point_2t yrange)
Returns a svg_element with the chart and labels Assume: vgrange x axis is monotonically increasing.
path_element make_path_triangle(const point_2t origin, const style styl, const double r=4, const double angle=120, const bool selfclosingtagp=true)
Center a triangle at this point.
std::vector< point_2t > vrange
point_2t max_vrange(vspace &xpoints, vspace &ypoints, const uint pown)
For each dimension of vrnage, find min/max and return (xmax, ymax) NB: Assumes zero is min.
polyline_element make_polyline(const vrange &points, const style s, const stroke_style sstyle={ })
Polyline primitive.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space.
Per-graph constants, metadata, text.
static constexpr uint marginy
static constexpr uint yticdigits
static constexpr uint xticdigits
static constexpr uint th1sz
static constexpr uint marginx
static constexpr uint tticsz
static constexpr uint ttitlesz
Glyph type sizes.
static constexpr uint tpsz
render_state_base(const select m=select::none)
bool is_visible(const select v) const
Additional path/line/polyline stroke styles.
Datum consolidating style preferences.
void set_colors(const svg::color &klr)
Convenience function to set all colors at once.
@ central
For rotated text.