react-native-chart-kit
Version:
Beautiful React Native charts for dashboards, reports, and data-rich mobile apps.
24 lines (23 loc) • 1.33 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { SvgCircle, SvgLine, SvgPath, SvgRect } from "./primitives";
import { createSvgSymbolDiamondPath } from "./symbolGeometry";
export const SvgSymbol = ({ cornerRadius, fill, opacity, shape, size, stroke, strokeLinecap = "round", strokeWidth, testID, x, y }) => {
const paintProps = {
...(testID ? { testID } : {}),
...(fill ? { fill } : {}),
...(opacity !== undefined ? { opacity } : {}),
...(stroke ? { stroke } : {}),
...(strokeWidth !== undefined ? { strokeWidth } : {})
};
const lineStroke = stroke ?? fill;
if (shape === "line") {
return (_jsx(SvgLine, { x1: x - size / 2, x2: x + size / 2, y1: y, y2: y, strokeLinecap: strokeLinecap, strokeWidth: strokeWidth ?? 2, ...(testID ? { testID } : {}), ...(lineStroke ? { stroke: lineStroke } : {}), ...(opacity !== undefined ? { opacity } : {}) }));
}
if (shape === "square") {
return (_jsx(SvgRect, { x: x - size / 2, y: y - size / 2, width: size, height: size, rx: cornerRadius ?? Math.min(3, size * 0.225), ...paintProps }));
}
if (shape === "diamond") {
return (_jsx(SvgPath, { d: createSvgSymbolDiamondPath({ x, y, size }), ...paintProps }));
}
return _jsx(SvgCircle, { cx: x, cy: y, r: size / 2, ...paintProps });
};