You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You don't see the problem in the examples only because the deleted data is at the end of the arrays. If you remove any item other than the last one then this happens
Expected Behavior
When the data is deleted, the underlying hiddenIndex to be removed too so that no new items are hidden.
Current Behavior
The chart retains the state of the hiddenIndices and sets the next available item to hidden.
Steps to Reproduce
Create a doughnut, set any item other than the last one to hidden, then delete any data item that has a lower index than the hidden one.
@kurkle this is related to #9450. When the dataset controller updates, the controller _hiddenIndices object needs to be updated too. It looks like it would need to be rebuilt because all of the indexes will have potentially shifted.
I'm not sure what the best way to achieve this fix would be. In theory the datasets could be different lengths but I think in practice that cannot be the case. Perhaps we need to use listenArrayEvents but specifically listen to the data.labels array as well and use that to update the hidden indices mapping. It might also make sense for _hiddenIndices to be an array rather than a dict because they we can just apply the operations directly without having to recalculate everything. Does that make sense?
Did not look closely, but maybe this could be done at the same time with elements (insertElements etc). Internally we could change to an array, if its easier to handle. Also need to consider the case when data/labels is replaced.
When removing data that has been hidden, the chart retains the hidden indexes, and goes out of sync with its legend.
Screen.Recording.Google.Chrome.mp4
Screen.Recording.Google.Chrome.2.mp4
You don't see the problem in the examples only because the deleted data is at the end of the arrays. If you remove any item other than the last one then this happens
Expected Behavior
When the data is deleted, the underlying hiddenIndex to be removed too so that no new items are hidden.
Current Behavior
The chart retains the state of the hiddenIndices and sets the next available item to hidden.
Steps to Reproduce
Create a doughnut, set any item other than the last one to hidden, then delete any data item that has a lower index than the hidden one.
https://codepen.io/juliankigwana/pen/PoKKEvj
Context
I need the ability to add and remove data without the legend going out of sync
Environment
The text was updated successfully, but these errors were encountered: