Bug description
Recreation Steps 1. Create a stacked Bar Chart with two or more dimensions 2. Add Legends to the chart 3. Show Totals on the bar 4. Use the legend to exclude one of the dimensions
Expected Result The total on top of each bar adjusts to show the total based on the specific selection, along with the adjustment of the Y Axis. For example in the screenshots below the second picture should not be showing 156, 279, 374 & 81 in the last 4 bars
Actual Result Instead even upon excluding one of the dimensions even though the Y axis correctly updates. The total still show the values as if all dimensions were selected. And does not include any totals when the dimension that is on the top is removed
Screenshots/recordings
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
Hello @dvsingh-kearney! I'm Dosu, a bot here to help you solve bugs, answer questions, and assist you in becoming a contributor. I'm ready to help while you wait for a human maintainer.
The issue you're experiencing with the stacked bar chart not updating the totals when excluding dimensions from the legend might be related to how the extractDataTotalValues
function processes the data. This function calculates the total stacked values by summing the values of dimensions that are not excluded based on the legendState
. If the totals are not updating correctly, it could be due to the function not properly accounting for the legend state when recalculating the totals [1].
To address this, you might want to ensure that the legendState
is correctly reflecting the dimensions that are currently visible. The function should exclude dimensions that are disabled in the legendState
from the total calculation. If the logic in the function is not correctly filtering out these dimensions, it could lead to the totals not updating as expected.
Additionally, the Y-axis updates correctly because it uses the computeYDomain
function, which filters out disabled data and calculates the domain based on the visible data [2][3]. This suggests that the issue is specifically with the total values calculation rather than the Y-axis adjustment.
You may need to review the implementation of the extractDataTotalValues
function to ensure it properly handles the legend state and updates the totals accordingly.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
Comment From: msyavuz
I couldn't reproduce this in master. Can you check you can still reproduce it?