Labels not re-rendering correctly when data changes.
See original GitHub issueWhat is the problem?
Labels and XAxis not re-rendering properly when the data changes. The old values are still visible, overlapping the new ones.
Before data changes: (ok)
After:
When does it happen?
When the data changes and the chart re-renders.
Code to reproduce
renderPeriodoBar() {
if (this.props.dashboard.caseVolume) {
console.log('DASH',this.props.dashboard.caseVolume);
const values = [10,20,30,40];
const labels = ["A","B","C","D"];
const axesSvg = { fontSize: 10, fill: this.colors.secondary_text, textAlign: 'center' };
const verticalContentInset = { top: 10, bottom: 10 }
const xAxisHeight = 25;
var max = Math.max(...values);
const Labels = ({ x, y, bandwidth, data }) => (
data.map((value, index) => (
<T
belowChart={true}
key={index}
y={y(value) - 10}
x={x(index) + (bandwidth / 2)}
fontSize={10}
font={{
fontFamily: 'Roboto-Light',
}}
fontData={{ name: 'Roboto-Light' }}
fill={this.colors.secondary_text}
alignmentBaseline={'middle'}
textAnchor={'middle'}>
{value}
</T>
))
)
return (
<View style={{ height: 180, paddingTop: 12, flexDirection: 'row' }}>
<View style={{ flex: 1, marginLeft: 0 }}>
<BarChart
data={values}
style={{ flex: 1 }}
gridMin={0}
gridMax={max * 1.5}
contentInset={{ verticalContentInset }}
svg={{
fill: this.colors.accent,
opacity: 0.80,
}}>
<Labels belowChart={true} />
</BarChart>
<XAxis
style={{ marginTop: 6, height: xAxisHeight }}
data={values}
scale={scale.scaleBand}
formatLabel={(value, index) => labels[index]}
svg={axesSvg}
/>
</View>
</View>)
}
}
render(){
return(
<View>
{this.renderPeriodoBar()}
</View>
)
}
Just call the above function on the render method, then change the data inside the function and re-render
What platform?
- [X ] iOS 11
React Native version: 0.54.3
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
javascript - ChartJS not rendering after update
I recreate the chart. It's not good practice but a quick fix. The this.chart.update() does not work for me either. – Maihan Nijat....
Read more >Rerendered Inputfield Label Not Displaying (VF)
Hello, I am trying have an inputfield render based upon what a user selects on another picklist field. The new field is rendering,...
Read more >ASP.NET Core Razor component rendering - Blazor
Therefore, ComponentBase can only trigger rerendering when the Task is first returned and when the Task finally completes. The framework can't ...
Read more >Updating the Data for an LWC lightning-datatable isn't re- ...
My guess is that the table doesn't know to update because you have specified a key field of id but you have not...
Read more >A Story of a React Re-Rendering Bug - Engineering Blog
When we find a bug, no matter how tricky it is, ... /><span data-mce-type= "bookmark" style= "display: inline-block; width: 0px; ...
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
it is updated o/
Let me know if you need something more! Thank you very much for maintaining this awesome repo!!
This should be reopened as this still happens, and can easily be reproduced