Skip to content

feat(theme): enable generalized ECharts theme overrides for array properties#37965

Merged
rusackas merged 1 commit into
masterfrom
fix/echarts-series-theme-overrides
Mar 3, 2026
Merged

feat(theme): enable generalized ECharts theme overrides for array properties#37965
rusackas merged 1 commit into
masterfrom
fix/echarts-series-theme-overrides

Conversation

@rusackas
Copy link
Copy Markdown
Member

Summary

This PR adds a custom merge function for ECharts theme overrides that enables theme authors to apply default styles to all items in array-based ECharts options (like series, xAxis, yAxis, dataZoom, etc.) using a simple object syntax.

The Problem

Previously, mergeReplaceArrays would replace arrays entirely. This made it impossible to set default styles for all series items via theme overrides:

// ❌ BEFORE: This didn't work!
echartsOptionsOverridesByChartType: {
  echarts_bar: {
    // Specifying series as an object was ignored because the chart's
    // series is an array, and object-to-array merge doesn't make sense
    series: { itemStyle: { borderRadius: 4 } }
  }
}

The only workaround was to replace the entire series array, which would break the chart since you'd lose all the actual data.

The Solution

The new mergeEchartsThemeOverrides function detects when you're merging an object into an array and applies the object to each array item:

// ✅ AFTER: This now works!
echartsOptionsOverridesByChartType: {
  echarts_bar: {
    // Applied to ALL bar series - each one gets borderRadius: 4
    series: { itemStyle: { borderRadius: 4 } },
    // Applied to ALL y-axes (for charts with multiple axes)
    yAxis: { axisLabel: { rotate: 45 } }
  }
}

What's Now Possible

Override Effect
series: { itemStyle: { borderRadius: 4 } } All series get rounded corners
series: { label: { show: true, fontSize: 12 } } All series show labels
xAxis: { axisLabel: { rotate: 45 } } All x-axes get rotated labels
yAxis: { splitLine: { show: false } } All y-axes hide grid lines
dataZoom: { filterMode: 'filter' } All data zoom controls use filter mode

Backward Compatibility

Array overrides still replace entirely (existing behavior preserved):

// This still works as before - replaces the entire series array
series: [{ type: 'pie', data: [...] }]

Test plan

  • 18 unit tests covering all scenarios
  • TypeScript compiles correctly
  • Basic deep merge behavior preserved
  • Array replacement (backward compat) still works
  • Object-to-array merging works for series, xAxis, yAxis, dataZoom
  • Edge cases handled (non-object items, empty overrides, missing properties)

🤖 Generated with Claude Code

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Feb 13, 2026

