bito-code-review[bot] commented on PR #42761:
URL: https://github.com/apache/superset/pull/42761#issuecomment-5185051980
<!-- Bito Reply -->
The flagged issue is correct. The `showValuesAs` control exposes percentage
options that require specific rollup levels (row, column, or grand totals) to
calculate correctly. If these rollups are disabled in the pivot table
configuration, the calculation logic will fail to find the required
denominator, resulting in `NaN%` or `Infinity%` values.
To resolve this, you can update the `controlPanel.tsx` to conditionally
disable these choices based on the state of the rollup toggles. You can use the
`visibility` property in the control configuration to hide or disable the
percentage options when the corresponding totals are not enabled.
Example implementation for `controlPanel.tsx`:
```tsx
// Inside controlPanel.tsx, update the showValuesAs control configuration:
visibility: ({ controls }) => {
const rowTotals = controls?.rowTotals?.value;
const colTotals = controls?.colTotals?.value;
// Logic to filter choices based on rowTotals/colTotals
return { ... };
},
```
I have checked the available comments on this PR, and there are no other
review comments to address. Would you like me to proceed with implementing this
fix in the `controlPanel.tsx` file?
**superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx**
```
visibility: ({ controls }) => {
const rowTotals = controls?.rowTotals?.value;
const colTotals = controls?.colTotals?.value;
// Logic to filter choices based on rowTotals/colTotals
return { ... };
},
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]