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

Function YAxis

src/ui-react-dom-charts/components/YAxis.tsx:7–63  ·  view source on GitHub ↗
({
  className,
  tickFormatter,
  yTicks,
  yMin,
  yMax,
  yTitle,
  plotFrame,
  tickSize,
  tickGap,
  axisWidth,
}: {
  readonly className?: string;
  readonly tickFormatter?: (tick: number) => string;
  readonly yTicks: Ticks;
  readonly yMin: number | undefined;
  readonly yMax: number | undefined;
  readonly yTitle: string;
  readonly plotFrame: PlotFrame;
  readonly tickSize: number;
  readonly tickGap: number;
  readonly axisWidth: number;
})

Source from the content-addressed store, hash-verified

5import type {PlotFrame, Ticks} from '../common/types.ts';
6
7export const YAxis = ({
8 className,
9 tickFormatter,
10 yTicks,
11 yMin,
12 yMax,
13 yTitle,
14 plotFrame,
15 tickSize,
16 tickGap,
17 axisWidth,
18}: {
19 readonly className?: string;
20 readonly tickFormatter?: (tick: number) => string;
21 readonly yTicks: Ticks;
22 readonly yMin: number | undefined;
23 readonly yMax: number | undefined;
24 readonly yTitle: string;
25 readonly plotFrame: PlotFrame;
26 readonly tickSize: number;
27 readonly tickGap: number;
28 readonly axisWidth: number;
29}) => {
30 const [plotX, plotY, , plotHeight] = plotFrame;
31 return isNullish(yMin) || isNullish(yMax) ? null : (
32 <g className={isNullish(className) ? 'y' : `y ${className}`}>
33 <path
34 className="line"
35 d={`M${plotX},${plotY}v${plotHeight}`}
36 fill="none"
37 stroke={CURRENT_COLOR}
38 strokeOpacity={0.5}
39 strokeWidth={1}
40 />
41 <g className="ticks" dominantBaseline="middle" textAnchor="end">
42 {arrayMap(yTicks, (tick) => {
43 const y = plotHeight - getScale(tick, yMin, yMax, plotHeight);
44 return (
45 <text key={tick} x={plotX - tickSize - tickGap} y={plotY + y}>
46 {tickFormatter?.(tick) ?? string(tick)}
47 </text>
48 );
49 })}
50 </g>
51 <text
52 className="title"
53 dominantBaseline="text-before-edge"
54 textAnchor="middle"
55 transform={`translate(${plotX - axisWidth} ${
56 plotFrame[1] + plotFrame[3] / 2
57 }) rotate(-90)`}
58 >
59 {yTitle}
60 </text>
61 </g>
62 );
63};

Callers 1

_AppFunction · 0.90

Calls 4

isNullishFunction · 0.90
arrayMapFunction · 0.90
getScaleFunction · 0.90
stringFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…