diff --git a/src/graphs/barchart.cpp b/src/graphs/barchart.cpp index f026b337..95b3e001 100644 --- a/src/graphs/barchart.cpp +++ b/src/graphs/barchart.cpp @@ -466,6 +466,10 @@ namespace Wisteria::Graphs if (barLabels.size() != GetBars().size()) { return; } + // bar groups and brackets connected to bars' positions will need to be removed + m_barGroups.clear(); + GetBarAxis().ClearBrackets(); + // verify that provided labels are in the existing bars // (if not, then add a empty bar for it) for (const auto& label : labels) @@ -602,8 +606,9 @@ namespace Wisteria::Graphs GetBarAxis().IsReversed()) { return; } - // bar groups connected to bars' positions will need to be removed + // bar groups and brackets connected to bars' positions will need to be removed m_barGroups.clear(); + GetBarAxis().ClearBrackets(); const bool isDisplayingOuterLabels = GetBarAxis().IsShowingOuterLabels(); GetBarAxis().ClearCustomLabels(); diff --git a/src/graphs/barchart.h b/src/graphs/barchart.h index 8b9b7678..66e25ebe 100644 --- a/src/graphs/barchart.h +++ b/src/graphs/barchart.h @@ -986,6 +986,8 @@ namespace Wisteria::Graphs /// @param direction SortAscending to sort smallest-to-largest (A-Z), /// going top-to-bottom or left-to-right. /// SortDescending to sort largest-to-smallest (A-Z). + /// @warning If there are bar groups or brackets along the bar axis, then those + /// will be removed when sorting. virtual void SortBars(const BarSortComparison sortMethod, const SortDirection direction); /// @brief Sorts the bars (based on a specified order of axis labels). /// This is similar to what @c forcats::fct_relevel() does in R. @@ -1001,6 +1003,8 @@ namespace Wisteria::Graphs /// Finally, all bar labels must be unique for the label ordering to work; /// otherwise, the sort could not be deterministic. If there are multiple bars /// with the same axis label, then this will return without sorting. + /// @warning If there are bar groups or brackets along the bar axis, then those + /// will be removed when sorting. virtual void SortBars(std::vector labels, const SortDirection direction); /// @returns @c true if the bars can be sorted (i.e., reordered) in terms of bar length. virtual bool IsSortable() const noexcept