| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
- };
- import { Path } from '@antv/g';
- import { line, curveLinearClosed } from 'd3-shape';
- import { isTranspose } from '../../utils/coordinate';
- import { select } from '../../utils/selection';
- import { applyStyle, getShapeTheme, reorder } from '../utils';
- /**
- * Adjust and return the new `points`.
- */
- function getFunnelPoints(points, nextPoints, coordinate) {
- const [p0, p1, p2, p3] = points;
- if (isTranspose(coordinate)) {
- const newP1 = [nextPoints ? nextPoints[0][0] : p1[0], p1[1]];
- const newP2 = [nextPoints ? nextPoints[3][0] : p2[0], p2[1]];
- return [p0, newP1, newP2, p3];
- }
- const newP1 = [p1[0], nextPoints ? nextPoints[0][1] : p1[1]];
- const newP2 = [p2[0], nextPoints ? nextPoints[3][1] : p2[1]];
- return [p0, newP1, newP2, p3];
- }
- /**
- * Render funnel in different coordinate and using color channel for stroke and fill attribute.
- */
- export const Funnel = (options) => {
- const { adjustPoints = getFunnelPoints } = options, style = __rest(options, ["adjustPoints"]);
- return (points, value, coordinate, theme, point2d, ...args) => {
- const { index, mark, shape, defaultShape } = value;
- const _a = getShapeTheme(theme, mark, shape, defaultShape), { defaultColor } = _a, defaults = __rest(_a, ["defaultColor"]);
- const nextPoints = point2d[index + 1];
- const funnelPoints = adjustPoints(points, nextPoints, coordinate);
- const tpShape = !!isTranspose(coordinate);
- const [p0, p1, p2, p3] = tpShape ? reorder(funnelPoints) : funnelPoints;
- const { color = defaultColor, opacity } = value;
- const b = line().curve(curveLinearClosed)([p0, p1, p2, p3]);
- return select(new Path({}))
- .call(applyStyle, defaults)
- .style('path', b)
- .style('fill', color)
- .style('fillOpacity', opacity)
- .call(applyStyle, style)
- .node();
- };
- };
- Funnel.props = {
- defaultMarker: 'square',
- };
- //# sourceMappingURL=funnel.js.map
|