korbit-ai[bot] commented on code in PR #36002:
URL: https://github.com/apache/superset/pull/36002#discussion_r2494402483
##########
superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/controlPanel.tsx:
##########
@@ -145,6 +146,64 @@ const config: ControlPanelConfig = {
[subtitleFontSize],
[showMetricNameControl],
[metricNameFontSizeWithVisibility],
+ [<ControlSubSectionHeader>{t('X Axis')}</ControlSubSectionHeader>],
+ [
+ {
+ name: 'show_x_axis',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show X-axis'),
+ renderTrigger: true,
+ default: false,
+ description: t('Whether to display the X Axis'),
+ },
+ },
+ ],
+ [
+ {
+ name: 'show_x_axis_min_max_labels',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show min/max axis labels'),
+ renderTrigger: true,
+ default: false,
+ description: t(
+ 'When enabled, the axis will display labels for the minimum
and maximum values of your data',
+ ),
+ visibility: ({ controls }: ControlPanelsContainerProps) =>
+ Boolean(controls?.show_x_axis?.value),
+ },
+ },
+ ],
+ [<ControlSubSectionHeader>{t('Y Axis')}</ControlSubSectionHeader>],
+ [
+ {
+ name: 'show_y_axis',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show Y-axis'),
+ renderTrigger: true,
+ default: false,
+ description: t('Whether to display the Y Axis'),
+ },
+ },
+ ],
+ [
+ {
+ name: 'show_y_axis_min_max_labels',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show min/max axis labels'),
+ renderTrigger: true,
+ default: false,
+ description: t(
+ 'When enabled, the axis will display labels for the minimum
and maximum values of your data',
+ ),
+ visibility: ({ controls }: ControlPanelsContainerProps) =>
+ Boolean(controls?.show_y_axis?.value),
Review Comment:
### Unsafe property access in visibility function <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The visibility function for show_y_axis_min_max_labels control may fail if
controls.show_y_axis is undefined or null, potentially causing a runtime error
when accessing the value property.
###### Why this matters
This could cause the control panel to crash or behave unexpectedly when the
show_y_axis control hasn't been initialized yet or is in an undefined state.
###### Suggested change ∙ *Feature Preview*
Add additional safety checks to handle undefined controls:
```typescript
visibility: ({ controls }: ControlPanelsContainerProps) =>
Boolean(controls?.show_y_axis?.value)
```
Or more defensively:
```typescript
visibility: ({ controls }: ControlPanelsContainerProps) =>
controls?.show_y_axis?.value === true
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1ba93128-a040-4825-afa4-18861e357acc/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1ba93128-a040-4825-afa4-18861e357acc?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1ba93128-a040-4825-afa4-18861e357acc?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1ba93128-a040-4825-afa4-18861e357acc?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1ba93128-a040-4825-afa4-18861e357acc)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:54005ded-1596-43a0-809a-59fd3f074491 -->
[](54005ded-1596-43a0-809a-59fd3f074491)
##########
superset-frontend/plugins/plugin-chart-echarts/src/BigNumber/BigNumberWithTrendline/controlPanel.tsx:
##########
@@ -145,6 +146,64 @@ const config: ControlPanelConfig = {
[subtitleFontSize],
[showMetricNameControl],
[metricNameFontSizeWithVisibility],
+ [<ControlSubSectionHeader>{t('X Axis')}</ControlSubSectionHeader>],
+ [
+ {
+ name: 'show_x_axis',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show X-axis'),
+ renderTrigger: true,
+ default: false,
+ description: t('Whether to display the X Axis'),
+ },
+ },
+ ],
+ [
+ {
+ name: 'show_x_axis_min_max_labels',
+ config: {
+ type: 'CheckboxControl',
+ label: t('Show min/max axis labels'),
+ renderTrigger: true,
+ default: false,
+ description: t(
+ 'When enabled, the axis will display labels for the minimum
and maximum values of your data',
+ ),
+ visibility: ({ controls }: ControlPanelsContainerProps) =>
+ Boolean(controls?.show_x_axis?.value),
Review Comment:
### Unsafe property access in visibility function <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The visibility function for show_x_axis_min_max_labels control may fail if
controls.show_x_axis is undefined or null, potentially causing a runtime error
when accessing the value property.
###### Why this matters
This could cause the control panel to crash or behave unexpectedly when the
show_x_axis control hasn't been initialized yet or is in an undefined state.
###### Suggested change ∙ *Feature Preview*
Add additional safety checks to handle undefined controls:
```typescript
visibility: ({ controls }: ControlPanelsContainerProps) =>
Boolean(controls?.show_x_axis?.value)
```
Or more defensively:
```typescript
visibility: ({ controls }: ControlPanelsContainerProps) =>
controls?.show_x_axis?.value === true
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fc3477a6-abe9-4086-b62e-9958752a73ed/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fc3477a6-abe9-4086-b62e-9958752a73ed?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fc3477a6-abe9-4086-b62e-9958752a73ed?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fc3477a6-abe9-4086-b62e-9958752a73ed?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/fc3477a6-abe9-4086-b62e-9958752a73ed)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:f6f38c02-f203-4a4c-b01c-e4d5ec52d6fb -->
[](f6f38c02-f203-4a4c-b01c-e4d5ec52d6fb)
--
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]