bito-code-review[bot] commented on PR #43810:
URL: https://github.com/apache/superset/pull/43810#issuecomment-5520039710
<!-- Bito Reply -->
The flagged issue is correct. The current implementation in
`handleDeprecatedControls` blindly copies `granularity` to `x_axis` for ECharts
timeseries charts, which causes issues when `granularity` is a time grain
(e.g., 'P1D') rather than a column name.
To resolve this, you should validate that the `granularity` value is a valid
column name before assigning it to `x_axis`. Since `handleDeprecatedControls`
does not have access to the datasource metadata, a common approach is to check
if the value looks like a time grain (e.g., starts with 'P') or to ensure it is
not one of the known time grain strings.
Here is a suggested fix for `superset-frontend/src/explore/store.ts`:
```typescript
if (
formData.viz_type &&
echartsTimeseriesVizTypes.has(formData.viz_type) &&
!('x_axis' in formData) &&
formData.granularity &&
!formData.granularity.startsWith('P') // Exclude time grains like P1D
) {
formData.x_axis = formData.granularity;
}
```
There are no other comments on this PR to address.
**superset-frontend/src/explore/store.ts**
```
if (
formData.viz_type &&
echartsTimeseriesVizTypes.has(formData.viz_type) &&
!('x_axis' in formData) &&
formData.granularity &&
!formData.granularity.startsWith('P') // Exclude time grains like P1D
) {
formData.x_axis = formData.granularity;
}
```
--
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]