Skip to content

fix(plugin-chart-echarts): fallback temporal formatters when labels would show NaN#39208

Open
JCelento wants to merge 5 commits intoapache:masterfrom
JCelento:fix/echarts-timeseries-epoch-x-axis-labels
Open

fix(plugin-chart-echarts): fallback temporal formatters when labels would show NaN#39208
JCelento wants to merge 5 commits intoapache:masterfrom
JCelento:fix/echarts-timeseries-epoch-x-axis-labels

Conversation

@JCelento
Copy link
Copy Markdown
Contributor

@JCelento JCelento commented Apr 8, 2026

SUMMARY

Temporal tooltips and x-axis labels on ECharts Timeseries and Mixed timeseries charts could render strings
containing NaN when the primary d3-based formatter failed on invalid or edge-case timestamp values.
This change introduces withNaNFallback in plugin-chart-echarts to wrap the existing tooltip and x-axis
temporal formatters: if the primary result is not a safe string (contains NaN, or throws), we fall back to the
smart date / verbose smart date formatters, and finally String(value) so labels never show as broken NaN text.

TESTING INSTRUCTIONS

  1. Open a Timeseries or Mixed timeseries chart with a temporal x-axis.
  2. Use data or settings that previously produced invalid-date formatting (e.g. numeric epoch-ms column treated as
    time where formatting could fail).
  3. Confirm x-axis labels and tooltip timestamps show sensible dates or raw values, not NaN /
    NaN/NaN/NaN style output.
  4. Run frontend tests for the plugin:
    cd superset-frontend && npm test -- plugins/plugin-chart-echarts/test/ (or your usual test command for that
    package).

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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
Copy Markdown
Contributor

bito-code-review bot commented Apr 8, 2026

Code Review Agent Run #688c4b

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts - 1
    • Redundant Date validation in epoch check · Line 945-945
      The Date constructor check `!Number.isNaN(new Date(n).getTime())` is unnecessary, as JavaScript's Date constructor accepts any finite number within the valid range (ensured by prior checks) and returns it unchanged.
      Code suggestion
       @@ -945,1 +945,1 @@
      -  return !Number.isNaN(new Date(n).getTime());
      +  return true;
Review Details
  • Files reviewed - 8 · Commit Range: a6f8329..5db7b68
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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

@dosubot dosubot bot added plugins viz:charts:echarts Related to Echarts viz:charts:timeseries Related to Timeseries labels Apr 8, 2026
@JCelento JCelento force-pushed the fix/echarts-timeseries-epoch-x-axis-labels branch from 5db7b68 to 40365c9 Compare April 8, 2026 20:16
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 8, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 5db7b68
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69d6b72ee8aba00008b6cdde
😎 Deploy Preview https://deploy-preview-39208--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.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 8, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit b35850b
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69d9017590fe43000895d419
😎 Deploy Preview https://deploy-preview-39208--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.

@JCelento JCelento force-pushed the fix/echarts-timeseries-epoch-x-axis-labels branch from 1b6cff6 to 8c645e4 Compare April 8, 2026 21:09
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 8, 2026

Code Review Agent Run #06cc12

Actionable Suggestions - 0
Review Details
  • Files reviewed - 8 · Commit Range: 8f52708..8c645e4
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 92.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.43%. Comparing base (e9911fb) to head (70cca18).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...d/plugins/plugin-chart-echarts/src/utils/series.ts 86.84% 5 Missing ⚠️
...ugins/plugin-chart-echarts/src/utils/formatters.ts 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39208      +/-   ##
==========================================
+ Coverage   64.40%   64.43%   +0.02%     
==========================================
  Files        2553     2553              
  Lines      132558   132616      +58     
  Branches    30746    30765      +19     
==========================================
+ Hits        85377    85447      +70     
+ Misses      45695    45683      -12     
  Partials     1486     1486              
Flag Coverage Δ
javascript 66.13% <92.00%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@JCelento JCelento force-pushed the fix/echarts-timeseries-epoch-x-axis-labels branch 2 times, most recently from dea3109 to e677a20 Compare April 9, 2026 20:08
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 9, 2026

Code Review Agent Run #ab9d86

