ResponsiveBar in production build - Y axis tick values not updating on setstate
See original GitHub issueDescribe/explain the bug I’m using ResponsiveBar to visualize simple grade percentage data. In development everything works as expected however, in production the tick values don’t seem to update on setstate.
Code
<ResponsiveBar
data={gradePrecentage}
keys={["A", "B", "C", "D", "F", "O"]}
indexBy="id"
margin={{ top: 0, right: 60, bottom: 50, left: 50 }}
padding={0.1}
valueScale={{ type: "linear" }}
indexScale={{ type: "band", round: true }}
label={(d) => `${d.value}%`}
colors={[
"#41ab5d",
"#7fc97f",
"#f16913",
"#ef3b2c",
"#e41a1c",
"#e41a1c",
]}
itemHeight={"120px"}
axisTop={null}
axisRight={null}
axisBottom={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: "Grade",
legendPosition: "middle",
legendOffset: 32,
}}
axisLeft={{
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: "% of Students",
legendPosition: "middle",
legendOffset: -40,
}}
/>
data = [{id: key, data: value}]
Expected behavior Y axis Tick values should update as data changes on setstate in production build.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser chrome 88.0, safari 14.0.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
d3 Axis Ticks Not Updating - Stack Overflow
That is all working fine and the data is plotted correctly. But, the tick marks remain 0 to 1 on the Y axis...
Read more >Integrating D3 with React
The idea behind declarative visualization is that you can focus on building your logic, not how to render something. Same as we discussed...
Read more >Top React Chart Libraries to Visualize your Data in 2023
Best React Chart Libraries help you to build user-friendly, responsive charts for your web App: Checkout most popular React Chart ...
Read more >React debugging session - Why is this function called ...
Your code seems to work. Until it doesn't. Either it's not working as expected at all or only in some situations.
Read more >7 React Chart Libraries For Your Web Projects
Meaning that you can focus on producing the actual data and leave the heavy-lifting of designing the graphs and charts on the library...
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
I should have updated – I was able to fix it using this solution
Essentially due to an issue with
react-spring
, you have to setsideEffects: false
in your config – like @monzilnepali says above.We’ve update to the latest react-spring and this workaround won’t be needed.