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

Function computeBaseYDomain

src/core/createRenderCoordinator.ts:1255–1285  ·  view source on GitHub ↗
(
  options: ResolvedChartGPUOptions,
  runtimeRawBoundsByIndex?: ReadonlyArray<Bounds | null> | null,
  visibleBoundsOverride?: Bounds | null
)

Source from the content-addressed store, hash-verified

1253};
1254
1255const computeBaseYDomain = (
1256 options: ResolvedChartGPUOptions,
1257 runtimeRawBoundsByIndex?: ReadonlyArray<Bounds | null> | null,
1258 visibleBoundsOverride?: Bounds | null
1259): { readonly min: number; readonly max: number } => {
1260 // Explicit min/max ALWAYS take precedence over auto-bounds
1261 const explicitMin = finiteOrUndefined(options.yAxis.min);
1262 const explicitMax = finiteOrUndefined(options.yAxis.max);
1263
1264 // If both min and max are explicit, use them directly (no auto-bounds needed)
1265 if (explicitMin !== undefined && explicitMax !== undefined) {
1266 return normalizeDomain(explicitMin, explicitMax);
1267 }
1268
1269 // Determine which bounds to use based on autoBounds mode
1270 const autoBoundsMode = options.yAxis.autoBounds ?? 'visible';
1271 let bounds: Bounds;
1272
1273 if (autoBoundsMode === 'visible' && visibleBoundsOverride) {
1274 // Use visible bounds from renderSeries (zoom-aware, computed from visible data only)
1275 bounds = visibleBoundsOverride;
1276 } else {
1277 // Use global bounds from full dataset (pre-zoom behavior, computed from all raw data)
1278 bounds = computeGlobalBounds(options.series, runtimeRawBoundsByIndex);
1279 }
1280
1281 // Merge explicit bounds with computed bounds (partial override support)
1282 const yMin = explicitMin ?? bounds.yMin;
1283 const yMax = explicitMax ?? bounds.yMax;
1284 return normalizeDomain(yMin, yMax);
1285};
1286
1287const computeVisibleXDomain = (
1288 baseXDomain: { readonly min: number; readonly max: number },

Callers 2

setOptionsFunction · 0.85
renderFunction · 0.85

Calls 3

finiteOrUndefinedFunction · 0.70
normalizeDomainFunction · 0.70
computeGlobalBoundsFunction · 0.70

Tested by

no test coverage detected