How to completely rerender the graph?
See original GitHub issueWhat is the current behavior?
When I change the data
to LineChart
, the only curve is rerendered. But the initial animation(showing the drawing of the graph) is not there. I am using this into a ResponsiveContainer
.
Here is my state and state update function:
state = {
first: true,
second: false,
color: '#44cc44'
}
componentDidMount () {
this.timer = setInterval(() => {
if (this.state.first) {
this.setState({
first: false,
second: true,
color: '#44cc44'
})
} else {
this.setState({
first: true,
second: false,
color: '#ff0000'
})
}
}, 4000)
}
{
this.state.first
? (
<ResponsiveContainer height={120}>
<LineChart data={data0}>
<Line type='monotone' dataKey='pv' dot={false} strokeWidth={5} stroke={this.state.color} />
<CartesianGrid vertical={false} />
</LineChart>
</ResponsiveContainer>
)
: (
<ResponsiveContainer height={120}>
<LineChart data={data1.slice()}>
<Line type='monotone' dataKey='pv' dot={false} strokeWidth={5} stroke={this.state.color} />
<CartesianGrid vertical={false} />
</LineChart>
</ResponsiveContainer>
)
}
What is the expected behavior?
When I change the data, the whole graph should be rerendered.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to mange the re-rendering of components through the app
When I uncheck the checkbox on a <ChartDataList> I would like to update the chart's options to provoke a re-render of the chart....
Read more >Force chart re-render and ZoomPanModifier beyond min and ...
After I load all my data to the chart, how can I force to re-render the chart? The problem I'm having is that...
Read more >Updating Charts - Chart.js
To update the options, mutating the options property in place or passing in a new options object are supported. If the options are...
Read more >How to check if your component rerendered - and why!
There's a very handy tooltip that shows up when hovering over a component in the "Flamegraph", that shows the reason for a render...
Read more >Force re-render function React component (or class component)
For example, when you need to fetch fresh data and re-render a graph for example. Below is some imaginary random data, you can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can force a remount by setting and changing the
key
propThank you @klarstrup, this just saved me hours of headache with this finicky library.