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

Function resolvePieCenterPlotCss

src/ChartGPU.ts:409–424  ·  view source on GitHub ↗
(
  center: PieCenter | undefined,
  plotWidthCss: number,
  plotHeightCss: number
)

Source from the content-addressed store, hash-verified

407};
408
409const resolvePieCenterPlotCss = (
410 center: PieCenter | undefined,
411 plotWidthCss: number,
412 plotHeightCss: number
413): { readonly x: number; readonly y: number } => {
414 const xRaw = center?.[0] ?? '50%';
415 const yRaw = center?.[1] ?? '50%';
416
417 const x = parseNumberOrPercent(xRaw, plotWidthCss);
418 const y = parseNumberOrPercent(yRaw, plotHeightCss);
419
420 return {
421 x: Number.isFinite(x) ? x! : plotWidthCss * 0.5,
422 y: Number.isFinite(y) ? y! : plotHeightCss * 0.5,
423 };
424};
425
426const isPieRadiusTuple = (radius: PieRadius): radius is readonly [inner: number | string, outer: number | string] =>
427 Array.isArray(radius);

Callers 1

Calls 1

parseNumberOrPercentFunction · 0.70

Tested by

no test coverage detected