MCPcopy Create free account
hub / github.com/ChartGPU/ChartGPU / setOptions

Function setOptions

src/core/createRenderCoordinator.ts:3041–3206  ·  view source on GitHub ↗
(resolvedOptions)

Source from the content-addressed store, hash-verified

3039 };
3040
3041 const setOptions: RenderCoordinator['setOptions'] = (resolvedOptions) => {
3042 assertNotDisposed();
3043
3044 // Capture "from" snapshot BEFORE overwriting coordinator state.
3045 const fromZoomRange = zoomState?.getRange() ?? null;
3046 const fromSnapshot: UpdateTransitionSnapshot = (() => {
3047 // Requirement (mid-flight updates): if a transition is running, rebase from the current blended state.
3048 if (updateTransition && updateAnimId) {
3049 try {
3050 updateAnimController.update(performance.now());
3051 } catch {
3052 // best-effort
3053 }
3054 return computeUpdateSnapshotAtProgress(updateTransition, updateProgress01, fromZoomRange);
3055 }
3056
3057 const fromXBase = computeBaseXDomain(currentOptions, runtimeRawBoundsByIndex);
3058 const fromXVisible = computeVisibleXDomain(fromXBase, fromZoomRange);
3059 const fromYBase = computeBaseYDomain(currentOptions, runtimeRawBoundsByIndex, cachedVisibleYBounds);
3060 return {
3061 xBaseDomain: fromXBase,
3062 xVisibleDomain: { min: fromXVisible.min, max: fromXVisible.max },
3063 yBaseDomain: fromYBase,
3064 series: renderSeries,
3065 };
3066 })();
3067
3068 // Cancel any prior update transition AFTER capturing the rebased "from" snapshot.
3069 cancelUpdateTransition();
3070 const likelyDataChanged = didSeriesDataLikelyChange(currentOptions.series, resolvedOptions.series);
3071
3072 currentOptions = resolvedOptions;
3073 runtimeBaseSeries = resolvedOptions.series;
3074 renderSeries = resolvedOptions.series;
3075 // Recompute visible y-bounds from the new series
3076 cachedVisibleYBounds = null;
3077 gpuSeriesKindByIndex = new Array(resolvedOptions.series.length).fill('unknown');
3078 lastSampledData = new Array(resolvedOptions.series.length).fill(null);
3079 legend?.update(resolvedOptions.series, resolvedOptions.theme);
3080 cancelZoomResampleDebounce();
3081 zoomResampleDue = false;
3082 cancelScheduledFlush();
3083 initRuntimeSeriesFromOptions();
3084 recomputeRuntimeBaseSeries();
3085 updateZoom();
3086 recomputeRenderSeries();
3087
3088 // Tooltip enablement may change at runtime.
3089 if (overlayContainer) {
3090 const shouldHaveTooltip = currentOptions.tooltip?.show !== false;
3091 if (shouldHaveTooltip && !tooltip) {
3092 tooltip = createTooltip(overlayContainer);
3093 lastTooltipContent = null;
3094 lastTooltipX = null;
3095 lastTooltipY = null;
3096 }
3097 if (!shouldHaveTooltip && tooltip) {
3098 hideTooltip();

Callers

nothing calls this directly

Calls 15

createTooltipFunction · 0.90
computeBaseXDomainFunction · 0.85
computeVisibleXDomainFunction · 0.85
computeBaseYDomainFunction · 0.85
cancelUpdateTransitionFunction · 0.85
cancelScheduledFlushFunction · 0.85
updateZoomFunction · 0.85

Tested by

no test coverage detected