@@ -411,11 +411,22 @@ void PlotBuilder::calcLegendAndLabel(const Data::DataTable &dataTable)
411411 if (auto &&meas = plot->getOptions ()
412412 ->getChannels ()
413413 .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 ();
415423 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 ())}},
418428 ::Anim::String{meas->getColIndex ()}};
429+ }
419430}
420431
421432void PlotBuilder::calcAxis (const Data::DataTable &dataTable,
@@ -500,6 +511,19 @@ void PlotBuilder::addAlignment(const Buckets &subBuckets) const
500511 }
501512
502513 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+
503527 const Base::Align align{plot->getOptions ()->align , {0.0 , 1.0 }};
504528 for (auto &&bucket : subBuckets) {
505529 Math::Range<> range;
@@ -510,9 +534,13 @@ void PlotBuilder::addAlignment(const Buckets &subBuckets) const
510534
511535 auto &&transform = align.getAligned (range) / range;
512536
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+ }
516544 }
517545}
518546
0 commit comments