@@ -504,44 +504,44 @@ void PlotBuilder::addAlignment(const Buckets &subBuckets) const
504504void PlotBuilder::addSeparation (const Buckets &subBuckets,
505505 const std::size_t &mainBucketSize) const
506506{
507- if (plot->getOptions ()->isSplit ()) {
508- auto align = plot->getOptions ()->align ;
509-
510- std::vector ranges{mainBucketSize,
511- Math::Range<>::Raw ({}, {})};
512- std::vector<bool > anyEnabled (mainBucketSize);
513-
514- auto &&subAxis = plot->getOptions ()->subAxisType ();
515- for (auto &&bucket : subBuckets)
516- for (std::size_t i{}, prIx{};
517- auto &&[marker, idx] : bucket) {
518- (i += idx.itemId - std::exchange (prIx, idx.itemId )) %=
519- ranges.size ();
520- if (marker.enabled ) {
521- ranges[i].include (
522- marker.getSizeBy (subAxis).size ());
523- anyEnabled[i] = true ;
524- }
525- }
507+ if (!plot->getOptions ()->isSplit ()) return ;
526508
527- auto max = Math::Range<>::Raw ({}, {});
528- for (auto i = 0U ; i < ranges.size (); ++i)
529- if (anyEnabled[i]) max = max + ranges[i];
530-
531- for (auto i = 1U ; i < ranges.size (); ++i)
532- ranges[i] = ranges[i] + ranges[i - 1 ].getMax ()
533- + (anyEnabled[i - 1 ] ? max.getMax () / 15 : 0 );
534-
535- for (auto &&bucket : subBuckets)
536- for (std::size_t i{}, prIx{};
537- auto &&[marker, idx] : bucket) {
538- (i += idx.itemId - std::exchange (prIx, idx.itemId )) %=
539- ranges.size ();
540- marker.setSizeBy (subAxis,
541- Base::Align{align, ranges[i]}.getAligned (
542- marker.getSizeBy (subAxis)));
543- }
544- }
509+ auto align = plot->getOptions ()->align ;
510+
511+ std::vector ranges{mainBucketSize, Math::Range<>::Raw ({}, {})};
512+ std::vector<bool > anyEnabled (mainBucketSize);
513+
514+ auto &&subAxis = plot->getOptions ()->subAxisType ();
515+ for (auto &&bucket : subBuckets)
516+ for (std::size_t i{}, prIx{}; auto &&[marker, idx] : bucket) {
517+ if (!marker.enabled ) continue ;
518+ (i += idx.itemId - std::exchange (prIx, idx.itemId )) %=
519+ ranges.size ();
520+ ranges[i].include (marker.getSizeBy (subAxis).size ());
521+ anyEnabled[i] = true ;
522+ }
523+
524+ auto max = Math::Range<>::Raw ({}, {});
525+ for (auto i = 0U ; i < ranges.size (); ++i)
526+ if (anyEnabled[i]) max = max + ranges[i];
527+
528+ auto &axis = plot->getStyle ().plot .getAxis (
529+ plot->getOptions ()->subAxisType ());
530+ auto splitSpace = axis.split ->get (max.getMax (),
531+ plot->getStyle ().calculatedSize ());
532+
533+ for (auto i = 1U ; i < ranges.size (); ++i)
534+ ranges[i] = ranges[i] + ranges[i - 1 ].getMax ()
535+ + (anyEnabled[i - 1 ] ? splitSpace : 0 );
536+
537+ for (auto &&bucket : subBuckets)
538+ for (std::size_t i{}, prIx{}; auto &&[marker, idx] : bucket) {
539+ (i += idx.itemId - std::exchange (prIx, idx.itemId )) %=
540+ ranges.size ();
541+ marker.setSizeBy (subAxis,
542+ Base::Align{align, ranges[i]}.getAligned (
543+ marker.getSizeBy (subAxis)));
544+ }
545545}
546546
547547void PlotBuilder::normalizeSizes ()
0 commit comments