Giter Site home page Giter Site logo

Comments (4)

qnpbgood avatar qnpbgood commented on June 12, 2024 3
return <DefaultTooltipContent payload={payload} {...props} />

Thank you! That's what I was looking for.

from recharts.

ckifer avatar ckifer commented on June 12, 2024

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.

qnpbgood avatar qnpbgood commented on June 12, 2024

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.

ckifer avatar ckifer commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.