Comments (4)
return <DefaultTooltipContent payload={payload} {...props} />
Thank you! That's what I was looking for.
from recharts.
This is specific to when there is a custom Tooltip and it looks to be specifically because of this line
if (!active || !payload || !payload.length) return null;
Remove that and everything works normally
from recharts.
Thanks for the quick response. In my case, I need to check the availability of payload because further logic for outputting data to Tooltip depends on this. As an alternative to returning null, I return any tag with insignificant content and this fixes my problem but seems a bit clunky. Could it be possible to return some default tooltip behavior?
export const CustomizedTooltip: React.FC<TooltipProps<ValueType, NameType>> = ({
payload,
active,
}) => {
if (active && payload && payload.length) {
// Some logic that depends on payload
return <div> Tooltip content </div>;
} else {
// It's works fine but looks ugly
return <span>.</span>;
}
};
Empty tag not work here
from recharts.
what do you mean it looks ugly? The code looks ugly? The functionality looks the same as it does by default.
I think ideally, we would change the tooltip behavior to not "fly in" like it currently does and just have it appear at the first point and animate from there.
For now you can do this
export const CustomizedTooltip: React.FC<TooltipProps<ValueType, NameType>> = ({
payload,
active,
...props
}) => {
if (active && payload && payload.length) {
// Some logic that depends on payload
return <div> Tooltip content </div>;
}
return <DefaultTooltipContent payload={payload} {...props} />
};
from recharts.
Related Issues (20)
- Cannot customize recharts-active-dot HOT 1
- Uncaught TypeError: import_events.default is not a constructor HOT 3
- Apply `className` to the `label` and `labelLine` in `PieChart` component. HOT 1
- Layer: TypeScript error with latest `@types/react` version HOT 19
- accessibility issue with using 2 charts on the same page. HOT 7
- Pie charts that are 100% a single value have a line that shouldn't be there HOT 5
- how can I pin a tooltip in a chart HOT 8
- Automatically format large axis label values HOT 6
- Tooltip deprecation HOT 1
- Negative interval number HOT 5
- Getting lowest and highest possible x and y in a line chart? HOT 24
- Tooltip first render HOT 7
- YAxis is missing if value = null || undefined HOT 2
- different name on tooltip from xaxis on barchart HOT 4
- Better API documentation HOT 3
- Issues with typing Legend props HOT 7
- Stacking Xaxis dataKey text HOT 3
- AreaChart and LineChart do not show the values correctly HOT 1
- Question on exporting `useChartWidth` and similar api HOT 2
- BarChart : Without BarSize bug, with BarSize another Bug HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recharts.