Skip to content

feat(plugin-chart-echarts): add gridline and axis tick controls - #43428

Open
rlei-odes wants to merge 1 commit into
apache:masterfrom
rlei-odes:feat/echarts-axis-gridline-controls
Open

feat(plugin-chart-echarts): add gridline and axis tick controls#43428
rlei-odes wants to merge 1 commit into
apache:masterfrom
rlei-odes:feat/echarts-axis-gridline-controls

Conversation

@rlei-odes

@rlei-odes rlei-odes commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

The ECharts timeseries family exposes Minor ticks and Minor Split Line
as controls, but the main gridlines and main axis ticks are hardcoded in the
transform, on the lines immediately around them:

minorTick:      { show: isSmallChart ? false : minorTicks },
minorSplitLine: { show: isSmallChart ? false : minorSplitLine },
splitLine:      { show: !isSmallChart },   // no control
axisTick:       { show: !isSmallChart },   // no control

So the faint gridlines between the labelled ticks can be turned off, while the
main ones they subdivide cannot. That asymmetry reads as accidental rather than
deliberate.

This adds the two matching checkboxes, Gridlines and Axis ticks, to the
Customize tab of every chart that already carries the minor pair: Bar, Line,
Area, Step, Scatter, Smooth Line and Mixed.

Each control covers exactly the axes its minor counterpart already covers:

Control Axes Mirrors
Gridlines wherever ECharts draws them minorSplitLine
Axis ticks both axes minorTicks

In practice that means the value axis, which is why it mirrors minorSplitLine.
ECharts defaults category and time axes to splitLine: { show: false } and
value and log axes to show: true, so unticking writes show: false on both
axes without enumerating axis types: it hides gridlines where they exist and is
a no-op where they do not. Ticking never writes the key at all, so no axis
gains gridlines it does not already have.

Three details worth flagging for review:

  • Both default to on, so nothing renders differently until a user unticks
    one.
    The transform destructures from { ...DEFAULT_FORM_DATA, ...formData },
    so charts saved before this change pick the defaults up too. Where an axis had
    no axisTick key at all, the ticked state writes show: 'auto' rather than
    show: true'auto' is ECharts' own default, and it resolves to hidden
    on a banded category axis. Forcing true would have added tick marks that
    bar charts do not currently draw.
  • The small-chart behaviour is preserved. Upstream already suppresses
    gridlines and ticks below compactChartHeight, and the new controls are
    written as isSmallChart ? false : gridlines — matching the line above them —
    so a ticked box cannot put gridlines back on a chart too small to carry them.
  • The Mixed chart's secondary y-axis keeps splitLine: { show: false }
    unconditionally
    , as it does today, so the two grids can never double up.
    The control governs the primary axis only.
  • On the Mixed chart, Axis ticks has nothing to act on in the common case.
    Neither of its axes overrides axisTick, and ECharts' 'auto' resolves to
    hidden whenever the other axis is a category or time scale — which covers most
    Mixed charts. The checkbox is subtractive, so with no ticks drawn there is
    nothing for it to hide. Making it meaningful there would mean adding ticks
    by default, which this PR deliberately does not do. Happy to drop the control
    from the Mixed panel instead if reviewers prefer.

Motivation: a sparse, low-gridline chart currently requires hand-written JSON in
Customize → ECharts Options. Background:
#43426

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before — gridlines and axis ticks as they render today.

gridline_controls_before

After — the same chart with both unticked.

gridline_controls_after

The two new controls, on the Customize tab beside the minor pair they
mirror.

gridline_controls_ui

TESTING INSTRUCTIONS

Unit tests: npm run test -- plugins/plugin-chart-echarts/test/Timeseries/transformProps plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps

Manually, on any Bar or Mixed chart:

  1. Open an existing chart that has never seen these controls and confirm it
    renders exactly as before — this is the regression that matters most.
  2. Customize → untick Gridlines. The horizontal lines across the plot area
    disappear; the axis labels and ticks stay.
  3. Untick Axis ticks. The small marks on both axes disappear.
  4. Re-tick both and confirm the chart returns to its original look.
  5. On a Bar chart, set Orientation to Horizontal and untick Gridlines. The
    gridlines still follow the value axis, which is now the horizontal one.
  6. Shrink a chart on a dashboard below 100px tall. Gridlines and ticks stay
    hidden regardless of the checkboxes, as they do today.

Charts verified by hand

Chart Gridlines Axis ticks
Bar (vertical and horizontal) works works
Line works works
Area works works
Scatter works works
Mixed works nothing to hide — see above
Step, Smooth Line not checked separately not checked separately

Step and Smooth Line share Timeseries/transformProps.ts with Bar, Line, Area
and Scatter, with no branching between them, so the four checked charts cover
the same code. Histogram, Waterfall and Box Plot are untouched: they carry
neither minorTicks nor minorSplitLine, and this PR only adds controls where
the minor pair already exists.

Two things noticed while testing that are not caused by this PR, recorded in
case they are news:

  • On Area, the existing Minor ticks control draws nothing, while the same
    control works on Bar, Line and Mixed. Those charts run the identical
    transform, and this PR does not touch minorTick in any file, so the cause
    lies in how ECharts computes minor tick positions for that axis extent
    (getMinorTicksCoords returns an empty list and the builder bails).
  • On Mixed, minor ticks render in a different colour from the gridlines. That
    is ECharts' own defaulting: minorTick inherits its stroke from axisTick,
    falling back to the axis line colour, whereas splitLine has its own theme
    token.

