| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import { baseGeometryChannels, basePostInference, basePreInference, createBandOffset, tooltip2d, } from './utils';
- /**
- * Convert value for each channel to point shapes.
- * Calc the bbox of each point based on x, y and r.
- * This is for allowing their radius can be affected by coordinate(e.g. fisheye).
- */
- export const Point = (options) => {
- return (index, scale, value, coordinate) => {
- const { x: X, y: Y, x1: X1, y1: Y1, size: S, dx: DX, dy: DY } = value;
- const [width, height] = coordinate.getSize();
- const offset = createBandOffset(scale, value, options);
- const xy = (i) => {
- const dx = +((DX === null || DX === void 0 ? void 0 : DX[i]) || 0);
- const dy = +((DY === null || DY === void 0 ? void 0 : DY[i]) || 0);
- const x = X1 ? (+X[i] + +X1[i]) / 2 : +X[i];
- const y = Y1 ? (+Y[i] + +Y1[i]) / 2 : +Y[i];
- const cx = x + dx;
- const cy = y + dy;
- return [cx, cy];
- };
- const P = S
- ? Array.from(index, (i) => {
- const [cx, cy] = xy(i);
- const r = +S[i];
- const a = r / width;
- const b = r / height;
- const p1 = [cx - a, cy - b];
- const p2 = [cx + a, cy + b];
- return [
- coordinate.map(offset(p1, i)),
- coordinate.map(offset(p2, i)),
- ];
- })
- : Array.from(index, (i) => [coordinate.map(offset(xy(i), i))]);
- return [index, P];
- };
- };
- const shapes = [
- 'hollow',
- 'hollowDiamond',
- 'hollowHexagon',
- 'hollowSquare',
- 'hollowTriangleDown',
- 'hollowTriangle',
- 'hollowBowtie',
- 'point',
- 'plus',
- 'diamond',
- 'square',
- 'triangle',
- 'hexagon',
- 'cross',
- 'bowtie',
- 'hyphen',
- 'line',
- 'tick',
- 'triangleDown',
- ];
- Point.props = {
- defaultShape: 'hollow',
- defaultLabelShape: 'label',
- composite: false,
- channels: [
- ...baseGeometryChannels({ shapes }),
- { name: 'x', required: true },
- { name: 'y', required: true },
- { name: 'series', scale: 'band' },
- { name: 'size', scale: 'sqrt' },
- { name: 'dx', scale: 'identity' },
- { name: 'dy', scale: 'identity' },
- ],
- preInference: [
- ...basePreInference(),
- { type: 'maybeZeroY' },
- { type: 'maybeZeroX' },
- ],
- postInference: [
- ...basePostInference(),
- { type: 'maybeSize' },
- ...tooltip2d(),
- ],
- };
- //# sourceMappingURL=point.js.map
|