Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
r59q committed Apr 14, 2024
1 parent 6a1079f commit 5f45611
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/graphs/knngraph/KNNModelGraphController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class KNNModelGraphController {
if (!filteredXs.includes(NaN)) {
axis && drawData.push(liveData);
}

this.graphDrawer.draw(draw.config, drawData);
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/graphs/knngraph/KNNModelGraphDrawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class KNNModelGraphDrawer {
if (!this.allowRedraw()) {
return;
}
this.svg.selectAll('*').remove(); // clear svg for redraw

// this.svg.selectAll('*').remove(); // clear svg for redraw
// Add grid
this.addGrid(drawConfig);

Expand All @@ -46,6 +45,7 @@ class KNNModelGraphDrawer {
this.addAxis({ x: 0, y: 1, z: 0 }, 'yScale', drawConfig, StaticConfiguration.liveGraphColors[1]);
this.addAxis({ x: 0, y: 0, z: 1 }, 'zScale', drawConfig, StaticConfiguration.liveGraphColors[2]);


// Add points
drawData.forEach((clazz, classIndex) => {
clazz.forEach((sample, exampleIndex) => {
Expand Down Expand Up @@ -206,11 +206,12 @@ class KNNModelGraphDrawer {
const gridData = grid3d(xGrid);

// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
const xGridE = this.svg.selectAll('path.grid').data(gridData, (d: any) => d.id);
const xGridE = this.svg.selectAll('path.grid').remove().data(gridData, (d: any) => d.id);

xGridE
.enter()
.append('path')
.lower()
.attr('class', `${this.classId} grid`)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down

0 comments on commit 5f45611

Please sign in to comment.