getRenderThreshold static method
Implementation
static int getRenderThreshold(BuildContext context, int totalPoints) {
if (totalPoints <= 0) return 0;
final dpr = MediaQuery.devicePixelRatioOf(context);
final safeDpr = dpr.isFinite && dpr > 0 ? dpr : 1.0;
final base = (minRenderThreshold * safeDpr)
.clamp(minRenderThreshold, maxRenderThreshold)
.toInt();
// For ultra-large datasets, use dynamic percentage while keeping a hard
// upper bound so painters do not accidentally render every visible point.
if (totalPoints > ultraLargePointCount) {
return (totalPoints * 0.05)
.clamp(base, maxRenderThreshold)
.toInt()
.clamp(0, totalPoints);
}
return base.clamp(0, totalPoints);
}