sample static method
Down-sample data to at most threshold points by keeping local min & max.
Each bucket contributes local extrema, then the result is compacted when needed so render budgets remain predictable.
Implementation
static List<DataPoint> sample(List<DataPoint> data, int threshold) {
final finiteData = _finiteDataPoints(data);
return _sampleFinite(finiteData, threshold);
}