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
{{ message }}
Repository navigation
Removing an active item's data makes the next update() throw in a scriptable option #12563
When an active element's data point is removed (data.pop() or a shorter data array), the next chart.update() still re-applies or removes the hover style for that index. getStyle then resolves options for an index past the end of the data, so a scriptable option gets the dataset context, where ctx.raw is undefined.
constchart=newChart(ctx,{type: 'line',data: {datasets: [{data: [1,2,3,4,5,6].map((y,x)=>({x, y})),pointBackgroundColor: (ctx)=>(ctx.raw.y>1 ? 'red' : 'blue')}]},options: {scales: {x: {type: 'linear'}}}});chart.setActiveElements([{datasetIndex: 0,index: 5}]);// or hover the last pointchart.data.datasets[0].data.pop();chart.update();// TypeError: Cannot read properties of undefined (reading 'y')
It throws in 4.6.1, 4.6.2 (the published UMD builds) and on master (31a75bf), with setActiveElements and with pointer hover, after pop() or after replacing the array, with update() and update('none'), and with animations on or off.
With setActiveElements, the throw comes from update() → _updateHoverStyles → setHoverStyle → getStyle(5). With pointer hover, it comes from the replayed event's removeHoverStyle for index 5.
The stale item stays in _active after the throw, so every later update() throws again.
Without a scriptable option nothing throws, but getActiveElements() keeps returning {datasetIndex: 0, index: 5} for an element that is no longer in the dataset.
Expected: an active item whose data was removed stops being active at the next update, and no option is resolved for it.
A possible fix, not yet measured: drop active items whose index is not below the dataset's element count at the start of update(). #12560 adds the same filter for hidden data, and it could be extended to cover removed indices.
I'll take this — working on a fix that drops stale active items in update() once the element counts are current, so no option is resolved for a removed index. PR shortly.
Activity
FullStraing commentedon Nov 27, 2026
I'll take this — working on a fix that drops stale active items in update() once the element counts are current, so no option is resolved for a removed index. PR shortly.