UNPKG

1.21 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.MaybeStackY = void 0;
4const stackY_1 = require("./stackY");
5// Avoid duplicate stackY.
6// In most of case only one of stackY and dodgeX is needed.
7// So pass statistic with stackY and dodgeX.
8function exclude(transform) {
9 const { type } = transform;
10 const excludes = ['stackY', 'dodgeX', 'groupX'];
11 return typeof type === 'string' && excludes.includes(type);
12}
13/**
14 * Add zero constant encode for x channel.
15 * This is useful for interval geometry.
16 */
17const MaybeStackY = (options) => {
18 return (I, mark, context) => {
19 // Skip some transform.
20 const { encode, transform = [] } = mark;
21 if (transform.some(exclude))
22 return [I, mark];
23 // StackY need both x and y channel values.
24 const { x, y } = encode;
25 if (x === undefined || y === undefined)
26 return [I, mark];
27 const { series } = options;
28 const groupBy = series ? ['x', 'series'] : 'x';
29 return (0, stackY_1.StackY)({ groupBy })(I, mark, context);
30 };
31};
32exports.MaybeStackY = MaybeStackY;
33exports.MaybeStackY.props = {};
34//# sourceMappingURL=maybeStackY.js.map
\No newline at end of file