Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove the blue rectangle which appears on a sector in pie chart from recharts library?

When clicking on a sector in pie chart in recharts library I want the blue rectangle that appears to not appear.enter image description here The recharts library is being used in react app.

<PieChart width={800} height={400} onMouseEnter={this.onPieEnter}>
        <Pie
          data={data}
          cx={120}
          cy={200}
          innerRadius={60}
          outerRadius={80}
          fill="#8884d8"
          paddingAngle={5}
          dataKey="value"
        >
          <Tooltip cursor={{ stroke: 'red', strokeWidth: 2 }} />
          {data.map((entry, index) => (
            <Cell stroke="5" 
            style={{
                filter: `drop-shadow(0px 0px 5px ${COLORS[index % COLORS.length]}`
              }}
              key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
          ))}
            
        </Pie>
        <Pie
          data={data}
          cx={420}
          cy={200}
          startAngle={180}
          endAngle={0}
          innerRadius={60}
          outerRadius={80}
          fill="#8884d8"
          paddingAngle={5}
          dataKey="value"
        >
          {data.map((entry, index) => (
            <Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
          ))}
        </Pie>
      </PieChart>
like image 224
qwas Avatar asked Jan 23 '26 13:01

qwas


2 Answers

You should add outline: none to the Chart element

<PieChart width={800} height={400} onMouseEnter={this.onPieEnter}>
  <Pie
    data={data}
    cx={120}
    cy={200}
    innerRadius={60}
    outerRadius={80}
    fill="#8884d8"
    paddingAngle={5}
    dataKey="value"
  >
    <Tooltip cursor={{ stroke: "red", strokeWidth: 2 }} />
    {data.map((entry, index) => (
      <Cell
        stroke="5"
        style={{
          filter: `drop-shadow(0px 0px 5px ${COLORS[index % COLORS.length]}`,
          outline: "none",
        }}
        key={`cell-${index}`}
        fill={COLORS[index % COLORS.length]}
      />
    ))}
  </Pie>
  <Pie
    data={data}
    cx={420}
    cy={200}
    startAngle={180}
    endAngle={0}
    innerRadius={60}
    outerRadius={80}
    fill="#8884d8"
    paddingAngle={5}
    dataKey="value"
  >
    {data.map((entry, index) => (
      <Cell
        style={{ outline: "none" }}
        key={`cell-${index}`}
        fill={COLORS[index % COLORS.length]}
      />
    ))}
  </Pie>
</PieChart>;
like image 99
Jerónimo Ekerdt Avatar answered Jan 26 '26 03:01

Jerónimo Ekerdt


You can add outline: none in the <Pie/> Component

            <Pie
              ...
              style={{outline: 'none'}}
            />
like image 35
CCCC Avatar answered Jan 26 '26 03:01

CCCC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!