Actionable Suggestions - 0
Review Details
  • Files reviewed - 8 · Commit Range: e34000a..e677a20
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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

@JCelento JCelento force-pushed the fix/echarts-timeseries-epoch-x-axis-labels branch 2 times, most recently from ff8e2ae to 06269c4 Compare April 9, 2026 21:30
Copy link
Copy Markdown
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 #cf00b3

Actionable Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts - 1
Review Details
  • Files reviewed - 8 · Commit Range: 3c97222..06269c4
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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 173 to +176
export function getXAxisFormatter(
format?: string,
timeGrain?: string,
): TimeFormatter | StringConstructor | undefined {
): TimeFormatter | undefined {
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.

Type Mismatch in Return Type

The getXAxisFormatter function's return type is declared as TimeFormatter | undefined, but the implementation always returns a TimeFormatter. This type mismatch could confuse callers and lead to unnecessary null checks, especially since existing usage asserts non-null with '!'. Update the type to match the actual behavior.

Code suggestion
Check the AI-generated fix before applying
Suggested change
export function getXAxisFormatter(
format?: string,
timeGrain?: string,
): TimeFormatter | StringConstructor | undefined {
): TimeFormatter | undefined {
export function getXAxisFormatter(
format?: string,
timeGrain?: string,
): TimeFormatter {

Code Review Run #cf00b3


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

  • Yes, avoid them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

getInstance().get(formatId) at line 73 of TimeFormatterRegistrySingleton.ts can return undefined

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.

No, the suggestion isn’t fully correct — getTimeFormatter can return undefined when an unrecognized format is passed, so getXAxisFormatter may also return undefined in that case.

superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts

export function getXAxisFormatter(
  format?: string,
  timeGrain?: string,
): TimeFormatter | undefined {
  if (format === SMART_DATE_ID || !format) {
    return getSmartDateFormatter(timeGrain);
  }
  return getTimeFormatter(format);
}

@JCelento JCelento force-pushed the fix/echarts-timeseries-epoch-x-axis-labels branch 2 times, most recently from 2b8d12c to 700eb81 Compare April 10, 2026 13:53
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 10, 2026

Code Review Agent Run #a13ce3

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts - 1
    • Broad Exception Handling · Line 204-204
      The `withNaNFallback` function uses bare `catch` blocks, which violates the guideline to avoid broad exception catches. While functional here for fallback handling, specifying `catch (error: unknown)` improves clarity and adheres to best practices.
Review Details
  • Files reviewed - 8 · Commit Range: 62d188b..b35850b
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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

@JCelento JCelento force-pushed the fix/echarts-timeseries-epoch-x-axis-labels branch from b35850b to 8a94469 Compare April 10, 2026 17:22
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 10, 2026

Code Review Agent Run #1b4967

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts - 1
    • Redundant Date Validation Check · Line 938-946
      The isLikelyEpochMilliseconds function has a redundant check `return !Number.isNaN(new Date(n).getTime());` that is always true when the prior conditions pass, since `new Date(n).getTime()` returns `n` for any finite `n`. This can be simplified by changing it to `return true;` for clarity and to avoid unnecessary computation.
      Code suggestion
       @@ -945,1 +945,1 @@
      -  return !Number.isNaN(new Date(n).getTime());
      +  return true;
Review Details
  • Files reviewed - 8 · Commit Range: 97dc950..8a94469
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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

…r and getXAxisFormatter

getTooltipTimeFormatter previously returned StringConstructor when no
format was provided, and getXAxisFormatter had an unreachable return String
branch. Both are passed to withNaNFallback which requires TimeFormatter,
causing TS2345 type errors. Changed both to always return TimeFormatter
by defaulting to smart date formatters instead of String.
@JCelento JCelento force-pushed the fix/echarts-timeseries-epoch-x-axis-labels branch from 8a94469 to 70cca18 Compare April 10, 2026 19:01
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Apr 10, 2026

Code Review Agent Run #2daf30

Actionable Suggestions - 0
Review Details
  • Files reviewed - 8 · Commit Range: 99912c8..70cca18
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/formatters.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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

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.

1 participant