| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import { baseGeometryChannels, basePostInference, basePreInference, tooltip2d, } from './utils';
- /**
- * Convert value for each channel to Cell shapes.
- * Calc the bbox of each Cell based on x, y and r.
- * This is for allowing their radius can be affected by coordinate(e.g. fisheye).
- */
- export const Cell = () => {
- return (index, scale, value, coordinate) => {
- const { x: X, y: Y } = value;
- const x = scale.x;
- const y = scale.y;
- const P = Array.from(index, (i) => {
- const width = x.getBandWidth(x.invert(+X[i]));
- const height = y.getBandWidth(y.invert(+Y[i]));
- const x1 = +X[i];
- const y1 = +Y[i];
- const p1 = [x1, y1];
- const p2 = [x1 + width, y1];
- const p3 = [x1 + width, y1 + height];
- const p4 = [x1, y1 + height];
- return [p1, p2, p3, p4].map((d) => coordinate.map(d));
- });
- return [index, P];
- };
- };
- const shapes = ['cell', 'hollow'];
- Cell.props = {
- defaultShape: 'cell',
- defaultLabelShape: 'label',
- composite: false,
- channels: [
- ...baseGeometryChannels({ shapes }),
- { name: 'x', required: true, scale: 'band' },
- { name: 'y', required: true, scale: 'band' },
- ],
- preInference: [
- ...basePreInference(),
- { type: 'maybeZeroX' },
- { type: 'maybeZeroY' },
- { type: 'maybeZeroPadding' },
- ],
- postInference: [...basePostInference(), ...tooltip2d()],
- };
- //# sourceMappingURL=cell.js.map
|