UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.MaybeDefaultX = void 0;
4const util_1 = require("@antv/util");
5const helper_1 = require("./utils/helper");
6/**
7 * Add a default encode for rangeX
8 * when data is just an array
9 */
10const MaybeDefaultX = () => {
11 return (I, mark) => {
12 const { data } = mark;
13 if (Array.isArray(data) &&
14 (data.every(Array.isArray) || !data.some(helper_1.isObject))) {
15 const extractX = (data, index) => Array.isArray(data[0])
16 ? data.map((item) => item[index])
17 : [data[index]];
18 return [
19 I,
20 (0, util_1.deepMix)({}, mark, {
21 encode: {
22 x: (0, helper_1.column)(extractX(data, 0)),
23 x1: (0, helper_1.column)(extractX(data, 1)),
24 },
25 }),
26 ];
27 }
28 return [I, mark];
29 };
30};
31exports.MaybeDefaultX = MaybeDefaultX;
32exports.MaybeDefaultX.props = {};
33//# sourceMappingURL=maybeDefaultX.js.map
\No newline at end of file