| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { baseGeometryChannels, basePostInference, basePreInference, tooltip2d, } from './utils';
- /**
- * Convert value for each channel to polygon shapes.
- */
- export const Polygon = () => {
- return (index, scale, value, coordinate) => {
- const Xn = Object.entries(value)
- .filter(([key]) => key.startsWith('x'))
- .map(([, value]) => value);
- const Yn = Object.entries(value)
- .filter(([key]) => key.startsWith('y'))
- .map(([, value]) => value);
- const P = index.map((i) => {
- const Pn = [];
- for (let j = 0; j < Xn.length; j++) {
- const x = Xn[j][i];
- if (x === undefined)
- break;
- const y = Yn[j][i];
- Pn.push(coordinate.map([+x, +y]));
- }
- return Pn;
- });
- return [index, P];
- };
- };
- const shapes = ['polygon', 'ribbon'];
- Polygon.props = {
- defaultShape: 'polygon',
- defaultLabelShape: 'label',
- composite: false,
- channels: [
- ...baseGeometryChannels({ shapes }),
- { name: 'x', required: true },
- { name: 'y', required: true },
- ],
- preInference: [...basePreInference()],
- postInference: [...basePostInference(), ...tooltip2d()],
- };
- //# sourceMappingURL=polygon.js.map
|