-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Scatter Plot won't render a large number of points #919
Comments
does this happen in all browsers? all OSs? all machines? might also be limit of specific gpu or driver? there's nothing in uPlot that restricts data size, so any issues where some arbitrary number fails to draw will probably be env/hardware dependent. |
Tested a few different things: Macbook Pro 16:
Dell Precision 5760 - Arch Linux:
Dell Precision 5760 - Windows:
To confirm the behavior does seem to be related to the number of points in a single series (which makes no sense to me). Adding multiple additional series in different colors on the same plots works as long as the single series is below 180 000. So the total number of Canvas elements can very easily exceed the 180 000 limit. |
Alright a little more info: Seems to be related to some combination of Chrome, hardware acceleration, and some intel hardware? This thread looks similiar although I think two issues are getting conflated into one there. Forcing the canvas into software mode does fix the issue (with obvious side effects). |
interesting 👍 |
it might be some limit with you can draw directly to |
btw, usually seeing all raw data is unnecessary. you can sample 10-20% and still get a full understanding of the distribution. there's not much that 180k points will tell you that 50k points won't. you can also create a heatmap from the full dataset. a heatmap will always have some fixed and reasonable limit to the number of items in the grid, and will be much faster, since you can also skip alpha opacity, and avoid antialiasing by drawing squares instead of circles. then maybe use a scatter plot as a second level drill-down when clicking on subset of heatmap cells. |
It took a while before I got back to this but confirmed it is a problem with Path2D. Agree 180k points is too many but I plot user generated data so I have minimal control over what comes in without opaquely decimating data. For anyone else running into this problem: const drawPoints: Series.PathBuilder = (u, seriesIdx) => {
const size = 2 * devicePixelRatio
uPlot.orient(
u,
seriesIdx,
(
series,
dataX,
dataY,
scaleX,
scaleY,
valToPosX,
valToPosY,
xOff,
yOff,
xDim,
yDim,
moveTo,
lineTo,
rect,
arc,
) => {
const x = u.data[seriesIdx][0]
const y = u.data[seriesIdx][1]
u.ctx.fillStyle = series?.stroke?.()
const deg360 = 2 * Math.PI
console.time('points')
const paths = [new Path2D()]
let pathIdx = 0
const r = size / 2
if (!x || !Array.isArray(x) || !Array.isArray(y)) return
x.forEach((x_pos, idx) => {
if (idx % 5 !== 0) return
// There are chrome issues rendering past 180000 points. Create a new path every 150000 points to be safe
if (idx && idx % 150000 === 0) {
paths.push(new Path2D())
pathIdx += 1
}
const y_pos = y[idx]
if (
x_pos >= scaleX.min &&
x_pos <= scaleX.max &&
y_pos >= scaleY.min &&
y_pos <= scaleY.max
) {
const cx = valToPosX(x_pos, scaleX, xDim, xOff)
const cy = valToPosY(y_pos, scaleY, yDim, yOff)
paths[pathIdx].moveTo(cx + r, cy)
arc(paths[pathIdx], cx, cy, r, 0, deg360)
}
})
console.timeEnd('points')
paths.forEach((p) => u.ctx.fill(p))
},
)
return null
} |
I am playing around with large scatter datasets (single series). I noticed over about 180 000 points the plot just stops rendering.
Using
scatter.html
as a base I created the below minimum example. With a single plot series (plus the empty series[0]) the plot stops rendering at 182 000 points.The actual number of points does not seem to be an issue. At 180 000 points I am able to see the plot and it on my system the renders in 108ms. I am also able to add a second series also with 180 000 points so the limitation seems to be on a single series with a large number of points. I don't see any debugging output.
The text was updated successfully, but these errors were encountered: