Repository navigation
Conversation
Adds truncateMetric/truncateMetricB to MixedTimeseries so a grouped
series can drop the "metric, " prefix and show only the groupby/dimension
values, matching the single-query Timeseries truncate_metric behavior.
Reuses the same metric-vs-dimension split the existing "metric, dimension"
branch already applies to the label-map tuple, and runs before the shared
displayLabelMap/displayLabelMapB population so formatter lookups keyed by
the truncated name still resolve correctly.
Also keeps the query-identifier suffix ("(Query A)"/"(Query B)") when
showQueryIdentifiers is on, even while truncating, or Query A and Query B
become indistinguishable whenever they share a groupby value.
Adopted from #38451 (MelikHajlawi), rebuilt against current master since
that branch's history had diverged too far to rebase cleanly.
Co-Authored-By: MelikHajlawi <melik.hajlawi@medtech.tn>
Co-Authored-By: Evan Rusackas <evan@preset.io>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #45555 +/- ##
===========================================
- Coverage 84.63% 65.84% -18.79%
===========================================
Files 3069 3070 +1
Lines 205446 202416 -3030
Branches 48306 47608 -698
===========================================
- Hits 173879 133283 -40596
- Misses 28277 66181 +37904
+ Partials 3290 2952 -338
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… series name Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
WhentruncateMetricand/ortruncateMetricBare enabled whileshowQueryIdentifiersis off,… · New WhentruncateMetricand/ortruncateMetricBare enabled whileshowQueryIdentifiersis off,… · New The truncation logic for Query A and Query B is effectively duplicated (including the multi-line… · New The truncation logic for Query A and Query B is effectively duplicated (including the multi-line… · NewensureIsArray(metrics).length > 1(and the B equivalent) is recomputed for every series entry… · NewensureIsArray(metrics).length > 1(and the B equivalent) is recomputed for every series entry… · New
What changed in this PR
Fixes Mixed Timeseries series naming to honor truncateMetric/truncateMetricB when groupby is set, aligning behavior with single-query Timeseries and preserving query identifier suffixes when enabled.
Changes:
- Add
truncateMetric/truncateMetricBform-data fields (with defaults) for Mixed Timeseries. - Update
MixedTimeseries/transformProps.tsto drop metric prefixes from series names when truncation is enabled and groupby is present (optionally preserving(Query A/B)). - Add Jest coverage for truncation behavior (including multi-dimension groupby and query identifier suffix retention).
| File | Description |
|---|---|
| superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts | Implements truncation-aware series naming for Query A/B when groupby is present. |
| superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts | Adds form-data fields + defaults for truncateMetric and truncateMetricB. |
| superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts | Adds tests validating truncation behavior and identifier suffix handling. |
Review effort: Lite
…mparison Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ames Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
| expect(seriesNames).not.toContain('m1, boy (Query A)'); | ||
| }); | ||
|
|
||
| test('applies the metric count per query: one metric for A, two for B', () => { |
There was a problem hiding this comment.
None of the new cases enable truncation together with a time comparison, or with an empty groupby, so the !hasTimeComparison / !hasTimeComparisonB and groupby.length > 0 guards in transformProps.ts aren't exercised by any test. Swapping time_compare and time_compare_b in those two conditions, or dropping either guard, would still pass this suite, and a comparison series would then collapse into the same truncated name as the current one.
Could you add a case with truncateMetric: true, showQueryIdentifiers: true, and time_compare set only for Query A (then time_compare_b set only for Query B), asserting the compared query keeps its offset-based names while the other query still drops the metric prefix? A mirrored case with groupby: [] and truncation on, asserting the verbose metric name is unchanged, would cover the other guard.
There was a problem hiding this comment.
Added cases for time_compare on A only, time_compare_b on B only, and an empty groupby with truncation on. Swapping the flags or dropping either guard now fails.
…pty groupby Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>



SUMMARY
Adopts #38451 from @MelikHajlawi, which fixes
truncate_metric/truncate_metricBhaving no effect on the Mixed Timeseries chart's series names. With a groupby set, a grouped series always rendered as"<metric>, <dimension>"regardless of the Truncate Metric checkbox, unlike the single-query Timeseries chart.Adds
truncateMetric/truncateMetricBhandling inMixedTimeseries/transformProps.ts: when the flag is on and there's a groupby, the series name drops the metric prefix and shows only the groupby/dimension value(s), reusing the same metric-vs-dimension split the existing"metric, dimension"branch already applies to the label-map tuple. This runs ahead of the shareddisplayLabelMap/displayLabelMapBpopulation, so formatter lookups keyed by the truncated name still resolve correctly.This PR also resolves everything raised across the original PR's review threads:
"(Query A)"/"(Query B)") is now preserved when truncating andshowQueryIdentifiersis on, so Query A and Query B stay distinguishable when they share a groupby value (sadpandajoe/codeant, Aug 21).displayLabelMap/displayLabelMapBpopulation already covers the truncated name on currentmaster(this was a real gap back when the original PR was opened, butmasterhas since grown a shared population step that runs after either branch setsdisplayName).any[]test-assertion nit, the duplicate-debug-log and stray generated files from early revisions, and the "no groupby → blank name" case are all already clean/resolved in this rebuild.DEFAULT_FORM_DATA'struncateMetric/truncateMetricBshould default totrueto match the shared control's default. Deliberately left asfalse: the siblingrenameOperator(which implements the same setting server-side for the single-query Timeseries chart) explicitly treats an omitted field as off (truncate_metric !== undefined && !!truncate_metric), not as the control's UI default. The control'sdefault: trueonly seeds a brand-new chart's checkbox state in Explore; defaulting the transform layer totruewould silently start truncating every existing saved Mixed Timeseries chart with a groupby the next time it renders. Flagging this explicitly in case there's a reason to revisit it, but matching the backend's own semantics seemed safer.inverted[entryName] || entryName(used to resolve Query B's label-map key) could theoretically collide if a groupby value happens to equal another column's verbose label. That's pre-existing shared code the untruncated"metric, dimension"branch already relies on for the exact same lookup, not something this change introduces, so it's out of scope here and worth its own follow-up if it's a real-world problem.Closes #38451
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
See #38451 for the original before/after screenshots - this PR is a straight rebuild of that same fix (plus the thread fixes above) against current
master, with no further UI changes.TESTING INSTRUCTIONS
(Query A)/(Query B)so overlapping groupby values from both queries stay distinguishable.npx jest --runInBand plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts— the newtruncateMetric / truncateMetricBdescribe block covers all of the above.ADDITIONAL INFORMATION