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

Fix Vega Scene Graph Errors after Confirming Output Cohorts #67

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 0 deletions src/Taskview/SearchColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export default class SearchColumn {
public clear() {
select(this.$searchColumn).select('.task.selected').classed('selected', false); // deselect all others
this.searchBar.removeAllSelectedOptions();

// tellt tasks that the attributes changed/were cleared
this.updateTasks();
}

private getSelectedAttributes(): IAttribute[] {
Expand Down
7 changes: 6 additions & 1 deletion src/Taskview/columns/AttributeColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IAttribute } from '../../data/IAttribute';
import { Histogram } from './Histogram';

export default class AttributeColumn extends ADataColumn {
private hists: WeakMap<ICohort, Histogram> = new WeakMap();
private hists: Map<ICohort, Histogram> = new Map();

private showOutputChtHistRef = false;

Expand Down Expand Up @@ -154,4 +154,9 @@ export default class AttributeColumn extends ADataColumn {
this.hists.set(cht, hist);
cell.appendChild(hist.getNode());
}

public close(): void {
this.hists.forEach((hist) => hist.remove());
super.close();
}
}
8 changes: 7 additions & 1 deletion src/Taskview/columns/Histogram.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import vegaEmbed from 'vega-embed';
import { TopLevelSpec as VegaLiteSpec } from 'vega-lite';
import { View as VegaView } from 'vega';
import { colors } from '../../config/colors';
import { IAttribute } from '../../data';
import { INumRange, IEqualsList, NumRangeOperators } from '../../base';
Expand All @@ -14,7 +15,7 @@ export class Histogram {

readonly $hist: HTMLDivElement;

vegaView: any;
vegaView: VegaView;

public showReference = true;

Expand All @@ -36,6 +37,11 @@ export class Histogram {
setTimeout(() => that.updateNode.bind(that)(), 0); // run async
}

public async remove() {
this.vegaView?.finalize();
this.$node.remove();
}

public async updateNode() {
this.$hist.remove();
try {
Expand Down
9 changes: 4 additions & 5 deletions src/Taskview/tasks/Filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ export class Filter extends ATask {

async show(columnHeader: HTMLDivElement, container: HTMLDivElement, attributes: IAttribute[], cohorts: ICohort[]) {
super.show(columnHeader, container, attributes, cohorts);

if (attributes.length > 0) {
this.addVisSelector();
}

// remove old vis (if any) as it will be replaced
this.vis?.destroy();

this.$visContainer = this.body.append('div').classed('vis-container', true).node();
// TODO #427 check number of attributes and theid types to define the visualizations
switch (attributes.length) {
Expand Down Expand Up @@ -173,10 +175,7 @@ export class Filter extends ATask {
async showWithVis(vis: AVegaVisualization) {
const eventId = ++this.eventID; // get new eventID, we will compare it with the field again to see if it is still up to date

// remove old vis
if (this.vis) {
this.vis.destroy();
}
this.vis?.destroy();
this.$visContainer.innerHTML = '';

// show loading
Expand Down
Loading