sadpandajoe opened a new pull request, #44628:
URL: https://github.com/apache/superset/pull/44628

   ### SUMMARY
   Bar charts using a time grain smaller than a day (hourly, 15-minute, etc.) 
rendered
   incorrectly when the query returned data for only a small portion of the 
requested
   range — e.g. one populated hour out of a 24-hour window. Two independent 
frontend
   defects caused this:
   
   1. The only width constraint on a bar series was a flat `barMaxWidth: 100` 
(px),
      unrelated to chart size or the resolved time grain. ECharts' own bandwidth
      fallback for sparse data on a `time`-type axis (80% of the plotted span 
for a
      single point, or the smallest inter-point gap for scattered points) 
already
      computes a width far wider than one grain bucket at typical chart sizes, 
and the
      flat cap didn't correct for that — so a single hourly bucket could render 
several
      hours wide. Fixed by deriving the bar-width cap from the axis's actual 
resolved
      grid area (accounting for legend/label padding and chart orientation) and 
the
      time grain, instead of a flat constant.
   2. When a query response's `coltypes` didn't classify the x-axis column as 
temporal
      (a missing entry, or a raw SQL-type string instead of the expected type
      descriptor), the x-axis silently fell back to a category axis and 
rendered the
      raw millisecond timestamp as its label instead of a formatted date/time. 
Fixed by
      cross-referencing the dataset's own column metadata 
(`is_dttm`/`type_generic`)
      for the chart's actual selected x-axis column, so a real temporal column 
is still
      recognized as such even when a given query response's `coltypes` is 
malformed —
      while a genuinely non-temporal column (e.g. a numeric column under an 
unrelated
      dashboard-level time-grain filter) is correctly left alone.
   
   Both fixes apply to the `Timeseries` and `MixedTimeseries` echarts chart 
plugins.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Before: an hourly-grain bar chart with only one populated hour rendered that 
bar
   stretched across several neighboring (unpopulated) hours, and/or showed raw
   epoch/millisecond values on the x-axis instead of time-of-day labels — 
despite the
   tooltip correctly reporting the single-bucket value on hover.
   
   After: the bar occupies only its own grain interval regardless of how sparse 
the
   returned data is, and the x-axis renders time-of-day labels for a genuinely 
temporal
   column even when a given response's column-type metadata is malformed.
   
   Evidence to follow (independent QA pass against this exact commit).
   
   ### TESTING INSTRUCTIONS
   1. Create or open a chart using `echarts_timeseries_bar` (or 
`MixedTimeseries` with a
      bar series) on a dataset with a datetime column.
   2. Set the time grain to something sub-daily (e.g. hour or 15 minutes).
   3. Filter the time range or dataset so only a small portion of the grain 
buckets in
      the visible window actually have data (e.g. one hour out of 24).
   4. Confirm the bar for the populated bucket is sized to roughly its own grain
      interval (not spanning several neighboring hours), and the x-axis shows
      time-of-day labels, not raw numbers — including when the chart is set to
      horizontal orientation, or the legend takes up significant chart width.
   5. A new regression test at
      
`superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/Bar/sparseSubDailyBarGeometry.test.ts`
      covers both mechanisms directly against the generated chart option 
object; run it
      via `npx jest 
plugins/plugin-chart-echarts/test/Timeseries/Bar/sparseSubDailyBarGeometry.test.ts`
 in `superset-frontend/`.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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]

Reply via email to