Skip to content

fix(format): preserve literal dollar sequences in component formatter templates - #21809

Open
soujasK wants to merge 1 commit into
apache:releasefrom
soujasK:fix/literal-dollar-in-formatters
Open

soujasK wants to merge 1 commit into
apache:releasefrom
soujasK:fix/literal-dollar-in-formatters

Conversation

@soujasK

@soujasK soujasK commented Oct 27, 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?

Applies the fix from #21751 to the other string formatter templates ({value}, {name}, {a}), so names and values containing $$, $&, $` or $' are shown as they are.

Fixed issues

None reported. Follow-up to #21751 and #21787, which fixed the same problem in formatTpl and the aria labels.

Details

Before: What was the problem?

Several components fill a string formatter with formatter.replace('{value}', text). When the replacement is a string, String.prototype.replace interprets $ sequences in it, so the inserted name or value is changed:

  • xAxis: { type: 'category', data: ['$$'], axisLabel: { formatter: '<{value}>' } } shows <$>; a category $& shows <{value}>.
  • legend.formatter: '[{name}]' with a series named US$$ shows [US$].
  • The same applies to radar.axisName.formatter, visualMap.formatter (piecewise categories), dataZoom.labelFormatter, the axis pointer label formatter and geo.label.formatter.

Price tiers ($, $$, $$$) as axis categories or series names are a realistic example.

After: How does it behave after the fixing?

These calls pass a function as the replacement, as #21751 did in formatTpl, so the inserted text is used literally. Formatters that only insert numbers (gauge, boxplot item names, the scrollable legend page counter) are unchanged.

test/ut/spec/component/formatterLiteralDollar.test.ts checks the axis label, legend, radar indicator name and visualMap category text with each of the four sequences: all 16 cases fail on release and pass with this change. The full unit test suite (242 tests), npx tsc --noEmit and eslint on the changed files pass.

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Merging options

  • Please squash the commits into a single one when merging.

Other information

@echarts-bot

echarts-bot Bot commented Oct 27, 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.

@plainheart plainheart added this to the 6.2.0 milestone Oct 28, 2026

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.

2 participants