UNPKG

1.08 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.JitterX = void 0;
4const util_1 = require("@antv/util");
5const helper_1 = require("./utils/helper");
6const jitter_1 = require("./jitter");
7/**
8 * The JitterX transform produce dy channels for marks (especially for point)
9 * with ordinal x and y dimension, say to make them jitter in their own space.
10 */
11const JitterX = (options = {}) => {
12 const { padding = 0, random = Math.random } = options;
13 return (I, mark) => {
14 const { encode, scale } = mark;
15 const { x: scaleX } = scale;
16 const [X] = (0, helper_1.columnOf)(encode, 'x');
17 const rangeX = (0, jitter_1.rangeOf)(X, scaleX, padding);
18 const DX = I.map(() => (0, jitter_1.interpolate)(random(), ...rangeX));
19 return [
20 I,
21 (0, util_1.deepMix)({ scale: { x: { padding: 0.5 } } }, mark, {
22 encode: { dx: (0, helper_1.column)(DX) },
23 }),
24 ];
25 };
26};
27exports.JitterX = JitterX;
28exports.JitterX.props = {};
29//# sourceMappingURL=jitterX.js.map
\No newline at end of file