@@ -345,10 +345,6 @@ void PlotBuilder::calcAxises(const Data::DataTable &dataTable,
345345 (mainAxis == AxisId::x ? subBoundRect : mainBoundRect)
346346 .min ));
347347
348- if (!mainRanges.empty ())
349- plot->getOptions ()->mainAxis ().range = {};
350- if (!subRanges.empty ()) plot->getOptions ()->subAxis ().range = {};
351-
352348 mainBoundRect =
353349 plot->getOptions ()->mainAxis ().range .getRange (mainBoundRect);
354350 subBoundRect =
@@ -526,7 +522,7 @@ void PlotBuilder::addAlignment(const Buckets &buckets,
526522 if (axisProps.align == Base::Align::Type::none) return ;
527523
528524 if (axisProps.align == Base::Align::Type::center) {
529- auto &&halfSize = axisRange.size () / 2.0 ;
525+ auto &&halfSize = axisRange.middle () ;
530526 axisRange = {axisRange.min - halfSize,
531527 axisRange.max - halfSize};
532528 }
@@ -585,19 +581,21 @@ PlotBuilder::addSeparation(const Buckets &buckets,
585581 max.size (),
586582 plot->getStyle ().calculatedSize ());
587583
588- res[0 ].atRange =
589- res[0 ].containsValues - res[0 ].containsValues .min ;
590- auto onMax = res[0 ].containsValues .size ();
591- for (auto i = 1U ; i < res.size (); ++i) {
592- if (!res[i].enabled ) continue ;
593- onMax += splitSpace;
594- res[i].atRange =
595- res[i].containsValues + onMax - res[i].containsValues .min ;
596- onMax += res[i].containsValues .size ();
584+ double onMax = 0.0 ;
585+ bool first = true ;
586+ for (auto &&resItem : res) {
587+ if (!resItem.enabled ) continue ;
588+ if (first)
589+ first = false ;
590+ else
591+ onMax += splitSpace;
592+ resItem.atRange = resItem.containsValues + onMax
593+ - resItem.containsValues .min ;
594+ onMax += resItem.containsValues .size ();
597595 }
598596
599597 if (plot->getOptions ()->coordSystem == CoordSystem::polar
600- && axisIndex == AxisId::x)
598+ && axisIndex == AxisId::x && !first )
601599 onMax += splitSpace;
602600
603601 for (auto &&bucket : buckets)
@@ -616,24 +614,25 @@ PlotBuilder::addSeparation(const Buckets &buckets,
616614
617615 auto alignedRange = maxRange;
618616 if (align == Base::Align::Type::center) {
619- auto &&halfSize = maxRange.size () / 2.0 ;
617+ auto &&halfSize = maxRange.middle () ;
620618 alignedRange = {maxRange.min - halfSize,
621619 maxRange.max - halfSize};
622620 }
623621
624622 for (auto &resItem : res) {
625623 if (!resItem.enabled ) continue ;
626624
627- resItem.atRange =
628- ((resItem.atRange - resItem.atRange .min ) * maxRange.size ()
629- / resItem.containsValues .size ()
630- + resItem.atRange .min - resItem.containsValues .min
631- + maxRange.min )
632- / onMax;
625+ auto aligned =
626+ Base::Align{align, resItem.containsValues }.getAligned (
627+ maxRange);
628+
629+ resItem.atRange = (aligned + resItem.atRange .min
630+ - resItem.containsValues .min )
631+ / onMax;
633632
634633 resItem.containsValues = {
635- maxRange .rescale (resItem.containsValues .min ),
636- maxRange .rescale (resItem.containsValues .max )};
634+ aligned .rescale (resItem.containsValues .min ),
635+ aligned .rescale (resItem.containsValues .max )};
637636 }
638637
639638 stats.setIfRange (axisIndex, alignedRange);
0 commit comments