0z5a opened a new pull request, #21844:
URL: https://github.com/apache/echarts/pull/21844

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Makes `formatTpl` and `formatTplSimple` replace every occurrence of a 
template variable, not only the first one.
   
   ### Fixed issues
   
   - #21843: String formatter templates only replace the first occurrence of 
`{a}`/`{b}`/`{c}`
   
   ## Details
   
   ### Before: What was the problem?
   
   `formatTpl` used `tpl.replace(string, value)`, which only replaces the first 
match. A label formatter such as `'{b}: {c} | {b}: {c}'` rendered `Mon: 120 | 
{b}: {c}`, and multi-series templates that repeat `{a0}`/`{c1}` kept the later 
copies as literal text. `formatTplSimple` (calendar and matrix label 
formatters) had the same problem. `{@xxx}` dimension variables and time axis 
tokens were already replaced at every occurrence.
   
   ### After: How does it behave after the fixing?
   
   Both functions use a small `replaceAll` helper 
(`str.split(search).join(value + '')`), so `'{b}: {c} | {b}: {c}'` renders 
`Mon: 120 | Mon: 120`. The inserted value stays literal, so `$` sequences in 
names are still kept as they are (same result as #21751). Unknown variables and 
out-of-range series indexes are left unchanged, as before.
   
   ## 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.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   `test/ut/spec/util/format.test.ts` covers repeated `{b}`/`{c}` and 
`{a}`/`{a0}`, repeated indexed variables across two series, HTML encoding, 
unknown variables, `formatTplSimple`, and a bar series label formatter. The new 
cases fail without the fix and pass with it. The full unit test suite, `npx tsc 
--noEmit` and ESLint on the changed files pass.
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### Other information
   
   Based on `release`, which already has the replacers from #21751. The helper 
takes the value as a `string`, and the inserted text stays literal, so the `$` 
tests from #21751 still pass. On `release`, the full unit test suite (231 
tests), `npx tsc --noEmit` and ESLint on the changed files pass.
   
   This change was drafted with Claude Code (claude-opus-5-5); the test results 
above are from the runs described.
   


-- 
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