@visactor/vtable 0.11.1-alpha.6 → 0.11.1-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +12 -4
- package/cjs/index.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +7 -9
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/util.js +26 -3
- package/cjs/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
- package/cjs/scenegraph/scenegraph.d.ts +2 -0
- package/cjs/scenegraph/scenegraph.js +6 -0
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/tools/get-data-path/create-dataset.d.ts +3 -0
- package/cjs/tools/get-data-path/create-dataset.js +136 -0
- package/cjs/tools/get-data-path/create-dataset.js.map +1 -0
- package/cjs/tools/get-data-path/index.d.ts +2 -0
- package/cjs/tools/get-data-path/index.js +32 -0
- package/cjs/tools/get-data-path/index.js.map +1 -0
- package/dist/vtable.js +299 -16
- package/dist/vtable.min.js +1 -1
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.js.map +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/scenegraph/group-creater/cell-helper.js +1 -1
- package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +8 -9
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
- package/es/scenegraph/group-creater/progress/update-position/util.js +26 -3
- package/es/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
- package/es/scenegraph/scenegraph.d.ts +2 -0
- package/es/scenegraph/scenegraph.js +6 -0
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/tools/get-data-path/create-dataset.d.ts +3 -0
- package/es/tools/get-data-path/create-dataset.js +130 -0
- package/es/tools/get-data-path/create-dataset.js.map +1 -0
- package/es/tools/get-data-path/index.d.ts +2 -0
- package/es/tools/get-data-path/index.js +28 -0
- package/es/tools/get-data-path/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.createDataset = void 0;
|
|
6
|
+
|
|
7
|
+
const dataset_1 = require("../../dataset/dataset"), ts_types_1 = require("../../ts-types");
|
|
8
|
+
|
|
9
|
+
function createDataset(options) {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11
|
+
const dataConfig = {
|
|
12
|
+
isPivotChart: !0
|
|
13
|
+
}, rowKeys = null !== (_b = null === (_a = options.rows) || void 0 === _a ? void 0 : _a.reduce(((keys, rowObj) => ("string" == typeof rowObj ? keys.push(rowObj) : keys.push(rowObj.dimensionKey),
|
|
14
|
+
keys)), [])) && void 0 !== _b ? _b : [], columnKeys = null !== (_d = null === (_c = options.columns) || void 0 === _c ? void 0 : _c.reduce(((keys, columnObj) => ("string" == typeof columnObj ? keys.push(columnObj) : keys.push(columnObj.dimensionKey),
|
|
15
|
+
keys)), [])) && void 0 !== _d ? _d : [], indicatorKeys = null !== (_f = null === (_e = options.indicators) || void 0 === _e ? void 0 : _e.reduce(((keys, indicatorObj) => ("string" == typeof indicatorObj ? keys.push(indicatorObj) : keys.push(indicatorObj.indicatorKey),
|
|
16
|
+
keys)), [])) && void 0 !== _f ? _f : [];
|
|
17
|
+
dataConfig.collectValuesBy = _generateCollectValuesConfig(options, columnKeys, rowKeys),
|
|
18
|
+
dataConfig.aggregationRules = _generateAggregationRules(options);
|
|
19
|
+
return new dataset_1.Dataset(dataConfig, null, rowKeys, columnKeys, indicatorKeys, options.records, options.columnTree, options.rowTree, !0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _generateCollectValuesConfig(option, columnKeys, rowKeys) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
24
|
+
const collectValuesBy = {};
|
|
25
|
+
for (let i = 0, len = null === (_a = option.indicators) || void 0 === _a ? void 0 : _a.length; i < len; i++) if ("string" != typeof option.indicators[i] && option.indicators[i].chartSpec) if (!1 === option.indicatorsAsCol) {
|
|
26
|
+
const indicatorDefine = option.indicators[i];
|
|
27
|
+
if (collectValuesBy[indicatorDefine.indicatorKey] = {
|
|
28
|
+
by: rowKeys,
|
|
29
|
+
range: !0,
|
|
30
|
+
sumBy: !1 !== (null === (_b = indicatorDefine.chartSpec) || void 0 === _b ? void 0 : _b.stack) && columnKeys.concat(null === (_c = indicatorDefine.chartSpec) || void 0 === _c ? void 0 : _c.xField)
|
|
31
|
+
}, indicatorDefine.chartSpec.series) indicatorDefine.chartSpec.series.forEach((chartSeries => {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
33
|
+
const xField = "string" == typeof chartSeries.xField ? chartSeries.xField : chartSeries.xField[0];
|
|
34
|
+
collectValuesBy[xField] = {
|
|
35
|
+
by: columnKeys,
|
|
36
|
+
type: "horizontal" !== chartSeries.direction ? "xField" : void 0,
|
|
37
|
+
range: "horizontal" === chartSeries.direction,
|
|
38
|
+
sortBy: "horizontal" !== chartSeries.direction ? null !== (_d = null === (_c = null === (_b = null === (_a = null == chartSeries ? void 0 : chartSeries.data) || void 0 === _a ? void 0 : _a.fields) || void 0 === _b ? void 0 : _b[xField]) || void 0 === _c ? void 0 : _c.domain) && void 0 !== _d ? _d : null === (_h = null === (_g = null === (_f = null === (_e = indicatorDefine.chartSpec) || void 0 === _e ? void 0 : _e.data) || void 0 === _f ? void 0 : _f.fields) || void 0 === _g ? void 0 : _g[xField]) || void 0 === _h ? void 0 : _h.domain : void 0
|
|
39
|
+
};
|
|
40
|
+
const yField = chartSeries.yField;
|
|
41
|
+
collectValuesBy[yField] = {
|
|
42
|
+
by: rowKeys,
|
|
43
|
+
range: "horizontal" !== chartSeries.direction,
|
|
44
|
+
sumBy: !1 !== chartSeries.stack && columnKeys.concat(null == chartSeries ? void 0 : chartSeries.xField),
|
|
45
|
+
sortBy: "horizontal" === chartSeries.direction ? null !== (_m = null === (_l = null === (_k = null === (_j = null == chartSeries ? void 0 : chartSeries.data) || void 0 === _j ? void 0 : _j.fields) || void 0 === _k ? void 0 : _k[yField]) || void 0 === _l ? void 0 : _l.domain) && void 0 !== _m ? _m : null === (_r = null === (_q = null === (_p = null === (_o = indicatorDefine.chartSpec) || void 0 === _o ? void 0 : _o.data) || void 0 === _p ? void 0 : _p.fields) || void 0 === _q ? void 0 : _q[yField]) || void 0 === _r ? void 0 : _r.domain : void 0
|
|
46
|
+
};
|
|
47
|
+
})); else {
|
|
48
|
+
const xField = "string" == typeof indicatorDefine.chartSpec.xField ? indicatorDefine.chartSpec.xField : indicatorDefine.chartSpec.xField[0];
|
|
49
|
+
collectValuesBy[xField] = {
|
|
50
|
+
by: columnKeys,
|
|
51
|
+
type: "horizontal" !== indicatorDefine.chartSpec.direction ? "xField" : void 0,
|
|
52
|
+
range: "horizontal" === indicatorDefine.chartSpec.direction,
|
|
53
|
+
sortBy: "horizontal" !== indicatorDefine.chartSpec.direction ? null === (_g = null === (_f = null === (_e = null === (_d = indicatorDefine.chartSpec) || void 0 === _d ? void 0 : _d.data) || void 0 === _e ? void 0 : _e.fields) || void 0 === _f ? void 0 : _f[xField]) || void 0 === _g ? void 0 : _g.domain : void 0
|
|
54
|
+
};
|
|
55
|
+
const yField = indicatorDefine.chartSpec.yField;
|
|
56
|
+
collectValuesBy[yField] = {
|
|
57
|
+
by: rowKeys,
|
|
58
|
+
range: "horizontal" !== option.indicators[i].chartSpec.direction,
|
|
59
|
+
sumBy: !1 !== indicatorDefine.chartSpec.stack && columnKeys.concat(null === (_h = indicatorDefine.chartSpec) || void 0 === _h ? void 0 : _h.xField),
|
|
60
|
+
sortBy: "horizontal" === indicatorDefine.chartSpec.direction ? null === (_m = null === (_l = null === (_k = null === (_j = indicatorDefine.chartSpec) || void 0 === _j ? void 0 : _j.data) || void 0 === _k ? void 0 : _k.fields) || void 0 === _l ? void 0 : _l[yField]) || void 0 === _m ? void 0 : _m.domain : void 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
const indicatorDefine = option.indicators[i];
|
|
65
|
+
if (collectValuesBy[indicatorDefine.indicatorKey] = {
|
|
66
|
+
by: columnKeys,
|
|
67
|
+
range: !0,
|
|
68
|
+
sumBy: !1 !== (null === (_o = indicatorDefine.chartSpec) || void 0 === _o ? void 0 : _o.stack) && rowKeys.concat(null === (_p = indicatorDefine.chartSpec) || void 0 === _p ? void 0 : _p.yField)
|
|
69
|
+
}, indicatorDefine.chartSpec.series) indicatorDefine.chartSpec.series.forEach((chartSeries => {
|
|
70
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
71
|
+
const yField = "string" == typeof chartSeries.yField ? chartSeries.yField : chartSeries.yField[0];
|
|
72
|
+
collectValuesBy[yField] = {
|
|
73
|
+
by: rowKeys,
|
|
74
|
+
type: "horizontal" === chartSeries.direction ? "yField" : void 0,
|
|
75
|
+
range: "horizontal" !== chartSeries.direction,
|
|
76
|
+
sortBy: "horizontal" === chartSeries.direction ? null !== (_d = null === (_c = null === (_b = null === (_a = null == chartSeries ? void 0 : chartSeries.data) || void 0 === _a ? void 0 : _a.fields) || void 0 === _b ? void 0 : _b[yField]) || void 0 === _c ? void 0 : _c.domain) && void 0 !== _d ? _d : null === (_h = null === (_g = null === (_f = null === (_e = indicatorDefine.chartSpec) || void 0 === _e ? void 0 : _e.data) || void 0 === _f ? void 0 : _f.fields) || void 0 === _g ? void 0 : _g[yField]) || void 0 === _h ? void 0 : _h.domain : void 0
|
|
77
|
+
};
|
|
78
|
+
const xField = chartSeries.xField;
|
|
79
|
+
collectValuesBy[xField] = {
|
|
80
|
+
by: columnKeys,
|
|
81
|
+
range: "horizontal" === chartSeries.direction,
|
|
82
|
+
sumBy: !1 !== chartSeries.stack && rowKeys.concat(null == chartSeries ? void 0 : chartSeries.yField),
|
|
83
|
+
sortBy: "horizontal" !== chartSeries.direction ? null !== (_m = null === (_l = null === (_k = null === (_j = null == chartSeries ? void 0 : chartSeries.data) || void 0 === _j ? void 0 : _j.fields) || void 0 === _k ? void 0 : _k[xField]) || void 0 === _l ? void 0 : _l.domain) && void 0 !== _m ? _m : null === (_r = null === (_q = null === (_p = null === (_o = indicatorDefine.chartSpec) || void 0 === _o ? void 0 : _o.data) || void 0 === _p ? void 0 : _p.fields) || void 0 === _q ? void 0 : _q[xField]) || void 0 === _r ? void 0 : _r.domain : void 0
|
|
84
|
+
};
|
|
85
|
+
})); else {
|
|
86
|
+
const yField = "string" == typeof indicatorDefine.chartSpec.yField ? indicatorDefine.chartSpec.yField : indicatorDefine.chartSpec.yField[0];
|
|
87
|
+
collectValuesBy[yField] = {
|
|
88
|
+
by: rowKeys,
|
|
89
|
+
type: "horizontal" === indicatorDefine.chartSpec.direction ? "yField" : void 0,
|
|
90
|
+
range: "horizontal" !== indicatorDefine.chartSpec.direction,
|
|
91
|
+
sortBy: "horizontal" === indicatorDefine.chartSpec.direction ? null === (_t = null === (_s = null === (_r = null === (_q = indicatorDefine.chartSpec) || void 0 === _q ? void 0 : _q.data) || void 0 === _r ? void 0 : _r.fields) || void 0 === _s ? void 0 : _s[yField]) || void 0 === _t ? void 0 : _t.domain : void 0
|
|
92
|
+
};
|
|
93
|
+
const xField = indicatorDefine.chartSpec.xField;
|
|
94
|
+
collectValuesBy[xField] = {
|
|
95
|
+
by: columnKeys,
|
|
96
|
+
range: "horizontal" === option.indicators[i].chartSpec.direction,
|
|
97
|
+
sumBy: !1 !== indicatorDefine.chartSpec.stack && rowKeys.concat(null === (_u = indicatorDefine.chartSpec) || void 0 === _u ? void 0 : _u.yField),
|
|
98
|
+
sortBy: "horizontal" !== indicatorDefine.chartSpec.direction ? null === (_y = null === (_x = null === (_w = null === (_v = indicatorDefine.chartSpec) || void 0 === _v ? void 0 : _v.data) || void 0 === _w ? void 0 : _w.fields) || void 0 === _x ? void 0 : _x[xField]) || void 0 === _y ? void 0 : _y.domain : void 0
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return collectValuesBy;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function _generateAggregationRules(options) {
|
|
106
|
+
var _a;
|
|
107
|
+
const aggregationRules = [];
|
|
108
|
+
return null === (_a = options.indicators) || void 0 === _a || _a.forEach((indicator => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
if ("string" == typeof indicator) aggregationRules.push({
|
|
111
|
+
indicatorKey: indicator,
|
|
112
|
+
field: indicator,
|
|
113
|
+
aggregationType: ts_types_1.AggregationType.RECORD
|
|
114
|
+
}); else if (null === (_a = indicator.chartSpec) || void 0 === _a ? void 0 : _a.series) {
|
|
115
|
+
const fields = [];
|
|
116
|
+
null === (_b = indicator.chartSpec) || void 0 === _b || _b.series.forEach((seriesSpec => {
|
|
117
|
+
const seriesField = !1 === options.indicatorsAsCol ? seriesSpec.yField : seriesSpec.xField;
|
|
118
|
+
-1 === fields.indexOf(seriesField) && fields.push(seriesField);
|
|
119
|
+
})), aggregationRules.push({
|
|
120
|
+
indicatorKey: indicator.indicatorKey,
|
|
121
|
+
field: fields,
|
|
122
|
+
aggregationType: ts_types_1.AggregationType.RECORD
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
const field = !1 === options.indicatorsAsCol ? indicator.chartSpec.yField : indicator.chartSpec.xField;
|
|
126
|
+
aggregationRules.push({
|
|
127
|
+
indicatorKey: indicator.indicatorKey,
|
|
128
|
+
field: null != field ? field : indicator.indicatorKey,
|
|
129
|
+
aggregationType: ts_types_1.AggregationType.RECORD
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
})), aggregationRules;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
exports.createDataset = createDataset;
|
|
136
|
+
//# sourceMappingURL=create-dataset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["tools/get-data-path/create-dataset.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAShD,6CAAiD;AAGjD,SAAgB,aAAa,CAAC,OAAqC;;IACjE,MAAM,UAAU,GAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAEvD,MAAM,OAAO,GACX,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACpC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACnB;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SAChC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,mCAAI,EAAE,CAAC;IACf,MAAM,UAAU,GACd,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,MAAM,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAC1C,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACtB;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;SACnC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,mCAAI,EAAE,CAAC;IACf,MAAM,aAAa,GACjB,MAAA,MAAA,OAAO,CAAC,UAAU,0CAAE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MAAM;iBACxC,CAAC,CAAC;aACJ;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC;AAC1B,CAAC","file":"create-dataset.js","sourcesContent":["import { Dataset } from '../../dataset/dataset';\nimport type {\n AggregationRule,\n AggregationRules,\n CollectValueBy,\n IDataConfig,\n IIndicator,\n PivotChartConstructorOptions\n} from '../../ts-types';\nimport { AggregationType } from '../../ts-types';\nimport type { IChartColumnIndicator } from '../../ts-types/pivot-table/indicator/chart-indicator';\n\nexport function createDataset(options: PivotChartConstructorOptions) {\n const dataConfig: IDataConfig = { isPivotChart: true };\n\n const rowKeys =\n options.rows?.reduce((keys, rowObj) => {\n if (typeof rowObj === 'string') {\n keys.push(rowObj);\n } else {\n keys.push(rowObj.dimensionKey);\n }\n return keys;\n }, []) ?? [];\n const columnKeys =\n options.columns?.reduce((keys, columnObj) => {\n if (typeof columnObj === 'string') {\n keys.push(columnObj);\n } else {\n keys.push(columnObj.dimensionKey);\n }\n return keys;\n }, []) ?? [];\n const indicatorKeys =\n options.indicators?.reduce((keys, indicatorObj) => {\n if (typeof indicatorObj === 'string') {\n keys.push(indicatorObj);\n } else {\n keys.push(indicatorObj.indicatorKey);\n }\n return keys;\n }, []) ?? [];\n\n dataConfig.collectValuesBy = _generateCollectValuesConfig(options, columnKeys, rowKeys);\n dataConfig.aggregationRules = _generateAggregationRules(options);\n\n const dataset = new Dataset(\n dataConfig,\n null,\n rowKeys,\n columnKeys,\n indicatorKeys,\n options.records,\n options.columnTree,\n options.rowTree,\n true\n );\n\n return dataset;\n}\n\nfunction _generateCollectValuesConfig(\n option: PivotChartConstructorOptions,\n columnKeys: string[],\n rowKeys: string[]\n): Record<string, CollectValueBy> {\n const collectValuesBy: Record<string, CollectValueBy> = {};\n\n for (let i = 0, len = option.indicators?.length; i < len; i++) {\n if (typeof option.indicators[i] !== 'string' && (option.indicators[i] as IChartColumnIndicator).chartSpec) {\n if (option.indicatorsAsCol === false) {\n const indicatorDefine = option.indicators[i] as IIndicator;\n // 收集指标值的范围\n collectValuesBy[indicatorDefine.indicatorKey] = {\n by: rowKeys,\n range: true,\n // 判断是否需要匹配维度值相同的进行求和计算\n sumBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec?.stack !== false &&\n columnKeys.concat((indicatorDefine as IChartColumnIndicator).chartSpec?.xField)\n };\n if ((indicatorDefine as IChartColumnIndicator).chartSpec.series) {\n (indicatorDefine as IChartColumnIndicator).chartSpec.series.forEach((chartSeries: any) => {\n const xField = typeof chartSeries.xField === 'string' ? chartSeries.xField : chartSeries.xField[0];\n collectValuesBy[xField] = {\n by: columnKeys,\n type: chartSeries.direction !== 'horizontal' ? 'xField' : undefined,\n range: chartSeries.direction === 'horizontal',\n sortBy:\n chartSeries.direction !== 'horizontal'\n ? chartSeries?.data?.fields?.[xField]?.domain ??\n (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[xField]?.domain\n : undefined\n };\n\n const yField = chartSeries.yField;\n collectValuesBy[yField] = {\n by: rowKeys,\n range: chartSeries.direction !== 'horizontal', // direction默认为'vertical'\n sumBy: chartSeries.stack !== false && columnKeys.concat(chartSeries?.xField), // 逻辑严谨的话 这个concat的值也需要结合 chartSeries.direction来判断是xField还是yField\n sortBy:\n chartSeries.direction === 'horizontal'\n ? chartSeries?.data?.fields?.[yField]?.domain ??\n (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[yField]?.domain\n : undefined\n };\n });\n } else {\n const xField =\n typeof (indicatorDefine as IChartColumnIndicator).chartSpec.xField === 'string'\n ? (indicatorDefine as IChartColumnIndicator).chartSpec.xField\n : (indicatorDefine as IChartColumnIndicator).chartSpec.xField[0];\n collectValuesBy[xField] = {\n by: columnKeys,\n type:\n (indicatorDefine as IChartColumnIndicator).chartSpec.direction !== 'horizontal' ? 'xField' : undefined,\n range: (indicatorDefine as IChartColumnIndicator).chartSpec.direction === 'horizontal',\n sortBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec.direction !== 'horizontal'\n ? (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[xField]?.domain\n : undefined\n };\n //下面这个收集的值 应该是和收集的 collectValuesBy[indicatorDefine.indicatorKey] 相同\n const yField = (indicatorDefine as IChartColumnIndicator).chartSpec.yField;\n collectValuesBy[yField] = {\n by: rowKeys,\n range: (option.indicators[i] as IChartColumnIndicator).chartSpec.direction !== 'horizontal', // direction默认为'vertical'\n sumBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec.stack !== false &&\n columnKeys.concat((indicatorDefine as IChartColumnIndicator).chartSpec?.xField), // 逻辑严谨的话 这个concat的值也需要结合 chartSeries.direction来判断是xField还是yField\n sortBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec.direction === 'horizontal'\n ? (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[yField]?.domain\n : undefined\n };\n }\n } else {\n const indicatorDefine = option.indicators[i] as IIndicator;\n // 收集指标值的范围\n collectValuesBy[indicatorDefine.indicatorKey] = {\n by: columnKeys,\n range: true,\n // 判断是否需要匹配维度值相同的进行求和计算\n sumBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec?.stack !== false &&\n rowKeys.concat((indicatorDefine as IChartColumnIndicator).chartSpec?.yField)\n };\n if ((indicatorDefine as IChartColumnIndicator).chartSpec.series) {\n (indicatorDefine as IChartColumnIndicator).chartSpec.series.forEach((chartSeries: any) => {\n const yField = typeof chartSeries.yField === 'string' ? chartSeries.yField : chartSeries.yField[0];\n collectValuesBy[yField] = {\n by: rowKeys,\n type: chartSeries.direction === 'horizontal' ? 'yField' : undefined,\n range: chartSeries.direction !== 'horizontal',\n sortBy:\n chartSeries.direction === 'horizontal'\n ? chartSeries?.data?.fields?.[yField]?.domain ??\n (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[yField]?.domain\n : undefined\n };\n\n const xField = chartSeries.xField;\n collectValuesBy[xField] = {\n by: columnKeys,\n range: chartSeries.direction === 'horizontal', // direction默认为'vertical'\n sumBy: chartSeries.stack !== false && rowKeys.concat(chartSeries?.yField),\n sortBy:\n chartSeries.direction !== 'horizontal'\n ? chartSeries?.data?.fields?.[xField]?.domain ??\n (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[xField]?.domain\n : undefined\n };\n });\n } else {\n const yField =\n typeof (indicatorDefine as IChartColumnIndicator).chartSpec.yField === 'string'\n ? (indicatorDefine as IChartColumnIndicator).chartSpec.yField\n : (indicatorDefine as IChartColumnIndicator).chartSpec.yField[0];\n collectValuesBy[yField] = {\n by: rowKeys,\n type:\n (indicatorDefine as IChartColumnIndicator).chartSpec.direction === 'horizontal' ? 'yField' : undefined,\n range: (indicatorDefine as IChartColumnIndicator).chartSpec.direction !== 'horizontal',\n sortBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec.direction === 'horizontal'\n ? (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[yField]?.domain\n : undefined\n };\n //下面这个收集的值 应该是和收集的 collectValuesBy[indicatorDefine.indicatorKey] 相同\n const xField = (indicatorDefine as IChartColumnIndicator).chartSpec.xField;\n collectValuesBy[xField] = {\n by: columnKeys,\n range: (option.indicators[i] as IChartColumnIndicator).chartSpec.direction === 'horizontal', // direction默认为'vertical'\n sumBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec.stack !== false &&\n rowKeys.concat((indicatorDefine as IChartColumnIndicator).chartSpec?.yField),\n sortBy:\n (indicatorDefine as IChartColumnIndicator).chartSpec.direction !== 'horizontal'\n ? (indicatorDefine as IChartColumnIndicator).chartSpec?.data?.fields?.[xField]?.domain\n : undefined\n };\n }\n }\n }\n }\n\n return collectValuesBy;\n}\n\nfunction _generateAggregationRules(options: PivotChartConstructorOptions) {\n const aggregationRules: AggregationRules = [];\n // indicatorFromChartSpec = true;\n options.indicators?.forEach((indicator: IIndicator | string) => {\n if (typeof indicator === 'string') {\n aggregationRules.push({\n indicatorKey: indicator, //field转为指标key\n field: indicator, //指标依据字段\n aggregationType: AggregationType.RECORD //计算类型\n } as AggregationRule<AggregationType.RECORD>);\n } else {\n if ((indicator as IChartColumnIndicator).chartSpec?.series) {\n // 如果chartSpec配置了组合图 series 则需要考虑 series中存在的多个指标\n const fields: string[] = [];\n (indicator as IChartColumnIndicator).chartSpec?.series.forEach((seriesSpec: any) => {\n const seriesField = options.indicatorsAsCol === false ? seriesSpec.yField : seriesSpec.xField;\n if (fields.indexOf(seriesField) === -1) {\n fields.push(seriesField);\n }\n });\n aggregationRules.push({\n indicatorKey: indicator.indicatorKey, //field转为指标key\n field: fields, //指标依据字段\n aggregationType: AggregationType.RECORD //计算类型\n });\n } else {\n const field =\n options.indicatorsAsCol === false\n ? (indicator as IChartColumnIndicator).chartSpec.yField\n : (indicator as IChartColumnIndicator).chartSpec.xField;\n aggregationRules.push({\n indicatorKey: indicator.indicatorKey, //field转为指标key\n field: field ?? indicator.indicatorKey, //指标依据字段\n aggregationType: AggregationType.RECORD //计算类型\n });\n }\n }\n });\n\n return aggregationRules;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.getDataCellPath = void 0;
|
|
6
|
+
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), pivot_layout_1 = require("../../layout/pivot-layout"), create_dataset_1 = require("./create-dataset");
|
|
8
|
+
|
|
9
|
+
function getDataCellPath(options, data) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const dataset = (0, create_dataset_1.createDataset)(options), mockTable = {
|
|
12
|
+
options: options,
|
|
13
|
+
isPivotChart: () => !0,
|
|
14
|
+
pivotChartAxes: [],
|
|
15
|
+
_selectedDataItemsInChart: [],
|
|
16
|
+
_getActiveChartInstance: () => ({
|
|
17
|
+
updateState: () => {}
|
|
18
|
+
})
|
|
19
|
+
}, layoutMap = new pivot_layout_1.PivotLayoutMap(mockTable, dataset);
|
|
20
|
+
for (let col = 0; col < layoutMap.colCount; col++) for (let row = 0; row < layoutMap.rowCount; row++) {
|
|
21
|
+
if (layoutMap.isHeader(col, row)) continue;
|
|
22
|
+
const colKey = null !== (_a = dataset.colKeysPath[layoutMap.getRecordIndexByCol(col)]) && void 0 !== _a ? _a : [], rowKey = null !== (_b = dataset.rowKeysPath[layoutMap.getRecordIndexByRow(row)]) && void 0 !== _b ? _b : [], aggregator = dataset.getAggregator(rowKey[rowKey.length - 1], colKey[colKey.length - 1], layoutMap.getIndicatorKey(col, row)), result = compareData(aggregator.value ? aggregator.value() : void 0, data, col, row, layoutMap);
|
|
23
|
+
if (result) return result;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function compareData(data1, data2, col, row, layoutMap) {
|
|
28
|
+
if ((0, vutils_1.isArray)(data1)) for (let i = 0; i < data1.length; i++) if (JSON.stringify(data1[i]) === JSON.stringify(data2)) return layoutMap.getCellHeaderPaths(col, row);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.getDataCellPath = getDataCellPath;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["tools/get-data-path/index.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAE3C,4DAA2D;AAE3D,qDAAiD;AAEjD,SAAgB,eAAe,CAC7B,OAAqC,EACrC,IAAY;;IAGZ,MAAM,OAAO,GAAG,IAAA,8BAAa,EAAC,OAAO,CAAC,CAAC;IAGvC,MAAM,SAAS,GAAG;QAChB,OAAO;QACP,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI;QACxB,cAAc,EAAE,EAAW;QAC3B,yBAAyB,EAAE,EAAW;QACtC,uBAAuB,EAAE,GAAG,EAAE;YAC5B,OAAO;gBACL,WAAW,EAAE,GAAG,EAAE;gBAElB,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;IAGF,MAAM,SAAS,GAAG,IAAI,6BAAc,CAAC,SAAuB,EAAE,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K,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;gBACtD,OAAO,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;aAC/C;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","file":"index.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport type { PivotChart } from '../../PivotChart';\nimport { PivotLayoutMap } from '../../layout/pivot-layout';\nimport type { IPivotTableCellHeaderPaths, PivotChartConstructorOptions } from '../../ts-types';\nimport { createDataset } from './create-dataset';\n\nexport function getDataCellPath(\n options: PivotChartConstructorOptions,\n data: Object\n): IPivotTableCellHeaderPaths | undefined {\n // mock dataset\n const dataset = createDataset(options);\n\n // mock pivotChart\n const mockTable = {\n options,\n isPivotChart: () => true,\n pivotChartAxes: [] as any[],\n _selectedDataItemsInChart: [] as any[],\n _getActiveChartInstance: () => {\n return {\n updateState: () => {\n // do nothing\n }\n };\n }\n };\n\n // mock layoutMap\n const layoutMap = new PivotLayoutMap(mockTable as PivotChart, dataset);\n\n // compare data\n for (let col = 0; col < layoutMap.colCount; col++) {\n for (let row = 0; row < layoutMap.rowCount; row++) {\n if (layoutMap.isHeader(col, row)) {\n continue;\n }\n const colKey = dataset.colKeysPath[layoutMap.getRecordIndexByCol(col)] ?? [];\n const rowKey = dataset.rowKeysPath[layoutMap.getRecordIndexByRow(row)] ?? [];\n const aggregator = dataset.getAggregator(\n rowKey[rowKey.length - 1],\n colKey[colKey.length - 1],\n (layoutMap as PivotLayoutMap).getIndicatorKey(col, row)\n );\n const result = compareData(aggregator.value ? aggregator.value() : undefined, data, col, row, layoutMap);\n if (result) {\n return result;\n }\n }\n }\n return undefined;\n}\n\nfunction compareData(data1: Object[], data2: Object, col: number, row: number, layoutMap: PivotLayoutMap) {\n if (isArray(data1)) {\n for (let i = 0; i < data1.length; i++) {\n if (JSON.stringify(data1[i]) === JSON.stringify(data2)) {\n return layoutMap.getCellHeaderPaths(col, row);\n }\n }\n }\n return undefined;\n}\n"]}
|
package/dist/vtable.js
CHANGED
|
@@ -50835,7 +50835,7 @@
|
|
|
50835
50835
|
return newCellGroup;
|
|
50836
50836
|
}
|
|
50837
50837
|
function updateCellContent(type, define, table, col, row, bgColorFunc, cellWidth, cellHeight, oldCellGroup, padding, textAlign, textBaseline, mayHaveIcon, isMerge, range, addNew, cellTheme) {
|
|
50838
|
-
const newCellGroup = createCell(type, define, table, col, row, table.getColWidth(col), cellWidth, cellHeight, addNew ? table.scenegraph.getColGroup(col) : oldCellGroup.parent, addNew ? 0 :
|
|
50838
|
+
const newCellGroup = createCell(type, define, table, col, row, table.getColWidth(col), cellWidth, cellHeight, addNew ? table.scenegraph.getColGroup(col) : oldCellGroup.parent, addNew ? 0 : table.scenegraph.getCellGroupY(row), padding, textAlign, textBaseline, mayHaveIcon, isMerge, range, cellTheme);
|
|
50839
50839
|
if (!addNew) {
|
|
50840
50840
|
oldCellGroup.parent.insertAfter(newCellGroup, oldCellGroup);
|
|
50841
50841
|
oldCellGroup.parent.removeChild(oldCellGroup);
|
|
@@ -51057,7 +51057,10 @@
|
|
|
51057
51057
|
continue;
|
|
51058
51058
|
}
|
|
51059
51059
|
const range = getCellMergeInfo(proxy.table, col, row);
|
|
51060
|
-
|
|
51060
|
+
range && clearHadMergedRow(range.start.row, range.end.row, col, proxy);
|
|
51061
|
+
if (range &&
|
|
51062
|
+
range.start.row !== row &&
|
|
51063
|
+
proxy.highPerformanceGetCell(range.start.col, range.start.row, true).role !== 'cell') {
|
|
51061
51064
|
const oldCellGroup = proxy.highPerformanceGetCell(col, row, true);
|
|
51062
51065
|
const newCellGroup = updateCell$1(range.start.col, range.start.row, proxy.table, true);
|
|
51063
51066
|
newCellGroup.col = col;
|
|
@@ -51080,10 +51083,10 @@
|
|
|
51080
51083
|
continue;
|
|
51081
51084
|
}
|
|
51082
51085
|
const range = getCellMergeInfo(proxy.table, col, row);
|
|
51083
|
-
|
|
51084
|
-
|
|
51085
|
-
|
|
51086
|
-
|
|
51086
|
+
range && clearHadMergedColumn(range.start.col, range.end.col, row, proxy);
|
|
51087
|
+
if (range &&
|
|
51088
|
+
range.start.col !== col &&
|
|
51089
|
+
proxy.highPerformanceGetCell(range.start.col, range.start.row, true).role !== 'cell') {
|
|
51087
51090
|
const oldCellGroup = proxy.highPerformanceGetCell(col, row, true);
|
|
51088
51091
|
const newCellGroup = updateCell$1(range.start.col, range.start.row, proxy.table, true);
|
|
51089
51092
|
newCellGroup.col = col;
|
|
@@ -51099,14 +51102,33 @@
|
|
|
51099
51102
|
}
|
|
51100
51103
|
}
|
|
51101
51104
|
}
|
|
51102
|
-
function
|
|
51105
|
+
function clearHadMergedRow(rowStart, rowEnd, col, proxy) {
|
|
51106
|
+
for (let row = rowStart; row <= rowEnd; row++) {
|
|
51107
|
+
const cellGroup = proxy.highPerformanceGetCell(col, row, true);
|
|
51108
|
+
if (cellGroup.role !== 'shadow-cell' && cellGroup.role !== 'empty' && cellGroup.row !== rowStart) {
|
|
51109
|
+
cellGroup.role = 'shadow-cell';
|
|
51110
|
+
cellGroup.setAttributes({
|
|
51111
|
+
width: 0,
|
|
51112
|
+
height: proxy.table.getRowHeight(cellGroup.row),
|
|
51113
|
+
y: proxy.table.getRowsHeight(proxy.table.columnHeaderLevelCount, cellGroup.row - 1)
|
|
51114
|
+
});
|
|
51115
|
+
cellGroup.clear();
|
|
51116
|
+
}
|
|
51117
|
+
}
|
|
51118
|
+
}
|
|
51119
|
+
function clearHadMergedColumn(colStart, colEnd, row, proxy) {
|
|
51103
51120
|
for (let col = colStart; col <= colEnd; col++) {
|
|
51104
|
-
|
|
51105
|
-
|
|
51106
|
-
|
|
51121
|
+
const cellGroup = proxy.highPerformanceGetCell(col, row, true);
|
|
51122
|
+
if (cellGroup.role !== 'shadow-cell' && cellGroup.role !== 'empty' && cellGroup.row !== colStart) {
|
|
51123
|
+
cellGroup.role = 'shadow-cell';
|
|
51124
|
+
cellGroup.setAttributes({
|
|
51125
|
+
width: 0,
|
|
51126
|
+
height: proxy.table.getRowHeight(cellGroup.row),
|
|
51127
|
+
y: proxy.table.getRowsHeight(proxy.table.columnHeaderLevelCount, cellGroup.row - 1)
|
|
51128
|
+
});
|
|
51129
|
+
cellGroup.clear();
|
|
51107
51130
|
}
|
|
51108
51131
|
}
|
|
51109
|
-
return false;
|
|
51110
51132
|
}
|
|
51111
51133
|
function getFirstChild(containerGroup) {
|
|
51112
51134
|
let child = containerGroup.firstChild;
|
|
@@ -51424,7 +51446,6 @@
|
|
|
51424
51446
|
if (count < proxy.rowEnd - proxy.rowStart) {
|
|
51425
51447
|
const startRow = direction === 'up' ? proxy.rowStart : proxy.rowEnd - count + 1;
|
|
51426
51448
|
const endRow = direction === 'up' ? proxy.rowStart + count - 1 : proxy.rowEnd;
|
|
51427
|
-
updatePartRowPosition(startRow, endRow, direction, proxy);
|
|
51428
51449
|
const distStartRow = direction === 'up' ? proxy.rowEnd + 1 : proxy.rowStart - count;
|
|
51429
51450
|
const distEndRow = direction === 'up' ? proxy.rowEnd + count : proxy.rowStart - 1;
|
|
51430
51451
|
let syncTopRow;
|
|
@@ -51440,10 +51461,11 @@
|
|
|
51440
51461
|
syncBottomRow = Math.min(distEndRow, BottomRow);
|
|
51441
51462
|
}
|
|
51442
51463
|
computeRowsHeight(proxy.table, syncTopRow, syncBottomRow);
|
|
51464
|
+
updatePartRowPosition(startRow, endRow, direction, proxy);
|
|
51443
51465
|
proxy.rowStart = direction === 'up' ? proxy.rowStart + count : proxy.rowStart - count;
|
|
51444
51466
|
proxy.rowEnd = direction === 'up' ? proxy.rowEnd + count : proxy.rowEnd - count;
|
|
51445
|
-
checkFirstRowMerge(syncTopRow, proxy);
|
|
51446
51467
|
updateRowContent(syncTopRow, syncBottomRow, proxy);
|
|
51468
|
+
checkFirstRowMerge(syncTopRow, proxy);
|
|
51447
51469
|
if (proxy.table.heightMode === 'autoHeight') {
|
|
51448
51470
|
updateAutoRow(proxy.bodyLeftCol, proxy.bodyRightCol, syncTopRow, syncBottomRow, proxy.table, direction);
|
|
51449
51471
|
const cellGroup = proxy.table.scenegraph.highPerformanceGetCell(proxy.bodyLeftCol, screenTopRow, true);
|
|
@@ -51464,7 +51486,6 @@
|
|
|
51464
51486
|
const distStartRow = direction === 'up' ? proxy.rowStart + count : proxy.rowStart - count;
|
|
51465
51487
|
const distEndRow = direction === 'up' ? proxy.rowEnd + count : proxy.rowEnd - count;
|
|
51466
51488
|
const distStartRowY = proxy.table.getRowsHeight(proxy.bodyTopRow, distStartRow - 1);
|
|
51467
|
-
updateAllRowPosition(distStartRowY, count, direction, proxy);
|
|
51468
51489
|
let syncTopRow;
|
|
51469
51490
|
let syncBottomRow;
|
|
51470
51491
|
if (proxy.table.heightMode === 'autoHeight') {
|
|
@@ -51476,6 +51497,7 @@
|
|
|
51476
51497
|
syncBottomRow = Math.min(proxy.bodyBottomRow, screenTopRow + proxy.screenRowCount * 2);
|
|
51477
51498
|
}
|
|
51478
51499
|
computeRowsHeight(proxy.table, syncTopRow, syncBottomRow);
|
|
51500
|
+
updateAllRowPosition(distStartRowY, count, direction, proxy);
|
|
51479
51501
|
proxy.rowStart = distStartRow;
|
|
51480
51502
|
proxy.rowEnd = distEndRow;
|
|
51481
51503
|
checkFirstRowMerge(syncTopRow, proxy);
|
|
@@ -54145,6 +54167,30 @@
|
|
|
54145
54167
|
return false;
|
|
54146
54168
|
});
|
|
54147
54169
|
}
|
|
54170
|
+
getColumnGroupX(col) {
|
|
54171
|
+
if (col < this.table.rowHeaderLevelCount) {
|
|
54172
|
+
return this.table.getColsWidth(0, col - 1);
|
|
54173
|
+
}
|
|
54174
|
+
else if (col < this.table.colCount - this.table.rightFrozenColCount) {
|
|
54175
|
+
return this.table.getColsWidth(this.table.rowHeaderLevelCount, col - 1);
|
|
54176
|
+
}
|
|
54177
|
+
else if (col < this.table.colCount) {
|
|
54178
|
+
return this.table.getColsWidth(this.table.colCount - this.table.bottomFrozenRowCount, col - 1);
|
|
54179
|
+
}
|
|
54180
|
+
return 0;
|
|
54181
|
+
}
|
|
54182
|
+
getCellGroupY(row) {
|
|
54183
|
+
if (row < this.table.columnHeaderLevelCount) {
|
|
54184
|
+
return this.table.getRowsHeight(0, row - 1);
|
|
54185
|
+
}
|
|
54186
|
+
else if (row < this.table.rowCount - this.table.bottomFrozenRowCount) {
|
|
54187
|
+
return this.table.getRowsHeight(this.table.columnHeaderLevelCount, row - 1);
|
|
54188
|
+
}
|
|
54189
|
+
else if (row < this.table.rowCount) {
|
|
54190
|
+
return this.table.getRowsHeight(this.table.rowCount - this.table.bottomFrozenRowCount, row - 1);
|
|
54191
|
+
}
|
|
54192
|
+
return 0;
|
|
54193
|
+
}
|
|
54148
54194
|
}
|
|
54149
54195
|
function showIcon(scene, cellGroup, visibleTime) {
|
|
54150
54196
|
cellGroup.forEachChildren((child) => {
|
|
@@ -59904,7 +59950,7 @@
|
|
|
59904
59950
|
return TABLE_EVENT_TYPE;
|
|
59905
59951
|
}
|
|
59906
59952
|
options;
|
|
59907
|
-
version = "0.11.1-alpha.
|
|
59953
|
+
version = "0.11.1-alpha.7";
|
|
59908
59954
|
pagination;
|
|
59909
59955
|
id = `VTable${Date.now()}`;
|
|
59910
59956
|
headerStyleCache;
|
|
@@ -69479,11 +69525,247 @@
|
|
|
69479
69525
|
percentCalc: percentCalc
|
|
69480
69526
|
});
|
|
69481
69527
|
|
|
69528
|
+
function createDataset(options) {
|
|
69529
|
+
const dataConfig = { isPivotChart: true };
|
|
69530
|
+
const rowKeys = options.rows?.reduce((keys, rowObj) => {
|
|
69531
|
+
if (typeof rowObj === 'string') {
|
|
69532
|
+
keys.push(rowObj);
|
|
69533
|
+
}
|
|
69534
|
+
else {
|
|
69535
|
+
keys.push(rowObj.dimensionKey);
|
|
69536
|
+
}
|
|
69537
|
+
return keys;
|
|
69538
|
+
}, []) ?? [];
|
|
69539
|
+
const columnKeys = options.columns?.reduce((keys, columnObj) => {
|
|
69540
|
+
if (typeof columnObj === 'string') {
|
|
69541
|
+
keys.push(columnObj);
|
|
69542
|
+
}
|
|
69543
|
+
else {
|
|
69544
|
+
keys.push(columnObj.dimensionKey);
|
|
69545
|
+
}
|
|
69546
|
+
return keys;
|
|
69547
|
+
}, []) ?? [];
|
|
69548
|
+
const indicatorKeys = options.indicators?.reduce((keys, indicatorObj) => {
|
|
69549
|
+
if (typeof indicatorObj === 'string') {
|
|
69550
|
+
keys.push(indicatorObj);
|
|
69551
|
+
}
|
|
69552
|
+
else {
|
|
69553
|
+
keys.push(indicatorObj.indicatorKey);
|
|
69554
|
+
}
|
|
69555
|
+
return keys;
|
|
69556
|
+
}, []) ?? [];
|
|
69557
|
+
dataConfig.collectValuesBy = _generateCollectValuesConfig(options, columnKeys, rowKeys);
|
|
69558
|
+
dataConfig.aggregationRules = _generateAggregationRules(options);
|
|
69559
|
+
const dataset = new Dataset(dataConfig, null, rowKeys, columnKeys, indicatorKeys, options.records, options.columnTree, options.rowTree, true);
|
|
69560
|
+
return dataset;
|
|
69561
|
+
}
|
|
69562
|
+
function _generateCollectValuesConfig(option, columnKeys, rowKeys) {
|
|
69563
|
+
const collectValuesBy = {};
|
|
69564
|
+
for (let i = 0, len = option.indicators?.length; i < len; i++) {
|
|
69565
|
+
if (typeof option.indicators[i] !== 'string' && option.indicators[i].chartSpec) {
|
|
69566
|
+
if (option.indicatorsAsCol === false) {
|
|
69567
|
+
const indicatorDefine = option.indicators[i];
|
|
69568
|
+
collectValuesBy[indicatorDefine.indicatorKey] = {
|
|
69569
|
+
by: rowKeys,
|
|
69570
|
+
range: true,
|
|
69571
|
+
sumBy: indicatorDefine.chartSpec?.stack !== false &&
|
|
69572
|
+
columnKeys.concat(indicatorDefine.chartSpec?.xField)
|
|
69573
|
+
};
|
|
69574
|
+
if (indicatorDefine.chartSpec.series) {
|
|
69575
|
+
indicatorDefine.chartSpec.series.forEach((chartSeries) => {
|
|
69576
|
+
const xField = typeof chartSeries.xField === 'string' ? chartSeries.xField : chartSeries.xField[0];
|
|
69577
|
+
collectValuesBy[xField] = {
|
|
69578
|
+
by: columnKeys,
|
|
69579
|
+
type: chartSeries.direction !== 'horizontal' ? 'xField' : undefined,
|
|
69580
|
+
range: chartSeries.direction === 'horizontal',
|
|
69581
|
+
sortBy: chartSeries.direction !== 'horizontal'
|
|
69582
|
+
? chartSeries?.data?.fields?.[xField]?.domain ??
|
|
69583
|
+
indicatorDefine.chartSpec?.data?.fields?.[xField]?.domain
|
|
69584
|
+
: undefined
|
|
69585
|
+
};
|
|
69586
|
+
const yField = chartSeries.yField;
|
|
69587
|
+
collectValuesBy[yField] = {
|
|
69588
|
+
by: rowKeys,
|
|
69589
|
+
range: chartSeries.direction !== 'horizontal',
|
|
69590
|
+
sumBy: chartSeries.stack !== false && columnKeys.concat(chartSeries?.xField),
|
|
69591
|
+
sortBy: chartSeries.direction === 'horizontal'
|
|
69592
|
+
? chartSeries?.data?.fields?.[yField]?.domain ??
|
|
69593
|
+
indicatorDefine.chartSpec?.data?.fields?.[yField]?.domain
|
|
69594
|
+
: undefined
|
|
69595
|
+
};
|
|
69596
|
+
});
|
|
69597
|
+
}
|
|
69598
|
+
else {
|
|
69599
|
+
const xField = typeof indicatorDefine.chartSpec.xField === 'string'
|
|
69600
|
+
? indicatorDefine.chartSpec.xField
|
|
69601
|
+
: indicatorDefine.chartSpec.xField[0];
|
|
69602
|
+
collectValuesBy[xField] = {
|
|
69603
|
+
by: columnKeys,
|
|
69604
|
+
type: indicatorDefine.chartSpec.direction !== 'horizontal' ? 'xField' : undefined,
|
|
69605
|
+
range: indicatorDefine.chartSpec.direction === 'horizontal',
|
|
69606
|
+
sortBy: indicatorDefine.chartSpec.direction !== 'horizontal'
|
|
69607
|
+
? indicatorDefine.chartSpec?.data?.fields?.[xField]?.domain
|
|
69608
|
+
: undefined
|
|
69609
|
+
};
|
|
69610
|
+
const yField = indicatorDefine.chartSpec.yField;
|
|
69611
|
+
collectValuesBy[yField] = {
|
|
69612
|
+
by: rowKeys,
|
|
69613
|
+
range: option.indicators[i].chartSpec.direction !== 'horizontal',
|
|
69614
|
+
sumBy: indicatorDefine.chartSpec.stack !== false &&
|
|
69615
|
+
columnKeys.concat(indicatorDefine.chartSpec?.xField),
|
|
69616
|
+
sortBy: indicatorDefine.chartSpec.direction === 'horizontal'
|
|
69617
|
+
? indicatorDefine.chartSpec?.data?.fields?.[yField]?.domain
|
|
69618
|
+
: undefined
|
|
69619
|
+
};
|
|
69620
|
+
}
|
|
69621
|
+
}
|
|
69622
|
+
else {
|
|
69623
|
+
const indicatorDefine = option.indicators[i];
|
|
69624
|
+
collectValuesBy[indicatorDefine.indicatorKey] = {
|
|
69625
|
+
by: columnKeys,
|
|
69626
|
+
range: true,
|
|
69627
|
+
sumBy: indicatorDefine.chartSpec?.stack !== false &&
|
|
69628
|
+
rowKeys.concat(indicatorDefine.chartSpec?.yField)
|
|
69629
|
+
};
|
|
69630
|
+
if (indicatorDefine.chartSpec.series) {
|
|
69631
|
+
indicatorDefine.chartSpec.series.forEach((chartSeries) => {
|
|
69632
|
+
const yField = typeof chartSeries.yField === 'string' ? chartSeries.yField : chartSeries.yField[0];
|
|
69633
|
+
collectValuesBy[yField] = {
|
|
69634
|
+
by: rowKeys,
|
|
69635
|
+
type: chartSeries.direction === 'horizontal' ? 'yField' : undefined,
|
|
69636
|
+
range: chartSeries.direction !== 'horizontal',
|
|
69637
|
+
sortBy: chartSeries.direction === 'horizontal'
|
|
69638
|
+
? chartSeries?.data?.fields?.[yField]?.domain ??
|
|
69639
|
+
indicatorDefine.chartSpec?.data?.fields?.[yField]?.domain
|
|
69640
|
+
: undefined
|
|
69641
|
+
};
|
|
69642
|
+
const xField = chartSeries.xField;
|
|
69643
|
+
collectValuesBy[xField] = {
|
|
69644
|
+
by: columnKeys,
|
|
69645
|
+
range: chartSeries.direction === 'horizontal',
|
|
69646
|
+
sumBy: chartSeries.stack !== false && rowKeys.concat(chartSeries?.yField),
|
|
69647
|
+
sortBy: chartSeries.direction !== 'horizontal'
|
|
69648
|
+
? chartSeries?.data?.fields?.[xField]?.domain ??
|
|
69649
|
+
indicatorDefine.chartSpec?.data?.fields?.[xField]?.domain
|
|
69650
|
+
: undefined
|
|
69651
|
+
};
|
|
69652
|
+
});
|
|
69653
|
+
}
|
|
69654
|
+
else {
|
|
69655
|
+
const yField = typeof indicatorDefine.chartSpec.yField === 'string'
|
|
69656
|
+
? indicatorDefine.chartSpec.yField
|
|
69657
|
+
: indicatorDefine.chartSpec.yField[0];
|
|
69658
|
+
collectValuesBy[yField] = {
|
|
69659
|
+
by: rowKeys,
|
|
69660
|
+
type: indicatorDefine.chartSpec.direction === 'horizontal' ? 'yField' : undefined,
|
|
69661
|
+
range: indicatorDefine.chartSpec.direction !== 'horizontal',
|
|
69662
|
+
sortBy: indicatorDefine.chartSpec.direction === 'horizontal'
|
|
69663
|
+
? indicatorDefine.chartSpec?.data?.fields?.[yField]?.domain
|
|
69664
|
+
: undefined
|
|
69665
|
+
};
|
|
69666
|
+
const xField = indicatorDefine.chartSpec.xField;
|
|
69667
|
+
collectValuesBy[xField] = {
|
|
69668
|
+
by: columnKeys,
|
|
69669
|
+
range: option.indicators[i].chartSpec.direction === 'horizontal',
|
|
69670
|
+
sumBy: indicatorDefine.chartSpec.stack !== false &&
|
|
69671
|
+
rowKeys.concat(indicatorDefine.chartSpec?.yField),
|
|
69672
|
+
sortBy: indicatorDefine.chartSpec.direction !== 'horizontal'
|
|
69673
|
+
? indicatorDefine.chartSpec?.data?.fields?.[xField]?.domain
|
|
69674
|
+
: undefined
|
|
69675
|
+
};
|
|
69676
|
+
}
|
|
69677
|
+
}
|
|
69678
|
+
}
|
|
69679
|
+
}
|
|
69680
|
+
return collectValuesBy;
|
|
69681
|
+
}
|
|
69682
|
+
function _generateAggregationRules(options) {
|
|
69683
|
+
const aggregationRules = [];
|
|
69684
|
+
options.indicators?.forEach((indicator) => {
|
|
69685
|
+
if (typeof indicator === 'string') {
|
|
69686
|
+
aggregationRules.push({
|
|
69687
|
+
indicatorKey: indicator,
|
|
69688
|
+
field: indicator,
|
|
69689
|
+
aggregationType: AggregationType.RECORD
|
|
69690
|
+
});
|
|
69691
|
+
}
|
|
69692
|
+
else {
|
|
69693
|
+
if (indicator.chartSpec?.series) {
|
|
69694
|
+
const fields = [];
|
|
69695
|
+
indicator.chartSpec?.series.forEach((seriesSpec) => {
|
|
69696
|
+
const seriesField = options.indicatorsAsCol === false ? seriesSpec.yField : seriesSpec.xField;
|
|
69697
|
+
if (fields.indexOf(seriesField) === -1) {
|
|
69698
|
+
fields.push(seriesField);
|
|
69699
|
+
}
|
|
69700
|
+
});
|
|
69701
|
+
aggregationRules.push({
|
|
69702
|
+
indicatorKey: indicator.indicatorKey,
|
|
69703
|
+
field: fields,
|
|
69704
|
+
aggregationType: AggregationType.RECORD
|
|
69705
|
+
});
|
|
69706
|
+
}
|
|
69707
|
+
else {
|
|
69708
|
+
const field = options.indicatorsAsCol === false
|
|
69709
|
+
? indicator.chartSpec.yField
|
|
69710
|
+
: indicator.chartSpec.xField;
|
|
69711
|
+
aggregationRules.push({
|
|
69712
|
+
indicatorKey: indicator.indicatorKey,
|
|
69713
|
+
field: field ?? indicator.indicatorKey,
|
|
69714
|
+
aggregationType: AggregationType.RECORD
|
|
69715
|
+
});
|
|
69716
|
+
}
|
|
69717
|
+
}
|
|
69718
|
+
});
|
|
69719
|
+
return aggregationRules;
|
|
69720
|
+
}
|
|
69721
|
+
|
|
69722
|
+
function getDataCellPath(options, data) {
|
|
69723
|
+
const dataset = createDataset(options);
|
|
69724
|
+
const mockTable = {
|
|
69725
|
+
options,
|
|
69726
|
+
isPivotChart: () => true,
|
|
69727
|
+
pivotChartAxes: [],
|
|
69728
|
+
_selectedDataItemsInChart: [],
|
|
69729
|
+
_getActiveChartInstance: () => {
|
|
69730
|
+
return {
|
|
69731
|
+
updateState: () => {
|
|
69732
|
+
}
|
|
69733
|
+
};
|
|
69734
|
+
}
|
|
69735
|
+
};
|
|
69736
|
+
const layoutMap = new PivotLayoutMap(mockTable, dataset);
|
|
69737
|
+
for (let col = 0; col < layoutMap.colCount; col++) {
|
|
69738
|
+
for (let row = 0; row < layoutMap.rowCount; row++) {
|
|
69739
|
+
if (layoutMap.isHeader(col, row)) {
|
|
69740
|
+
continue;
|
|
69741
|
+
}
|
|
69742
|
+
const colKey = dataset.colKeysPath[layoutMap.getRecordIndexByCol(col)] ?? [];
|
|
69743
|
+
const rowKey = dataset.rowKeysPath[layoutMap.getRecordIndexByRow(row)] ?? [];
|
|
69744
|
+
const aggregator = dataset.getAggregator(rowKey[rowKey.length - 1], colKey[colKey.length - 1], layoutMap.getIndicatorKey(col, row));
|
|
69745
|
+
const result = compareData(aggregator.value ? aggregator.value() : undefined, data, col, row, layoutMap);
|
|
69746
|
+
if (result) {
|
|
69747
|
+
return result;
|
|
69748
|
+
}
|
|
69749
|
+
}
|
|
69750
|
+
}
|
|
69751
|
+
return undefined;
|
|
69752
|
+
}
|
|
69753
|
+
function compareData(data1, data2, col, row, layoutMap) {
|
|
69754
|
+
if (isArray$2(data1)) {
|
|
69755
|
+
for (let i = 0; i < data1.length; i++) {
|
|
69756
|
+
if (JSON.stringify(data1[i]) === JSON.stringify(data2)) {
|
|
69757
|
+
return layoutMap.getCellHeaderPaths(col, row);
|
|
69758
|
+
}
|
|
69759
|
+
}
|
|
69760
|
+
}
|
|
69761
|
+
return undefined;
|
|
69762
|
+
}
|
|
69763
|
+
|
|
69482
69764
|
function VTag(params) {
|
|
69483
69765
|
return new Tag(params ? params.attribute : {});
|
|
69484
69766
|
}
|
|
69485
69767
|
|
|
69486
|
-
const version = "0.11.1-alpha.
|
|
69768
|
+
const version = "0.11.1-alpha.7";
|
|
69487
69769
|
function getIcons() {
|
|
69488
69770
|
return get$1();
|
|
69489
69771
|
}
|
|
@@ -69513,6 +69795,7 @@
|
|
|
69513
69795
|
exports.clearGlobal = clearGlobal;
|
|
69514
69796
|
exports.core = core;
|
|
69515
69797
|
exports.data = data;
|
|
69798
|
+
exports.getDataCellPath = getDataCellPath;
|
|
69516
69799
|
exports.getIcons = getIcons;
|
|
69517
69800
|
exports.jsx = jsx;
|
|
69518
69801
|
exports.register = register$1;
|