@visactor/vseed 0.0.1 → 0.0.2
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/builder/builder/build.d.ts +3 -0
- package/dist/builder/builder/buildAdvanced.d.ts +3 -0
- package/dist/builder/builder/buildSpec.d.ts +4 -0
- package/dist/builder/builder/builder.d.ts +216 -0
- package/dist/builder/builder/index.d.ts +1 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/register/index.d.ts +1 -0
- package/dist/builder/register/register.d.ts +3 -0
- package/dist/dataReshape/constant.d.ts +5 -0
- package/dist/dataReshape/dataReshapeFor1D1M.d.ts +13 -0
- package/dist/dataReshape/dataReshapeFor2D1M.d.ts +13 -0
- package/dist/dataReshape/foldMeasures.d.ts +31 -0
- package/dist/dataReshape/index.d.ts +4 -0
- package/dist/dataReshape/unfoldDimensions.d.ts +19 -0
- package/dist/index.cjs +616 -4
- package/dist/index.d.ts +5 -1
- package/dist/index.js +533 -2
- package/dist/pipeline/advanced/index.d.ts +1 -0
- package/dist/pipeline/advanced/pipeline/bar.d.ts +2 -0
- package/dist/pipeline/advanced/pipeline/column.d.ts +2 -0
- package/dist/pipeline/advanced/pipeline/index.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/encoding/encodingCartesian.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/encoding/index.d.ts +1 -0
- package/dist/pipeline/advanced/pipes/index.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/reshape/index.d.ts +2 -0
- package/dist/pipeline/advanced/pipes/reshape/reshapeTo1D1M.d.ts +8 -0
- package/dist/pipeline/advanced/pipes/reshape/reshapeTo2D1M.d.ts +8 -0
- package/dist/pipeline/index.d.ts +3 -0
- package/dist/pipeline/spec/index.d.ts +1 -0
- package/dist/pipeline/spec/pipeline/bar.d.ts +2 -0
- package/dist/pipeline/spec/pipeline/column.d.ts +2 -0
- package/dist/pipeline/spec/pipeline/index.d.ts +2 -0
- package/dist/pipeline/spec/pipes/axes/index.d.ts +4 -0
- package/dist/pipeline/spec/pipes/axes/xBand copy.d.ts +0 -0
- package/dist/pipeline/spec/pipes/axes/xBand.d.ts +2 -0
- package/dist/pipeline/spec/pipes/axes/xLinear copy.d.ts +0 -0
- package/dist/pipeline/spec/pipes/axes/xLinear.d.ts +2 -0
- package/dist/pipeline/spec/pipes/axes/yBand.d.ts +2 -0
- package/dist/pipeline/spec/pipes/axes/yLinear copy.d.ts +0 -0
- package/dist/pipeline/spec/pipes/axes/yLinear.d.ts +2 -0
- package/dist/pipeline/spec/pipes/dataset/dataset.d.ts +2 -0
- package/dist/pipeline/spec/pipes/dataset/index.d.ts +1 -0
- package/dist/pipeline/spec/pipes/index.d.ts +3 -0
- package/dist/pipeline/spec/pipes/init/bar.d.ts +2 -0
- package/dist/pipeline/spec/pipes/init/column.d.ts +2 -0
- package/dist/pipeline/spec/pipes/init/index.d.ts +2 -0
- package/dist/pipeline/utils/index.d.ts +1 -0
- package/dist/pipeline/utils/pipeline.d.ts +9 -0
- package/dist/types/builder/builder.d.ts +10 -0
- package/dist/types/builder/index.d.ts +1 -0
- package/dist/types/chartType/area/area.d.ts +46 -0
- package/dist/types/chartType/area/index.d.ts +1 -0
- package/dist/types/chartType/areaPercent/areaPercent.d.ts +45 -0
- package/dist/types/chartType/areaPercent/index.d.ts +1 -0
- package/dist/types/chartType/bar/bar.d.ts +45 -0
- package/dist/types/chartType/bar/index.d.ts +1 -0
- package/dist/types/chartType/barParallel/barParallel.d.ts +45 -0
- package/dist/types/chartType/barParallel/index.d.ts +1 -0
- package/dist/types/chartType/barPercent/barPercent.d.ts +45 -0
- package/dist/types/chartType/barPercent/index.d.ts +1 -0
- package/dist/types/chartType/column/column.d.ts +45 -0
- package/dist/types/chartType/column/index.d.ts +1 -0
- package/dist/types/chartType/columnParallel/columnParallel.d.ts +45 -0
- package/dist/types/chartType/columnParallel/index.d.ts +1 -0
- package/dist/types/chartType/columnPercent/columnPercent.d.ts +45 -0
- package/dist/types/chartType/columnPercent/index.d.ts +1 -0
- package/dist/types/chartType/donut/donut.d.ts +45 -0
- package/dist/types/chartType/donut/index.d.ts +1 -0
- package/dist/types/chartType/dualAxis/dualAxis.d.ts +47 -0
- package/dist/types/chartType/dualAxis/index.d.ts +1 -0
- package/dist/types/chartType/index.d.ts +16 -0
- package/dist/types/chartType/line/index.d.ts +1 -0
- package/dist/types/chartType/line/line.d.ts +45 -0
- package/dist/types/chartType/pie/index.d.ts +1 -0
- package/dist/types/chartType/pie/pie.d.ts +45 -0
- package/dist/types/chartType/pivotTable/index.d.ts +1 -0
- package/dist/types/chartType/pivotTable/pivotTable.d.ts +45 -0
- package/dist/types/chartType/rose/index.d.ts +1 -0
- package/dist/types/chartType/rose/rose.d.ts +45 -0
- package/dist/types/chartType/table/index.d.ts +1 -0
- package/dist/types/chartType/table/table.d.ts +45 -0
- package/dist/types/chartType/vseedDSL.d.ts +16 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/pipeline/advancedVSeed/advancedVSeed.d.ts +7 -0
- package/dist/types/pipeline/advancedVSeed/index.d.ts +1 -0
- package/dist/types/pipeline/index.d.ts +3 -0
- package/dist/types/pipeline/pipeline.d.ts +2 -0
- package/dist/types/pipeline/spec/index.d.ts +1 -0
- package/dist/types/pipeline/spec/spec.d.ts +9 -0
- package/dist/types/properties/advancedVSeed.d.ts +105 -0
- package/dist/types/properties/chartType/index.d.ts +2 -0
- package/dist/types/properties/chartType/zChartType.d.ts +36 -0
- package/dist/types/properties/dataset/dataset.d.ts +15 -0
- package/dist/types/properties/dataset/index.d.ts +2 -0
- package/dist/types/properties/datasetReshapeInfo/datasetReshapeInfo.d.ts +34 -0
- package/dist/types/properties/datasetReshapeInfo/index.d.ts +2 -0
- package/dist/types/properties/dimensions/dimensions.d.ts +23 -0
- package/dist/types/properties/dimensions/index.d.ts +2 -0
- package/dist/types/properties/encoding/encoding.d.ts +19 -0
- package/dist/types/properties/encoding/index.d.ts +2 -0
- package/dist/types/properties/index.d.ts +8 -0
- package/dist/types/properties/measures/index.d.ts +2 -0
- package/dist/types/properties/measures/measures.d.ts +109 -0
- package/dist/types/properties/vseed.d.ts +94 -0
- package/package.json +13 -2
package/dist/index.cjs
CHANGED
@@ -24,12 +24,624 @@ var __webpack_require__ = {};
|
|
24
24
|
var __webpack_exports__ = {};
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
27
|
-
|
27
|
+
registerAll: ()=>registerAll,
|
28
|
+
dataReshapeFor1D1M: ()=>dataReshapeFor1D1M,
|
29
|
+
zDatasetReshapeInfo: ()=>zDatasetReshapeInfo,
|
30
|
+
barAdvancedPipeline: ()=>barAdvancedPipeline,
|
31
|
+
zDatum: ()=>zDatum,
|
32
|
+
zFoldInfo: ()=>zFoldInfo,
|
33
|
+
execPipeline: ()=>execPipeline,
|
34
|
+
zDataset: ()=>zDataset,
|
35
|
+
zMeasureGroup: ()=>zMeasureGroup,
|
36
|
+
columnAdvancedPipeline: ()=>columnAdvancedPipeline,
|
37
|
+
dataReshapeFor2D1M: ()=>dataReshapeFor2D1M,
|
38
|
+
foldMeasures: ()=>foldMeasures,
|
39
|
+
zUnfoldInfo: ()=>zUnfoldInfo,
|
40
|
+
registerColumn: ()=>registerColumn,
|
41
|
+
zChartType: ()=>zChartType,
|
42
|
+
zDimension: ()=>zDimension,
|
43
|
+
zMeasures: ()=>zMeasures,
|
44
|
+
zMeasure: ()=>zMeasure,
|
45
|
+
zDimensions: ()=>zDimensions,
|
46
|
+
zVSeed: ()=>zVSeed,
|
47
|
+
barSpecPipeline: ()=>barSpecPipeline,
|
48
|
+
zEncoding: ()=>zEncoding,
|
49
|
+
unfoldDimensions: ()=>unfoldDimensions,
|
50
|
+
VSeedJSONSchema: ()=>VSeedJSONSchema,
|
51
|
+
Builder: ()=>Builder,
|
52
|
+
columnSpecPipeline: ()=>columnSpecPipeline,
|
53
|
+
zAdvancedVSeed: ()=>zAdvancedVSeed,
|
54
|
+
registerBar: ()=>registerBar
|
28
55
|
});
|
29
|
-
const
|
30
|
-
|
56
|
+
const execPipeline = (pipeline, context, initialValue = {})=>{
|
57
|
+
const result = pipeline.reduce((prev, cur)=>cur(prev, context), initialValue);
|
58
|
+
return result;
|
59
|
+
};
|
60
|
+
const buildAdvanced = (builder)=>{
|
61
|
+
const { chartType } = builder.vseed;
|
62
|
+
if (!chartType) throw new Error('chartType is nil in buildAdvanced');
|
63
|
+
const pipeline = builder.getAdvancedPipeline(chartType);
|
64
|
+
if (!pipeline) throw new Error(`no advanced pipeline for chartType ${chartType}`);
|
65
|
+
const context = {
|
66
|
+
vseed: builder.vseed
|
67
|
+
};
|
68
|
+
try {
|
69
|
+
return execPipeline(pipeline, context);
|
70
|
+
} catch (e) {
|
71
|
+
console.error(e);
|
72
|
+
throw new Error("buildAdvanced error, see error info in console");
|
73
|
+
}
|
74
|
+
};
|
75
|
+
const buildSpec = (builder, advancedVSeed)=>{
|
76
|
+
const { chartType } = builder.vseed;
|
77
|
+
if (!chartType) throw new Error('chartType is nil in buildSpec');
|
78
|
+
const pipeline = builder.getSpecPipeline(chartType);
|
79
|
+
if (!pipeline) throw new Error(`no spec pipeline for chartType ${chartType}`);
|
80
|
+
const context = {
|
81
|
+
vseed: builder.vseed,
|
82
|
+
advancedVSeed
|
83
|
+
};
|
84
|
+
try {
|
85
|
+
return execPipeline(pipeline, context);
|
86
|
+
} catch (e) {
|
87
|
+
console.error(e);
|
88
|
+
throw new Error("buildSpec error, see error info in console");
|
89
|
+
}
|
90
|
+
};
|
91
|
+
const build = (builder)=>{
|
92
|
+
const advancedVSeed = builder.buildAdvanced();
|
93
|
+
console.log('debug advancedVSeed', advancedVSeed);
|
94
|
+
if (!advancedVSeed) throw new Error('advancedVSeed is null');
|
95
|
+
const spec = builder.buildSpec(advancedVSeed);
|
96
|
+
console.log('debug spec', spec);
|
97
|
+
return spec;
|
98
|
+
};
|
99
|
+
class Builder {
|
100
|
+
_vseed;
|
101
|
+
_advancedVSeed;
|
102
|
+
static _advancedPipelineMap = {};
|
103
|
+
static _specPipelineMap = {};
|
104
|
+
static from = (vseed)=>new Builder(vseed);
|
105
|
+
constructor(vseed){
|
106
|
+
this._vseed = vseed;
|
107
|
+
this._advancedVSeed = null;
|
108
|
+
}
|
109
|
+
build = ()=>build(this);
|
110
|
+
buildSpec = (advanced)=>buildSpec(this, advanced);
|
111
|
+
buildAdvanced = ()=>buildAdvanced(this);
|
112
|
+
getAdvancedPipeline = (chartType)=>Builder._advancedPipelineMap[chartType];
|
113
|
+
getSpecPipeline = (chartType)=>Builder._specPipelineMap[chartType];
|
114
|
+
get vseed() {
|
115
|
+
return this._vseed;
|
116
|
+
}
|
117
|
+
set vseed(value) {
|
118
|
+
this._vseed = value;
|
119
|
+
}
|
120
|
+
get advancedVSeed() {
|
121
|
+
return this._advancedVSeed;
|
122
|
+
}
|
123
|
+
set advancedVSeed(value) {
|
124
|
+
this._advancedVSeed = value;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
const FoldMeasureName = '__MeaName__';
|
128
|
+
const FoldMeasureValue = '__MeaValue__';
|
129
|
+
const FoldMeasureId = '__MeaId__';
|
130
|
+
const FoldDimensionGroup = '__DimGroup__';
|
131
|
+
const Separator = '-';
|
132
|
+
const foldMeasures = (dataset, measures, measureId = FoldMeasureId, measureName = FoldMeasureName, measureValue = FoldMeasureValue)=>{
|
133
|
+
const foldInfo = {
|
134
|
+
measureId,
|
135
|
+
measureName,
|
136
|
+
measureValue,
|
137
|
+
foldMap: {}
|
138
|
+
};
|
139
|
+
const result = new Array(dataset.length * measures.length);
|
140
|
+
let index = 0;
|
141
|
+
for(let i = 0; i < dataset.length; i++)for(let j = 0; j < measures.length; j++){
|
142
|
+
const datum = {
|
143
|
+
...dataset[i]
|
144
|
+
};
|
145
|
+
const measure = measures[j];
|
146
|
+
const { id, alias } = measure;
|
147
|
+
datum[measureId] = id;
|
148
|
+
datum[measureName] = alias;
|
149
|
+
datum[measureValue] = dataset[i][id];
|
150
|
+
foldInfo.foldMap[id] = alias;
|
151
|
+
result[index++] = datum;
|
152
|
+
}
|
153
|
+
return {
|
154
|
+
dataset: result,
|
155
|
+
foldInfo
|
156
|
+
};
|
157
|
+
};
|
158
|
+
const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, foldGroupName = FoldDimensionGroup, dimensionsSeparator = Separator)=>{
|
159
|
+
if (unfoldStartIndex < 0 || unfoldStartIndex >= dimensions.length) throw new Error('unfoldStartIndex is out of range');
|
160
|
+
const dimensionsToBeUnfolded = dimensions.slice(unfoldStartIndex);
|
161
|
+
const unfoldInfo = {
|
162
|
+
groupName: foldGroupName,
|
163
|
+
colorItems: []
|
164
|
+
};
|
165
|
+
if (0 === dimensions.length || 0 === measures.length) return {
|
166
|
+
dataset,
|
167
|
+
unfoldInfo: {
|
168
|
+
groupName: foldGroupName,
|
169
|
+
colorItems: []
|
170
|
+
}
|
171
|
+
};
|
172
|
+
const colorItems = [];
|
173
|
+
for(let i = 0; i < dataset.length; i++){
|
174
|
+
const datum = dataset[i];
|
175
|
+
const colorItem = generateDimGroupName(dimensionsToBeUnfolded, datum, dimensionsSeparator);
|
176
|
+
datum[foldGroupName] = colorItem;
|
177
|
+
colorItems.push(colorItem);
|
178
|
+
}
|
179
|
+
unfoldInfo.colorItems = colorItems;
|
180
|
+
return {
|
181
|
+
dataset,
|
182
|
+
unfoldInfo
|
183
|
+
};
|
184
|
+
};
|
185
|
+
const generateDimGroupName = (dimensionsToBeGrouped, datum, dimensionsSeparator)=>dimensionsToBeGrouped.map((dim)=>String(datum[dim.id])).join(dimensionsSeparator);
|
186
|
+
const emptyReshapeResult = {
|
187
|
+
dataset: [],
|
188
|
+
foldInfo: {
|
189
|
+
foldMap: {},
|
190
|
+
measureId: '',
|
191
|
+
measureName: '',
|
192
|
+
measureValue: ''
|
193
|
+
},
|
194
|
+
unfoldInfo: {
|
195
|
+
colorItems: [],
|
196
|
+
groupName: ''
|
197
|
+
}
|
198
|
+
};
|
199
|
+
const dataReshapeFor2D1M = (dataset, dimensions, measures)=>{
|
200
|
+
if (0 === dimensions.length && 0 === measures.length) return emptyReshapeResult;
|
201
|
+
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, FoldMeasureId, FoldMeasureName, FoldMeasureValue);
|
202
|
+
if (0 === dimensions.length) {
|
203
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
204
|
+
{
|
205
|
+
id: FoldMeasureId,
|
206
|
+
alias: "\u6307\u6807Id",
|
207
|
+
location: 'dimension'
|
208
|
+
},
|
209
|
+
{
|
210
|
+
id: FoldMeasureName,
|
211
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
212
|
+
location: 'dimension'
|
213
|
+
}
|
214
|
+
], [
|
215
|
+
{
|
216
|
+
id: FoldMeasureValue,
|
217
|
+
alias: "\u6307\u6807\u503C"
|
218
|
+
}
|
219
|
+
], 1, FoldDimensionGroup);
|
220
|
+
return {
|
221
|
+
dataset: finalDataset,
|
222
|
+
foldInfo,
|
223
|
+
unfoldInfo
|
224
|
+
};
|
225
|
+
}
|
226
|
+
{
|
227
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
228
|
+
...dimensions,
|
229
|
+
{
|
230
|
+
id: FoldMeasureName,
|
231
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
232
|
+
location: 'dimension'
|
233
|
+
}
|
234
|
+
], [
|
235
|
+
{
|
236
|
+
id: FoldMeasureValue,
|
237
|
+
alias: "\u6307\u6807\u503C"
|
238
|
+
}
|
239
|
+
], 1, FoldDimensionGroup);
|
240
|
+
return {
|
241
|
+
dataset: finalDataset,
|
242
|
+
foldInfo,
|
243
|
+
unfoldInfo
|
244
|
+
};
|
245
|
+
}
|
246
|
+
};
|
247
|
+
const reshapeTo2D1M = (advancedVSeed, context)=>{
|
248
|
+
const result = {
|
249
|
+
...advancedVSeed
|
250
|
+
};
|
251
|
+
const { vseed } = context;
|
252
|
+
const { dimensions, measures, dataset } = vseed;
|
253
|
+
if (!measures || !dimensions || !dataset) return result;
|
254
|
+
if (0 === measures.length) throw new Error('measures can not be empty');
|
255
|
+
const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor2D1M(dataset, dimensions, measures);
|
256
|
+
return {
|
257
|
+
...result,
|
258
|
+
dataset: newDatasets,
|
259
|
+
datasetReshapeInfo: {
|
260
|
+
foldInfo,
|
261
|
+
unfoldInfo
|
262
|
+
},
|
263
|
+
dimensions,
|
264
|
+
measures
|
265
|
+
};
|
266
|
+
};
|
267
|
+
const encodingCartesian = (advancedVSeed)=>{
|
268
|
+
const result = {
|
269
|
+
...advancedVSeed
|
270
|
+
};
|
271
|
+
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
272
|
+
if (!datasetReshapeInfo || !dimensions) return result;
|
273
|
+
const { foldInfo, unfoldInfo } = datasetReshapeInfo;
|
274
|
+
const isSingleDimension = 0 === dimensions.length;
|
275
|
+
const x = [
|
276
|
+
isSingleDimension ? foldInfo.measureName : dimensions[0].id
|
277
|
+
];
|
278
|
+
const y = [
|
279
|
+
foldInfo.measureValue
|
280
|
+
];
|
281
|
+
const group = [
|
282
|
+
isSingleDimension ? foldInfo.measureName : unfoldInfo.groupName
|
283
|
+
];
|
284
|
+
const color = [
|
285
|
+
foldInfo.measureName
|
286
|
+
];
|
287
|
+
const encoding = [
|
288
|
+
{
|
289
|
+
x,
|
290
|
+
y,
|
291
|
+
group,
|
292
|
+
color
|
293
|
+
}
|
294
|
+
];
|
295
|
+
return {
|
296
|
+
...result,
|
297
|
+
encoding
|
298
|
+
};
|
299
|
+
};
|
300
|
+
const columnAdvancedPipeline = [
|
301
|
+
reshapeTo2D1M,
|
302
|
+
encodingCartesian
|
303
|
+
];
|
304
|
+
const initColumn = (spec, context)=>{
|
305
|
+
const result = {
|
306
|
+
...spec
|
307
|
+
};
|
308
|
+
const { advancedVSeed } = context;
|
309
|
+
const { encoding } = advancedVSeed;
|
310
|
+
result.type = 'bar';
|
311
|
+
result.direction = 'vertical';
|
312
|
+
result.xField = encoding[0].x?.[0];
|
313
|
+
result.yField = encoding[0].y?.[0];
|
314
|
+
result.seriesField = encoding[0].group?.[0];
|
315
|
+
result.data = {
|
316
|
+
values: advancedVSeed.dataset
|
317
|
+
};
|
318
|
+
return result;
|
319
|
+
};
|
320
|
+
const dataset_dataset = (spec, context)=>{
|
321
|
+
const { advancedVSeed } = context;
|
322
|
+
return {
|
323
|
+
...spec,
|
324
|
+
data: {
|
325
|
+
values: advancedVSeed.dataset
|
326
|
+
}
|
327
|
+
};
|
328
|
+
};
|
329
|
+
const xBand = (spec)=>{
|
330
|
+
const result = {
|
331
|
+
...spec
|
332
|
+
};
|
333
|
+
if (!result.axes) result.axes = [];
|
334
|
+
result.axes = [
|
335
|
+
...result.axes,
|
336
|
+
{
|
337
|
+
visible: true,
|
338
|
+
type: 'band',
|
339
|
+
orient: 'bottom'
|
340
|
+
}
|
341
|
+
];
|
342
|
+
return result;
|
343
|
+
};
|
344
|
+
const yLinear = (spec)=>{
|
345
|
+
const result = {
|
346
|
+
...spec
|
347
|
+
};
|
348
|
+
if (!result.axes) result.axes = [];
|
349
|
+
result.axes = [
|
350
|
+
...result.axes,
|
351
|
+
{
|
352
|
+
visible: true,
|
353
|
+
type: 'linear',
|
354
|
+
orient: 'left'
|
355
|
+
}
|
356
|
+
];
|
357
|
+
return result;
|
358
|
+
};
|
359
|
+
const columnSpecPipeline = [
|
360
|
+
initColumn,
|
361
|
+
dataset_dataset,
|
362
|
+
xBand,
|
363
|
+
yLinear
|
364
|
+
];
|
365
|
+
const barAdvancedPipeline = [
|
366
|
+
reshapeTo2D1M,
|
367
|
+
encodingCartesian
|
368
|
+
];
|
369
|
+
const initBar = (spec, context)=>{
|
370
|
+
const result = {
|
371
|
+
...spec
|
372
|
+
};
|
373
|
+
const { advancedVSeed } = context;
|
374
|
+
const { encoding } = advancedVSeed;
|
375
|
+
result.type = 'bar';
|
376
|
+
result.direction = 'horizontal';
|
377
|
+
result.yField = encoding[0].x?.[0];
|
378
|
+
result.xField = encoding[0].y?.[0];
|
379
|
+
result.seriesField = encoding[0].group?.[0];
|
380
|
+
return result;
|
381
|
+
};
|
382
|
+
const xLinear = (spec)=>{
|
383
|
+
const result = {
|
384
|
+
...spec
|
385
|
+
};
|
386
|
+
if (!result.axes) result.axes = [];
|
387
|
+
result.axes = [
|
388
|
+
...result.axes,
|
389
|
+
{
|
390
|
+
visible: true,
|
391
|
+
type: 'linear',
|
392
|
+
orient: 'bottom'
|
393
|
+
}
|
394
|
+
];
|
395
|
+
return result;
|
396
|
+
};
|
397
|
+
const yBand = (spec)=>{
|
398
|
+
const result = {
|
399
|
+
...spec
|
400
|
+
};
|
401
|
+
if (!result.axes) result.axes = [];
|
402
|
+
result.axes = [
|
403
|
+
...result.axes,
|
404
|
+
{
|
405
|
+
visible: true,
|
406
|
+
type: 'band',
|
407
|
+
orient: 'left'
|
408
|
+
}
|
409
|
+
];
|
410
|
+
return result;
|
411
|
+
};
|
412
|
+
const barSpecPipeline = [
|
413
|
+
initBar,
|
414
|
+
dataset_dataset,
|
415
|
+
xLinear,
|
416
|
+
yBand
|
417
|
+
];
|
418
|
+
const registerAll = ()=>{
|
419
|
+
registerColumn();
|
420
|
+
registerBar();
|
421
|
+
};
|
422
|
+
const registerColumn = ()=>{
|
423
|
+
Builder._advancedPipelineMap.column = columnAdvancedPipeline;
|
424
|
+
Builder._specPipelineMap.column = columnSpecPipeline;
|
425
|
+
};
|
426
|
+
const registerBar = ()=>{
|
427
|
+
Builder._advancedPipelineMap.bar = barAdvancedPipeline;
|
428
|
+
Builder._specPipelineMap.bar = barSpecPipeline;
|
429
|
+
};
|
430
|
+
const external_zod_namespaceObject = require("zod");
|
431
|
+
const zChartType = external_zod_namespaceObject.z["enum"]([
|
432
|
+
'table',
|
433
|
+
'pivotTable',
|
434
|
+
'line',
|
435
|
+
'column',
|
436
|
+
'columnPercent',
|
437
|
+
'columnParallel',
|
438
|
+
'bar',
|
439
|
+
'barPercent',
|
440
|
+
'barParallel',
|
441
|
+
'area',
|
442
|
+
'areaPercent',
|
443
|
+
'rose',
|
444
|
+
'pie',
|
445
|
+
'donut',
|
446
|
+
'dualAxis'
|
447
|
+
]);
|
448
|
+
const zDatum = external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string().or(external_zod_namespaceObject.z.number()), external_zod_namespaceObject.z.any());
|
449
|
+
const zDataset = external_zod_namespaceObject.z.array(zDatum);
|
450
|
+
const zDimension = external_zod_namespaceObject.z.object({
|
451
|
+
id: external_zod_namespaceObject.z.string(),
|
452
|
+
alias: external_zod_namespaceObject.z.string().optional(),
|
453
|
+
visible: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
454
|
+
location: external_zod_namespaceObject.z["enum"]([
|
455
|
+
'dimension',
|
456
|
+
'rowDimension',
|
457
|
+
'columnDimension'
|
458
|
+
])
|
459
|
+
});
|
460
|
+
const zDimensions = external_zod_namespaceObject.z.array(zDimension).optional();
|
461
|
+
const zMeasure = external_zod_namespaceObject.z.object({
|
462
|
+
id: external_zod_namespaceObject.z.string(),
|
463
|
+
alias: external_zod_namespaceObject.z.string().optional(),
|
464
|
+
visible: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
465
|
+
autoFormat: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
466
|
+
format: external_zod_namespaceObject.z.object({
|
467
|
+
type: external_zod_namespaceObject.z["enum"]([
|
468
|
+
'number',
|
469
|
+
'percent',
|
470
|
+
'permille'
|
471
|
+
]).optional().default('number'),
|
472
|
+
ratio: external_zod_namespaceObject.z.number().optional().default(1),
|
473
|
+
symbol: external_zod_namespaceObject.z.string().optional().default(''),
|
474
|
+
thousandSeparator: external_zod_namespaceObject.z.boolean().optional().default(false),
|
475
|
+
decimalPlaces: external_zod_namespaceObject.z.number().optional().default(2),
|
476
|
+
round: external_zod_namespaceObject.z["enum"]([
|
477
|
+
'round',
|
478
|
+
'floor',
|
479
|
+
'ceil'
|
480
|
+
]).optional().default('round'),
|
481
|
+
prefix: external_zod_namespaceObject.z.string().optional().default(''),
|
482
|
+
suffix: external_zod_namespaceObject.z.string().optional().default('')
|
483
|
+
}).optional()
|
484
|
+
});
|
485
|
+
const zMeasureGroup = external_zod_namespaceObject.z.object({
|
486
|
+
id: external_zod_namespaceObject.z.string(),
|
487
|
+
alias: external_zod_namespaceObject.z.string().optional(),
|
488
|
+
visible: external_zod_namespaceObject.z.boolean().default(true).optional(),
|
489
|
+
get children () {
|
490
|
+
return external_zod_namespaceObject.z.array(zMeasureGroup.or(zMeasure)).optional();
|
491
|
+
}
|
492
|
+
});
|
493
|
+
const zMeasures = external_zod_namespaceObject.z.array(zMeasureGroup.or(zMeasure)).optional();
|
494
|
+
const zVSeed = external_zod_namespaceObject.z.object({
|
495
|
+
chartType: zChartType,
|
496
|
+
dataset: zDataset,
|
497
|
+
dimensions: zDimensions,
|
498
|
+
measures: zMeasures
|
499
|
+
});
|
500
|
+
const VSeedJSONSchema = external_zod_namespaceObject.z.toJSONSchema(zVSeed);
|
501
|
+
const zEncoding = external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.object({
|
502
|
+
x: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
503
|
+
y: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
504
|
+
color: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
505
|
+
group: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
506
|
+
angle: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
507
|
+
radius: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
508
|
+
tooltip: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional()
|
509
|
+
}));
|
510
|
+
const zFoldInfo = external_zod_namespaceObject.z.object({
|
511
|
+
foldMap: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.string().or(external_zod_namespaceObject.z.undefined())),
|
512
|
+
measureId: external_zod_namespaceObject.z.string(),
|
513
|
+
measureName: external_zod_namespaceObject.z.string(),
|
514
|
+
measureValue: external_zod_namespaceObject.z.string()
|
515
|
+
});
|
516
|
+
const zUnfoldInfo = external_zod_namespaceObject.z.object({
|
517
|
+
colorItems: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
|
518
|
+
groupName: external_zod_namespaceObject.z.string()
|
519
|
+
});
|
520
|
+
const zDatasetReshapeInfo = external_zod_namespaceObject.z.object({
|
521
|
+
foldInfo: zFoldInfo,
|
522
|
+
unfoldInfo: zUnfoldInfo
|
523
|
+
});
|
524
|
+
const zAdvancedVSeed = external_zod_namespaceObject.z.object({
|
525
|
+
chartType: zChartType,
|
526
|
+
dataset: zDataset,
|
527
|
+
datasetReshapeInfo: zDatasetReshapeInfo,
|
528
|
+
dimensions: zDimensions,
|
529
|
+
measures: zMeasures,
|
530
|
+
encoding: zEncoding
|
531
|
+
});
|
532
|
+
const dataReshapeFor1D1M_emptyReshapeResult = {
|
533
|
+
dataset: [],
|
534
|
+
foldInfo: {
|
535
|
+
foldMap: {},
|
536
|
+
measureId: '',
|
537
|
+
measureName: '',
|
538
|
+
measureValue: ''
|
539
|
+
},
|
540
|
+
unfoldInfo: {
|
541
|
+
groupName: '',
|
542
|
+
colorItems: []
|
543
|
+
}
|
544
|
+
};
|
545
|
+
const dataReshapeFor1D1M = (dataset, dimensions, measures)=>{
|
546
|
+
if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D1M_emptyReshapeResult;
|
547
|
+
const { dataset: foldedDataset, foldInfo } = foldMeasures(dataset, measures, FoldMeasureId, FoldMeasureName, FoldMeasureValue);
|
548
|
+
if (0 === dimensions.length) {
|
549
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
550
|
+
{
|
551
|
+
id: FoldMeasureName,
|
552
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
553
|
+
location: 'dimension'
|
554
|
+
}
|
555
|
+
], [
|
556
|
+
{
|
557
|
+
id: FoldMeasureValue,
|
558
|
+
alias: "\u6307\u6807\u503C"
|
559
|
+
}
|
560
|
+
], 0, FoldDimensionGroup);
|
561
|
+
return {
|
562
|
+
dataset: finalDataset,
|
563
|
+
foldInfo,
|
564
|
+
unfoldInfo
|
565
|
+
};
|
566
|
+
}
|
567
|
+
{
|
568
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(foldedDataset, [
|
569
|
+
...dimensions,
|
570
|
+
{
|
571
|
+
id: FoldMeasureName,
|
572
|
+
alias: "\u6307\u6807\u540D\u79F0",
|
573
|
+
location: 'dimension'
|
574
|
+
}
|
575
|
+
], [
|
576
|
+
{
|
577
|
+
id: FoldMeasureValue,
|
578
|
+
alias: "\u6307\u6807\u503C"
|
579
|
+
}
|
580
|
+
], 0, FoldDimensionGroup);
|
581
|
+
return {
|
582
|
+
dataset: finalDataset,
|
583
|
+
foldInfo,
|
584
|
+
unfoldInfo
|
585
|
+
};
|
586
|
+
}
|
587
|
+
};
|
588
|
+
exports.Builder = __webpack_exports__.Builder;
|
589
|
+
exports.VSeedJSONSchema = __webpack_exports__.VSeedJSONSchema;
|
590
|
+
exports.barAdvancedPipeline = __webpack_exports__.barAdvancedPipeline;
|
591
|
+
exports.barSpecPipeline = __webpack_exports__.barSpecPipeline;
|
592
|
+
exports.columnAdvancedPipeline = __webpack_exports__.columnAdvancedPipeline;
|
593
|
+
exports.columnSpecPipeline = __webpack_exports__.columnSpecPipeline;
|
594
|
+
exports.dataReshapeFor1D1M = __webpack_exports__.dataReshapeFor1D1M;
|
595
|
+
exports.dataReshapeFor2D1M = __webpack_exports__.dataReshapeFor2D1M;
|
596
|
+
exports.execPipeline = __webpack_exports__.execPipeline;
|
597
|
+
exports.foldMeasures = __webpack_exports__.foldMeasures;
|
598
|
+
exports.registerAll = __webpack_exports__.registerAll;
|
599
|
+
exports.registerBar = __webpack_exports__.registerBar;
|
600
|
+
exports.registerColumn = __webpack_exports__.registerColumn;
|
601
|
+
exports.unfoldDimensions = __webpack_exports__.unfoldDimensions;
|
602
|
+
exports.zAdvancedVSeed = __webpack_exports__.zAdvancedVSeed;
|
603
|
+
exports.zChartType = __webpack_exports__.zChartType;
|
604
|
+
exports.zDataset = __webpack_exports__.zDataset;
|
605
|
+
exports.zDatasetReshapeInfo = __webpack_exports__.zDatasetReshapeInfo;
|
606
|
+
exports.zDatum = __webpack_exports__.zDatum;
|
607
|
+
exports.zDimension = __webpack_exports__.zDimension;
|
608
|
+
exports.zDimensions = __webpack_exports__.zDimensions;
|
609
|
+
exports.zEncoding = __webpack_exports__.zEncoding;
|
610
|
+
exports.zFoldInfo = __webpack_exports__.zFoldInfo;
|
611
|
+
exports.zMeasure = __webpack_exports__.zMeasure;
|
612
|
+
exports.zMeasureGroup = __webpack_exports__.zMeasureGroup;
|
613
|
+
exports.zMeasures = __webpack_exports__.zMeasures;
|
614
|
+
exports.zUnfoldInfo = __webpack_exports__.zUnfoldInfo;
|
615
|
+
exports.zVSeed = __webpack_exports__.zVSeed;
|
31
616
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
32
|
-
"
|
617
|
+
"Builder",
|
618
|
+
"VSeedJSONSchema",
|
619
|
+
"barAdvancedPipeline",
|
620
|
+
"barSpecPipeline",
|
621
|
+
"columnAdvancedPipeline",
|
622
|
+
"columnSpecPipeline",
|
623
|
+
"dataReshapeFor1D1M",
|
624
|
+
"dataReshapeFor2D1M",
|
625
|
+
"execPipeline",
|
626
|
+
"foldMeasures",
|
627
|
+
"registerAll",
|
628
|
+
"registerBar",
|
629
|
+
"registerColumn",
|
630
|
+
"unfoldDimensions",
|
631
|
+
"zAdvancedVSeed",
|
632
|
+
"zChartType",
|
633
|
+
"zDataset",
|
634
|
+
"zDatasetReshapeInfo",
|
635
|
+
"zDatum",
|
636
|
+
"zDimension",
|
637
|
+
"zDimensions",
|
638
|
+
"zEncoding",
|
639
|
+
"zFoldInfo",
|
640
|
+
"zMeasure",
|
641
|
+
"zMeasureGroup",
|
642
|
+
"zMeasures",
|
643
|
+
"zUnfoldInfo",
|
644
|
+
"zVSeed"
|
33
645
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
34
646
|
Object.defineProperty(exports, '__esModule', {
|
35
647
|
value: true
|
package/dist/index.d.ts
CHANGED