| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Point = void 0;
- const utils_1 = require("./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).
- */
- 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 = (0, utils_1.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];
- };
- };
- exports.Point = Point;
- const shapes = [
- 'hollow',
- 'hollowDiamond',
- 'hollowHexagon',
- 'hollowSquare',
- 'hollowTriangleDown',
- 'hollowTriangle',
- 'hollowBowtie',
- 'point',
- 'plus',
- 'diamond',
- 'square',
- 'triangle',
- 'hexagon',
- 'cross',
- 'bowtie',
- 'hyphen',
- 'line',
- 'tick',
- 'triangleDown',
- ];
- exports.Point.props = {
- defaultShape: 'hollow',
- defaultLabelShape: 'label',
- composite: false,
- channels: [
- ...(0, utils_1.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: [
- ...(0, utils_1.basePreInference)(),
- { type: 'maybeZeroY' },
- { type: 'maybeZeroX' },
- ],
- postInference: [
- ...(0, utils_1.basePostInference)(),
- { type: 'maybeSize' },
- ...(0, utils_1.tooltip2d)(),
- ],
- };
- //# sourceMappingURL=point.js.map
|