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

   ## Brief Information
   
   **This pull request is:**
   
   - [ ] Bug Fix
   - [x] New Feature
   - [ ] Other
   
   ### What does this PR do?
   
   Adds support for passing the associated **series name** as the second 
argument to the `legend.formatter` callback.
   
   **Related Issue:** #21730 — Support `legend.formatter(name, seriesName)`
   
   ---
   
   ## Details
   
   ### Before: What was the problem?
   
   Previously, the `legend.formatter` callback received only the legend item 
name:
   
   ```ts
   formatter(name)
   ```
   
   This made it difficult to identify the associated series, particularly when 
working with data-item legends such as pie charts.
   
   ### After: How does it work now?
   
   The callback now receives both the legend item name and its associated 
series name:
   
   ```ts
   formatter(name, seriesName)
   ```
   
   **Usage Example:**
   
   ```ts
   legend: {
       formatter(name, seriesName) {
           return `${seriesName}: ${name}`;
       }
   }
   ```
   
   The second argument is optional, ensuring **backward compatibility** with 
existing formatter callbacks.
   
   - Existing callbacks that accept only `name` continue to work.
   - String-based formatters remain unchanged.
   - The associated series name is now available when needed.
   
   ### Tests Added
   
   Unit tests have been added to cover:
   
   - Standard series legends.
   - Pie chart / data-item legends.
   
   **Test File:** `test/ut/spec/component/legend/formatter.test.ts`
   
   ---
   
   ## Validation & Testing
   
   The following checks have been completed successfully:
   
   - [x] Focused legend formatter tests passed.
   - [x] Full unit test suite passed (**196 tests**).
   - [x] Type checking passed.
   - [x] ESLint passed.
   
   ---
   
   ## Documentation
   
   - [x] This PR does not require documentation changes.
   - [ ] Documentation should be updated in a follow-up PR.
   - [ ] Documentation changes have been submitted in `apache/echarts-doc#xxx`.
   
   ---
   
   ## Miscellaneous
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (`ecomfe/zrender#xxx`).
   
   ### Merging Options
   
   - [x] Please squash all commits into a single commit when merging.
   
   ### Commit Message
   
   ```text
   feat(legend): support series name in formatter. close #21730
   ```
   
   ---
   
   **Summary:** This enhancement extends the `legend.formatter` callback with 
an optional `seriesName` argument, making it easier to associate legend items 
with their respective series while maintaining backward compatibility.


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