sadpandajoe commented on code in PR #43770:
URL: https://github.com/apache/superset/pull/43770#discussion_r4239560831
##########
superset/mcp_service/chart/preview_utils.py:
##########
@@ -1809,7 +1815,1060 @@ def generate_xy_vega_lite_preview(
spec["transform"] = [
{"fold": series_columns, "as": [series_field, value_field]}
]
- encoding["y"] = {"field": value_field, "type": "quantitative"}
+ # Vega-Lite stacks bar and area marks colored by a nominal field
+ # by default; follow the chart's saved ``stack`` control instead.
+ encoding["y"] = {
+ "field": value_field,
+ "type": "quantitative",
+ "stack": _xy_vega_lite_stack(form_data.get("stack")),
+ }
encoding["color"] = {"field": series_field, "type": "nominal"}
+ if (
+ spec.get("mark") == "bar"
+ and encoding["y"]["stack"] is None
+ and "x" in encoding
+ ):
+ # Unstacked bars sit side by side like Explore's grouped bars.
+ # Offset channels need a discrete band x scale, so temporal
+ # values stay date-formatted through a full-precision time
unit.
+ x_encoding = encoding["x"]
+ if x_encoding.get("type") == "temporal":
+ x_encoding["timeUnit"] = "yearmonthdatehoursminutesseconds"
Review Comment:
The `yearmonthdatehoursminutesseconds` time unit bins timestamps to whole
seconds, not full precision as the comment says. For an unstacked
`echarts_timeseries_bar` with `groupby=["region"]` and rows at
`2026-01-01T12:00:00.100` and `2026-01-01T12:00:00.900`, both land in the same
x band, so same-series bars overlap and one observation is hidden, while
Explore keeps them distinct. The test at
`test_review_query_and_preview_regressions.py:304` pins that second-level unit.
Should this use a unit that keeps milliseconds, or skip the unit and bin by the
actual timestamp values?
--
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]