farisbasha opened a new pull request, #21847:
URL: https://github.com/apache/echarts/pull/21847

   <!-- Please fill in the following information to help us review your PR more 
efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   
   Shows `$&`, `$$`, `` $` `` and `$'` literally in category axis labels, radar 
indicator names and geo region labels that use a string formatter.
   
   
   
   ### Fixed issues
   
   None filed. Same bug class as #21751 (formatTpl) and #21787 (aria label).
   
   
   ## Details
   
   ### Before: What was the problem?
   
   Three string formatters pass the user's text as the replacement string of 
`String.prototype.replace`, so JavaScript expands the special `$` patterns in 
it:
   
   - `src/coord/axisHelper.ts` `makeLabelFormatter`: `axisLabel.formatter` such 
as `'Label: {value}'`
   - `src/coord/radar/RadarModel.ts`: `radar.axisName.formatter` such as 
`'Name: {value}'`
   - `src/coord/geo/GeoModel.ts` `getFormattedLabel`: `geo.label.formatter` 
such as `'Geo: {a}'`
   
   For example, with `axisLabel.formatter: 'Label: {value}!'`:
   
   | category name | shown before |
   |---|---|
   | `Item $&` | `Label: Item {value}!` |
   | `Item $$` | `Label: Item $!` |
   | ``Item $` `` | `Label: Item Label: !` |
   | `Item $'` | `Label: Item !!` |
   
   
   
   ### After: How does it behave after the fixing?
   
   The value is passed through a replacer function (`() => value`), the same 
way #21751 and #21787 fixed `formatTpl` and the aria label, so the text is 
inserted as is. Nothing else changes.
   
   New unit test `test/ut/spec/component/stringFormatter.test.ts` checks the 
three formatters with `$&`, `$$`, `` $` ``, `$'` and plain text.
   
   
   
   ## Document Info
   
   One of the following should be checked.
   
   - [x] 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.
   
   <!-- PLEASE CHECK IT AGAINST: 
<https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors>
 -->
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   `test/ut/spec/component/stringFormatter.test.ts`
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information
   
   I used an AI assistant to find this and write the change. The new test runs 
in CI; I did not run the test suite locally.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to