Skip to content

Commit

Permalink
fix: still dispatch update event if no data present
Browse files Browse the repository at this point in the history
  • Loading branch information
huww98 committed May 13, 2020
1 parent 5a13af0 commit 86946e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/nearestPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export class NearestPointModel {
} else {
const domain = this.model.xScale.invert(this.lastX);
for (const s of this.options.series) {
if (s.data.length == 0) {
this.points.delete(s);
continue;
}
const pos = domainSearch(s.data, 0, s.data.length, domain, d => d.x);
const near: typeof s.data = [];
if (pos > 0) {
Expand Down
7 changes: 5 additions & 2 deletions src/renderModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export class RenderModel {
updated = new EventDispatcher();

update() {
this.updateModel();
this.updated.dispatch();
}

updateModel() {
for (const s of this.options.series) {
if (!this.seriesInfo.has(s)) {
this.seriesInfo.set(s, {
Expand Down Expand Up @@ -104,8 +109,6 @@ export class RenderModel {
this.yScale.domain([opYRange.min, opYRange.max])
}
}

this.updated.dispatch();
}

private redrawRequested = false;
Expand Down

0 comments on commit 86946e1

Please sign in to comment.