@antv/g2
Version:
the Grammar of Graphics in Javascript
25 lines • 901 B
JavaScript
import { deepMix } from '@antv/util';
import { column, columnOf } from './utils/helper';
import { rangeOf, interpolate } from './jitter';
/**
* The JitterY transform produce dy channels for marks (especially for point)
* with ordinal x and y dimension, say to make them jitter in their own space.
*/
export const JitterY = (options = {}) => {
const { padding = 0, random = Math.random } = options;
return (I, mark) => {
const { encode, scale } = mark;
const { y: scaleY } = scale;
const [Y] = columnOf(encode, 'y');
const rangeY = rangeOf(Y, scaleY, padding);
const DY = I.map(() => interpolate(random(), ...rangeY));
return [
I,
deepMix({ scale: { y: { padding: 0.5 } } }, mark, {
encode: { dy: column(DY) },
}),
];
};
};
JitterY.props = {};
//# sourceMappingURL=jitterY.js.map