You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "Mustansir-06 (via GitHub)" <gi...@apache.org> on 2026/01/09 10:14:48 UTC

[PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Mustansir-06 opened a new pull request, #21460:
URL: https://github.com/apache/echarts/pull/21460

   This PR adds the series name as a third argument to the valueFormatter function in the tooltip component.
   
   Currently, valueFormatter only receives value and dataIndex. Adding the name (series name) allows users to perform conditional formatting based on the series without having to write a full custom formatter HTML string.
   
   Changes
   src/component/tooltip/tooltipMarkup.ts: Updated buildNameValue to pass fragment.name into the valueFormatter call.
   
   src/util/types.ts: Updated the CommonTooltipOption and TooltipValueFormatter types to include the optional name?: string parameter to ensure TypeScript 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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on PR #21460:
URL: https://github.com/apache/echarts/pull/21460#issuecomment-3728905749

   Thanks for your suggestions and work! I don't think it's worth adding a new callback parameter when there's a feasible and less cumbersome solution available, so I'd rather not add it.


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Posted by "Mustansir-06 (via GitHub)" <gi...@apache.org>.
Mustansir-06 closed pull request #21460: feat(tooltip): add series name as third parameter to valueFormatter (#21459)
URL: https://github.com/apache/echarts/pull/21460


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Posted by "Mustansir-06 (via GitHub)" <gi...@apache.org>.
Mustansir-06 commented on PR #21460:
URL: https://github.com/apache/echarts/pull/21460#issuecomment-3728838822

   Thank you for the demo and the feedback @plainheart!
   
   I agree that defining individual formatters works well for a few series. However, the motivation for this PR is to support generic, reusable formatting functions.
   
   If a developer has many series (or a dynamic number of series), they currently have to define a new function for each one to include the series name. By passing the name as a third parameter, a single formatter can be written to handle multiple series dynamically:
   // With this PR, one function can handle multiple units dynamically
   const myGenericFormatter = (value, index, name) => {
       const unitMap = { 'Email': ' unit1', 'Union Ads': ' unit2' };
       return value + (unitMap[name] || '');
   };
   This brings valueFormatter in line with other ECharts formatters that already provide the name context. What are your thoughts on supporting this more dynamic approach?


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Posted by "Mustansir-06 (via GitHub)" <gi...@apache.org>.
Mustansir-06 commented on PR #21460:
URL: https://github.com/apache/echarts/pull/21460#issuecomment-3731807902

   Thank you for the demo, @plainheart!
   
   I see how using a closure within the series.forEach loop effectively captures the series context without needing an additional parameter in the valueFormatter callback. It's a clean way to handle the requirement using the existing API.
   
   I appreciate the time you took to review this and for providing the alternative approach. I'll close this PR for now. Thanks again!


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #21460:
URL: https://github.com/apache/echarts/pull/21460#issuecomment-3728265841

   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
   
   Please **DO NOT** commit the files in [dist](https://github.com/apache/echarts/tree/master/dist), [i18n](https://github.com/apache/echarts/tree/master/i18n), and [ssr/client/dist](https://github.com/apache/echarts/tree/master/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 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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on PR #21460:
URL: https://github.com/apache/echarts/pull/21460#issuecomment-3728750455

   `valueFormatter` is designed for **the tooltip of a single series** rather than the **global** tooltip option. See this [demo](https://echarts.apache.org/examples/editor.html?c=line-stack&code=pdK9bsIwEADgnae4za3KgG2QCBWVkAqdOtGfATG4xA2Wgo0cBxFVvHvvDKS_aiPFgy--nJ1PF7ttMM7CGN46AMG5PJjtKC5w6U2WaT8CpvamYJg7dHHKdaZtikVxtZ_gu3pHtdVYvlJBZ85XjAoAXlxpU-WrO4VHv6q80Md8qoIawYLdO8u6wB5KTeFZp3G1LinMvKEwVyGG0rLl2VH98uWdyvGUc0WhvdFYsoglx0IAqzZUOt0ok5-E9f7cWESccicfF70ucClw6nF66nchwZSQNPHesj7ja_toRM_M-Y0KgTp5sbuE8Q3s4AoYlNYETlgahxgj-wf10dI_mqRFE66I3CFxE-QK4grySvLKll7RxPtkUu2aevkg9hK9IrZ3gF5ee_stvbKJ99Z4vcIL9j9WUnMlYSVhJTVXfjRXtMP2m2DnWvnVGqY2--z7wzwkc0LmhMwJmXm8ETyq8Wq3Yw--sXFedg7X7w&enc=deflate) for recommended usage.


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


Re: [PR] feat(tooltip): add series name as third parameter to valueFormatter (#21459) [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on PR #21460:
URL: https://github.com/apache/echarts/pull/21460#issuecomment-3728945782

   > If a developer has many series (or a dynamic number of series), they currently have to define a new function for each one to include the series name
   
   This can be done with a loop. [Demo](https://echarts.apache.org/examples/editor.html?c=line-stack&code=jZLfa8IwEMff-1fkQaiCFNsqTMXBHnRPwmDOPYhgbGMNa5OSpmLR_u-7S2M32A98yfWud_f55nKRFIUmBVOcFSspU83zNU1L9ia4XtKczMjFIWSeUZ5OiLt3--C98EiXioH_0QTWPGYS3GzvOvXUcWSuuRS2VjddJ8YBV_EkYQqy6ZkXLsRqbJGyhIkYkox3foJ_bUWVIyuimiVSVYZIyF6WIqaqeqbQ-kDTgjXxmGo6IRt3KYXbJ-6qZGjeWWy8Y4lmoTiaV6qNKYW7vemofiGfcCCt0mZWgDApTSIhgmaYagZlFbb1KRcgwsasPj8Y9IkfBnAMfPwa9skYQkGIhz9AQRb4A2Lnfw8mMJgHxIwBEyAmQE6InPB_jnnWuy4zMsqBEpjLjIDit5RhS4Fz-21BvGaU3kGqOY2O3W7j98js0UhpdtPuD2yT_e_dItcrbFjdm34tmWeeaiFVRrVmCmtO2M7gd53LqSady5_LvrH98frbejd1oPcn&enc=deflate)


-- 
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: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org