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

Function appendData

src/ChartGPU.ts:1322–1374  ·  view source on GitHub ↗
(seriesIndex, newPoints)

Source from the content-addressed store, hash-verified

1320 requestRender();
1321 },
1322 appendData(seriesIndex, newPoints) {
1323 if (disposed) return;
1324 if (!Number.isFinite(seriesIndex)) return;
1325 if (seriesIndex < 0 || seriesIndex >= resolvedOptions.series.length) return;
1326 if (!newPoints || newPoints.length === 0) return;
1327
1328 const s = resolvedOptions.series[seriesIndex]!;
1329 if (s.type === 'pie') {
1330 // Pie series are non-cartesian and currently not supported by streaming append.
1331 if (!warnedPieAppendSeries.has(seriesIndex)) {
1332 warnedPieAppendSeries.add(seriesIndex);
1333 console.warn(
1334 `ChartGPU.appendData(${seriesIndex}, ...): pie series are not supported by streaming append. Use setOption(...) to replace pie data.`
1335 );
1336 }
1337 return;
1338 }
1339
1340 // Forward to coordinator (GPU buffers + render-state updates), then keep ChartGPU's
1341 // hit-testing runtime store in sync.
1342 coordinator?.appendData(seriesIndex, newPoints);
1343
1344 if (s.type === 'candlestick') {
1345 // Handle candlestick series with OHLC data points.
1346 const owned = (runtimeRawDataByIndex[seriesIndex] ?? []) as OHLCDataPoint[];
1347 owned.push(...(newPoints as OHLCDataPoint[]));
1348 runtimeRawDataByIndex[seriesIndex] = owned;
1349
1350 runtimeRawBoundsByIndex[seriesIndex] = extendBoundsWithOHLCDataPoints(
1351 runtimeRawBoundsByIndex[seriesIndex],
1352 newPoints as OHLCDataPoint[]
1353 );
1354 } else {
1355 // Handle other cartesian series (line, area, bar, scatter).
1356 const owned = (runtimeRawDataByIndex[seriesIndex] ?? []) as DataPoint[];
1357 owned.push(...(newPoints as DataPoint[]));
1358 runtimeRawDataByIndex[seriesIndex] = owned;
1359
1360 runtimeRawBoundsByIndex[seriesIndex] = extendBoundsWithDataPoints(
1361 runtimeRawBoundsByIndex[seriesIndex],
1362 newPoints as DataPoint[]
1363 );
1364 }
1365
1366 cachedGlobalBounds = computeGlobalBounds(resolvedOptions.series, runtimeRawBoundsByIndex);
1367
1368 runtimeHitTestSeriesCache = null;
1369 runtimeHitTestSeriesVersion++;
1370 interactionScalesCache = null;
1371
1372 // Ensure a render is scheduled (coalesced) like setOption does.
1373 requestRender();
1374 },
1375 resize,
1376 dispose,
1377 on(eventName, callback) {

Callers

nothing calls this directly

Calls 5

computeGlobalBoundsFunction · 0.70
requestRenderFunction · 0.70
appendDataMethod · 0.65

Tested by

no test coverage detected