-
Notifications
You must be signed in to change notification settings - Fork 668
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
Changing Legend onChange does not update component (temp fix found) #1548
Comments
Ok, so I've found the problematic section of code. This is in components/Legend/index.tsx:
The empty dependency array for this useEffect means it will only run on the first render. When props.onChange changes, the chart event is not updated. There is a fix. When you load the chart, you can get the g2Instance (a prop on Chart) and call .on yourself (the g2Instance is the 'view' referenced above) to re-register the legend click events when they change. I'm leaving this issue open since this does not follow the expected behavior. If you run into this issue, the fix above should work. |
BizCharts Version: 4.1.22
Platform: MacOS
Editing Legend properties such as visible and position will update immediately, but changing the onChange event handler does not. I cannot use forceUpdate on the Chart because it freezes the page. Example:
When
dependency
changes, theonLegendChange
function is updated. However, clicking items in the legend will still have the old behavior until the chart is manually re-rendered through some other means.The text was updated successfully, but these errors were encountered: