Skip to content

fix(radar): support symbol and symbolSize as functions on data items - #21820

Open
xh123637 wants to merge 1 commit into
apache:masterfrom
xh123637:fix/20471-radar-symbol-function
Open

xh123637 wants to merge 1 commit into
apache:masterfrom
xh123637:fix/20471-radar-symbol-function

Conversation

@xh123637

@xh123637 xh123637 commented Nov 6, 2026

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fix symbolType.indexOf is not a function when symbol / symbolSize are given as functions on radar data items, and make data-item symbol callbacks work for all series.

Fixed issues

Details

Before: What was the problem?

The documentation says symbol and symbolSize accept a callback (value, params) => string | number. Series-level callbacks worked, but a callback on a data item crashed rendering:

TypeError: symbolType.indexOf is not a function
    at createSymbol (src/util/symbol.ts:345)
    at createSymbol (src/chart/radar/RadarView.ts:60)

For example, this radar option threw on setOption:

series: [{
    type: 'radar',
    data: [{
        value: [80, 90, 70],
        symbol: function () { return 'triangle'; },
        symbolSize: function () { return 12; }
    }]
}]

After: How does it behave after the fixing?

Data-item symbol callbacks are invoked per data item and the returned values become the item visuals, so the radar renders the triangle symbol at size 12. The same fix also covers other series: a line series with a data-item symbol callback threw the identical error before this change.

Root cause

seriesSymbolTask (src/visual/symbol.ts) invokes series-level symbol callbacks per data item, but dataSymbolTask in the same file copied data-item option values into the item visuals verbatim. A function-valued symbol therefore reached RadarView.createSymbol (and Symbol.updateData for other series) as the raw function, and createSymbol called symbolType.indexOf('empty') on it.

Changes

  • src/visual/symbol.ts: in dataSymbolTask, invoke function-valued symbol, symbolSize, symbolRotate and symbolOffset item options with (rawValue, params) — the same arguments seriesSymbolTask uses — and store the result as the item visual.
  • test/ut/spec/series/radar.test.ts: new tests. The data-item test asserts the callbacks are called with the raw value and data index, and that the resolved item visuals are 'triangle' and 12. A series-level test guards the existing behavior.

Tests

  • New test fails on the unmodified code (TypeError: symbolType.indexOf is not a function) and passes with the fix.
  • test/ut/spec/series/radar.test.ts: 2/2 pass.
  • Full unit suite: 27 suites, 196 tests, all pass.
  • tsc --noEmit clean, ESLint clean on both touched files.

Not verified: the HTML visual test cases (no browser here) and npm run test:dts:fast.

@echarts-bot

echarts-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: PR: doc ready, PR: awaiting doc, PR: doc unchanged

This message is shown because the PR description doesn't contain the document related template.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant