user2128
user2128

Reputation: 640

Change the styling of tooltip - recharts

I created a custom tooltip for my chart that I implemented using recharts. I would like to change the styling of it but am unable to remove extra whitespaces between the lines. I tried changing line-height, padding and margin that would remove the space but nothing worked.

enter image description here

<div className="customTooltip">
  <h2 className="tooltipLabel">{e.payload[0].payload.initiatorUsername}</h2>
  <i className="tooltipTitle">{e.payload[0].payload.title}</i>
  <div className="tooltipContent">
    <p>Request startTime:</p>
    <p>Approver name:</p>
    <p>Approver Title</p>
    <p>
      Approved Time:{" "}
      {moment.unix(e.payload[0].payload.time).format("MMM Do YYYY, h:mm:ss")}
    </p>
  </div>
</div>
.recharts-tooltip-wrapper {
    .customTooltip {
      margin: 0;
      line-height: 5px;
      border: 1px solid #f5f5f5;
      background-color: rgba(255, 255, 255, 255);
      padding-bottom: 0%;
  
      .tooltipTitle {
        margin: -10px;
        color: #666;
        top:5px;
      }
    }
  }

which styling property would help me to achieve it ?

Upvotes: 5

Views: 15431

Answers (2)

Narendra Solanki
Narendra Solanki

Reputation: 1192

if anyone still looking for solution then try this as well

wrapperStyle={{ outline: "none" }} 

Full

    <Tooltip
     wrapperStyle={{ outline: "none" }}
     content={<CustomTooltip />}
    />

Upvotes: 0

anderssonola
anderssonola

Reputation: 2195

Looks like there is margins defined on the <p> elements.

.recharts-tooltip-wrapper {
  .customTooltip {
    p {
      margin:0;
    }
  }
}

Upvotes: 2

Related Questions