From 1cfe483fb34449a374fc3bcf25efe468aa034b28 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Fri, 27 Sep 2024 17:16:59 +0200 Subject: [PATCH 1/4] Fix drilldown 'fakely' splitted charts --- CHANGELOG.md | 4 ++++ src/chart/options/options.cpp | 18 ++++++++++----- src/chart/options/options.h | 12 ++++++++++ test/e2e/tests/fixes.json | 3 +++ test/e2e/tests/fixes/143.mjs | 42 +++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 test/e2e/tests/fixes/143.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index 80c5ec1c2..607da0ad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fix drilldown regroup strategy on fake-split charts. + ## [0.13.0] - 2024-09-13 ### Fixed diff --git a/src/chart/options/options.cpp b/src/chart/options/options.cpp index f5827371a..00561e85e 100644 --- a/src/chart/options/options.cpp +++ b/src/chart/options/options.cpp @@ -98,6 +98,13 @@ std::optional Options::secondaryStackType() const return std::nullopt; } +bool Options::isStacked() const +{ + auto dims = stackChannel().dimensions(); + dims.split_by(mainAxis().dimensions()); + return !dims.empty(); +} + Channels Options::shadowChannels() const { auto shadow = channels.shadow(); @@ -122,12 +129,11 @@ void Options::drilldownTo(const Options &other) { auto &stackChannel = this->stackChannel(); + if (this->split && !isStacked()) this->split = false; + for (auto &&dim : other.getChannels().getDimensions()) if (!getChannels().isSeriesUsed(dim)) stackChannel.addSeries(dim); - if (stackChannel.isDimension() - && geometry == ShapeType::rectangle) - this->align = Base::Align::Type::stretch; } void Options::intersection(const Options &other) @@ -192,9 +198,9 @@ bool Options::sameShadowAttribs(const Options &other) const return shape == shapeOther && coordSystem == other.coordSystem && angle == other.angle && orientation == other.orientation - && split == other.split && dataFilter == other.dataFilter - && align == other.align && sort == other.sort - && reverse == other.reverse; + && isSplit() == other.isSplit() + && dataFilter == other.dataFilter && align == other.align + && sort == other.sort && reverse == other.reverse; } bool Options::sameAttributes(const Options &other) const diff --git a/src/chart/options/options.h b/src/chart/options/options.h index 8a4bc42b8..acfba7bbc 100644 --- a/src/chart/options/options.h +++ b/src/chart/options/options.h @@ -109,6 +109,18 @@ class Options return channels.at(stackChannelType()); } + const Channel &stackChannel() const + { + return channels.at(stackChannelType()); + } + + [[nodiscard]] bool isStacked() const; + [[nodiscard]] bool isSplit() const + { + return split + && (stackChannelType() != subAxisType() || isStacked()); + } + Heading title{std::nullopt}; Heading subtitle{std::nullopt}; Heading caption{std::nullopt}; diff --git a/test/e2e/tests/fixes.json b/test/e2e/tests/fixes.json index 2ddbf8e0c..26352b2f8 100644 --- a/test/e2e/tests/fixes.json +++ b/test/e2e/tests/fixes.json @@ -7,6 +7,9 @@ "91": { "refs": ["1732a49"] }, + "143": { + "refs": ["4396a67"] + }, "144": { "refs": ["fde02e4"] }, diff --git a/test/e2e/tests/fixes/143.mjs b/test/e2e/tests/fixes/143.mjs new file mode 100644 index 000000000..db662e8ba --- /dev/null +++ b/test/e2e/tests/fixes/143.mjs @@ -0,0 +1,42 @@ +const testSteps = [ + (chart) => { + const data = { + series: [ + { + name: 'Colors', + type: 'dimension', + values: ['red', 'green', 'blue', 'red', 'green', 'blue', 'red', 'green', 'blue'] + }, + { + name: 'Letters', + type: 'dimension', + values: ['a', 'a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'] + }, + { + name: 'Val', + type: 'measure', + values: [3, 5, 4, 3 + 1, 5 + 1, 4 + 1, 3 + 2, 5 + 2, 4 + 2] + } + ] + } + + return chart.animate({ + data, + config: { + y: 'Colors', + x: 'Val' + } + }) + }, + (chart) => + chart.animate( + { + y: 'Val', + x: 'Letters', + split: true + }, + { regroupStrategy: 'drilldown' } + ) +] + +export default testSteps From 4aac8c0db1dc37f95fae1c120307b94da0086f34 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Fri, 27 Sep 2024 17:28:21 +0200 Subject: [PATCH 2/4] Fix size-stacked splitted chart intermediate splitness --- src/chart/options/options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/options/options.cpp b/src/chart/options/options.cpp index 00561e85e..af48464e3 100644 --- a/src/chart/options/options.cpp +++ b/src/chart/options/options.cpp @@ -129,7 +129,7 @@ void Options::drilldownTo(const Options &other) { auto &stackChannel = this->stackChannel(); - if (this->split && !isStacked()) this->split = false; + if (this->split && !isSplit()) this->split = false; for (auto &&dim : other.getChannels().getDimensions()) if (!getChannels().isSeriesUsed(dim)) From 2478dbf5dca9b5f3f019810e13b5e49d2ca91f77 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Fri, 27 Sep 2024 17:30:04 +0200 Subject: [PATCH 3/4] clang-tidy --- src/chart/options/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/options/options.h b/src/chart/options/options.h index acfba7bbc..ebade4a01 100644 --- a/src/chart/options/options.h +++ b/src/chart/options/options.h @@ -109,7 +109,7 @@ class Options return channels.at(stackChannelType()); } - const Channel &stackChannel() const + [[nodiscard]] const Channel &stackChannel() const { return channels.at(stackChannelType()); } From 9a3fa054f43038bd5f0b9c9d134bc5279cbd80df Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Fri, 27 Sep 2024 17:45:33 +0200 Subject: [PATCH 4/4] Fix dark theme --- test/e2e/test_cases/test_cases.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/test_cases/test_cases.json b/test/e2e/test_cases/test_cases.json index 1c472d1f8..4aeb8aeac 100644 --- a/test/e2e/test_cases/test_cases.json +++ b/test/e2e/test_cases/test_cases.json @@ -3236,7 +3236,7 @@ "refs": ["bd104b0"] }, "web_content/cookbook/style/dark_theme": { - "refs": ["f7c42b8"] + "refs": ["b23128f"] }, "web_content/cookbook/style/highligh_markers": { "refs": ["54fc3d3"]