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

Implement tooltip for PieChart #26

Closed
Cloudo opened this issue Feb 16, 2016 · 4 comments
Closed

Implement tooltip for PieChart #26

Cloudo opened this issue Feb 16, 2016 · 4 comments
Labels
enhancement Enhancement to a current API

Comments

@Cloudo
Copy link
Contributor

Cloudo commented Feb 16, 2016

No description provided.

@xile611 xile611 added the enhancement Enhancement to a current API label Feb 16, 2016
@xile611
Copy link
Member

xile611 commented Feb 18, 2016

Have implemented In v0.7.0
http://recharts.org/examples#TwoSimplePieChart

@xile611 xile611 closed this as completed Feb 18, 2016
@Cloudo
Copy link
Contributor Author

Cloudo commented Feb 18, 2016

Awesome, thanks!

@juanigaray
Copy link

There is no tooltip in that example

@fatemehqasemkhani
Copy link

fatemehqasemkhani commented Feb 3, 2020

you can set custom tooltip or default tooltip.

const PieChart = ({
  data,
  colors,
  fill,
  dataKey,
  innerRadius,
  outerRadius,
  cx,
  cy,
  paddingAngle,
  label,
  labelLine,
  payload,
}) => {
  const CustomTooltip = ({ payload }) => {
    return (
      <div>
        <div className="ant-popover-arrow" />
        <div className={s.customTooltip}>
          <b>{payload?.[0]?.payload?.name}</b>
          <span className={s.info}>
            <p className="desc">
              <small>{payload?.[0]?.payload?.totalCurrentPrice}</small>
            </p>
            <p>{payload?.[0]?.payload?.profitInPercentage} %</p>
          </span>
        </div>
      </div>
    );
  };

  return (
    <Chart width={150} height={150}>
      <Pie
        data={data}
        cx={cx}
        cy={cy}
        innerRadius={innerRadius}
        outerRadius={outerRadius}
        fill={fill}
        paddingAngle={paddingAngle}
        dataKey={dataKey}
        labelLine={labelLine}
        label={label}
      >
        {data.map((entry, index) => (
          <Cell key={entry.key} fill={colors[index % colors.length]} />
        ))}
      </Pie>
      <Tooltip content={<CustomTooltip />} />
    </Chart>
  );
};

if you omit content props in Tooltip, rechart default tooltip will be applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to a current API
Projects
None yet
Development

No branches or pull requests

4 participants