Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset changes but line chart not rerender reflect to new dataset change (2)? #732

Open
dumihi313 opened this issue Jul 26, 2024 · 1 comment

Comments

@dumihi313
Copy link

dumihi313 commented Jul 26, 2024

Simulator.Screen.Recording.-.iPhone.14.Pro.Max.-.2024-07-26.at.10.44.09.mp4

To continue with issue

When I change the dataset, it just rerenders for datapoints. It doesn't rerender to remove old line and add new line based on dataset

@dumihi313
Copy link
Author

dumihi313 commented Jul 26, 2024

this my code, I overcame by update a new timestamp to key prop (force rerender). Is there any better solution than this?

` useEffect(() => {

  if (batteryChart && batteryChart.length > 0) {
    const result = parseDTOtoChartModel(
      batteryChart,
      renderDataPointLabelComponent,
    ).dataSet
    setDataSet(result)
    savedDataSet.current = result.map(a => Object.assign({}, a))
    setRenderChartWithDateKey(date) // force rerender
  } else if (batteryChart) {
    setDataSet(emptyChart24hDataset)
    savedDataSet.current = emptyChart24hDataset.map(a =>
      Object.assign({}, a),
    )
    setRenderChartWithDateKey(date) // force rerender
  }
  
}, [batteryChart])`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant