MCPcopy Index your code
hub / github.com/tinyplex/tinybase / getX

Function getX

src/ui-react-dom-charts/common/data.ts:136–159  ·  view source on GitHub ↗
(
  xValue: XValue,
  xScale: XScale,
  timestampUnit: TimestampUnit,
  [xMin, xMax]: Domain,
  xCategories: Map<XValue, number>,
  width: number,
  kind: Kind,
)

Source from the content-addressed store, hash-verified

134};
135
136const getX = (
137 xValue: XValue,
138 xScale: XScale,
139 timestampUnit: TimestampUnit,
140 [xMin, xMax]: Domain,
141 xCategories: Map<XValue, number>,
142 width: number,
143 kind: Kind,
144): number | undefined => {
145 const continuousValue = getContinuousXValue(xValue, xScale, timestampUnit);
146 return xScale != CATEGORY
147 ? isUndefined(continuousValue)
148 ? undefined
149 : getScale(continuousValue, xMin, xMax, width)
150 : kind == BAR
151 ? (width * ((mapGet(xCategories, xValue) ?? 0) + 0.5)) /
152 collSize(xCategories)
153 : getScale(
154 mapGet(xCategories, xValue) ?? 0,
155 0,
156 collSize(xCategories) - 1,
157 width,
158 );
159};
160
161export const getScale = (
162 value: number,

Callers 1

getScaledPointsFunction · 0.70

Calls 5

isUndefinedFunction · 0.90
mapGetFunction · 0.90
collSizeFunction · 0.90
getContinuousXValueFunction · 0.70
getScaleFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…