Code Review Agent Run #24379b

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/utils/themeOverrides.ts - 1
    • Type Safety: Prohibited 'any' Types · Line 69-70
      The function signature and customizer use 'any' types, which violates the project's TypeScript standards that explicitly prohibit 'any' in favor of proper types. Consider using 'unknown' or more specific types like 'Record' for better type safety.
      Code suggestion
       @@ -69,2 +69,2 @@
      - export function mergeEchartsThemeOverrides<T = any>(...sources: any[]): T {
      -   const customizer = (objValue: any, srcValue: any): any => {
      + export function mergeEchartsThemeOverrides<T = unknown>(...sources: unknown[]): T {
      +   const customizer = (objValue: unknown, srcValue: unknown): unknown => {
Review Details
  • Files reviewed - 3 · Commit Range: cfc9e0a..cfc9e0a
    • superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/themeOverrides.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/themeOverrides.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 change:frontend Requires changing the frontend label Feb 13, 2026
@codeant-ai-for-open-source
Copy link
Copy Markdown
Contributor

Sequence Diagram

Shows how the Echart component now uses a custom merge function to apply theme overrides — including applying an object override to every item of array-based ECharts options — and then sets the merged options on the chart. This is the core behavior introduced in the PR.

sequenceDiagram
    participant EchartComponent
    participant ThemeMergeUtil as mergeEchartsThemeOverrides
    participant ECharts as ChartInstance

    EchartComponent->>ThemeMergeUtil: merge(baseTheme, echartOptions, globalOverrides, chartOverrides)
    ThemeMergeUtil-->>EchartComponent: mergedOptions (object-to-array merge: object applied to each array item; arrays in source replace dest)
    EchartComponent->>ECharts: setOption(mergedOptions, true)
    ECharts-->>EchartComponent: render updated chart
Loading

Generated by CodeAnt AI

@rusackas rusackas force-pushed the fix/echarts-series-theme-overrides branch from cfc9e0a to c8c4167 Compare February 13, 2026 16:52
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 13, 2026

Deploy Preview for superset-docs-preview ready!

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

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Feb 13, 2026

Code Review Agent Run #a4713b

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: c8c4167..c8c4167
    • superset-frontend/packages/superset-core/src/ui/theme/Theme.test.tsx
    • superset-frontend/packages/superset-core/src/ui/theme/Theme.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/themeOverrides.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/themeOverrides.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

@bito-code-review
Copy link
Copy Markdown
Contributor

Yes, it's possible to define more precise types for the echartsOptionsOverrides and echartsOptionsOverridesByChartType values using ECharts' type definitions from the echarts library, such as EChartsOption or specific chart option interfaces, instead of 'any' for better type safety and IntelliSense support.

@rusackas rusackas requested a review from Vitor-Avila February 24, 2026 18:26
Copy link
Copy Markdown
Contributor

@Vitor-Avila Vitor-Avila left a comment

Choose a reason for hiding this comment

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

Worth addressing @SBIN2010's comment, but overall lgtm!

@rusackas rusackas force-pushed the fix/echarts-series-theme-overrides branch from c8c4167 to c2005e5 Compare March 2, 2026 18:02
@rusackas
Copy link
Copy Markdown
Member Author

rusackas commented Mar 2, 2026

Should be all good if CI passes.

@codeant-ai-for-open-source
Copy link
Copy Markdown
Contributor

Sequence Diagram

This PR enables theme authors to apply default styles to all array items (series, axes) using object syntax. The new merge function detects object-to-array merges and applies the object to each array item.

sequenceDiagram
    participant ThemeConfig
    participant SupersetTheme
    participant EchartComponent
    participant mergeEchartsThemeOverrides

    ThemeConfig->>SupersetTheme: Pass echartsOptionsOverrides (config fix)
    
    EchartComponent->>mergeEchartsThemeOverrides: Merge baseTheme + chartOptions + overrides
    
    mergeEchartsThemeOverrides->>mergeEchartsThemeOverrides: Detect object-to-array<br/>(e.g., series: {...} → series: [{...}, {...}])
    
    mergeEchartsThemeOverrides->>mergeEchartsThemeOverrides: Apply object props to EACH array item
    
    mergeEchartsThemeOverrides-->>EchartComponent: Themed ECharts options
Loading

Generated by CodeAnt AI

…perties

Adds a custom merge function `mergeEchartsThemeOverrides` that handles
ECharts theme overrides with special array-to-object merge behavior:

1. Arrays in source values replace destination arrays entirely (backward compat)
2. When source is a plain object and destination is an array, the object
   is merged into each array item (allowing default styles for all items)

This enables theme authors to write intuitive overrides like:

```js
echartsOptionsOverridesByChartType: {
  echarts_bar: {
    series: { itemStyle: { borderRadius: 4 } },  // Applied to ALL series
    yAxis: { axisLabel: { rotate: 45 } }         // Applied to ALL y-axes
  }
}
```

Works for any array-based ECharts option: series, xAxis, yAxis, dataZoom,
visualMap, etc. - no need to handle each property specially.

Also fixes a bug where `echartsOptionsOverrides` and
`echartsOptionsOverridesByChartType` were not being passed through from
the theme config to the SupersetTheme object.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rusackas rusackas force-pushed the fix/echarts-series-theme-overrides branch from c2005e5 to 8437101 Compare March 2, 2026 18:47
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Mar 2, 2026

Code Review Agent Run #04e0db

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: 8437101..8437101
    • superset-frontend/packages/superset-core/src/ui/theme/Theme.test.tsx
    • superset-frontend/packages/superset-core/src/ui/theme/Theme.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/themeOverrides.test.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/themeOverrides.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

@rusackas rusackas merged commit 0681df3 into master Mar 3, 2026
105 of 108 checks passed
@rusackas rusackas deleted the fix/echarts-series-theme-overrides branch March 3, 2026 03:51
rusackas pushed a commit that referenced this pull request Apr 17, 2026
- theming.mdx: document ECharts array property overrides (PR #37965) —
  array values like color palettes are fully supported and replaced entirely
  (not merged); adds Array Property Overrides section with color palette example
- configuring-superset.mdx: document PKCE support for database OAuth2
  (PR #37067) — add PKCE section under Custom OAuth2 with code_challenge_method
  config and when to use it
- cache.mdx: document ETag support for thumbnail/screenshot endpoints
  (PR #37663) — conditional GET with If-None-Match to avoid downloading
  unchanged images
- exploring-data.mdx: document SQL Lab UX improvements (PRs #37298, #37694,
  #37756) — treeview table browser, Ctrl+F find widget, resizable panels;
  also adds time range natural language expressions section (PR #37098)
- creating-your-first-dashboard.mdx: document Table chart features — boolean
  and categorical conditional formatting (PRs #36338, #37756), gradient toggle
  (PR #36280), HTML cell rendering with security note (PR #37685), column
  header tooltips from dataset descriptions (PR #37179), Display Controls
  modal in dashboard view (PR #36062)
- databases.json: update StarRocks supports_catalog and supports_dynamic_catalog
  to true — the engine spec (PR #37026) already implemented full catalog support
  with get_catalog_names(), get_default_catalog(), and SHOW CATALOGS; the
  committed JSON was stale and did not reflect this

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
…perties (apache#37965)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.

3 participants