Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nameFormatter and headerFormatter added #16942

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

jiawulin001
Copy link
Member

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

New APIs tooltip.nameFormatter and tooltip.headerFormatter that allow user to change name and header respectively in tooltip are added.

Fixed issues

Details

Before: What was the problem?

"New formatter" like tooltip.valueFormatter is requested to change the name and header in tooltip. With these formatters users can change only the series name or the header (x-axis value), without changing the other default parts of the tooltip.

before #16703

Users cannot change the format of date and have to display the exact time despite they don't need it.

After: How is it fixed in this PR?

New APIs tooltip.nameFormatter and tooltip.headerFormatter are added. They allow user to change name and header respectively in tooltip without changing other default part.

After setting tooltip to:

tooltip: {
    trigger: 'axis',
    headerFormatter: header => `${new Date(header).toDateString()}`,
    nameFormatter: name => `Score`,
    valueFormatter: value => `${value}/10`
  }

We have
after #16703
User can change name and header as wish without having to write the whole thing from scratch with tooltip.formatter.

Misc

  • The API has been changed (apache/echarts-doc#xxx).
  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

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

Other information

@echarts-bot
Copy link

echarts-bot bot commented Apr 26, 2022

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.

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

@echarts-bot echarts-bot bot added PR: awaiting doc Document changes is required for this PR. PR: awaiting review labels Apr 26, 2022
@pissang pissang changed the base branch from master to next April 27, 2022 02:02
@pissang pissang added this to the 5.4 milestone Apr 27, 2022
@Airkro
Copy link

Airkro commented May 24, 2022

headerFormatter is really useful. Is it possible to land this feature sooner? Milestone 5.4 is too far.

There is a replacement: #16703 (comment)

@DavidMarquezF
Copy link

Any plans on merging this? nameFormatter would be really useful

@Ovilia Ovilia modified the milestones: 5.4, 5.4.1 Sep 1, 2022
Copy link
Contributor

@Ovilia Ovilia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature looks great! Please also provide a test case using npm mktest xxx.

valueFormatter: CommonTooltipOption<unknown>['valueFormatter']
valueFormatter: CommonTooltipOption<unknown>['valueFormatter'];
nameFormatter?: CommonTooltipOption<unknown>['nameFormatter'];
headerFormatter?: CommonTooltipOption<unknown>['headerFormatter']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ;

@plainheart plainheart modified the milestones: 5.4.1, 5.5.0 Nov 8, 2022
@plainheart plainheart modified the milestones: 5.5.0, TBD Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: awaiting doc Document changes is required for this PR. PR: revision needed size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question][Feature] How do you specify date format in tooltip?
6 participants