[Question][Feature] How do you specify date format in tooltip?
See original GitHub issueWhat problem does this feature solve?
Please see the following sample configuration:
option = {
dataset: {
source: [
{ date: '3022-03-01', count: 6 },
{ date: '3022-03-02', count: 3 },
{ date: '3022-03-03', count: 4 },
{ date: '3022-03-04', count: 6 },
{ date: '3022-03-05', count: 7 },
{ date: '3022-03-06', count: 2 },
{ date: '3022-03-07', count: 8 },
{ date: '3022-03-08', count: 6 },
{ date: '3022-03-09', count: 9 }
]
},
xAxis: {
type: 'time',
},
yAxis: {
type: 'value'
},
series: [
{
type: 'line',
name: 'Count'
}
],
tooltip: {
trigger: 'axis'
}
};
This results in the tooltip displaying the date with all zeros for time. Is there an easy way to format this as date-only? I know how to use a function for series.tooltip.valueFormatter
for the other values, but I’m not sure how to do this for the x-axis since no series is defined for it.
What does the proposed API look like?
Perhaps a valueFormatter option added to xAxis.tooltip
which accepts either a string or a function.
xAxis: {
type: 'time',
tooltip: {
valueFormatter: 'yyyy-MM-dd'
}
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Format Date used in Tooltip - Tableau Community
Right Click on the date field which you created --> Default Properties --> Date Format --> Select the format which you want to...
Read more >Localized date format in tooltip - amcharts - Stack Overflow
In my chart I'm displaying revenue data on a date axis by day. I would like to show the date in the tooltip...
Read more >How to Format Date in the Tooltip Label?
Solved: Hello! How and where can I format the date that is displayed in the tooltip label? I need it to just say...
Read more >How to Format Dates in the Tooltip in Chart.js - YouTube
Especially with the tooltip and having it shorten would be more suitable. Customizing the date in a format you want. To do this...
Read more >How to format date/time data in Tooltips and along X-axis?
The information itself is shown fine but now I want to change the contence of the Tooltips of the data points and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @jiawulin001. That works, but I don’t think it’s a great solution for the following reasons:
valueFormatter
functions for each series are now ignored and you have to use messier logic inside the main tooltipformatter
It would be much better if we could specify a
valueFormatter
for the independent axis so all other tooltip functionality works by default.Thanks @Airkro, that one seems to do the trick! Much appreciated!