{"size": 916, "ext": "js", "max_stars_repo_path": "src/components/Recharts/CustomTooltip.js", "max_stars_repo_name": "dimblek7/reactJS", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/Recharts/CustomTooltip.js", "max_issues_repo_name": "dimblek7/reactJS", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/Recharts/CustomTooltip.js", "max_forks_repo_name": "dimblek7/reactJS", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.5862068966, "max_line_length": 114, "alphanum_fraction": 0.5851528384}
import React from "react";
import { getShortNumber } from "utils";

const CustomToolTip = props => {
  const { active, payload, label, noCurrencyKeys = [], hideItems } = props;
  if (!active || !payload) {
    return null;
  }
  let toolTipItems = hideItems && hideItems.length ?  payload.filter(d => !hideItems.includes(d.name)): payload;
  return (
    <div className="custom-tooltip bg-white border p-3">
      <p>
        <strong>{label}</strong>
      </p>
      {toolTipItems.map((item, i) => {
        const hideCurrency = noCurrencyKeys.find(x => x === item.dataKey);
        return (
          <span key={i} className="d-block mb-1">
            <span style={{ color: item.color }}>{item.name}: </span>
            <span>{typeof item.value === "number" ? getShortNumber(item.value, !hideCurrency) : item.value}</span>
          </span>
        );
      })}
    </div>
  );
};

export default CustomToolTip;
