@@ -411,11 +411,22 @@ void PlotBuilder::calcLegendAndLabel(const Data::DataTable &dataTable)
411
411
if (auto &&meas = plot->getOptions ()
412
412
->getChannels ()
413
413
.at (ChannelId::label)
414
- .measure ())
414
+ .measure ()) {
415
+ auto markerLabelsUnitPercent =
416
+ plot->getStyle ().plot .marker .label .unit
417
+ == Styles::MarkerLabel::Unit::percent
418
+ && plot->getOptions ()->align == Base::Align::Type::stretch
419
+ && plot->getOptions ()->labelSeries (
420
+ plot->getOptions ()->subAxisType ())
421
+ == *meas
422
+ && !plot->getOptions ()->isSplit ();
415
423
plot->axises .label = {
416
- ::Anim::String{
417
- std::string{dataTable.getUnit (meas->getColIndex ())}},
424
+ ::Anim::String{std::string{
425
+ markerLabelsUnitPercent
426
+ ? " %"
427
+ : dataTable.getUnit (meas->getColIndex ())}},
418
428
::Anim::String{meas->getColIndex ()}};
429
+ }
419
430
}
420
431
421
432
void PlotBuilder::calcAxis (const Data::DataTable &dataTable,
@@ -500,6 +511,19 @@ void PlotBuilder::addAlignment(const Buckets &subBuckets) const
500
511
}
501
512
502
513
auto &&subAxis = plot->getOptions ()->subAxisType ();
514
+
515
+ auto &&subAxisLabel = plot->getOptions ()->labelSeries (subAxis);
516
+ auto markerLabelsUnitPercent =
517
+ plot->getStyle ().plot .marker .label .unit
518
+ == Styles::MarkerLabel::Unit::percent
519
+ && plot->getOptions ()->align == Base::Align::Type::stretch
520
+ && subAxisLabel.has_value ()
521
+ && subAxisLabel
522
+ == plot->getOptions ()
523
+ ->getChannels ()
524
+ .at (ChannelId::label)
525
+ .measure ();
526
+
503
527
const Base::Align align{plot->getOptions ()->align , {0.0 , 1.0 }};
504
528
for (auto &&bucket : subBuckets) {
505
529
Math::Range<> range;
@@ -510,9 +534,13 @@ void PlotBuilder::addAlignment(const Buckets &subBuckets) const
510
534
511
535
auto &&transform = align.getAligned (range) / range;
512
536
513
- for (auto &&[marker, idx] : bucket)
514
- marker.setSizeBy (subAxis,
515
- marker.getSizeBy (subAxis) * transform);
537
+ for (auto &&[marker, idx] : bucket) {
538
+ auto &&newRange = marker.getSizeBy (subAxis) * transform;
539
+ marker.setSizeBy (subAxis, newRange);
540
+ if (markerLabelsUnitPercent)
541
+ marker.label ->value .value .emplace (
542
+ newRange.size () * 100 );
543
+ }
516
544
}
517
545
}
518
546
0 commit comments