Skip to content

feat(chart): enable cross-filter on temporal x-axis (bar/label click) - #42792

Open
reveha wants to merge 3 commits into
apache:masterfrom
reveha:feat/temporal-xaxis-cross-filter
Open

feat(chart): enable cross-filter on temporal x-axis (bar/label click)#42792
reveha wants to merge 3 commits into
apache:masterfrom
reveha:feat/temporal-xaxis-cross-filter

Conversation

@reveha

@reveha reveha commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

Currently, clicking a bar or an axis label on a time-based (temporal) X-axis
does not trigger cross-filtering when no dimension/groupby is set — unlike the
existing categorical X-axis cross-filter support (#37407, #41111). This PR
extends that same no-dimension cross-filter capability to temporal X-axes.

  • Extend canCrossFilterByXAxis to support AxisType.Time in addition to
    AxisType.Category, gated by !hasDimensions
  • Add temporal TEMPORAL_RANGE data mask generation using
    createTimeRangeFromGranularity (day/month/year granularities)
  • Apply a +1ms adjustment to convert the utility's inclusive end into the
    backend's upper-exclusive bound, per get_time_filter semantics in
    superset/models/helpers.py
  • Add triggerEvent: true for temporal X-axis when no dimensions are set,
    enabling axis-label click events
  • Register an orientation-aware query event handler (xAxis/yAxis) guarded
    by targetType === 'axisLabel', covering both categorical and temporal
    label clicks
  • Fix a horizontal-orientation point-click bug reading the wrong tuple index
    (metric value instead of axis value) for the temporal cross-filter path,
    using the same orientation-aware extraction already used for the
    categorical path
  • Add regression tests covering day/month/year point-click and
    axis-label-click payloads, toggle behavior, horizontal/vertical
    orientation, and no-op behavior when dimensions are set

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — behavioral fix, no UI changes.

TESTING INSTRUCTIONS

  1. Create a bar chart (echarts_timeseries_bar) with no dimension/groupby,
    a temporal X-axis column, and any time grain (day/month/year).
  2. Add it to a dashboard alongside a target chart sharing the same temporal
    column, and enable cross-filtering.
  3. Click a bar → the target chart filters to the clicked time bucket via a
    TEMPORAL_RANGE filter.
  4. Click the same bar again → the filter clears (toggle behavior).
  5. Click an X-axis label directly → same cross-filter behavior as clicking
    the bar.
  6. Repeat steps 1–5 with orientation: horizontal — verify the correct time
    bucket is used (not the metric value).
  7. Set a groupby/dimension on the chart → clicking bars or labels should NOT
    trigger this temporal cross-filter path (existing dimension-based
    behavior applies instead).

Automated: npm run test -- EchartsTimeseries.test.tsx transformProps.test.ts

ADDITIONAL INFORMATION

  • Has associated issue: Related to Cross filtering by time range from time-based chart #31302 (community discussion reporting the same gap)
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

- Extend canCrossFilterByXAxis to support AxisType.Time in addition to AxisType.Category, gated by !hasDimensions
- Add temporal TEMPORAL_RANGE data mask generation using createTimeRangeFromGranularity (day/month/year granularities)
- Apply +1ms adjustment to convert inclusive end to backend's upper-exclusive bound, per get_time_filter semantics in superset/models/helpers.py
- Add triggerEvent: true for temporal x-axis when no dimensions are set, enabling axis-label click events
- Register orientation-aware query event handler (xAxis/yAxis) guarded by targetType === 'axisLabel' for both categorical and temporal label clicks
- Fix horizontal-orientation point click reading the wrong tuple index (metric value instead of axis value) for the temporal cross-filter path, using the same orientation-aware extraction as the categorical path
- Add regression tests covering day/month/year point-click and axis-label-click payloads, toggle behavior, horizontal/vertical orientation, and no-op behavior when dimensions are set
Copilot AI lite review requested due to automatic review settings August 5, 2026 07:51
@dosubot dosubot Bot added change:frontend Requires changing the frontend dashboard:cross-filters Related to the Dashboard cross filters viz:charts:bar Related to the Bar chart labels Aug 5, 2026
@bito-code-review

bito-code-review Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #6ac577

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx - 1
    • Missing callback dependency · Line 382-382
      The series click handler's useCallback at line 363 is missing `handleTimeAxisChange` in its dependency array (line 382), while `handleXAxisLabelClick` correctly includes it at line 505. This inconsistency could cause stale closures when the handler references the time axis change function.
Review Details
  • Files reviewed - 5 · Commit Range: 79aa206..79aa206
    • superset-frontend/packages/superset-ui-core/src/time-format/index.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.test.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@netlify

netlify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 79aa206
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a72eb8546fb1a00088ceac7
😎 Deploy Preview https://deploy-preview-42792--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.29730% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.81%. Comparing base (1605676) to head (fe09dae).
⚠️ Report is 14 commits behind head on master.

Files with missing lines Patch % Lines
...chart-echarts/src/Timeseries/EchartsTimeseries.tsx 97.26% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42792      +/-   ##
==========================================
+ Coverage   65.79%   65.81%   +0.02%     
==========================================
  Files        2842     2842              
  Lines      162106   162169      +63     
  Branches    37148    37183      +35     
==========================================
+ Hits       106653   106738      +85     
+ Misses      53388    53366      -22     
  Partials     2065     2065              
Flag Coverage Δ
javascript 72.11% <97.29%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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.

This PR enables cross-filtering on temporal (time) X-axes for ECharts timeseries charts when no dimensions are set, including both point clicks and axis-label clicks.

Changes:

  • Enable triggerEvent for AxisType.Time X-axes (when groupby is empty) to support axis-label click events.
  • Add temporal TEMPORAL_RANGE data mask generation based on configured time grain (with an upper-exclusive end).
  • Update click/label-click handlers to be orientation-aware and support time axes; add regression tests for the new behaviors.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts Adds a regression test ensuring temporal x-axis enables triggerEvent when no dimensions are set.
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts Extends triggerEvent enabling logic to include AxisType.Time.
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx Implements temporal x-axis cross-filtering via point/label clicks and orientation-aware value extraction.
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.test.tsx Adds extensive tests for temporal cross-filter payloads, toggling, and orientation behavior.
superset-frontend/packages/superset-ui-core/src/time-format/index.ts Exposes createTimeRangeFromGranularity from @superset-ui/core.

…s-filter

- Use resolvedTimeGrain (dashboard-level override aware) instead of formData.timeGrainSqla directly when generating temporal cross-filter masks, keeping click behavior consistent with the rendered axis grain
- Add missing AxisType.Time branch to context-menu cross-filter generation, matching existing point-click support
- Fix lint/typecheck/pre-commit CI failures
- Add regression tests for both fixes
…, logging, formatting, tests)

- Handle string-typed axis values in temporal point-click path, matching axis-label click parsing
- Replace console.warn with project logging convention
- Verify/harden millisecond precision in temporal range end formatting to protect the +1ms exclusivity adjustment
- Switch debounce-dependent tests to Jest fake timers for speed and determinism
- Add regression tests to close Codecov-reported coverage gaps
@bito-code-review

bito-code-review Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4f9369

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.test.tsx - 1
    • New test validates utility function outside its module · Line 513-528
      This new test validates the behavior of `createTimeRangeFromGranularity` from `@superset-ui/core` — a unit-test concern that belongs at the source of that function, not in a component integration test file. This creates divergence risk if the utility is refactored.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.test.tsx - 1
Review Details
  • Files reviewed - 5 · Commit Range: 79aa206..fe09dae
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.test.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/types.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dashboard:cross-filters Related to the Dashboard cross filters packages plugins size/XL viz:charts:bar Related to the Bar chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants