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

add pane primitives #1660

Merged
merged 15 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/api/pane-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,5 @@ export class PaneApi<HorzScaleItem> implements IPaneApi<HorzScaleItem> {

public detachPrimitive(primitive: IPanePrimitive<HorzScaleItem>): void {
this._pane.detachPrimitive(primitive as IPanePrimitiveBase<unknown>);
if (primitive.detached) {
primitive.detached();
}
}
}
2 changes: 2 additions & 0 deletions src/model/chart-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ export class ChartModel<HorzScaleItem> implements IDestroyable, IChartModelBase

assert(index >= 0 && index < this._panes.length, 'Invalid pane index');

const pane = this._panes[index];
this._panes.splice(index, 1);
pane.destroy();
SlicedSilver marked this conversation as resolved.
Show resolved Hide resolved
this.fullUpdate();
}

Expand Down
11 changes: 11 additions & 0 deletions src/model/pane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ export class Pane implements IDestroyable, IPrimitiveHitTestSource {
source.destroy();
}
});
this._primitives = this._primitives.filter((primitive: PanePrimitiveWrapper) => {
const p = primitive.primitive();
if (p.detached) {
p.detached();
}
return false;
});
this._destroyed.fire();
}

Expand Down Expand Up @@ -366,6 +373,10 @@ export class Pane implements IDestroyable, IPrimitiveHitTestSource {

public detachPrimitive(source: IPanePrimitiveBase): void {
illetid marked this conversation as resolved.
Show resolved Hide resolved
this._primitives = this._primitives.filter((wrapper: PanePrimitiveWrapper) => wrapper.primitive() !== source);
if (source.detached) {
source.detached();
}
this._model.lightUpdate();
}

public primitives(): PanePrimitiveWrapper[] {
Expand Down