Skip to content

fix(echarts): correct time shift handling in Timeseries transformProps#38126

Open
YousufFFFF wants to merge 2 commits intoapache:masterfrom
YousufFFFF:fix/echarts-annotation-timeshift
Open

fix(echarts): correct time shift handling in Timeseries transformProps#38126
YousufFFFF wants to merge 2 commits intoapache:masterfrom
YousufFFFF:fix/echarts-annotation-timeshift

Conversation

@YousufFFFF
Copy link
Contributor

SUMMARY

This PR fixes incorrect time shift behavior in the ECharts Timeseries path used by the Bar chart.
Fixes #36966.

Previously, when a time shift (e.g., 1 month, 5 months) was applied, the shifted series was not properly aligned during series construction inside transformProps.ts. This caused incorrect rendering and misalignment of shifted data along the x-axis.

This update corrects the time shift handling logic to ensure proper timestamp alignment and consistent rendering across different shift values and dimension combinations.


BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before (Time Shift Not Functioning Correctly)

  • Time shift not reflected properly on x-axis

After (Time Shift Working as Expected)

Base.Test.-.Google.Chrome.2026-02-20.23-36-29.mp4
  • Shifted series aligns correctly with timestamps
  • Multiple shift values render properly
  • Behavior consistent with expected time shift semantics

TESTING INSTRUCTIONS

  1. Create a Bar Chart
  2. Select Timeseries mode
  3. Add a metric
  4. Apply a Time Shift (e.g., 1 month, 5 months)
  5. Optionally add one or more Dimensions
  6. Verify:
    • Shifted series renders correctly
    • X-axis alignment is accurate
    • No duplicated or broken series
    • Chart behaves consistently across different shift values

Tested locally using Docker environment.


ADDITIONAL INFORMATION

  • Has associated issue: Fixes Certain Annotation Options Have No Effect in Time Series Annotations #36966
  • 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

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 20, 2026

Code Review Agent Run #1b0812

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts - 1
    • Type Safety Violation · Line 685-685
      The 'as any' type assertion is unnecessary here, as 'layer.overrides?.time_shift' is properly typed according to the TimeseriesAnnotationLayer interface. This violates the repository's TypeScript standards that prohibit 'any' types.
      Code suggestion
       @@ -684,3 +684,3 @@
      -  const shiftMs = parseTimeShiftToMs(
      -  (layer as any)?.overrides?.time_shift,
      -  );
      +  const shiftMs = parseTimeShiftToMs(
      +  layer?.overrides?.time_shift,
      +  );
Review Details
  • Files reviewed - 1 · Commit Range: 5894a6d..5894a6d
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.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

@dosubot dosubot bot added the viz:charts:timeseries Related to Timeseries label Feb 20, 2026
@netlify
Copy link

netlify bot commented Feb 20, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 837d432
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/699968aac85e380008892af1
😎 Deploy Preview https://deploy-preview-38126--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@YousufFFFF YousufFFFF force-pushed the fix/echarts-annotation-timeshift branch from 5894a6d to e5221d6 Compare February 21, 2026 05:35
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 21, 2026

Code Review Agent Run #dc6bb3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: e5221d6..e5221d6
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.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

@YousufFFFF YousufFFFF force-pushed the fix/echarts-annotation-timeshift branch from e83c65c to 837d432 Compare February 21, 2026 08:11
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Feb 21, 2026

Code Review Agent Run #f8bf02

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts - 1
    • Duplicate Test Assertion · Line 309-309
      The assertion expect(formulaSeries).toBeDefined() appears twice in this test block, which is redundant and may indicate a copy-paste error during refactoring. Consider removing the second occurrence for cleaner test code.
Review Details
  • Files reviewed - 3 · Commit Range: 04d8cad..837d432
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.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

@YousufFFFF YousufFFFF force-pushed the fix/echarts-annotation-timeshift branch from 837d432 to eb1b3be Compare February 21, 2026 09:30
Copy link
Contributor

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #aee9e6

Actionable Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts - 1
Review Details
  • Files reviewed - 3 · Commit Range: 04d8cad..eb1b3be
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.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

Comment on lines +684 to +702
const shiftMs = parseTimeShiftToMs((layer as any)?.overrides?.time_shift);

const result = annotationData[name];
const isHorizontal = orientation === OrientationType.Horizontal;
const { records } = result;
if (records) {
const data = records.map(record => {
const keys = Object.keys(record);
const x = keys.length > 0 ? record[keys[0]] : 0;

let x = keys.length > 0 ? record[keys[0]] : 0;
const y = keys.length > 1 ? record[keys[1]] : 0;

if (shiftMs !== 0 && x != null) {
const xMs = typeof x === 'string' ? new Date(x).getTime() : Number(x);

if (!Number.isNaN(xMs)) {
x = xMs + shiftMs;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add tests for time_shift feature

The new time_shift feature in transformTimeseriesAnnotation lacks test coverage. Existing tests in transformers.test.ts verify data transformation but don't test the time shifting logic added here.

Code Review Run #aee9e6


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Certain Annotation Options Have No Effect in Time Series Annotations

1 participant