recharts: Dots don't appear
Hello,
I call this 2 Component 2 times from the same function to get 2 identical graphs, only data change :
<ResponsiveContainer>
<ComposedChart data={areaLine.slice()} margin={{ top: 10, right: 30, left: 0, bottom: 0 }} stroke="none">
<XAxis dataKey="name" tick={{ fill: '#ffffff' }} stroke="rgba(255,255,255,.5)"/>
<YAxis tick={{ fill: '#ffffff' }} stroke="rgba(255,255,255,.5)"/>
<CartesianGrid strokeDasharray="3 3" stroke="rgba(255,255,255,.5)"/>
<Tooltip />
<Area type="monotone" dataKey="Periode actuelle" stroke="#236cb6" strokeWidth={2} fillOpacity={0.3} fill="#44c0ff" activeDot={{ stroke: '#white', strokeWidth: 4, r: 8, fill: '#ff5f4a'}} dot={{ stroke: '#44c0ff', strokeWidth: 4, r: 2, fill: 'blue'}}/>
<Line type="monotone" dataKey="Periode precedente" stroke="#ff7f78" strokeWidth={2} activeDot={{ stroke: '#white', strokeWidth: 4, r: 8, fill: '#ff5f4a'}} dot={{ stroke: '#44c0ff', strokeWidth: 4, r: 2, fill: 'blue'}} />
</ComposedChart>
</ResponsiveContainer>
And the result is :

Why dot is only on the last line? and not on both graph and on the Area and Line ?
Thanks in advance š
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 20
- Comments: 34 (5 by maintainers)
Same issue. Setting
isAnimationActiveonLinetofalsealso solves it for me. Version: 1.6.2Hello guys! On #1624 issue, @klarstrup gave a solution that worked for me. Apparently this problem happens in other types of graphic too, as in my case, was using Bar.
The solution, proposed by @klarstrup, was to put a key prop on the BarChart component, so when it changes, the whole graphic will re-render, with all the animations. I just put key={Math.random()}, so he always renders now š
@xile611 it persists.
Having the same issue but I donāt want to turn off the animation + I canāt set key={Math.random()} because I toggle lines (show/hide - and the animation is happening only for specific Line) and I donāt want the whole chart to rerender when the data changes.
I think itās safe to infer this may be a
react-smoothissue, so I opened an issue against that repo:https://github.com/recharts/react-smooth/issues/44
I having a similar issue. If the animation is on, the areas stop drawing. Itās fully drawn if the window resizes. If the animation is off, everything works as expected.
I magically solved the issue by using
useMemo, which might work for your case~I have managed to make it work with animation active. As mentioned before, the key is using the
keyprop.This increments the iteration of data and re-renders with the new key, forcing react to update the chart components. The only downside is that, in case of data change, the chart doesnāt ātransitionā but rather draws the line from beginning.
Hello everyone
Please, just add
<Tooltip />below<YAxis />and setisAnimationActive={false}for<Line />Worked in my case
Iām having the same issue. It seems to be if the animation is interrupted then the dots donāt get drawn.