UNPKG

@apptane/react-ui-charts

Version:
58 lines (54 loc) 2.41 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import { useContext } from "react"; import { ChartDatumContext } from "../parts/ChartDatumContext.js"; import { jsx as _jsx } from "@emotion/react/jsx-runtime"; export function XYBubbleLayer(_ref) { let { componentId, data, offset } = _ref; const selectedDatumId = useContext(ChartDatumContext); const bubbles = []; data.forEach(_ref2 => { let { id, index, color, loColor, hiColor, pri, sec } = _ref2; const unselected = selectedDatumId != null && id !== selectedDatumId; const key = id !== null && id !== void 0 ? id : "_".concat(index); [pri, sec].forEach((_, i) => { if (_ != null && _.length > 0) { const strokeProps = i === 1 ? { stroke: color, strokeWidth: 1, strokeDasharray: "2" } : {}; _.forEach(p => { if (p.c != null) { bubbles.push(_jsx("circle", _objectSpread({ transform: "translate(".concat(p.c.x, ",").concat(p.c.y, ")"), cx: 0, cy: 0, r: p.c.d * 0.5, fill: unselected ? loColor : i === 1 ? hiColor : color }, strokeProps), "".concat(key, "-").concat(i, "-").concat(p.index))); } }); } }); }); return _jsx("g", { transform: "translate(".concat(offset, ",0)"), clipPath: "url(#".concat(componentId, "-main-clip)"), children: bubbles }); } //# sourceMappingURL=XYBubbleLayer.js.map