| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- var __rest = (this && this.__rest) || function (s, e) {
- var t = {};
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
- t[p] = s[p];
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
- t[p[i]] = s[p[i]];
- }
- return t;
- };
- import { deepMix } from '@antv/util';
- import { column, columnOf, maybeColumnOf } from './utils/helper';
- import { createGroups, normalizeComparator, applyOrder, domainOf, } from './utils/order';
- /**
- * The dodge group marks into series by color or series channel,
- * and then produce new series channel for each series by specified order,
- * say to form horizontal "columns" by specified channels.
- */
- export const DodgeX = (options = {}) => {
- const { groupBy = 'x', reverse = false, orderBy, padding } = options, rest = __rest(options, ["groupBy", "reverse", "orderBy", "padding"]);
- return (I, mark) => {
- const { data, encode, scale } = mark;
- const { series: scaleSeries } = scale;
- const [Y] = columnOf(encode, 'y');
- const [S] = maybeColumnOf(encode, 'series', 'color');
- const domainSeries = domainOf(S, scaleSeries);
- // Create groups and apply specified order for each group.
- const groups = createGroups(groupBy, I, mark);
- const createComparator = normalizeComparator(orderBy);
- const comparator = createComparator(data, Y, S);
- if (comparator)
- applyOrder(groups, comparator);
- // Update series for each mark related to series domain.
- const newS = new Array(I.length);
- for (const G of groups) {
- if (reverse)
- G.reverse();
- for (let i = 0; i < G.length; i++) {
- newS[G[i]] = domainSeries[i];
- }
- }
- return [
- I,
- deepMix({}, mark, {
- scale: {
- series: {
- domain: domainSeries,
- paddingInner: padding,
- },
- },
- encode: {
- series: column(newS),
- },
- }),
- ];
- };
- };
- DodgeX.props = {};
- //# sourceMappingURL=dodgeX.js.map
|