From e6bf879d97bdb06f46211a2c2a68b8c71c5f6e7c Mon Sep 17 00:00:00 2001 From: Fritz Lekschas Date: Tue, 7 Jan 2025 15:06:52 -0500 Subject: [PATCH] Fix: prevent drawing points if all are filtered out --- CHANGELOG.md | 4 ++++ src/index.js | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f820938..9cf9146 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.12.1 + +- Fix: prevent drawing points if all are filtered out ([#201](https://github.com/flekschas/regl-scatterplot/issues/201)) + ## 1.12.0 - Feat: add support for adjusting the anti-aliasing via `scatterplot.set({ antiAliasing: 1 })`. ([#175](https://github.com/flekschas/regl-scatterplot/issues/175)) diff --git a/src/index.js b/src/index.js index 228e30d..e4f872b 100644 --- a/src/index.js +++ b/src/index.js @@ -2242,7 +2242,7 @@ const createScatterplot = ( const filteredSelectedPoints = []; for (const pointIdx of pointIdxsArray) { - if (pointIdx < 0 || pointIdx >= numPoints) { + if (!Number.isFinite(pointIdx) || pointIdx < 0 || pointIdx >= numPoints) { // Skip invalid filtered points continue; } @@ -4281,7 +4281,8 @@ const createScatterplot = ( }); } - if (isPointsDrawn) { + const numPoints = getNormalNumPoints(); + if (isPointsDrawn && numPoints > 0) { drawPointBodies(); }