49 const string viztitle(
"chord-graph-" + aggname);
50 svg_element obj(viztitle, a);
53 const auto width = a._M_width;
54 const double hspace((width - (k::metamargin * 2)) /
hdenom);
55 const uint xstart(k::metamargin + hspace + hspace);
59 const auto height = a._M_height;
60 const double vcenter(height / 2);
62 typography typol = get_metadata_typo(
lsz,
true);
63 sized_text(obj, typol,
lsz,
"age values", k::metamargin, vcenter);
65 typography typoli = get_metadata_typo(
asz,
false);
67 sized_text(obj, typoli,
ssz,
"birth age values per decile", k::metamargin,
69 string playingll(
"#" + k::playing +
" age values per decile");
70 sized_text(obj, typoli,
ssz, playingll, k::metamargin,
77 style styll = get_metadata_style(
false);
78 styll._M_stroke_size = 0.5;
79 styll._M_stroke_opacity = 1.0;
80 for (
const auto& val : k::age_values)
83 sized_text(obj, typol,
lsz, val, xoff, vcenter);
86 point_2t topstart(xoff, vcenter -
lsz -
vlspace);
88 points_to_line(obj, styll, topstart, topend);
91 point_2t bstart(xoff, vcenter +
lsz +
vlspace);
93 points_to_line(obj, styll, bstart, bend);
119 const uint rwidth = 10)
125 const auto width = a._M_width;
126 const double hspace((width - (k::metamargin * 2)) /
hdenom);
127 const uint xstart(k::metamargin + hspace + hspace);
131 const auto height = a._M_height;
132 const double vcenter(height / 2);
141 const uint agesi = k::find_id_index(
"ages");
142 const umids& ages = cumulative[agesi];
146 for (
const auto& val : ages)
148 auto [ id, count ] = val;
150 if (
id.find(k::playing) != string::npos)
154 maxno = std::max(maxno, count);
156 const id_size maxn = maxno * 2;
157 std::cout <<
"max n is: " << maxn << std::endl;
173 for (
const auto& val : agesvp)
175 auto [ id, count ] = val;
180 split_playing_value(
id, ageso, agesplaying);
181 for (
const string& valso : ageso)
183 for (
const string& valsp : agesplaying)
185 const string splayings = k::space + k::playing + k::space;
186 const string valpflat = valso + splayings + valsp;
187 if (agesvpflat.count(valpflat))
189 auto& val = agesvpflat.at(valpflat);
193 agesvpflat.insert(make_pair(valpflat, count));
199 typography typol = get_metadata_typo(
lsz,
true);
200 sized_text(obj, typol,
lsz,
"age values", k::metamargin, vcenter);
202 typography typov = get_metadata_typo(
lsz,
false,
true);
204 const uint ytotalgraphspace(vcenter -
vspace -
vlspace - k::metamargin);
205 const uint ygraphdelta = std::round(yscale * ytotalgraphspace);
208 const uint ydelta(ygraphdelta / 2);
215 vul vsum(k::age_values.size(), 0);
216 for (
const auto& val : agesvo)
218 auto [ id, count ] = val;
222 double rheight = scale_value_on_range(count, 1, maxn, 10, ydelta);
223 double rystart = voffstart - (rheight / 2);
224 point_to_rect_centered(obj, std::make_tuple(xoff, rystart),
225 get_metadata_style(), rwidth, rheight);
228 sized_text(obj, typov,
asz, to_string(count), xoff,
229 voffstart - rheight -
vlspace);
231 const auto indx = k::age_value_to_multiple(
id,
true);
239 style pstyl = { color::gray40, 1.0, color::gray40, 0.0, 0 };
240 style pstyll = { color::gray40, 0.0, color::red, 1, 2 };
243 vul vpsum(k::age_values.size(), 0);
246 vul vpyoffsets(k::age_values.size(), 0);
247 for (
const auto& val : agesvpflat)
249 auto [ idp, count ] = val;
254 split_playing_value(idp, ageso, agesplaying);
260 for (
const string& agepv : agesplaying)
262 const auto indxp = k::age_value_to_multiple(agepv,
true);
265 const auto aend = ageso.end();
266 const bool agesamep = std::find(ageso.begin(), aend, agepv) != aend;
271 vsum[indxp] += count;
276 ulong& yoffset = vpyoffsets[indxp];
278 uint yoff = vpoffstart + yoffset;
281 auto normalize_v_o_r = scale_value_on_range;
282 double rheight = normalize_v_o_r(count, 1, maxn, 10, ydelta);
283 auto rectcp = std::make_tuple(xoff, yoff + (rheight / 2));
284 point_to_rect_centered(obj, rectcp , pstyl, rwidth, rheight);
287 sized_text(obj, typov,
ssz, to_string(count), xoff,
294 for (
const string& agev : ageso)
297 style pstylage = pstyll;
298 auto klr = age_value_to_color_tint_shade(agepv);
299 pstylage._M_stroke_color = klr;
303 const bool vback = agepv == k::age_values.back();
304 const bool vfront = agepv == k::age_values.front();
308 const bool strokewidenp =
false;
312 strokesz = pstylage._M_stroke_size * count;
313 pstylage._M_stroke_size = strokesz;
317 point_2t bstart(xoffvo, vcenter +
vlspace);
318 point_2t bend(xoff, yoff + (pstylage._M_stroke_size / 2));
320 points_to_line(obj, pstylage, bstart, bend, dashstr);
323 vpsum[indxp] += count;
325 const auto indx = k::age_value_to_multiple(agev,
true);
333 for (
const auto& val : k::age_values)
335 auto indx = k::age_value_to_multiple(val,
true);
337 uint yoff = vcenter -
vspace;
338 uint total = vsum[indx];
341 sized_text(obj, typov,
asz, to_string(total), xoff, yoff);
344 double rheight = scale_value_on_range(total, 1, maxn, 10, ydelta);
345 double ynotch = voffstart - rheight -
vlspace -
asz;
348 point_2t topstart(xoff - (rwidth / 2), ynotch);
349 point_2t topend(xoff + (rwidth / 2), ynotch);
352 nstyl._M_stroke_size = 3;
353 nstyl._M_stroke_opacity = 1.0;
354 points_to_line(obj, nstyl, topstart, topend);
359 for (
const auto& val : k::age_values)
361 auto indx = k::age_value_to_multiple(val,
true);
363 uint yoff = vpoffstart -
vlspace;
364 uint total = vpsum[indx];
366 sized_text(obj, typov,
asz, to_string(total), xoff, yoff);
370 uint avocount = std::accumulate(vsum.begin(), vsum.end(), uint(0));
371 uint avpcount = std::accumulate(vpsum.begin(), vpsum.end(), uint(0));
372 double playingper = double(avpcount) / (avpcount + avocount);
373 uint playingperi =
static_cast<uint
>(playingper * 100);
374 string playingperstr = std::to_string(playingperi) +
"% playing";
376 const uint xsumoff = width - k::metamargin;
379 sized_text(obj, typol,
lsz,
"total values found", xsumoff, vcenter);
382 sized_text(obj, typol,
asz, to_string(avocount), xsumoff,
384 sized_text(obj, typol,
asz, to_string(avpcount), xsumoff,
386 sized_text(obj, typol,
asz, playingperstr, xsumoff,
396 const strings& namedkeyso,
const string aggname)
399 vsids idsranked(k::id_dimensions.size());
400 for (uint index(0); index < k::id_dimensions.size(); ++index)
402 sids& csids = idsranked[index];
403 const umids& cumuids = cumulative[index];
404 for (
const auto& idp : cumuids)
406 auto [ name, count ] = idp;
407 csids.insert(make_tuple(count, name));
412 serialize_metadata_aggregate(idsranked, namedkeyso, aggname);
415 const string outname = mangle_aggregate(aggname);
420 typography typot = get_metadata_typo(tsz,
true,
false);
422 auto [ width, height ] = obj._M_area;
423 auto xpos = width - k::metamargin;
424 auto ypos = height - k::metamargin;
427 string title(
"ages");
428 if (!aggname.empty())
429 title += string(k::space + aggname);
430 sized_text_r(obj, typot, tsz, title, xpos, ypos, -90);
433 render_metadata_aggregate_namekeys(obj, namedkeyso, xpos);