Open Rafael-Ramblas opened 1 month ago
Thanks for the bug report with the helpful example.
I think it makes more sense if the library automatically refreshes the chart when a primitive is removed instead of relying on the Plugin code to do this within the detached
lifecycle hook. So while it would be possible to fix this within the plugins code (in this case plugin-base
), it would make more sense to implement this by adding this._series.model().fullUpdate();
to the end of detachPrimitive
method.
I found one more information about this. This issue only happens for line charts, other types of charts works as expected without having the need to call the requestUpdate
method, and adding the line suggested actually causes a runtime error.
Lightweight Charts™ Version: 4.1.4
Importing the code from the band-indicator example and using in a React component there's an issue with detaching the primitive using a controlled state, as shown in the code below, the chart isn't updated after executing the function
detachPrimitive
.The problem relies on the file
plugin-base.ts
that implements the method for detaching the primitive. The method doesn't call therequestUpdate
function before destroying the instance data. If we add the linethis.requestUpdate();
beforethis._requestUpdate = undefined;
the feature works as expected.Actual behavior:
The chat isn't updated when the method
detachPrimitive
is executed.Expected behavior:
The chart should update and remove the primitive draw.
CodeSandbox/JSFiddle/etc link:
https://codesandbox.io/p/sandbox/jolly-christian-lkmqnh