Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add solid round dot in rechart

I'm plotting lineChart with rechart, and when there is dashed line, dot of that chart also becoming dash, but I want full circle instead of dashed circle how to do that?

This is the code I've used

<LineChart width={600} height={300} data={data}
        margin={{top: 20, right: 30, left: 20, bottom: 10}}>
   <CartesianGrid strokeDasharray="3 3"/>
   <XAxis dataKey="name" height={60} />
   <YAxis/>
   <Tooltip/>
   <Legend />
   <Line type="monotone"  dataKey="pv" stroke="#8884d8" label={<CustomizedLabel />}/>
   <Line type="monotone"  strokeDasharray="3 3" dataKey="uv" stroke="red" />
  </LineChart>

And output:

enter image description here

I want red dot to be fully circle instead of dotted circle, only line shouid be dashed,Please someone help

Thanks

like image 490
sss Avatar asked Oct 16 '25 18:10

sss


1 Answers

You can customize and render custom dot by using active dot property inside Line component, here is example :

   <Line type="monotone"  strokeDasharray="3 3" dataKey="uv" stroke="red" 
   dot={{ stroke: 'red', strokeWidth: 1, r: 4,strokeDasharray:''}}
   />

here is another example of customizing dot in the official documentation of recharts : https://recharts.org/en-US/examples/CustomizedDotLineChart

here is an adaptation of your code: https://jsfiddle.net/ys6zwjaL/#&togetherjs=0jVcg5yr0N

like image 154
Taha LAGHZALI Avatar answered Oct 19 '25 14:10

Taha LAGHZALI