feat(time-pivot): migrate time_pivot chart to v1 chart data API - #41727
Conversation
Adds a buildQuery mirroring the legacy NVD3TimePivotViz.query_obj (a timeseries query with the single metric) and ports the get_data reshape into a transformData helper: timestamps are bucketed by a pandas-style offset rollback (AS/A, MS/M, W and W-XXX, D, H, T aliases; multiplier prefixes keep the same anchor), periods ranked most-recent-first as current/-1/-2, points shifted onto the latest period's time axis, and one series emitted per period with the legacy rank/perc metadata. A TimePivot-specific transformProps reshapes v1 records before delegating to the shared nvd3 transformProps; legacy payloads pass through. No DB migration needed: viz_type is unchanged and legacy granularity_sqla/time_range form data flows through extractExtras. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bito Automatic Review Skipped - Branch Excluded |
|
The suggestion to replace the To resolve this, you can replace the test('builds a timeseries query with the single metric', () => {
const formData: QueryFormData = {
datasource: '5__table',
granularity_sqla: 'ds',
time_range: 'Last quarter',
viz_type: 'time_pivot',
metric: 'sum__num',
freq: 'W-MON',
};
const [query] = buildQuery(formData).queries;
expect(query.metrics).toEqual(['sum__num']);
expect(query.is_timeseries).toBe(true);
});Would you like me to check the rest of the comments on this PR and implement fixes for them as well? superset-frontend/plugins/legacy-preset-chart-nvd3/test/TimePivot.test.ts |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## remove-legacy-viz-pipeline #41727 +/- ##
===========================================================
Coverage 64.08% 64.09%
===========================================================
Files 2687 2690 +3
Lines 148467 148562 +95
Branches 34262 34292 +30
===========================================================
+ Hits 95147 95220 +73
- Misses 51558 51580 +22
Partials 1762 1762
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:
|
…ribe Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
SUMMARY
Tier 2 of #41714 (targets
remove-legacy-viz-pipeline): migrate the nvd3 Time-series Period Pivot (time_pivot) offexplore_jsononto/api/v1/chart/data.TimePivot/buildQuery.tsmirroring the legacyNVD3TimePivotViz.query_obj: timeseries query with the single metric.get_datareshape is ported totransformData: timestamps are bucketed into periods with a pandas-compatibleoffset.rollback(normalize=True)implementation covering the frequency control's aliases (AS/A,MS/M,W/W-XXXincl. multiplier prefixes like52W-MON,D,H,T; freeform rules fall back to day boundaries), periods are dense-ranked most-recent-first (current,-1,-2, …), points are shifted onto the latest period's time axis, and each period becomes a series carrying the legacyrank/percmetadata.transformPropsreshapes v1 records and then delegates to the shared nvd3transformProps, so legacy payloads pass through untouched.useLegacyApi: trueremoved (and the "Legacy" tag dropped).viz_typeunchanged.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
No visual change — same renderer, same data shape, different endpoint.
TESTING INSTRUCTIONS
npm run test -- plugins/legacy-preset-chart-nvd3— 10 new Jest tests (rollback per alias incl. month-end and multiplier-prefix weeks, period pivot with rank/perc, axis shifting, empty input); 47 total pass.POST /api/v1/chart/data; period overlays identical.ADDITIONAL INFORMATION
🤖 Generated with Claude Code