apexcharts.js
apexcharts.js copied to clipboard
Ability to exclude zero-values from tooltip
Summary
A have a dynamic data with unknown amount of series for a given time range. As apexcharts not allowing to draw null vlaues as 0 - i had to transform missing data to be 0, but now 0 values appear in tooltip.
API Changes
Add an undefined as tooltip value formatter that means - do not display this item in tooltip.
Or maybe add ability to draw null values as some others values (0 for me).
Intended Use Case
As for now i was not able to find how to exclude zero-values from tooltip of area charts (or, actually, draw missing values as 0). This leads to very high tooltip that occasionally causes page to have a scrollbar and this triggers tooltip to hide.

After trying to make nulls work figured that nulls are also displayed within tooltip🤔

This can be easy resolved using the tooltip formatter:
tooltip: { y: { formatter: function(value, { series, seriesIndex, dataPointIndex, w }) { if(value){ return value } } } }
The type of a formatter function does not expect undefined to be returned. There is an issue in types then.
Can you show your example by forking this codepen? https://codepen.io/PlippiePlop/pen/zYJMYYE?editors=0010
Your codepen is JS-only, im talking about issue with types.
https://github.com/apexcharts/apexcharts.js/blob/main/types/apexcharts.d.ts#L940
It is clearly typed that it always expects a value to be returned.
But even within your codepen the issue persists https://codepen.io/xobotyi/pen/KKxrVzo

Change 'Y' to 'X'
what for? x is time and i want to hide some series that has y equals 0
I do not know why you see undefined, if i test it, it either displays 0 or null not 'undefined'
because i do return it (just like your yesterday example) once again - the goal is to exclude zero\null values from tooltip
Hey, we also experienced this issue when we upgraded to latest version.
this is working on version
"apexcharts": "3.24.0",
"react-apexcharts": "1.3.7",

but not on version
"apexcharts": "3.37.2",
"react-apexcharts": "1.4.0",

Is this what you are looking for? Chart without 0 or null series in tooltip
yes, but im definely don't want to create my own custom tooltip for that purpose =)
CSS solution:
.apexcharts-tooltip-series-group:has(.apexcharts-tooltip-text-y-value:empty) { display: none !important; }
options = {
tooltip: {
hideEmptySeries: true
}
}
As tested on 4.4.0, the above property works well in hiding zero values in a tooltip.