UNPKG

@antv/g2

Version:

the Grammar of Graphics in Javascript

41 lines 1.3 kB
import { MaybeIdentityX, MaybeIdentityY } from '../transform'; import { LinkArc, LinkShape, LinkSmooth, LinkVHV } from '../shape'; import { baseGeometryChannels, basePostInference, basePreInference, createBandOffset, tooltip2d, } from './utils'; const shape = { link: LinkShape, arc: LinkArc, smooth: LinkSmooth, vhv: LinkVHV, }; /** * Connect `start` to `end` with single line. */ export const Link = (options) => { return (index, scale, value, coordinate) => { const { x: X, y: Y, x1: X1 = X, y1: Y1 = Y } = value; const offset = createBandOffset(scale, value, options); const P = index.map((i) => [ coordinate.map(offset([+X[i], +Y[i]], i)), coordinate.map(offset([+X1[i], +Y1[i]], i)), ]); return [index, P]; }; }; Link.props = { defaultShape: 'link', defaultLabelShape: 'label', composite: false, shape, channels: [ ...baseGeometryChannels({ shapes: Object.keys(shape) }), { name: 'x', required: true }, { name: 'y', required: true }, ], preInference: [ ...basePreInference(), { type: MaybeIdentityY }, { type: MaybeIdentityX }, ], postInference: [...basePostInference(), ...tooltip2d()], }; //# sourceMappingURL=link.js.map