@vue-pivottable/multi-value-renderer 0.2.2 → 0.3.0-beta.0
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/dist/core.js +80 -3
- package/dist/core.mjs +80 -3
- package/dist/index.js +2 -6
- package/dist/index.mjs +3 -7
- package/dist/vue2.js +57 -2
- package/dist/vue2.mjs +56 -1
- package/dist/vue3.js +418 -3
- package/dist/vue3.mjs +418 -3
- package/package.json +1 -1
- package/dist/MultiValuePivotData.js +0 -81
- package/dist/MultiValueTableRenderer.js +0 -364
package/dist/core.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const MultiValuePivotData = require("./MultiValuePivotData.js");
|
|
4
3
|
function createMultiAggregator(aggregatorMap, aggregators) {
|
|
5
4
|
const defaultAggregator = "Sum";
|
|
6
5
|
return function multiAggregatorFactory(vals) {
|
|
@@ -85,8 +84,86 @@ function validateAggregatorMap(aggregatorMap, aggregators) {
|
|
|
85
84
|
errors
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
function createMultiValueAggregator(aggregatorMap, aggregators, vals) {
|
|
88
|
+
return function multiValueAggregatorFactory(data, rowKey, colKey) {
|
|
89
|
+
const subAggregators = {};
|
|
90
|
+
vals.forEach((val) => {
|
|
91
|
+
const aggName = aggregatorMap[val] || "Sum";
|
|
92
|
+
const aggFactory = aggregators[aggName];
|
|
93
|
+
if (aggFactory) {
|
|
94
|
+
subAggregators[val] = aggFactory([val])(data, rowKey, colKey);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
push(record) {
|
|
99
|
+
vals.forEach((val) => {
|
|
100
|
+
if (subAggregators[val]) {
|
|
101
|
+
subAggregators[val].push(record);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
value() {
|
|
106
|
+
const results = {};
|
|
107
|
+
vals.forEach((val) => {
|
|
108
|
+
if (subAggregators[val]) {
|
|
109
|
+
results[val] = subAggregators[val].value();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return results;
|
|
113
|
+
},
|
|
114
|
+
valueOf(valName) {
|
|
115
|
+
if (subAggregators[valName]) {
|
|
116
|
+
return subAggregators[valName].value();
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
},
|
|
120
|
+
format(values) {
|
|
121
|
+
if (typeof values !== "object") {
|
|
122
|
+
return String(values ?? "");
|
|
123
|
+
}
|
|
124
|
+
return vals.map((val) => {
|
|
125
|
+
const v = values[val];
|
|
126
|
+
const subAgg = subAggregators[val];
|
|
127
|
+
return subAgg && subAgg.format ? subAgg.format(v) : String(v ?? "");
|
|
128
|
+
}).join(" / ");
|
|
129
|
+
},
|
|
130
|
+
formatOf(valName, value) {
|
|
131
|
+
if (subAggregators[valName] && subAggregators[valName].format) {
|
|
132
|
+
return subAggregators[valName].format(value);
|
|
133
|
+
}
|
|
134
|
+
return String(value ?? "");
|
|
135
|
+
},
|
|
136
|
+
getSubAggregator(valName) {
|
|
137
|
+
return subAggregators[valName] || null;
|
|
138
|
+
},
|
|
139
|
+
numInputs: vals.length
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function extendPivotData(BasePivotData) {
|
|
144
|
+
return class MultiValuePivotData extends BasePivotData {
|
|
145
|
+
constructor(inputProps = {}) {
|
|
146
|
+
const { aggregatorMap = {}, ...restProps } = inputProps;
|
|
147
|
+
const multiValueAgg = createMultiValueAggregator(
|
|
148
|
+
aggregatorMap,
|
|
149
|
+
restProps.aggregators || BasePivotData.defaultProps.aggregators,
|
|
150
|
+
restProps.vals || []
|
|
151
|
+
);
|
|
152
|
+
const modifiedProps = {
|
|
153
|
+
...restProps,
|
|
154
|
+
aggregators: {
|
|
155
|
+
...restProps.aggregators,
|
|
156
|
+
"Multi-Value": () => multiValueAgg
|
|
157
|
+
},
|
|
158
|
+
aggregatorName: "Multi-Value"
|
|
159
|
+
};
|
|
160
|
+
super(modifiedProps);
|
|
161
|
+
this.aggregatorMap = aggregatorMap;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
90
165
|
exports.createMultiAggregator = createMultiAggregator;
|
|
166
|
+
exports.createMultiValueAggregator = createMultiValueAggregator;
|
|
91
167
|
exports.defaultColorScaleGenerator = defaultColorScaleGenerator;
|
|
168
|
+
exports.extendPivotData = extendPivotData;
|
|
92
169
|
exports.validateAggregatorMap = validateAggregatorMap;
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { c, e } from "./MultiValuePivotData.js";
|
|
2
1
|
function createMultiAggregator(aggregatorMap, aggregators) {
|
|
3
2
|
const defaultAggregator = "Sum";
|
|
4
3
|
return function multiAggregatorFactory(vals) {
|
|
@@ -83,10 +82,88 @@ function validateAggregatorMap(aggregatorMap, aggregators) {
|
|
|
83
82
|
errors
|
|
84
83
|
};
|
|
85
84
|
}
|
|
85
|
+
function createMultiValueAggregator(aggregatorMap, aggregators, vals) {
|
|
86
|
+
return function multiValueAggregatorFactory(data, rowKey, colKey) {
|
|
87
|
+
const subAggregators = {};
|
|
88
|
+
vals.forEach((val) => {
|
|
89
|
+
const aggName = aggregatorMap[val] || "Sum";
|
|
90
|
+
const aggFactory = aggregators[aggName];
|
|
91
|
+
if (aggFactory) {
|
|
92
|
+
subAggregators[val] = aggFactory([val])(data, rowKey, colKey);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return {
|
|
96
|
+
push(record) {
|
|
97
|
+
vals.forEach((val) => {
|
|
98
|
+
if (subAggregators[val]) {
|
|
99
|
+
subAggregators[val].push(record);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
value() {
|
|
104
|
+
const results = {};
|
|
105
|
+
vals.forEach((val) => {
|
|
106
|
+
if (subAggregators[val]) {
|
|
107
|
+
results[val] = subAggregators[val].value();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return results;
|
|
111
|
+
},
|
|
112
|
+
valueOf(valName) {
|
|
113
|
+
if (subAggregators[valName]) {
|
|
114
|
+
return subAggregators[valName].value();
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
},
|
|
118
|
+
format(values) {
|
|
119
|
+
if (typeof values !== "object") {
|
|
120
|
+
return String(values ?? "");
|
|
121
|
+
}
|
|
122
|
+
return vals.map((val) => {
|
|
123
|
+
const v = values[val];
|
|
124
|
+
const subAgg = subAggregators[val];
|
|
125
|
+
return subAgg && subAgg.format ? subAgg.format(v) : String(v ?? "");
|
|
126
|
+
}).join(" / ");
|
|
127
|
+
},
|
|
128
|
+
formatOf(valName, value) {
|
|
129
|
+
if (subAggregators[valName] && subAggregators[valName].format) {
|
|
130
|
+
return subAggregators[valName].format(value);
|
|
131
|
+
}
|
|
132
|
+
return String(value ?? "");
|
|
133
|
+
},
|
|
134
|
+
getSubAggregator(valName) {
|
|
135
|
+
return subAggregators[valName] || null;
|
|
136
|
+
},
|
|
137
|
+
numInputs: vals.length
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function extendPivotData(BasePivotData) {
|
|
142
|
+
return class MultiValuePivotData extends BasePivotData {
|
|
143
|
+
constructor(inputProps = {}) {
|
|
144
|
+
const { aggregatorMap = {}, ...restProps } = inputProps;
|
|
145
|
+
const multiValueAgg = createMultiValueAggregator(
|
|
146
|
+
aggregatorMap,
|
|
147
|
+
restProps.aggregators || BasePivotData.defaultProps.aggregators,
|
|
148
|
+
restProps.vals || []
|
|
149
|
+
);
|
|
150
|
+
const modifiedProps = {
|
|
151
|
+
...restProps,
|
|
152
|
+
aggregators: {
|
|
153
|
+
...restProps.aggregators,
|
|
154
|
+
"Multi-Value": () => multiValueAgg
|
|
155
|
+
},
|
|
156
|
+
aggregatorName: "Multi-Value"
|
|
157
|
+
};
|
|
158
|
+
super(modifiedProps);
|
|
159
|
+
this.aggregatorMap = aggregatorMap;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
86
163
|
export {
|
|
87
164
|
createMultiAggregator,
|
|
88
|
-
|
|
165
|
+
createMultiValueAggregator,
|
|
89
166
|
defaultColorScaleGenerator,
|
|
90
|
-
|
|
167
|
+
extendPivotData,
|
|
91
168
|
validateAggregatorMap
|
|
92
169
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const core = require("./core.js");
|
|
4
|
-
const MultiValuePivotData = require("./MultiValuePivotData.js");
|
|
5
|
-
const MultiValueTableRenderer = require("./MultiValueTableRenderer.js");
|
|
6
4
|
exports.createMultiAggregator = core.createMultiAggregator;
|
|
5
|
+
exports.createMultiValueAggregator = core.createMultiValueAggregator;
|
|
7
6
|
exports.defaultColorScaleGenerator = core.defaultColorScaleGenerator;
|
|
7
|
+
exports.extendPivotData = core.extendPivotData;
|
|
8
8
|
exports.validateAggregatorMap = core.validateAggregatorMap;
|
|
9
|
-
exports.createMultiValueAggregator = MultiValuePivotData.createMultiValueAggregator;
|
|
10
|
-
exports.extendPivotData = MultiValuePivotData.extendPivotData;
|
|
11
|
-
exports.MultiValueRenderers = MultiValueTableRenderer.MultiValueTableRenderer;
|
|
12
|
-
exports.makeMultiValueRenderer = MultiValueTableRenderer.makeMultiValueRenderer;
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { createMultiAggregator, defaultColorScaleGenerator, validateAggregatorMap } from "./core.mjs";
|
|
2
|
-
import { c, e } from "./MultiValuePivotData.js";
|
|
3
|
-
import { M, m } from "./MultiValueTableRenderer.js";
|
|
1
|
+
import { createMultiAggregator, createMultiValueAggregator, defaultColorScaleGenerator, extendPivotData, validateAggregatorMap } from "./core.mjs";
|
|
4
2
|
export {
|
|
5
|
-
M as MultiValueRenderers,
|
|
6
3
|
createMultiAggregator,
|
|
7
|
-
|
|
4
|
+
createMultiValueAggregator,
|
|
8
5
|
defaultColorScaleGenerator,
|
|
9
|
-
|
|
10
|
-
m as makeMultiValueRenderer,
|
|
6
|
+
extendPivotData,
|
|
11
7
|
validateAggregatorMap
|
|
12
8
|
};
|
package/dist/vue2.js
CHANGED
|
@@ -1,8 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const vuePivottable = require("vue-pivottable");
|
|
4
|
-
const MultiValuePivotData = require("./MultiValuePivotData.js");
|
|
5
4
|
const { PivotData } = vuePivottable.PivotUtilities;
|
|
5
|
+
function createMultiValueAggregator(aggregatorMap, aggregators, vals) {
|
|
6
|
+
return function multiValueAggregatorFactory(data, rowKey, colKey) {
|
|
7
|
+
const subAggregators = {};
|
|
8
|
+
vals.forEach((val) => {
|
|
9
|
+
const aggName = aggregatorMap[val] || "Sum";
|
|
10
|
+
const aggFactory = aggregators[aggName];
|
|
11
|
+
if (aggFactory) {
|
|
12
|
+
subAggregators[val] = aggFactory([val])(data, rowKey, colKey);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
push(record) {
|
|
17
|
+
vals.forEach((val) => {
|
|
18
|
+
if (subAggregators[val]) {
|
|
19
|
+
subAggregators[val].push(record);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
value() {
|
|
24
|
+
const results = {};
|
|
25
|
+
vals.forEach((val) => {
|
|
26
|
+
if (subAggregators[val]) {
|
|
27
|
+
results[val] = subAggregators[val].value();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return results;
|
|
31
|
+
},
|
|
32
|
+
valueOf(valName) {
|
|
33
|
+
if (subAggregators[valName]) {
|
|
34
|
+
return subAggregators[valName].value();
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
},
|
|
38
|
+
format(values) {
|
|
39
|
+
if (typeof values !== "object") {
|
|
40
|
+
return String(values ?? "");
|
|
41
|
+
}
|
|
42
|
+
return vals.map((val) => {
|
|
43
|
+
const v = values[val];
|
|
44
|
+
const subAgg = subAggregators[val];
|
|
45
|
+
return subAgg && subAgg.format ? subAgg.format(v) : String(v ?? "");
|
|
46
|
+
}).join(" / ");
|
|
47
|
+
},
|
|
48
|
+
formatOf(valName, value) {
|
|
49
|
+
if (subAggregators[valName] && subAggregators[valName].format) {
|
|
50
|
+
return subAggregators[valName].format(value);
|
|
51
|
+
}
|
|
52
|
+
return String(value ?? "");
|
|
53
|
+
},
|
|
54
|
+
getSubAggregator(valName) {
|
|
55
|
+
return subAggregators[valName] || null;
|
|
56
|
+
},
|
|
57
|
+
numInputs: vals.length
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
6
61
|
function redColorScaleGenerator(values) {
|
|
7
62
|
const numericValues = values.filter((v) => typeof v === "number" && !isNaN(v));
|
|
8
63
|
if (numericValues.length === 0) {
|
|
@@ -218,7 +273,7 @@ function makeMultiValueRenderer(opts = {}) {
|
|
|
218
273
|
* Create PivotData-like structure with multi-value aggregation
|
|
219
274
|
*/
|
|
220
275
|
createPivotData() {
|
|
221
|
-
const multiValueAgg =
|
|
276
|
+
const multiValueAgg = createMultiValueAggregator(
|
|
222
277
|
this.aggregatorMap,
|
|
223
278
|
this.aggregators,
|
|
224
279
|
this.vals
|
package/dist/vue2.mjs
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
import { PivotUtilities } from "vue-pivottable";
|
|
2
|
-
import { c as createMultiValueAggregator } from "./MultiValuePivotData.js";
|
|
3
2
|
const { PivotData } = PivotUtilities;
|
|
3
|
+
function createMultiValueAggregator(aggregatorMap, aggregators, vals) {
|
|
4
|
+
return function multiValueAggregatorFactory(data, rowKey, colKey) {
|
|
5
|
+
const subAggregators = {};
|
|
6
|
+
vals.forEach((val) => {
|
|
7
|
+
const aggName = aggregatorMap[val] || "Sum";
|
|
8
|
+
const aggFactory = aggregators[aggName];
|
|
9
|
+
if (aggFactory) {
|
|
10
|
+
subAggregators[val] = aggFactory([val])(data, rowKey, colKey);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
push(record) {
|
|
15
|
+
vals.forEach((val) => {
|
|
16
|
+
if (subAggregators[val]) {
|
|
17
|
+
subAggregators[val].push(record);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
value() {
|
|
22
|
+
const results = {};
|
|
23
|
+
vals.forEach((val) => {
|
|
24
|
+
if (subAggregators[val]) {
|
|
25
|
+
results[val] = subAggregators[val].value();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return results;
|
|
29
|
+
},
|
|
30
|
+
valueOf(valName) {
|
|
31
|
+
if (subAggregators[valName]) {
|
|
32
|
+
return subAggregators[valName].value();
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
format(values) {
|
|
37
|
+
if (typeof values !== "object") {
|
|
38
|
+
return String(values ?? "");
|
|
39
|
+
}
|
|
40
|
+
return vals.map((val) => {
|
|
41
|
+
const v = values[val];
|
|
42
|
+
const subAgg = subAggregators[val];
|
|
43
|
+
return subAgg && subAgg.format ? subAgg.format(v) : String(v ?? "");
|
|
44
|
+
}).join(" / ");
|
|
45
|
+
},
|
|
46
|
+
formatOf(valName, value) {
|
|
47
|
+
if (subAggregators[valName] && subAggregators[valName].format) {
|
|
48
|
+
return subAggregators[valName].format(value);
|
|
49
|
+
}
|
|
50
|
+
return String(value ?? "");
|
|
51
|
+
},
|
|
52
|
+
getSubAggregator(valName) {
|
|
53
|
+
return subAggregators[valName] || null;
|
|
54
|
+
},
|
|
55
|
+
numInputs: vals.length
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}
|
|
4
59
|
function redColorScaleGenerator(values) {
|
|
5
60
|
const numericValues = values.filter((v) => typeof v === "number" && !isNaN(v));
|
|
6
61
|
if (numericValues.length === 0) {
|