Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix drilldown 'fakely' splitted charts #583

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Fix drilldown regroup strategy on fake-split charts.

## [0.13.0] - 2024-09-13

### Fixed
Expand Down
18 changes: 12 additions & 6 deletions src/chart/options/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ std::optional<ChannelId> 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();
Expand All @@ -122,12 +129,11 @@ void Options::drilldownTo(const Options &other)
{
auto &stackChannel = this->stackChannel();

if (this->split && !isSplit()) 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)
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/chart/options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ class Options
return channels.at(stackChannelType());
}

[[nodiscard]] 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};
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3236,7 +3236,7 @@
"refs": ["bd104b0"]
},
"web_content/cookbook/style/dark_theme": {
"refs": ["f7c42b8"]
"refs": ["b23128f"]
},
"web_content/cookbook/style/highligh_markers": {
"refs": ["54fc3d3"]
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/tests/fixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"91": {
"refs": ["1732a49"]
},
"143": {
"refs": ["4396a67"]
},
"144": {
"refs": ["fde02e4"]
},
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/tests/fixes/143.mjs
Original file line number Diff line number Diff line change
@@ -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