korbit-ai[bot] commented on code in PR #32707:
URL: https://github.com/apache/superset/pull/32707#discussion_r1999520297


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -420,6 +422,16 @@ export default function transformProps(
       }
     });
 
+  if(stackbydimension && stackdimension 
+      && chartProps.rawFormData.groupby){
+    const idxSelectedDimension = formData.metrics.length > 1 ? 1 : 0 
+      + chartProps.rawFormData.groupby.indexOf(stackdimension);

Review Comment:
   ### Incorrect Operator Precedence in Dimension Index Calculation 
<sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The operator precedence in the expression is incorrect. The addition will be 
performed before the ternary operation, leading to incorrect dimension index 
calculation.
   
   ###### Why this matters
   This will cause incorrect stack grouping as the wrong dimension index will 
be used, potentially stacking data points that shouldn't be stacked together.
   
   ###### Suggested change ∙ *Feature Preview*
   Wrap the addition in parentheses to ensure correct operator precedence:
   ```typescript
   const idxSelectedDimension = formData.metrics.length > 1 ? 1 : (0 + 
chartProps.rawFormData.groupby.indexOf(stackdimension));
   ```
   
   
   </details>
   
   <sub>
   
   [![Report a problem with this 
comment](https://img.shields.io/badge/Report%20a%20problem%20with%20this%20comment-gray.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmNWVjMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10cmlhbmdsZS1hbGVydCI+PHBhdGggZD0ibTIxLjczIDE4LTgtMTRhMiAyIDAgMCAwLTMuNDggMGwtOCAxNEEyIDIgMCAwIDAgNCAyMWgxNmEyIDIgMCAwIDAgMS43My0zIi8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4=)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c1decd5d-1fe0-4406-b3fd-793276058a71?suggestedFixEnabled=true)
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:1bd124d4-3d7c-4799-9ab5-7944f45130a5 -->
   



##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx:
##########
@@ -317,6 +319,42 @@
       label: t('Chart Options'),
       expanded: true,
       controlSetRows: [
+        [
+          {
+            name: 'stackbydimension',
+            config: {
+              type: 'CheckboxControl',
+              label: t('Stack by dimension'),
+              default: stackbydimension,
+              renderTrigger: true,
+              description: t('Stack in groups, where each group corresponds to 
a dimension'),
+            },
+          },
+        ],
+        [
+          {
+            name: 'stackdimension',
+            config: {
+              type: 'SelectControl',
+              label: t('Dimension to stack by'),
+              renderTrigger: true,
+              description: t('Stack in groups, where each group corresponds to 
a dimension'),
+              shouldMapStateToProps: (prevState, state, controlState, 
chartState) => {
+                return true;
+              },

Review Comment:
   ### Redundant shouldMapStateToProps Function <sub>![category 
Readability](https://img.shields.io/badge/Readability-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The shouldMapStateToProps function always returns true and serves no 
purpose, making the code unnecessarily complex.
   
   ###### Why this matters
   This adds cognitive overhead as developers need to understand why this 
function exists when it doesn't provide any conditional logic.
   
   ###### Suggested change ∙ *Feature Preview*
   Remove the shouldMapStateToProps property as it's not providing any value:
   ```typescript
   config: {
     type: 'SelectControl',
     label: t('Dimension to stack by'),
     renderTrigger: true,
     description: t('Stack in groups, where each group corresponds to a 
dimension'),
     mapStateToProps: (state, controlState, chartState) => {
   ```
   
   
   </details>
   
   <sub>
   
   [![Report a problem with this 
comment](https://img.shields.io/badge/Report%20a%20problem%20with%20this%20comment-gray.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmNWVjMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10cmlhbmdsZS1hbGVydCI+PHBhdGggZD0ibTIxLjczIDE4LTgtMTRhMiAyIDAgMCAwLTMuNDggMGwtOCAxNEEyIDIgMCAwIDAgNCAyMWgxNmEyIDIgMCAwIDAgMS43My0zIi8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4=)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/d1e852cf-c343-4097-a4c9-14390cb99d4d?suggestedFixEnabled=true)
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:2612b9af-35e0-405f-aa39-ddc2c28b5772 -->
   



##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx:
##########
@@ -317,6 +319,42 @@ const config: ControlPanelConfig = {
       label: t('Chart Options'),
       expanded: true,
       controlSetRows: [
+        [
+          {
+            name: 'stackbydimension',
+            config: {
+              type: 'CheckboxControl',
+              label: t('Stack by dimension'),
+              default: stackbydimension,
+              renderTrigger: true,
+              description: t('Stack in groups, where each group corresponds to 
a dimension'),
+            },
+          },
+        ],
+        [
+          {
+            name: 'stackdimension',
+            config: {
+              type: 'SelectControl',
+              label: t('Dimension to stack by'),

Review Comment:
   ### Missing conditional visibility for stack dimension control 
<sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The stackdimension control is not conditionally visible based on the 
stackbydimension checkbox state.
   
   ###### Why this matters
   Users will see and potentially interact with the stackdimension dropdown 
even when stacking by dimension is disabled, leading to confusion and potential 
misconfigurations.
   
   ###### Suggested change ∙ *Feature Preview*
   Add visibility configuration to the control:
   ```typescript
   name: 'stackdimension',
   config: {
     type: 'SelectControl',
     label: t('Dimension to stack by'),
     visibility: ({ controls }) => Boolean(controls?.stackbydimension?.value),
   ```
   
   
   </details>
   
   <sub>
   
   [![Report a problem with this 
comment](https://img.shields.io/badge/Report%20a%20problem%20with%20this%20comment-gray.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmNWVjMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10cmlhbmdsZS1hbGVydCI+PHBhdGggZD0ibTIxLjczIDE4LTgtMTRhMiAyIDAgMCAwLTMuNDggMGwtOCAxNEEyIDIgMCAwIDAgNCAyMWgxNmEyIDIgMCAwIDAgMS43My0zIi8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4=)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e2e45e12-4303-4ce0-8666-c4afbda7dc47?suggestedFixEnabled=true)
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:ed7ff76a-39dc-4219-97fb-db4ae0ca0b2d -->
   



-- 
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-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to