({
className,
points,
tickFormatter,
xTicks,
xMin,
xMax,
xTitle,
plotFrame,
tickSize,
tickGap,
axisHeight,
fontSize,
timestampUnit,
xScale,
}: {
readonly className?: string;
readonly points: ScaledPoint[];
readonly tickFormatter?: TickFormatter;
readonly xTicks: Ticks;
readonly xMin: boolean | number | string | undefined;
readonly xMax: boolean | number | string | undefined;
readonly xTitle: string;
readonly plotFrame: PlotFrame;
readonly tickSize: number;
readonly tickGap: number;
readonly axisHeight: number;
readonly fontSize: number;
readonly timestampUnit: TimestampUnit;
readonly xScale: XScale;
})
| 21 | type TickFormatter = (tick: any, timestamp: any) => string; |
| 22 | |
| 23 | export const XAxis = ({ |
| 24 | className, |
| 25 | points, |
| 26 | tickFormatter, |
| 27 | xTicks, |
| 28 | xMin, |
| 29 | xMax, |
| 30 | xTitle, |
| 31 | plotFrame, |
| 32 | tickSize, |
| 33 | tickGap, |
| 34 | axisHeight, |
| 35 | fontSize, |
| 36 | timestampUnit, |
| 37 | xScale, |
| 38 | }: { |
| 39 | readonly className?: string; |
| 40 | readonly points: ScaledPoint[]; |
| 41 | readonly tickFormatter?: TickFormatter; |
| 42 | readonly xTicks: Ticks; |
| 43 | readonly xMin: boolean | number | string | undefined; |
| 44 | readonly xMax: boolean | number | string | undefined; |
| 45 | readonly xTitle: string; |
| 46 | readonly plotFrame: PlotFrame; |
| 47 | readonly tickSize: number; |
| 48 | readonly tickGap: number; |
| 49 | readonly axisHeight: number; |
| 50 | readonly fontSize: number; |
| 51 | readonly timestampUnit: TimestampUnit; |
| 52 | readonly xScale: XScale; |
| 53 | }) => { |
| 54 | const [plotX, plotY, plotWidth, plotHeight] = plotFrame; |
| 55 | const titleGap = mathMax(axisHeight - tickSize - tickGap - 2 * fontSize, 0); |
| 56 | return ( |
| 57 | <g |
| 58 | className={isNullish(className) ? 'x' : `x ${className}`} |
| 59 | dominantBaseline="hanging" |
| 60 | textAnchor="middle" |
| 61 | > |
| 62 | <path |
| 63 | className="line" |
| 64 | d={`M${plotX},${plotY + plotHeight}h${plotWidth}`} |
| 65 | fill="none" |
| 66 | stroke={CURRENT_COLOR} |
| 67 | strokeOpacity={0.5} |
| 68 | strokeWidth={1} |
| 69 | /> |
| 70 | <g className="ticks"> |
| 71 | {arrayIsEmpty(xTicks) || !isNumber(xMin) || !isNumber(xMax) |
| 72 | ? arrayMap(points, ([rowId, xValue, , x]) => ( |
| 73 | <text |
| 74 | key={rowId} |
| 75 | x={plotX + x} |
| 76 | y={plotY + plotHeight + tickSize + tickGap} |
| 77 | > |
| 78 | {getTickLabel(xValue, tickFormatter, xScale, timestampUnit)} |
| 79 | </text> |
| 80 | )) |
no test coverage detected
searching dependent graphs…