ADDITIONAL INFORMATION

  • Has associated issue: Making per-series chart styling reachable #43426
  • 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

The minor gridlines and minor ticks are exposed as controls, but their
main counterparts are hardcoded in the transform, one line apart:

  minorSplitLine: { show: isSmallChart ? false : minorSplitLine },
  splitLine:      { show: !isSmallChart },
  axisTick:       { show: !isSmallChart },

Adds the two matching checkboxes, on every chart that already carries the
minor pair. Both default to on and only ever subtract: where an axis had
no such key, the enabled state leaves ECharts' own default in place
rather than forcing the option on, so existing charts render unchanged.
@dosubot dosubot Bot added change:frontend Requires changing the frontend viz:charts:echarts Related to Echarts labels Aug 22, 2026
@bito-code-review

bito-code-review Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #48e5d8

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/controlPanel.tsx - 1
    • Missing tests for new controls · Line 45-46
      The new `axisTicks` and `gridlines` controls (lines 45-46, 485-486) wire into the same transform pipeline used by Line/Bar/Area charts and are backed by existing form-data fields. However, the Scatter-specific test suite (transformProps.test.ts, controlPanel.test.ts) has zero coverage for either control — neither keyword appears in either file. Without a dedicated assertion, toggling these controls in the Scatter chart UI cannot be verified.
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts - 1
    • Inconsistent axisTick value type · Line 1283-1283
      X-axis `axisTick.show` uses string 'auto' when true, but Y-axis uses boolean directly (line 1343). This inconsistent type causes maintenance confusion and potential type errors. Simplify to `axisTick: { show: axisTicks }` for consistency.
Review Details
  • Files reviewed - 16 · Commit Range: 8abe0c4..8abe0c4
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/types.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Area/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.test.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Line/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Scatter/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/SmoothLine/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Step/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/constants.ts
    • 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/src/controls.tsx
    • 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 an incremental AI Review.

  • /review full - 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

},
minorTick: { show: minorTicks },
axisTick: { show: axisTicks ? 'auto' : false },
...(gridlines ? {} : { splitLine: { show: false } }),

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.

Suggestion: When gridlines is false, this unconditionally adds splitLine.show = false to the x-axis, including temporal axes. The control is intended to control the value-axis gridlines and only suppress x-axis gridlines when the x-axis is numeric; this currently overrides any existing temporal x-axis split-line configuration and makes the behavior broader than the control's documented scope. Restrict the x-axis override to numeric x-axis types. [api mismatch]

Severity Level: Minor 🧹
- ⚠️ Temporal x-axis split-line configuration is suppressed unexpectedly.
- ⚠️ Gridlines control exceeds its documented numeric-axis scope.
- ⚠️ Returned ECharts options differ for temporal charts.

Use CodeAnt Skill

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
**Line:** 1284:1284
**Comment:**
	*Api Mismatch: When `gridlines` is false, this unconditionally adds `splitLine.show = false` to the x-axis, including temporal axes. The control is intended to control the value-axis gridlines and only suppress x-axis gridlines when the x-axis is numeric; this currently overrides any existing temporal x-axis split-line configuration and makes the behavior broader than the control's documented scope. Restrict the x-axis override to numeric x-axis types.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The current implementation in transformProps.ts unconditionally sets splitLine.show = false on the x-axis when gridlines is false, which incorrectly overrides temporal axes that should not be affected by this control. To resolve this, you should restrict the override to numeric x-axis types by checking xAxisType.

Here is the corrected implementation for superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:

    minorTick: { show: minorTicks },
    axisTick: { show: axisTicks ? 'auto' : false },
    ...(gridlines || xAxisType !== AxisType.Numeric ? {} : { splitLine: { show: false } }),
    minInterval:
      xAxisType === AxisType.Time && resolvedTimeGrain && !forceMaxInterval

I have checked the other comments on this PR, and there are no additional review comments to address. Would you like me to perform any further analysis?

superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts

minorTick: { show: minorTicks },
    axisTick: { show: axisTicks ? 'auto' : false },
    ...(gridlines || xAxisType !== AxisType.Numeric ? {} : { splitLine: { show: false } }),
    minInterval:
      xAxisType === AxisType.Time && resolvedTimeGrain && !forceMaxInterval

@rlei-odes

Copy link
Copy Markdown
Contributor Author

Thanks — I looked into this and I'd like to keep the current form, for three reasons.

Nothing is being overridden on temporal axes. The transform sets xAxis.splitLine in only one place, the line in question. ECharts defaults both category and time axes to splitLine: { show: false } (coord/axisDefault.js), so writing show: false on a temporal axis is a no-op rather than a broadening. And because custom echart_options are merged over the computed options, a user who deliberately enables x-axis gridlines still wins.

AxisType.Numeric doesn't exist. The enum is Category | Value | Time | Log, so the suggested line wouldn't compile.

Gating on a single axis type would introduce a bug. logAxis is built from the value-axis defaults, including splitLine: { show: true }, so a log x-axis does draw gridlines. Restricting the override to AxisType.Value would leave them on screen after the user unticked the control. The unconditional form covers Value and Log without having to enumerate axis types, and stays correct if a future axis type also defaults to showing them.

The control only ever subtracts — ticked writes nothing, so no axis can gain gridlines it doesn't already have.

You did catch a real inaccuracy in the PR description, though: it said the x-axis is only affected "when that axis is numeric", which is narrower than what the code does. I've corrected that wording.

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 plugins size/L viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant