You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gerbermichi (via GitHub)" <gi...@apache.org> on 2024/12/17 09:21:52 UTC
[PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
gerbermichi opened a new pull request, #31495:
URL: https://github.com/apache/superset/pull/31495
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
This PR resolves an issue where the Sunburst chart's cross-filtering did not work properly for hierarchies with more than two levels. Previously, only the first and last hierarchies allowed cross-filtering, whereas any interactions with the middle hierarchies let to an error.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
Create a sunburst chart with more than two hierarchies.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #31495:
URL: https://github.com/apache/superset/pull/31495#discussion_r2237733740
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props: SunburstTransformedProps) {
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
+ const value = treePath[treePath.length - 1];
+
+ const isCurrentValueSelected =
+ Object.values(selectedValues).includes(joinedThreePath);
+
+ if (!columns?.length || isCurrentValueSelected) {
+ return {
+ dataMask: {
+ extraFormData: {
+ filters: [],
+ },
+ filterState: {
+ value: null,
+ selectedValues: [],
+ },
+ },
+ isCurrentValueSelected,
+ };
}
- const labels = values.map(value => labelMap[value]);
return {
dataMask: {
extraFormData: {
- filters:
- values.length === 0 || !columns
- ? []
- : columns.slice(0, treePath.length).map((col, idx) => {
- const val = labels.map(v => v[idx]);
- if (val === null || val === undefined)
- return {
- col,
- op: 'IS NULL' as const,
- };
- return {
- col,
- op: 'IN' as const,
- val: val as (string | number | boolean)[],
- };
- }),
+ filters: [
+ {
+ col: columns[treePath.length - 1],
+ op: '==' as const,
+ val: value,
+ },
+ ],
Review Comment:
### Incomplete hierarchical filtering in Sunburst chart <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The filter is only being applied to the last level of the tree path, ignoring parent levels. This doesn't maintain the hierarchical relationship in the Sunburst chart's filtering.
###### Why this matters
Users might see incorrect data when filtering because parent-child relationships in the hierarchy are not preserved. For example, if there are two nodes with the same name at different levels or under different parents, the current filter would match both incorrectly.
###### Suggested change ∙ *Feature Preview*
Modify the filter generation to include all levels of the hierarchy:
```typescript
filters: treePath.map((path, idx) => ({
col: columns[idx],
op: '==' as const,
val: path,
})),
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:5b1979b6-3a8b-433e-b4a9-5cf525d87b76 -->
[](5b1979b6-3a8b-433e-b4a9-5cf525d87b76)
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
Review Comment:
### Typo in Variable Name <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Variable name contains a typo ('Three' instead of 'Tree') which could cause confusion.
###### Why this matters
Typos in variable names can mislead developers about the variable's purpose and make code harder to maintain.
###### Suggested change ∙ *Feature Preview*
```typescript
const joinedTreePath = treePath.join(',');
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:9b95bcac-19a4-4885-8640-274ab34cda28 -->
[](9b95bcac-19a4-4885-8640-274ab34cda28)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #31495:
URL: https://github.com/apache/superset/pull/31495
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #31495:
URL: https://github.com/apache/superset/pull/31495#discussion_r2237728377
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props: SunburstTransformedProps) {
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
+ const value = treePath[treePath.length - 1];
+
+ const isCurrentValueSelected =
+ Object.values(selectedValues).includes(joinedThreePath);
+
+ if (!columns?.length || isCurrentValueSelected) {
+ return {
+ dataMask: {
+ extraFormData: {
+ filters: [],
+ },
+ filterState: {
+ value: null,
+ selectedValues: [],
+ },
+ },
+ isCurrentValueSelected,
+ };
}
- const labels = values.map(value => labelMap[value]);
return {
dataMask: {
extraFormData: {
- filters:
- values.length === 0 || !columns
- ? []
- : columns.slice(0, treePath.length).map((col, idx) => {
- const val = labels.map(v => v[idx]);
- if (val === null || val === undefined)
- return {
- col,
- op: 'IS NULL' as const,
- };
- return {
- col,
- op: 'IN' as const,
- val: val as (string | number | boolean)[],
- };
- }),
+ filters: [
+ {
+ col: columns[treePath.length - 1],
+ op: '==' as const,
+ val: value,
+ },
+ ],
},
filterState: {
- value: labels.length ? labels : null,
- selectedValues: values.length ? values : null,
+ value,
+ selectedValues: [joinedThreePath],
Review Comment:
Variable reference contains the same typo: 'joinedThreePath' should be 'joinedTreePath'.
```suggestion
selectedValues: [joinedTreePath],
```
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props: SunburstTransformedProps) {
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
+ const value = treePath[treePath.length - 1];
+
+ const isCurrentValueSelected =
+ Object.values(selectedValues).includes(joinedThreePath);
Review Comment:
Variable name contains a typo: 'joinedThreePath' should be 'joinedTreePath' (missing 'e' in 'tree').
```suggestion
const joinedTreePath = treePath.join(',');
const value = treePath[treePath.length - 1];
const isCurrentValueSelected =
Object.values(selectedValues).includes(joinedTreePath);
```
##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props: SunburstTransformedProps) {
const getCrossFilterDataMask = useCallback(
(treePathInfo: TreePathInfo[]) => {
const treePath = extractTreePathInfo(treePathInfo);
- const name = treePath.join(',');
- const selected = Object.values(selectedValues);
- let values: string[];
- if (selected.includes(name)) {
- values = selected.filter(v => v !== name);
- } else {
- values = [name];
+ const joinedThreePath = treePath.join(',');
+ const value = treePath[treePath.length - 1];
+
+ const isCurrentValueSelected =
+ Object.values(selectedValues).includes(joinedThreePath);
Review Comment:
Variable reference contains the same typo: 'joinedThreePath' should be 'joinedTreePath'.
```suggestion
const joinedTreePath = treePath.join(',');
const value = treePath[treePath.length - 1];
const isCurrentValueSelected =
Object.values(selectedValues).includes(joinedTreePath);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-2549276091
Thanks again for all the sunburst attention! Pinging a couple of subject matter experts :D
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-3138308158
Thanks! LGTM!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "gerbermichi (via GitHub)" <gi...@apache.org>.
gerbermichi commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-3135197708
> Looks to me like it's working, but is there a test case that exhibits the bug using example datasets, or perhaps a video you can paste in here, so we can see the difference more explicitly?
@rusackas I've updated the description of this PR and uploaded a before and after gif.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-3129173751
@rusackas Processing your ephemeral environment request [here](https://github.com/apache/superset/actions/runs/16578877443). Action: **up**. More information on [how to use or configure ephemeral environments](https://superset.apache.org/docs/contributing/howtos/#github-ephemeral-environments)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-3129168783
/korbit-review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "gerbermichi (via GitHub)" <gi...@apache.org>.
gerbermichi commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-3106435203
@stephenLYZ, @kgabryje or @michael-s-molina could you please have a look at this pr?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-3129263278
@rusackas Ephemeral environment spinning up at http://35.160.221.40:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(sunburst): Fix sunburst chart cross-filter logic [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #31495:
URL: https://github.com/apache/superset/pull/31495#issuecomment-3134047190
Looks to me like it's working, but is there a test case that exhibits the bug using example datasets, or perhaps a video you can paste in here, so we can see the difference more explicitly?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org