MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / sampleSeriesDataPoints

Function sampleSeriesDataPoints

src/data/sampleSeries.ts:112–138  ·  view source on GitHub ↗
(
  data: ReadonlyArray<DataPoint>,
  sampling: SeriesSampling,
  samplingThreshold: number
)

Source from the content-addressed store, hash-verified

110}
111
112export function sampleSeriesDataPoints(
113 data: ReadonlyArray<DataPoint>,
114 sampling: SeriesSampling,
115 samplingThreshold: number
116): ReadonlyArray<DataPoint> {
117 const threshold = clampTargetPoints(samplingThreshold);
118
119 // Disabled or already under threshold: keep original reference (avoid extra allocations).
120 if (sampling === 'none') return data;
121 if (!(threshold > 0)) return data;
122 if (data.length <= threshold) return data;
123
124 switch (sampling) {
125 case 'lttb':
126 return lttbSample(data, threshold);
127 case 'average':
128 return sampleByBuckets(data, threshold, 'average');
129 case 'max':
130 return sampleByBuckets(data, threshold, 'max');
131 case 'min':
132 return sampleByBuckets(data, threshold, 'min');
133 default: {
134 // Defensive for JS callers / widened types.
135 return data;
136 }
137 }
138}
139

Callers 4

recomputeRenderSeriesFunction · 0.90
resolveOptionsFunction · 0.90
sampling-config.tsFile · 0.90

Calls 3

lttbSampleFunction · 0.90
clampTargetPointsFunction · 0.85
sampleByBucketsFunction · 0.85

Tested by

no test coverage detected