@visactor/vseed 0.0.21 → 0.0.23
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/advanced/colorItems.d.ts +1 -0
- package/dist/builder/builder/advanced/index.d.ts +1 -1
- package/dist/builder/builder/builder.d.ts +947 -63
- package/dist/builder/register/chartType.d.ts +1 -0
- package/dist/builder/register/custom.d.ts +3 -0
- package/dist/builder/register/index.d.ts +1 -0
- package/dist/dataReshape/dataReshapeFor1D.d.ts +19 -0
- package/dist/dataReshape/index.d.ts +1 -0
- package/dist/index.cjs +713 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +667 -48
- package/dist/index.js.map +1 -1
- package/dist/pipeline/advanced/chart/pipeline/areaRange.d.ts +2 -0
- package/dist/pipeline/advanced/chart/pipeline/index.d.ts +1 -0
- package/dist/pipeline/advanced/chart/pipes/analysis/index.d.ts +1 -0
- package/dist/pipeline/advanced/chart/pipes/analysis/sort.d.ts +4 -0
- package/dist/pipeline/advanced/chart/pipes/encoding/encodingXYY.d.ts +2 -0
- package/dist/pipeline/advanced/chart/pipes/encoding/index.d.ts +1 -0
- package/dist/pipeline/advanced/chart/pipes/index.d.ts +1 -0
- package/dist/pipeline/advanced/chart/pipes/init/autoMeasuresBy2M1Group.d.ts +8 -0
- package/dist/pipeline/advanced/chart/pipes/init/index.d.ts +1 -0
- package/dist/pipeline/advanced/chart/pipes/reshape/index.d.ts +2 -0
- package/dist/pipeline/advanced/chart/pipes/reshape/pivotReshapeTo1D.d.ts +8 -0
- package/dist/pipeline/advanced/chart/pipes/reshape/reshapeTo1D.d.ts +8 -0
- package/dist/pipeline/spec/chart/pipeline/areaRange.d.ts +1 -0
- package/dist/pipeline/spec/chart/pipeline/index.d.ts +1 -0
- package/dist/pipeline/spec/chart/pipes/dataset/datasetPivot.d.ts +0 -1
- package/dist/pipeline/spec/chart/pipes/dataset/index.d.ts +1 -1
- package/dist/pipeline/spec/chart/pipes/index.d.ts +1 -0
- package/dist/pipeline/spec/chart/pipes/init/areaRange.d.ts +4 -0
- package/dist/pipeline/spec/chart/pipes/init/index.d.ts +1 -0
- package/dist/pipeline/spec/chart/pipes/series/index.d.ts +1 -0
- package/dist/pipeline/spec/chart/pipes/series/series.d.ts +2 -0
- package/dist/types/advancedVSeed.d.ts +310 -0
- package/dist/types/chartType/area/area.d.ts +25 -1
- package/dist/types/chartType/areaPercent/areaPercent.d.ts +25 -1
- package/dist/types/chartType/areaRange/areaRange.d.ts +1337 -0
- package/dist/types/chartType/areaRange/index.d.ts +1 -0
- package/dist/types/chartType/bar/bar.d.ts +25 -1
- package/dist/types/chartType/barParallel/barParallel.d.ts +25 -1
- package/dist/types/chartType/barPercent/barPercent.d.ts +25 -1
- package/dist/types/chartType/column/column.d.ts +25 -1
- package/dist/types/chartType/columnParallel/columnParallel.d.ts +25 -1
- package/dist/types/chartType/columnPercent/columnPercent.d.ts +25 -1
- package/dist/types/chartType/index.d.ts +1 -0
- package/dist/types/chartType/line/line.d.ts +41 -1
- package/dist/types/properties/analysis/analysis.d.ts +4 -0
- package/dist/types/properties/analysis/index.d.ts +3 -0
- package/dist/types/properties/analysis/sortAxis.d.ts +39 -0
- package/dist/types/properties/analysis/sortLegend.d.ts +39 -0
- package/dist/types/properties/chartType/chartType.d.ts +3 -1
- package/dist/types/properties/config/config.d.ts +307 -0
- package/dist/types/properties/index.d.ts +1 -0
- package/dist/types/properties/theme/customTheme.d.ts +306 -0
- package/dist/types/vseed.d.ts +1206 -1
- package/dist/umd/index.js +8847 -350
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { clone, groupBy, isArray, isEmpty, isNullish, isNumber, isString, mergeDeep, omit, pick, unique } from "remeda";
|
1
|
+
import { clone, groupBy, isArray, isEmpty, isNullish, isNumber, isString, mergeDeep, omit, pick, sort, unique } from "remeda";
|
2
2
|
import { color as external_d3_color_color } from "d3-color";
|
3
|
-
import { z } from "zod";
|
3
|
+
import zod, { z } from "zod";
|
4
4
|
const initAdvancedVSeed = (advancedVSeed, context)=>{
|
5
5
|
const { vseed } = context;
|
6
6
|
const { chartType, locale } = vseed;
|
@@ -62,7 +62,6 @@ const createNumFormatter = (format, locale = intl.getLocale())=>{
|
|
62
62
|
roundingMode,
|
63
63
|
roundingPriority
|
64
64
|
};
|
65
|
-
console.log('debug roundingMode', roundingMode);
|
66
65
|
if (isNumber(fractionDigits)) {
|
67
66
|
if (fractionDigits >= 0) {
|
68
67
|
numFormatterOptions.minimumFractionDigits = fractionDigits;
|
@@ -300,6 +299,51 @@ const autoDimensions = (advancedVSeed, context)=>{
|
|
300
299
|
}));
|
301
300
|
return result;
|
302
301
|
};
|
302
|
+
const autoMeasuresBy2M1Group = (advancedVSeed, context)=>{
|
303
|
+
const result = {
|
304
|
+
...advancedVSeed
|
305
|
+
};
|
306
|
+
const { vseed } = context;
|
307
|
+
const { measures, dataset } = vseed;
|
308
|
+
if (!dataset) throw new Error('dataset is required');
|
309
|
+
if (0 === dataset.length) return result;
|
310
|
+
if (measures) {
|
311
|
+
result.measures = auto2M1Group(measures);
|
312
|
+
return result;
|
313
|
+
}
|
314
|
+
const top100dataset = dataset.slice(0, 100);
|
315
|
+
const sample = top100dataset.reduce((prev, cur)=>({
|
316
|
+
...prev,
|
317
|
+
...cur
|
318
|
+
}), {});
|
319
|
+
const newMeasures = Object.keys(sample).filter((key)=>top100dataset.some((item)=>'number' == typeof item[key]) && ![
|
320
|
+
'',
|
321
|
+
null,
|
322
|
+
void 0
|
323
|
+
].includes(key)).map((measure)=>({
|
324
|
+
id: measure,
|
325
|
+
alias: measure
|
326
|
+
}));
|
327
|
+
result.measures = auto2M1Group(newMeasures);
|
328
|
+
return result;
|
329
|
+
};
|
330
|
+
const auto2M1Group = (measures)=>{
|
331
|
+
const allMeasures = findAllMeasures(measures);
|
332
|
+
if (allMeasures.length <= 2) return allMeasures;
|
333
|
+
const groups = measures.filter((measure)=>'children' in measure);
|
334
|
+
const singleMeasures = measures.filter((measure)=>!('children' in measure));
|
335
|
+
for(let i = 0; i < singleMeasures.length; i += 2){
|
336
|
+
const group = autoMeasuresBy2M1Group_createEmptyMeasureGroup();
|
337
|
+
group.children = allMeasures.slice(i, i + 2);
|
338
|
+
groups.push(group);
|
339
|
+
}
|
340
|
+
return groups;
|
341
|
+
};
|
342
|
+
const autoMeasuresBy2M1Group_createEmptyMeasureGroup = ()=>({
|
343
|
+
id: '',
|
344
|
+
alias: '',
|
345
|
+
children: []
|
346
|
+
});
|
303
347
|
const FoldMeasureName = '__MeaName__';
|
304
348
|
const FoldMeasureValue = '__MeaValue__';
|
305
349
|
const FoldMeasureId = '__MeaId__';
|
@@ -330,10 +374,10 @@ const unfoldDimensions = (dataset, dimensions, measures, unfoldStartIndex = 0, u
|
|
330
374
|
for(let i = 0; i < dataset.length; i++){
|
331
375
|
const datum = dataset[i];
|
332
376
|
const colorName = generateDimGroupName(dimensionsToBeUnfolded, datum, dimensionsSeparator);
|
333
|
-
const colorId = [
|
377
|
+
const colorId = datum[foldMeasureId] ? [
|
334
378
|
colorName,
|
335
|
-
datum[foldMeasureId]
|
336
|
-
].join(dimensionsSeparator);
|
379
|
+
datum[foldMeasureId]
|
380
|
+
].join(dimensionsSeparator) : colorName;
|
337
381
|
datum[unfoldGroupName] = colorName;
|
338
382
|
datum[unfoldGroupId] = colorId;
|
339
383
|
colorItems.push(colorId);
|
@@ -559,6 +603,58 @@ const dataReshapeFor1D2M = (dataset, dimensions, measures, options)=>{
|
|
559
603
|
};
|
560
604
|
}
|
561
605
|
};
|
606
|
+
const dataReshapeFor1D_emptyReshapeResult = {
|
607
|
+
dataset: [],
|
608
|
+
foldInfo: {
|
609
|
+
foldMap: {},
|
610
|
+
measureId: '',
|
611
|
+
measureName: '',
|
612
|
+
measureValue: ''
|
613
|
+
},
|
614
|
+
unfoldInfo: {
|
615
|
+
groupName: '',
|
616
|
+
groupId: '',
|
617
|
+
colorItems: [],
|
618
|
+
colorIdMap: {}
|
619
|
+
}
|
620
|
+
};
|
621
|
+
const dataReshapeFor1D = (dataset, dimensions, measures, options)=>{
|
622
|
+
const { foldMeasureId = FoldMeasureId, foldMeasureName = FoldMeasureName, foldMeasureValue = FoldMeasureValue, unfoldDimensionGroup = UnfoldDimensionGroup, unfoldDimensionGroupId = UnfoldDimensionGroupId } = options || {};
|
623
|
+
if (0 === dimensions.length && 0 === measures.length) return dataReshapeFor1D_emptyReshapeResult;
|
624
|
+
if (0 === dimensions.length) {
|
625
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(dataset, [], [], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
|
626
|
+
return {
|
627
|
+
dataset: finalDataset,
|
628
|
+
foldInfo: {
|
629
|
+
foldMap: {},
|
630
|
+
measureId: foldMeasureId,
|
631
|
+
measureName: foldMeasureName,
|
632
|
+
measureValue: foldMeasureValue
|
633
|
+
},
|
634
|
+
unfoldInfo
|
635
|
+
};
|
636
|
+
}
|
637
|
+
{
|
638
|
+
const { dataset: finalDataset, unfoldInfo } = unfoldDimensions(dataset, [
|
639
|
+
...dimensions
|
640
|
+
], [
|
641
|
+
{
|
642
|
+
id: foldMeasureValue,
|
643
|
+
alias: i18n`指标值`
|
644
|
+
}
|
645
|
+
], 0, unfoldDimensionGroup, unfoldDimensionGroupId, foldMeasureId);
|
646
|
+
return {
|
647
|
+
dataset: finalDataset,
|
648
|
+
foldInfo: {
|
649
|
+
foldMap: {},
|
650
|
+
measureId: foldMeasureId,
|
651
|
+
measureName: foldMeasureName,
|
652
|
+
measureValue: foldMeasureValue
|
653
|
+
},
|
654
|
+
unfoldInfo
|
655
|
+
};
|
656
|
+
}
|
657
|
+
};
|
562
658
|
const reshapeTo2D1M = (advancedVSeed, context)=>{
|
563
659
|
const result = {
|
564
660
|
...advancedVSeed
|
@@ -627,6 +723,28 @@ const reshapeTo1D2M = (advancedVSeed, context)=>{
|
|
627
723
|
]
|
628
724
|
};
|
629
725
|
};
|
726
|
+
const reshapeTo1D = (advancedVSeed, context)=>{
|
727
|
+
const result = {
|
728
|
+
...advancedVSeed
|
729
|
+
};
|
730
|
+
const { vseed } = context;
|
731
|
+
const { dataset } = vseed;
|
732
|
+
const { dimensions, measures } = advancedVSeed;
|
733
|
+
if (!measures || !dimensions || !dataset) return result;
|
734
|
+
if (0 === measures.length) throw new Error('measures can not be empty');
|
735
|
+
const { dataset: newDatasets, foldInfo, unfoldInfo } = dataReshapeFor1D(dataset, dimensions, measures);
|
736
|
+
return {
|
737
|
+
...result,
|
738
|
+
dataset: newDatasets,
|
739
|
+
datasetReshapeInfo: [
|
740
|
+
{
|
741
|
+
id: '1D2M',
|
742
|
+
foldInfo,
|
743
|
+
unfoldInfo
|
744
|
+
}
|
745
|
+
]
|
746
|
+
};
|
747
|
+
};
|
630
748
|
const pivotReshapeTo1D1M = (advancedVSeed, context)=>{
|
631
749
|
const result = {
|
632
750
|
...advancedVSeed
|
@@ -747,17 +865,58 @@ const pivotReshapeTo2D1M = (advancedVSeed, context)=>{
|
|
747
865
|
datasetReshapeInfo: datasetReshapeInfo
|
748
866
|
};
|
749
867
|
};
|
868
|
+
const pivotReshapeTo1D = (advancedVSeed, context)=>{
|
869
|
+
const result = {
|
870
|
+
...advancedVSeed
|
871
|
+
};
|
872
|
+
const { vseed } = context;
|
873
|
+
const { dataset } = vseed;
|
874
|
+
const { measures } = advancedVSeed;
|
875
|
+
const dimensions = advancedVSeed.dimensions;
|
876
|
+
if (!measures || !dimensions) return result;
|
877
|
+
const measureGroups = [];
|
878
|
+
if (measures) measures.forEach((measure)=>{
|
879
|
+
if (measure.children && measure.children.length > 0) measureGroups.push(measure);
|
880
|
+
});
|
881
|
+
const newDatasets = [];
|
882
|
+
const datasetReshapeInfo = [];
|
883
|
+
measureGroups.forEach((measureGroup)=>{
|
884
|
+
const measures = measureGroup.children;
|
885
|
+
if (!measures) return;
|
886
|
+
const commonDimensions = dimensions.filter((dim)=>'dimension' === dim.location);
|
887
|
+
const groupId = measureGroup.id;
|
888
|
+
const { dataset: newSubDataset, foldInfo, unfoldInfo } = dataReshapeFor1D(dataset, commonDimensions, measures, {
|
889
|
+
foldMeasureId: FoldMeasureId,
|
890
|
+
foldMeasureName: FoldMeasureName,
|
891
|
+
foldMeasureValue: FoldMeasureValue + groupId,
|
892
|
+
unfoldDimensionGroup: UnfoldDimensionGroup
|
893
|
+
});
|
894
|
+
const reshapeInfo = {
|
895
|
+
id: groupId,
|
896
|
+
foldInfo,
|
897
|
+
unfoldInfo
|
898
|
+
};
|
899
|
+
newDatasets.push(newSubDataset);
|
900
|
+
datasetReshapeInfo.push(reshapeInfo);
|
901
|
+
});
|
902
|
+
return {
|
903
|
+
...result,
|
904
|
+
dataset: newDatasets,
|
905
|
+
datasetReshapeInfo: datasetReshapeInfo
|
906
|
+
};
|
907
|
+
};
|
750
908
|
const encodingXY = (advancedVSeed)=>{
|
751
909
|
const result = {
|
752
910
|
...advancedVSeed
|
753
911
|
};
|
754
912
|
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
755
913
|
if (!datasetReshapeInfo || !dimensions) return result;
|
914
|
+
const xDimension = dimensions.find((item)=>'rowDimension' !== item.location && 'columnDimension' !== item.location);
|
756
915
|
const isZeroDimension = 0 === dimensions.length;
|
757
916
|
const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
|
758
917
|
const { foldInfo, unfoldInfo } = cur;
|
759
918
|
const x = [
|
760
|
-
isZeroDimension ? foldInfo.measureName :
|
919
|
+
isZeroDimension ? foldInfo.measureName : xDimension?.id
|
761
920
|
];
|
762
921
|
const y = [
|
763
922
|
foldInfo.measureValue
|
@@ -789,11 +948,12 @@ const encodingYX = (advancedVSeed)=>{
|
|
789
948
|
};
|
790
949
|
const { datasetReshapeInfo, dimensions } = advancedVSeed;
|
791
950
|
if (!datasetReshapeInfo || !dimensions) return result;
|
951
|
+
const yDimension = dimensions.find((item)=>'rowDimension' !== item.location && 'columnDimension' !== item.location);
|
792
952
|
const isZeroDimension = 0 === dimensions.length;
|
793
953
|
const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
|
794
954
|
const { foldInfo, unfoldInfo } = cur;
|
795
955
|
const y = [
|
796
|
-
isZeroDimension ? foldInfo.measureName :
|
956
|
+
isZeroDimension ? foldInfo.measureName : yDimension?.id
|
797
957
|
];
|
798
958
|
const x = [
|
799
959
|
foldInfo.measureValue
|
@@ -855,12 +1015,81 @@ const encodingYY = (advancedVSeed)=>{
|
|
855
1015
|
encoding
|
856
1016
|
};
|
857
1017
|
};
|
1018
|
+
const encodingXYY = (advancedVSeed)=>{
|
1019
|
+
const result = {
|
1020
|
+
...advancedVSeed
|
1021
|
+
};
|
1022
|
+
const { datasetReshapeInfo, dimensions, measures } = advancedVSeed;
|
1023
|
+
if (!datasetReshapeInfo || !dimensions || !measures) return result;
|
1024
|
+
const encoding = datasetReshapeInfo.reduce((prev, cur, index)=>{
|
1025
|
+
const measure = measures[index];
|
1026
|
+
if ('children' in measure) {
|
1027
|
+
const m1 = measure.children?.[0];
|
1028
|
+
const m2 = measure.children?.[1] || m1;
|
1029
|
+
const { foldInfo, unfoldInfo } = cur;
|
1030
|
+
const x = [
|
1031
|
+
unfoldInfo.groupId
|
1032
|
+
];
|
1033
|
+
const y = [
|
1034
|
+
m1?.id,
|
1035
|
+
m2?.id
|
1036
|
+
];
|
1037
|
+
const group = [
|
1038
|
+
unfoldInfo.groupId
|
1039
|
+
];
|
1040
|
+
const color = [
|
1041
|
+
foldInfo.measureName
|
1042
|
+
];
|
1043
|
+
return [
|
1044
|
+
...prev,
|
1045
|
+
{
|
1046
|
+
x,
|
1047
|
+
y,
|
1048
|
+
group,
|
1049
|
+
color
|
1050
|
+
}
|
1051
|
+
];
|
1052
|
+
}
|
1053
|
+
{
|
1054
|
+
const m1 = measures[index];
|
1055
|
+
const m2 = measures[index + 1] || m1;
|
1056
|
+
const { foldInfo, unfoldInfo } = cur;
|
1057
|
+
const x = [
|
1058
|
+
unfoldInfo.groupId
|
1059
|
+
];
|
1060
|
+
const y = [
|
1061
|
+
m1.id,
|
1062
|
+
m2.id
|
1063
|
+
];
|
1064
|
+
const group = [
|
1065
|
+
unfoldInfo.groupId
|
1066
|
+
];
|
1067
|
+
const color = [
|
1068
|
+
foldInfo.measureName
|
1069
|
+
];
|
1070
|
+
return [
|
1071
|
+
...prev,
|
1072
|
+
{
|
1073
|
+
x,
|
1074
|
+
y,
|
1075
|
+
group,
|
1076
|
+
color
|
1077
|
+
}
|
1078
|
+
];
|
1079
|
+
}
|
1080
|
+
}, []);
|
1081
|
+
return {
|
1082
|
+
...result,
|
1083
|
+
encoding
|
1084
|
+
};
|
1085
|
+
};
|
858
1086
|
const encodingRose = (advancedVSeed)=>{
|
859
1087
|
const result = {
|
860
1088
|
...advancedVSeed
|
861
1089
|
};
|
862
1090
|
const { datasetReshapeInfo, dimensions, measures } = advancedVSeed;
|
863
1091
|
if (!datasetReshapeInfo || !dimensions || !measures) return result;
|
1092
|
+
const angleDimension = dimensions.find((item)=>'rowDimension' !== item.location && 'columnDimension' !== item.location);
|
864
1093
|
const is1D1M = 1 === dimensions.length && 1 === measures.length;
|
865
1094
|
const isZeroDimension = 0 === dimensions.length;
|
866
1095
|
const encoding = datasetReshapeInfo.reduce((prev, cur)=>{
|
@@ -869,13 +1098,13 @@ const encodingRose = (advancedVSeed)=>{
|
|
869
1098
|
foldInfo.measureValue
|
870
1099
|
];
|
871
1100
|
const angle = [
|
872
|
-
isZeroDimension ? foldInfo.measureName :
|
1101
|
+
isZeroDimension ? foldInfo.measureName : angleDimension?.id
|
873
1102
|
];
|
874
1103
|
const group = [
|
875
|
-
is1D1M ?
|
1104
|
+
is1D1M ? angleDimension?.id : unfoldInfo.groupId
|
876
1105
|
];
|
877
1106
|
const color = [
|
878
|
-
is1D1M ?
|
1107
|
+
is1D1M ? angleDimension?.id : unfoldInfo.groupId
|
879
1108
|
];
|
880
1109
|
return [
|
881
1110
|
...prev,
|
@@ -1095,6 +1324,81 @@ const annotation_annotation = (advancedVSeed, context)=>{
|
|
1095
1324
|
annotation
|
1096
1325
|
};
|
1097
1326
|
};
|
1327
|
+
const sortXBandAxis = (advancedVSeed, context)=>{
|
1328
|
+
const result = {
|
1329
|
+
...advancedVSeed
|
1330
|
+
};
|
1331
|
+
const { vseed } = context;
|
1332
|
+
const { sortAxis, dataset } = vseed;
|
1333
|
+
const { encoding } = advancedVSeed;
|
1334
|
+
const xField = encoding?.[0]?.x?.[0];
|
1335
|
+
if (!sortAxis || !xField) return advancedVSeed;
|
1336
|
+
if (!result.analysis) result.analysis = {};
|
1337
|
+
if (!result.analysis.orderMapping) result.analysis.orderMapping = {};
|
1338
|
+
const axisOrderResult = calcOrder(sortAxis, xField, dataset);
|
1339
|
+
result.analysis.orderMapping[xField] = axisOrderResult;
|
1340
|
+
return result;
|
1341
|
+
};
|
1342
|
+
const sortYBandAxis = (advancedVSeed, context)=>{
|
1343
|
+
const result = {
|
1344
|
+
...advancedVSeed
|
1345
|
+
};
|
1346
|
+
const { vseed } = context;
|
1347
|
+
const { sortAxis, dataset } = vseed;
|
1348
|
+
const { encoding } = advancedVSeed;
|
1349
|
+
const yField = encoding?.[0]?.y?.[0];
|
1350
|
+
if (!sortAxis || !yField) return advancedVSeed;
|
1351
|
+
if (!result.analysis) result.analysis = {};
|
1352
|
+
if (!result.analysis.orderMapping) result.analysis.orderMapping = {};
|
1353
|
+
const axisOrderResult = calcOrder(sortAxis, yField, dataset);
|
1354
|
+
result.analysis.orderMapping[yField] = axisOrderResult;
|
1355
|
+
return result;
|
1356
|
+
};
|
1357
|
+
const sort_sortLegend = (advancedVSeed, context)=>{
|
1358
|
+
const result = {
|
1359
|
+
...advancedVSeed
|
1360
|
+
};
|
1361
|
+
const { vseed } = context;
|
1362
|
+
const { sortLegend } = vseed;
|
1363
|
+
const { datasetReshapeInfo } = advancedVSeed;
|
1364
|
+
const groupField = datasetReshapeInfo?.[0]?.unfoldInfo?.groupId;
|
1365
|
+
const colorIdMap = datasetReshapeInfo?.[0]?.unfoldInfo?.colorIdMap;
|
1366
|
+
const colorItems = datasetReshapeInfo?.[0]?.unfoldInfo?.colorItems;
|
1367
|
+
if (!sortLegend || !groupField || !colorIdMap || !colorItems) return advancedVSeed;
|
1368
|
+
if (!result.analysis) result.analysis = {};
|
1369
|
+
if (!result.analysis.orderMapping) result.analysis.orderMapping = {};
|
1370
|
+
if (sortLegend.customOrder) {
|
1371
|
+
const nameMap = Object.keys(colorIdMap).reduce((pre, cur)=>{
|
1372
|
+
pre[colorIdMap[cur]] = cur;
|
1373
|
+
return pre;
|
1374
|
+
}, {});
|
1375
|
+
const orderRes = sortLegend.customOrder.map((itemNameOrId)=>nameMap[itemNameOrId] ? nameMap[itemNameOrId] : itemNameOrId);
|
1376
|
+
result.analysis.orderMapping[groupField] = orderRes;
|
1377
|
+
return result;
|
1378
|
+
}
|
1379
|
+
const dataset = advancedVSeed.dataset?.flat(2);
|
1380
|
+
const orderRes = calcOrder(sortLegend, groupField, dataset || []);
|
1381
|
+
result.analysis.orderMapping[groupField] = orderRes;
|
1382
|
+
return result;
|
1383
|
+
};
|
1384
|
+
const calcOrder = (sortAxis, id, dataset)=>{
|
1385
|
+
if (sortAxis.customOrder) return sortAxis.customOrder;
|
1386
|
+
const order = sortAxis.order || 'asc';
|
1387
|
+
const orderBy = sortAxis.orderBy;
|
1388
|
+
const res = sort(dataset, (a, b)=>{
|
1389
|
+
const aValue = a[orderBy || id];
|
1390
|
+
const bValue = b[orderBy || id];
|
1391
|
+
if ('asc' === order) {
|
1392
|
+
if (aValue < bValue) return -1;
|
1393
|
+
if (aValue > bValue) return 1;
|
1394
|
+
return 0;
|
1395
|
+
}
|
1396
|
+
if (aValue > bValue) return -1;
|
1397
|
+
if (aValue < bValue) return 1;
|
1398
|
+
return 0;
|
1399
|
+
});
|
1400
|
+
return unique(res.map((item)=>item[id]));
|
1401
|
+
};
|
1098
1402
|
const lineAdvancedPipeline = [
|
1099
1403
|
initAdvancedVSeed,
|
1100
1404
|
autoMeasures,
|
@@ -1105,6 +1409,8 @@ const lineAdvancedPipeline = [
|
|
1105
1409
|
pivotReshapeTo2D1M
|
1106
1410
|
]),
|
1107
1411
|
encodingXY,
|
1412
|
+
sortXBandAxis,
|
1413
|
+
sort_sortLegend,
|
1108
1414
|
lineConfig,
|
1109
1415
|
theme_theme,
|
1110
1416
|
markStyle_markStyle,
|
@@ -1120,6 +1426,8 @@ const barAdvancedPipeline = [
|
|
1120
1426
|
pivotReshapeTo2D1M
|
1121
1427
|
]),
|
1122
1428
|
encodingYX,
|
1429
|
+
sortYBandAxis,
|
1430
|
+
sort_sortLegend,
|
1123
1431
|
barConfig,
|
1124
1432
|
theme_theme,
|
1125
1433
|
markStyle_markStyle,
|
@@ -1135,6 +1443,8 @@ const barParallelAdvancedPipeline = [
|
|
1135
1443
|
pivotReshapeTo2D1M
|
1136
1444
|
]),
|
1137
1445
|
encodingYX,
|
1446
|
+
sortYBandAxis,
|
1447
|
+
sort_sortLegend,
|
1138
1448
|
barParallelConfig,
|
1139
1449
|
theme_theme,
|
1140
1450
|
markStyle_markStyle,
|
@@ -1150,6 +1460,8 @@ const barPercentAdvancedPipeline = [
|
|
1150
1460
|
pivotReshapeTo2D1M
|
1151
1461
|
]),
|
1152
1462
|
encodingYX,
|
1463
|
+
sortYBandAxis,
|
1464
|
+
sort_sortLegend,
|
1153
1465
|
barPercentConfig,
|
1154
1466
|
theme_theme,
|
1155
1467
|
markStyle_markStyle,
|
@@ -1165,6 +1477,8 @@ const columnAdvancedPipeline = [
|
|
1165
1477
|
pivotReshapeTo2D1M
|
1166
1478
|
]),
|
1167
1479
|
encodingXY,
|
1480
|
+
sortXBandAxis,
|
1481
|
+
sort_sortLegend,
|
1168
1482
|
columnConfig,
|
1169
1483
|
theme_theme,
|
1170
1484
|
markStyle_markStyle,
|
@@ -1180,6 +1494,8 @@ const columnParallelAdvancedPipeline = [
|
|
1180
1494
|
pivotReshapeTo2D1M
|
1181
1495
|
]),
|
1182
1496
|
encodingXY,
|
1497
|
+
sortXBandAxis,
|
1498
|
+
sort_sortLegend,
|
1183
1499
|
columnParallelConfig,
|
1184
1500
|
theme_theme,
|
1185
1501
|
markStyle_markStyle,
|
@@ -1195,6 +1511,8 @@ const columnPercentAdvancedPipeline = [
|
|
1195
1511
|
pivotReshapeTo2D1M
|
1196
1512
|
]),
|
1197
1513
|
encodingXY,
|
1514
|
+
sortXBandAxis,
|
1515
|
+
sort_sortLegend,
|
1198
1516
|
columnPercentConfig,
|
1199
1517
|
theme_theme,
|
1200
1518
|
markStyle_markStyle,
|
@@ -1210,6 +1528,8 @@ const areaAdvancedPipeline = [
|
|
1210
1528
|
pivotReshapeTo2D1M
|
1211
1529
|
]),
|
1212
1530
|
encodingXY,
|
1531
|
+
sortXBandAxis,
|
1532
|
+
sort_sortLegend,
|
1213
1533
|
areaConfig,
|
1214
1534
|
theme_theme,
|
1215
1535
|
markStyle_markStyle,
|
@@ -1225,11 +1545,29 @@ const areaPercentAdvancedPipeline = [
|
|
1225
1545
|
pivotReshapeTo2D1M
|
1226
1546
|
]),
|
1227
1547
|
encodingXY,
|
1548
|
+
sortXBandAxis,
|
1549
|
+
sort_sortLegend,
|
1228
1550
|
areaPercentConfig,
|
1229
1551
|
theme_theme,
|
1230
1552
|
markStyle_markStyle,
|
1231
1553
|
annotation_annotation
|
1232
1554
|
];
|
1555
|
+
const areaRangeAdvancedPipeline = [
|
1556
|
+
initAdvancedVSeed,
|
1557
|
+
autoMeasuresBy2M1Group,
|
1558
|
+
autoDimensions,
|
1559
|
+
pivotAdapter([
|
1560
|
+
reshapeTo1D
|
1561
|
+
], [
|
1562
|
+
pivotReshapeTo1D
|
1563
|
+
]),
|
1564
|
+
encodingXYY,
|
1565
|
+
sortXBandAxis,
|
1566
|
+
areaConfig,
|
1567
|
+
theme_theme,
|
1568
|
+
markStyle_markStyle,
|
1569
|
+
annotation_annotation
|
1570
|
+
];
|
1233
1571
|
const pieAdvancedPipeline = [
|
1234
1572
|
initAdvancedVSeed,
|
1235
1573
|
autoMeasures,
|
@@ -1470,25 +1808,56 @@ const tableAdvancedPipeline = [
|
|
1470
1808
|
theme_theme
|
1471
1809
|
];
|
1472
1810
|
const dataset_dataset = (spec, context)=>{
|
1473
|
-
const { advancedVSeed } = context;
|
1474
|
-
const { encoding } = advancedVSeed;
|
1811
|
+
const { advancedVSeed, vseed } = context;
|
1812
|
+
const { encoding, analysis, datasetReshapeInfo } = advancedVSeed;
|
1813
|
+
const { orderMapping = {} } = analysis ?? {};
|
1475
1814
|
const angle = encoding[0]?.angle?.[0];
|
1476
1815
|
const x = encoding[0]?.x?.[0];
|
1816
|
+
const y = encoding[0]?.y?.[0];
|
1477
1817
|
const group = encoding[0]?.group?.[0];
|
1818
|
+
const id = datasetReshapeInfo[0].id;
|
1478
1819
|
const fields = {};
|
1479
1820
|
if (angle) fields[angle] = {
|
1480
1821
|
sortIndex: 0
|
1481
1822
|
};
|
1482
|
-
if (x)
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1823
|
+
if (x) {
|
1824
|
+
const order = orderMapping[x];
|
1825
|
+
if (order) fields[x] = {
|
1826
|
+
sortIndex: 0,
|
1827
|
+
domain: order,
|
1828
|
+
lockStatisticsByDomain: true
|
1829
|
+
};
|
1830
|
+
else fields[x] = {
|
1831
|
+
sortIndex: 0
|
1832
|
+
};
|
1833
|
+
}
|
1834
|
+
if (y) {
|
1835
|
+
const order = orderMapping[y];
|
1836
|
+
if (order) fields[y] = {
|
1837
|
+
sortIndex: 0,
|
1838
|
+
domain: order,
|
1839
|
+
lockStatisticsByDomain: true
|
1840
|
+
};
|
1841
|
+
else fields[y] = {
|
1842
|
+
sortIndex: 0
|
1843
|
+
};
|
1844
|
+
}
|
1845
|
+
if (group) {
|
1846
|
+
const order = orderMapping[group];
|
1847
|
+
if (order) fields[group] = {
|
1848
|
+
sortIndex: 0,
|
1849
|
+
domain: order,
|
1850
|
+
lockStatisticsByDomain: true
|
1851
|
+
};
|
1852
|
+
else fields[group] = {
|
1853
|
+
sortIndex: 0
|
1854
|
+
};
|
1855
|
+
}
|
1488
1856
|
return {
|
1489
1857
|
...spec,
|
1490
1858
|
data: {
|
1491
|
-
|
1859
|
+
id,
|
1860
|
+
values: isPivotChart(vseed) ? void 0 : advancedVSeed.dataset,
|
1492
1861
|
fields: fields
|
1493
1862
|
}
|
1494
1863
|
};
|
@@ -1509,12 +1878,6 @@ const datasetPivot = (spec, context)=>{
|
|
1509
1878
|
records: records
|
1510
1879
|
};
|
1511
1880
|
};
|
1512
|
-
const datasetPivotPlaceholder = (spec)=>({
|
1513
|
-
...spec,
|
1514
|
-
data: {
|
1515
|
-
id: 'placeholderDataId'
|
1516
|
-
}
|
1517
|
-
});
|
1518
1881
|
const initColumn = (spec, context)=>{
|
1519
1882
|
const result = {
|
1520
1883
|
...spec
|
@@ -1603,6 +1966,88 @@ const initArea = (spec, context)=>{
|
|
1603
1966
|
result.animation = true;
|
1604
1967
|
return result;
|
1605
1968
|
};
|
1969
|
+
const initAreaRange = (spec, context)=>{
|
1970
|
+
const result = {
|
1971
|
+
...spec
|
1972
|
+
};
|
1973
|
+
const { advancedVSeed } = context;
|
1974
|
+
const { encoding } = advancedVSeed;
|
1975
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
1976
|
+
const { color } = advancedVSeed.config.areaRange;
|
1977
|
+
result.type = 'rangeArea';
|
1978
|
+
result.direction = 'vertical';
|
1979
|
+
result.stack = false;
|
1980
|
+
result.xField = encoding[0].x[0];
|
1981
|
+
result.yField = [
|
1982
|
+
encoding[0].y[0],
|
1983
|
+
encoding[0].y[1]
|
1984
|
+
];
|
1985
|
+
result.animation = true;
|
1986
|
+
result.area = {
|
1987
|
+
style: {
|
1988
|
+
fill: color.colorScheme?.[0]
|
1989
|
+
}
|
1990
|
+
};
|
1991
|
+
return result;
|
1992
|
+
};
|
1993
|
+
const initAreaRangeLine1 = (spec, context)=>{
|
1994
|
+
const result = {
|
1995
|
+
...spec
|
1996
|
+
};
|
1997
|
+
const { advancedVSeed } = context;
|
1998
|
+
const { encoding } = advancedVSeed;
|
1999
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
2000
|
+
const { color } = advancedVSeed.config.areaRange;
|
2001
|
+
result.type = 'line';
|
2002
|
+
result.direction = 'vertical';
|
2003
|
+
result.stack = false;
|
2004
|
+
result.xField = encoding[0].x[0];
|
2005
|
+
result.yField = [
|
2006
|
+
encoding[0].y[0]
|
2007
|
+
];
|
2008
|
+
result.animation = true;
|
2009
|
+
result.line = {
|
2010
|
+
style: {
|
2011
|
+
stroke: color.colorScheme?.[0]
|
2012
|
+
}
|
2013
|
+
};
|
2014
|
+
result.point = {
|
2015
|
+
style: {
|
2016
|
+
visible: false,
|
2017
|
+
fill: color.colorScheme?.[0]
|
2018
|
+
}
|
2019
|
+
};
|
2020
|
+
return result;
|
2021
|
+
};
|
2022
|
+
const initAreaRangeLine2 = (spec, context)=>{
|
2023
|
+
const result = {
|
2024
|
+
...spec
|
2025
|
+
};
|
2026
|
+
const { advancedVSeed } = context;
|
2027
|
+
const { encoding } = advancedVSeed;
|
2028
|
+
if (!encoding[0].y || !encoding[0].x || !encoding[0].group) return result;
|
2029
|
+
const { color } = advancedVSeed.config.areaRange;
|
2030
|
+
result.type = 'line';
|
2031
|
+
result.direction = 'vertical';
|
2032
|
+
result.stack = false;
|
2033
|
+
result.xField = encoding[0].x[0];
|
2034
|
+
result.yField = [
|
2035
|
+
encoding[0].y[1]
|
2036
|
+
];
|
2037
|
+
result.animation = true;
|
2038
|
+
result.line = {
|
2039
|
+
style: {
|
2040
|
+
stroke: color.colorScheme?.[0]
|
2041
|
+
}
|
2042
|
+
};
|
2043
|
+
result.point = {
|
2044
|
+
style: {
|
2045
|
+
visible: false,
|
2046
|
+
fill: color.colorScheme?.[0]
|
2047
|
+
}
|
2048
|
+
};
|
2049
|
+
return result;
|
2050
|
+
};
|
1606
2051
|
const initLine = (spec, context)=>{
|
1607
2052
|
const result = {
|
1608
2053
|
...spec
|
@@ -2543,7 +2988,7 @@ const pivotDiscreteLegend = (spec, context)=>{
|
|
2543
2988
|
}), {});
|
2544
2989
|
const { legend, color } = baseConfig;
|
2545
2990
|
const { colorScheme } = color;
|
2546
|
-
const { enable, position = 'bottom', labelFontColor, labelFontSize = 12, labelFontWeight, maxSize, border, shapeType = 'rectRound' } = legend || {};
|
2991
|
+
const { enable, position = 'bottom', labelFontColor, labelFontSize = 12, labelFontWeight = 400, maxSize, border, shapeType = 'rectRound' } = legend || {};
|
2547
2992
|
const orient = [
|
2548
2993
|
'bottom',
|
2549
2994
|
'bottomLeft',
|
@@ -3876,6 +4321,21 @@ const horizontalCrosshairLine = (spec, context)=>{
|
|
3876
4321
|
};
|
3877
4322
|
return result;
|
3878
4323
|
};
|
4324
|
+
const series = (...args)=>{
|
4325
|
+
const result = {
|
4326
|
+
type: 'common',
|
4327
|
+
padding: 0,
|
4328
|
+
region: [
|
4329
|
+
{
|
4330
|
+
clip: true
|
4331
|
+
}
|
4332
|
+
]
|
4333
|
+
};
|
4334
|
+
return (_, context)=>{
|
4335
|
+
result.series = args.map((pipeline)=>execPipeline(pipeline, context, {}));
|
4336
|
+
return result;
|
4337
|
+
};
|
4338
|
+
};
|
3879
4339
|
const line_line = [
|
3880
4340
|
initLine,
|
3881
4341
|
color_color,
|
@@ -3904,7 +4364,7 @@ const pivotLine = [
|
|
3904
4364
|
initLine,
|
3905
4365
|
color_color,
|
3906
4366
|
background_backgroundColor,
|
3907
|
-
|
4367
|
+
dataset_dataset,
|
3908
4368
|
xBand,
|
3909
4369
|
yLinear,
|
3910
4370
|
label_label,
|
@@ -3955,7 +4415,7 @@ const pivotColumn = [
|
|
3955
4415
|
stackInverse,
|
3956
4416
|
color_color,
|
3957
4417
|
background_backgroundColor,
|
3958
|
-
|
4418
|
+
dataset_dataset,
|
3959
4419
|
xBand,
|
3960
4420
|
yLinear,
|
3961
4421
|
label_label,
|
@@ -4002,7 +4462,7 @@ const pivotColumnParallel = [
|
|
4002
4462
|
stackCornerRadius_stackCornerRadius,
|
4003
4463
|
color_color,
|
4004
4464
|
background_backgroundColor,
|
4005
|
-
|
4465
|
+
dataset_dataset,
|
4006
4466
|
xBand,
|
4007
4467
|
yLinear,
|
4008
4468
|
label_label,
|
@@ -4053,7 +4513,7 @@ const pivotColumnPercent = [
|
|
4053
4513
|
color_color,
|
4054
4514
|
percent,
|
4055
4515
|
background_backgroundColor,
|
4056
|
-
|
4516
|
+
dataset_dataset,
|
4057
4517
|
xBand,
|
4058
4518
|
yLinear,
|
4059
4519
|
label_label,
|
@@ -4100,7 +4560,8 @@ const pivotBar = [
|
|
4100
4560
|
stackCornerRadius_stackCornerRadius,
|
4101
4561
|
color_color,
|
4102
4562
|
background_backgroundColor,
|
4103
|
-
|
4563
|
+
dataset_dataset,
|
4564
|
+
xLinear,
|
4104
4565
|
yBand,
|
4105
4566
|
label_label,
|
4106
4567
|
label_label,
|
@@ -4147,9 +4608,9 @@ const pivotBarParallel = [
|
|
4147
4608
|
stackCornerRadius_stackCornerRadius,
|
4148
4609
|
color_color,
|
4149
4610
|
background_backgroundColor,
|
4150
|
-
|
4151
|
-
yBand,
|
4611
|
+
dataset_dataset,
|
4152
4612
|
xLinear,
|
4613
|
+
yBand,
|
4153
4614
|
label_label,
|
4154
4615
|
tooltip_tooltip,
|
4155
4616
|
horizontalCrosshairRect,
|
@@ -4196,7 +4657,7 @@ const pivotBarPercent = [
|
|
4196
4657
|
color_color,
|
4197
4658
|
background_backgroundColor,
|
4198
4659
|
percent,
|
4199
|
-
|
4660
|
+
dataset_dataset,
|
4200
4661
|
yBand,
|
4201
4662
|
xLinear,
|
4202
4663
|
label_label,
|
@@ -4246,7 +4707,7 @@ const pivotArea = [
|
|
4246
4707
|
color_color,
|
4247
4708
|
background_backgroundColor,
|
4248
4709
|
stackInverse,
|
4249
|
-
|
4710
|
+
dataset_dataset,
|
4250
4711
|
xBand,
|
4251
4712
|
yLinear,
|
4252
4713
|
label_label,
|
@@ -4300,7 +4761,7 @@ const pivotAreaPercent = [
|
|
4300
4761
|
color_color,
|
4301
4762
|
background_backgroundColor,
|
4302
4763
|
percent,
|
4303
|
-
|
4764
|
+
dataset_dataset,
|
4304
4765
|
xBand,
|
4305
4766
|
yLinear,
|
4306
4767
|
label_label,
|
@@ -4321,6 +4782,69 @@ const pivotAreaPercent = [
|
|
4321
4782
|
const areaPercentSpecPipeline = [
|
4322
4783
|
pivotAdapter_pivotAdapter(areaPercent, pivotAreaPercent)
|
4323
4784
|
];
|
4785
|
+
const areaRange = [
|
4786
|
+
series([
|
4787
|
+
initAreaRange,
|
4788
|
+
areaStyle_areaStyle
|
4789
|
+
], [
|
4790
|
+
initAreaRangeLine1,
|
4791
|
+
lineStyle_lineStyle,
|
4792
|
+
pointStyle_pointStyle,
|
4793
|
+
pointStateDimensionHover
|
4794
|
+
], [
|
4795
|
+
initAreaRangeLine2,
|
4796
|
+
lineStyle_lineStyle,
|
4797
|
+
pointStyle_pointStyle,
|
4798
|
+
pointStateDimensionHover
|
4799
|
+
]),
|
4800
|
+
dataset_dataset,
|
4801
|
+
background_backgroundColor,
|
4802
|
+
xBand,
|
4803
|
+
yLinear,
|
4804
|
+
label_label,
|
4805
|
+
verticalCrosshairLine,
|
4806
|
+
annotationPoint_annotationPoint,
|
4807
|
+
annotationVerticalLine_annotationVerticalLine,
|
4808
|
+
annotationHorizontalLine_annotationHorizontalLine,
|
4809
|
+
annotationArea_annotationArea
|
4810
|
+
];
|
4811
|
+
const pivotAreaRange = [
|
4812
|
+
initPivot,
|
4813
|
+
pivotGridStyle,
|
4814
|
+
pivotIndicators_pivotIndicatorsAsRow,
|
4815
|
+
datasetPivot,
|
4816
|
+
pivotIndicators([
|
4817
|
+
series([
|
4818
|
+
initAreaRange,
|
4819
|
+
areaStyle_areaStyle
|
4820
|
+
], [
|
4821
|
+
initAreaRangeLine1,
|
4822
|
+
lineStyle_lineStyle,
|
4823
|
+
pointStyle_pointStyle,
|
4824
|
+
pointStateDimensionHover
|
4825
|
+
], [
|
4826
|
+
initAreaRangeLine2,
|
4827
|
+
lineStyle_lineStyle,
|
4828
|
+
pointStyle_pointStyle,
|
4829
|
+
pointStateDimensionHover
|
4830
|
+
]),
|
4831
|
+
background_backgroundColor,
|
4832
|
+
dataset_dataset,
|
4833
|
+
xBand,
|
4834
|
+
yLinear,
|
4835
|
+
label_label,
|
4836
|
+
verticalCrosshairLine,
|
4837
|
+
annotationPoint_annotationPoint,
|
4838
|
+
annotationVerticalLine_annotationVerticalLine,
|
4839
|
+
annotationHorizontalLine_annotationHorizontalLine,
|
4840
|
+
annotationArea_annotationArea
|
4841
|
+
]),
|
4842
|
+
pivotRowDimensions,
|
4843
|
+
pivotColumnDimensions
|
4844
|
+
];
|
4845
|
+
const areaRangeSpecPipeline = [
|
4846
|
+
pivotAdapter_pivotAdapter(areaRange, pivotAreaRange)
|
4847
|
+
];
|
4324
4848
|
const pie = [
|
4325
4849
|
initPie,
|
4326
4850
|
color_color,
|
@@ -4343,7 +4867,7 @@ const pivotPie = [
|
|
4343
4867
|
initPie,
|
4344
4868
|
color_color,
|
4345
4869
|
background_backgroundColor,
|
4346
|
-
|
4870
|
+
dataset_dataset,
|
4347
4871
|
label_label,
|
4348
4872
|
tooltip_tooltip,
|
4349
4873
|
annotationPoint_annotationPoint,
|
@@ -4380,7 +4904,7 @@ const pivotDonut = [
|
|
4380
4904
|
initDonut,
|
4381
4905
|
color_color,
|
4382
4906
|
background_backgroundColor,
|
4383
|
-
|
4907
|
+
dataset_dataset,
|
4384
4908
|
label_label,
|
4385
4909
|
tooltip_tooltip,
|
4386
4910
|
annotationPoint_annotationPoint,
|
@@ -4420,7 +4944,7 @@ const pivotRose = [
|
|
4420
4944
|
stackInverse,
|
4421
4945
|
color_color,
|
4422
4946
|
background_backgroundColor,
|
4423
|
-
|
4947
|
+
dataset_dataset,
|
4424
4948
|
radiusAxis,
|
4425
4949
|
angleAxis,
|
4426
4950
|
label_label,
|
@@ -4461,7 +4985,7 @@ const pivotRoseParallel = [
|
|
4461
4985
|
stackCornerRadius_stackCornerRadius,
|
4462
4986
|
color_color,
|
4463
4987
|
background_backgroundColor,
|
4464
|
-
|
4988
|
+
dataset_dataset,
|
4465
4989
|
radiusAxis,
|
4466
4990
|
angleAxis,
|
4467
4991
|
label_label,
|
@@ -4501,7 +5025,7 @@ const pivotFunnel = [
|
|
4501
5025
|
initFunnel,
|
4502
5026
|
color_color,
|
4503
5027
|
background_backgroundColor,
|
4504
|
-
|
5028
|
+
dataset_dataset,
|
4505
5029
|
label_label,
|
4506
5030
|
tooltip_tooltip,
|
4507
5031
|
annotationPoint_annotationPoint,
|
@@ -4544,7 +5068,7 @@ const pivotScatter = [
|
|
4544
5068
|
initScatter,
|
4545
5069
|
color_color,
|
4546
5070
|
background_backgroundColor,
|
4547
|
-
|
5071
|
+
dataset_dataset,
|
4548
5072
|
xLinear,
|
4549
5073
|
yLinear,
|
4550
5074
|
label_label,
|
@@ -4585,6 +5109,9 @@ const initTable = (spec, context)=>{
|
|
4585
5109
|
type: 'one-by-one',
|
4586
5110
|
direction: 'row'
|
4587
5111
|
},
|
5112
|
+
hover: {
|
5113
|
+
highlightMode: 'row'
|
5114
|
+
},
|
4588
5115
|
theme: {
|
4589
5116
|
underlayBackgroundColor: 'transparent'
|
4590
5117
|
}
|
@@ -4749,7 +5276,7 @@ const bodyStyle = (spec, context)=>{
|
|
4749
5276
|
const fontSize = themConfig.bodyFontSize || 12;
|
4750
5277
|
const hoverCellBgColor = themConfig.hoverBodyBackgroundColor || '#bedaff';
|
4751
5278
|
const hoverInlineColor = external_d3_color_color(hoverCellBgColor)?.copy({
|
4752
|
-
opacity: 0.
|
5279
|
+
opacity: 0.2
|
4753
5280
|
}).toString();
|
4754
5281
|
result.theme.bodyStyle = {
|
4755
5282
|
borderColor: borderColor,
|
@@ -4941,7 +5468,7 @@ const frameStyle = (spec, context)=>{
|
|
4941
5468
|
result.theme.frameStyle = {
|
4942
5469
|
borderColor,
|
4943
5470
|
borderLineWidth: 0,
|
4944
|
-
cornerRadius:
|
5471
|
+
cornerRadius: 4
|
4945
5472
|
};
|
4946
5473
|
return result;
|
4947
5474
|
};
|
@@ -5035,6 +5562,16 @@ const getColorItems = (builder)=>{
|
|
5035
5562
|
}), {});
|
5036
5563
|
return colorItems.map((d)=>colorIdMap[d]);
|
5037
5564
|
};
|
5565
|
+
const getColorIdMap = (builder)=>{
|
5566
|
+
const advancedVSeed = builder.advancedVSeed;
|
5567
|
+
if (!advancedVSeed) return {};
|
5568
|
+
const { datasetReshapeInfo } = advancedVSeed;
|
5569
|
+
const colorIdMap = datasetReshapeInfo.reduce((prev, cur)=>({
|
5570
|
+
...prev,
|
5571
|
+
...cur.unfoldInfo.colorIdMap
|
5572
|
+
}), {});
|
5573
|
+
return colorIdMap;
|
5574
|
+
};
|
5038
5575
|
class Builder {
|
5039
5576
|
_vseed;
|
5040
5577
|
_advancedVSeed = null;
|
@@ -5046,11 +5583,22 @@ class Builder {
|
|
5046
5583
|
build = ()=>build(this);
|
5047
5584
|
buildSpec = (advanced)=>buildSpec(this, advanced);
|
5048
5585
|
buildAdvanced = ()=>buildAdvanced(this);
|
5049
|
-
getAdvancedPipeline = (chartType)=>
|
5050
|
-
|
5586
|
+
getAdvancedPipeline = (chartType)=>{
|
5587
|
+
const customPipe = Builder._customAdvancedPipe[chartType];
|
5588
|
+
const pipeline = Builder._advancedPipelineMap[chartType];
|
5589
|
+
if (customPipe) pipeline.push(customPipe);
|
5590
|
+
return pipeline;
|
5591
|
+
};
|
5592
|
+
getSpecPipeline = (chartType)=>{
|
5593
|
+
const customPipe = Builder._customSpecPipe[chartType];
|
5594
|
+
const pipeline = Builder._specPipelineMap[chartType];
|
5595
|
+
if (customPipe) pipeline.push(customPipe);
|
5596
|
+
return pipeline;
|
5597
|
+
};
|
5051
5598
|
getTheme = (themeKey)=>Builder._themeMap[themeKey];
|
5052
5599
|
getThemeMap = ()=>Builder._themeMap;
|
5053
5600
|
getColorItems = ()=>getColorItems(this);
|
5601
|
+
getColorIdMap = ()=>getColorIdMap(this);
|
5054
5602
|
get vseed() {
|
5055
5603
|
return this._vseed;
|
5056
5604
|
}
|
@@ -5071,6 +5619,8 @@ class Builder {
|
|
5071
5619
|
}
|
5072
5620
|
static _advancedPipelineMap = {};
|
5073
5621
|
static _specPipelineMap = {};
|
5622
|
+
static _customAdvancedPipe = {};
|
5623
|
+
static _customSpecPipe = {};
|
5074
5624
|
static _themeMap = {};
|
5075
5625
|
static from = (vseed)=>new Builder(vseed);
|
5076
5626
|
}
|
@@ -5094,6 +5644,10 @@ const registerAreaPercent = ()=>{
|
|
5094
5644
|
Builder._advancedPipelineMap.areaPercent = areaPercentAdvancedPipeline;
|
5095
5645
|
Builder._specPipelineMap.areaPercent = areaPercentSpecPipeline;
|
5096
5646
|
};
|
5647
|
+
const registerAreaRange = ()=>{
|
5648
|
+
Builder._advancedPipelineMap.areaRange = areaRangeAdvancedPipeline;
|
5649
|
+
Builder._specPipelineMap.areaRange = areaRangeSpecPipeline;
|
5650
|
+
};
|
5097
5651
|
const registerBarPercent = ()=>{
|
5098
5652
|
Builder._advancedPipelineMap.barPercent = barPercentAdvancedPipeline;
|
5099
5653
|
Builder._specPipelineMap.barPercent = barPercentSpecPipeline;
|
@@ -5385,6 +5939,12 @@ const darkTheme = ()=>{
|
|
5385
5939
|
yAxis: linearAxis,
|
5386
5940
|
crosshairLine: crosshairLine
|
5387
5941
|
},
|
5942
|
+
areaRange: {
|
5943
|
+
...baseConfig,
|
5944
|
+
xAxis: bandAxis,
|
5945
|
+
yAxis: linearAxis,
|
5946
|
+
crosshairLine: crosshairLine
|
5947
|
+
},
|
5388
5948
|
scatter: {
|
5389
5949
|
...baseConfig,
|
5390
5950
|
xAxis: {
|
@@ -5679,6 +6239,12 @@ const lightTheme = ()=>{
|
|
5679
6239
|
yAxis: linearAxis,
|
5680
6240
|
crosshairLine
|
5681
6241
|
},
|
6242
|
+
areaRange: {
|
6243
|
+
...baseConfig,
|
6244
|
+
xAxis: bandAxis,
|
6245
|
+
yAxis: linearAxis,
|
6246
|
+
crosshairLine
|
6247
|
+
},
|
5682
6248
|
scatter: {
|
5683
6249
|
...baseConfig,
|
5684
6250
|
xAxis: {
|
@@ -5752,6 +6318,7 @@ const registerAll = ()=>{
|
|
5752
6318
|
registerBarPercent();
|
5753
6319
|
registerArea();
|
5754
6320
|
registerAreaPercent();
|
6321
|
+
registerAreaRange();
|
5755
6322
|
registerPie();
|
5756
6323
|
registerDonut();
|
5757
6324
|
registerRose();
|
@@ -5763,6 +6330,12 @@ const registerAll = ()=>{
|
|
5763
6330
|
registerLightTheme();
|
5764
6331
|
registerDarkTheme();
|
5765
6332
|
};
|
6333
|
+
const updateAdvanced = (chartType, advancedPipe)=>{
|
6334
|
+
Builder._customAdvancedPipe[chartType] = advancedPipe;
|
6335
|
+
};
|
6336
|
+
const updateSpec = (chartType, specPipe)=>{
|
6337
|
+
Builder._customSpecPipe[chartType] = specPipe;
|
6338
|
+
};
|
5766
6339
|
const zChartType = z["enum"]([
|
5767
6340
|
'table',
|
5768
6341
|
'pivotTable',
|
@@ -5775,6 +6348,7 @@ const zChartType = z["enum"]([
|
|
5775
6348
|
'barParallel',
|
5776
6349
|
'area',
|
5777
6350
|
'areaPercent',
|
6351
|
+
'areaRange',
|
5778
6352
|
'rose',
|
5779
6353
|
'roseParallel',
|
5780
6354
|
'pie',
|
@@ -6105,6 +6679,7 @@ const zAreaConfig = z.object({
|
|
6105
6679
|
crosshairLine: zCrosshairLine.optional()
|
6106
6680
|
});
|
6107
6681
|
const zAreaPercentConfig = zAreaConfig;
|
6682
|
+
const zAreaRangeConfig = zAreaConfig;
|
6108
6683
|
const zRoseConfig = z.object({
|
6109
6684
|
backgroundColor: zBackgroundColor.optional(),
|
6110
6685
|
label: zLabel.optional(),
|
@@ -6157,6 +6732,7 @@ const zConfig = z.object({
|
|
6157
6732
|
barPercent: zBarPercentConfig.optional(),
|
6158
6733
|
area: zAreaConfig.optional(),
|
6159
6734
|
areaPercent: zAreaPercentConfig.optional(),
|
6735
|
+
areaRange: zAreaRangeConfig.optional(),
|
6160
6736
|
rose: zRoseConfig.optional(),
|
6161
6737
|
roseParallel: zRoseParallelConfig.optional(),
|
6162
6738
|
pie: zPieConfig.optional(),
|
@@ -6519,6 +7095,25 @@ const zAnnotation = z.object({
|
|
6519
7095
|
annotationHorizontalLine: zAnnotationHorizontalLine.or(z.array(zAnnotationHorizontalLine)).optional(),
|
6520
7096
|
annotationArea: zAnnotationArea.or(z.array(zAnnotationArea)).optional()
|
6521
7097
|
});
|
7098
|
+
const zSortAxis = z.object({
|
7099
|
+
order: z["enum"]([
|
7100
|
+
'asc',
|
7101
|
+
'desc'
|
7102
|
+
]).default('asc'),
|
7103
|
+
orderBy: z.string().optional(),
|
7104
|
+
customOrder: z.array(z.any()).optional()
|
7105
|
+
});
|
7106
|
+
const zSortLegend = z.object({
|
7107
|
+
order: z["enum"]([
|
7108
|
+
'asc',
|
7109
|
+
'desc'
|
7110
|
+
]).default('asc'),
|
7111
|
+
orderBy: z.string().optional(),
|
7112
|
+
customOrder: z.array(z.any()).optional()
|
7113
|
+
});
|
7114
|
+
const zAnalysis = zod.object({
|
7115
|
+
orderMapping: zod.record(zod.string(), zod.array(zod.string())).optional()
|
7116
|
+
});
|
6522
7117
|
const zLocale = z["enum"]([
|
6523
7118
|
'zh-CN',
|
6524
7119
|
'en-US'
|
@@ -6554,6 +7149,8 @@ const zLine = z.object({
|
|
6554
7149
|
xAxis: zXBandAxis.optional(),
|
6555
7150
|
yAxis: zYLinearAxis.optional(),
|
6556
7151
|
crosshairLine: zCrosshairLine.optional(),
|
7152
|
+
sortAxis: zSortAxis.optional(),
|
7153
|
+
sortLegend: zSortLegend.optional(),
|
6557
7154
|
theme: zTheme.optional(),
|
6558
7155
|
pointStyle: zPointStyle.optional(),
|
6559
7156
|
lineStyle: zLineStyle.optional(),
|
@@ -6741,6 +7338,26 @@ const zAreaPercent = z.object({
|
|
6741
7338
|
annotationArea: z.array(zAnnotationArea).or(zAnnotationArea).optional(),
|
6742
7339
|
locale: zLocale.optional()
|
6743
7340
|
});
|
7341
|
+
const zAreaRange = z.object({
|
7342
|
+
chartType: z.literal('areaRange'),
|
7343
|
+
dataset: zDataset.optional(),
|
7344
|
+
dimensions: zDimensions.optional(),
|
7345
|
+
measures: zMeasureTree.optional(),
|
7346
|
+
backgroundColor: zBackgroundColor.optional(),
|
7347
|
+
label: zLabel.optional(),
|
7348
|
+
xAxis: zXBandAxis.optional(),
|
7349
|
+
yAxis: zYLinearAxis.optional(),
|
7350
|
+
crosshairLine: zCrosshairLine.optional(),
|
7351
|
+
theme: zTheme.optional(),
|
7352
|
+
pointStyle: zPointStyle.optional(),
|
7353
|
+
lineStyle: zLineStyle.optional(),
|
7354
|
+
areaStyle: zAreaStyle.optional(),
|
7355
|
+
annotationPoint: z.array(zAnnotationPoint).or(zAnnotationPoint).optional(),
|
7356
|
+
annotationVerticalLine: z.array(zAnnotationVerticalLine).or(zAnnotationVerticalLine).optional(),
|
7357
|
+
annotationHorizontalLine: z.array(zAnnotationHorizontalLine).or(zAnnotationHorizontalLine).optional(),
|
7358
|
+
annotationArea: z.array(zAnnotationArea).or(zAnnotationArea).optional(),
|
7359
|
+
locale: zLocale.optional()
|
7360
|
+
});
|
6744
7361
|
const zRose = z.object({
|
6745
7362
|
chartType: z.literal('rose'),
|
6746
7363
|
dataset: zDataset.optional(),
|
@@ -6839,6 +7456,7 @@ const zVSeed = z.discriminatedUnion('chartType', [
|
|
6839
7456
|
zBarPercent,
|
6840
7457
|
zArea,
|
6841
7458
|
zAreaPercent,
|
7459
|
+
zAreaRange,
|
6842
7460
|
zPie,
|
6843
7461
|
zRose,
|
6844
7462
|
zRoseParallel,
|
@@ -6854,12 +7472,13 @@ const zAdvancedVSeed = z.object({
|
|
6854
7472
|
measures: zMeasureTree,
|
6855
7473
|
encoding: zEncoding,
|
6856
7474
|
config: zConfig,
|
7475
|
+
analysis: zAnalysis,
|
6857
7476
|
theme: zTheme,
|
6858
7477
|
markStyle: zMarkStyle,
|
6859
7478
|
customTheme: zCustomThemeConfig,
|
6860
7479
|
annotation: zAnnotation,
|
6861
7480
|
locale: zLocale
|
6862
7481
|
});
|
6863
|
-
export { Builder, FoldMeasureId, FoldMeasureName, FoldMeasureValue, ORIGINAL_DATA, Separator, UnfoldDimensionGroup, UnfoldDimensionGroupId, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaSpecPipeline, autoFormatter, autoNumFormatter, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, createFormatter, createNumFormatter, darkTheme, dataReshapeFor1D1M, dataReshapeFor1D2M, dataReshapeFor2D1M, donutAdvancedPipeline, donutSpecPipeline, execPipeline, findAllDimensions, findAllMeasures, findDimensionById, findFirstDimension, findFirstMeasure, findMeasureById, foldMeasures, funnelAdvancedPipeline, funnelSpecPipeline, i18n, intl, isPivotChart, isPivotTable, isTable, isVChart, isVTable, lightTheme, lineAdvancedPipeline, lineSpecPipeline, pieAdvancedPipeline, pieSpecPipeline, pivotTableAdvancedPipeline, pivotTableSpecPipeline, preorderTraverse, registerAll, registerArea, registerAreaPercent, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerDonut, registerFunnel, registerLightTheme, registerLine, registerPie, registerPivotTable, registerRose, registerRoseParallel, registerScatter, registerTable, roseAdvancedPipeline, roseParallelAdvancedPipeline, roseParallelSpecPipeline, roseSpecPipeline, scatterAdvancedPipeline, scatterSpecPipeline, tableAdvancedPipeline, tableSpecPipeline, unfoldDimensions, zAdvancedVSeed, zAnnotation, zAnnotationArea, zAnnotationHorizontalLine, zAnnotationPoint, zAnnotationVerticalLine, zArea, zAreaConfig, zAreaPercent, zAreaPercentConfig, zAreaStyle, zAxis, zBackgroundColor, zBar, zBarConfig, zBarParallel, zBarParallelConfig, zBarPercent, zBarPercentConfig, zBarStyle, zChartType, zColor, zColumn, zColumnConfig, zColumnParallel, zColumnParallelConfig, zColumnPercent, zColumnPercentConfig, zConfig, zCrosshairLine, zCrosshairRect, zCustomTheme, zCustomThemeConfig, zDataset, zDatasetReshapeInfo, zDatum, zDimension, zDimensionGroup, zDimensionTree, zDimensions, zDonut, zDonutConfig, zDualAxisConfig, zEncoding, zFoldInfo, zFunnel, zFunnelConfig, zLabel, zLegend, zLine, zLineConfig, zLineStyle, zLocale, zMarkStyle, zMeasure, zMeasureGroup, zMeasureTree, zMeasures, zNumFormat, zPie, zPieConfig, zPivotTable, zPivotTableConfig, zPointStyle, zRose, zRoseConfig, zRoseParallel, zRoseParallelConfig, zScatter, zScatterConfig, zStackCornerRadius, zTable, zTableConfig, zTheme, zTooltip, zUnfoldInfo, zVSeed, zXBandAxis, zXLinearAxis, zYBandAxis, zYLinearAxis };
|
7482
|
+
export { Builder, FoldMeasureId, FoldMeasureName, FoldMeasureValue, ORIGINAL_DATA, Separator, UnfoldDimensionGroup, UnfoldDimensionGroupId, areaAdvancedPipeline, areaPercentAdvancedPipeline, areaPercentSpecPipeline, areaRangeAdvancedPipeline, areaRangeSpecPipeline, areaSpecPipeline, autoFormatter, autoNumFormatter, barAdvancedPipeline, barParallelAdvancedPipeline, barParallelSpecPipeline, barPercentAdvancedPipeline, barPercentSpecPipeline, barSpecPipeline, columnAdvancedPipeline, columnParallelAdvancedPipeline, columnParallelSpecPipeline, columnPercentAdvancedPipeline, columnPercentSpecPipeline, columnSpecPipeline, createFormatter, createNumFormatter, darkTheme, dataReshapeFor1D, dataReshapeFor1D1M, dataReshapeFor1D2M, dataReshapeFor2D1M, donutAdvancedPipeline, donutSpecPipeline, execPipeline, findAllDimensions, findAllMeasures, findDimensionById, findFirstDimension, findFirstMeasure, findMeasureById, foldMeasures, funnelAdvancedPipeline, funnelSpecPipeline, i18n, intl, isPivotChart, isPivotTable, isTable, isVChart, isVTable, lightTheme, lineAdvancedPipeline, lineSpecPipeline, pieAdvancedPipeline, pieSpecPipeline, pivotTableAdvancedPipeline, pivotTableSpecPipeline, preorderTraverse, registerAll, registerArea, registerAreaPercent, registerAreaRange, registerBar, registerBarParallel, registerBarPercent, registerColumn, registerColumnParallel, registerColumnPercent, registerCustomTheme, registerDarkTheme, registerDonut, registerFunnel, registerLightTheme, registerLine, registerPie, registerPivotTable, registerRose, registerRoseParallel, registerScatter, registerTable, roseAdvancedPipeline, roseParallelAdvancedPipeline, roseParallelSpecPipeline, roseSpecPipeline, scatterAdvancedPipeline, scatterSpecPipeline, tableAdvancedPipeline, tableSpecPipeline, unfoldDimensions, updateAdvanced, updateSpec, zAdvancedVSeed, zAnalysis, zAnnotation, zAnnotationArea, zAnnotationHorizontalLine, zAnnotationPoint, zAnnotationVerticalLine, zArea, zAreaConfig, zAreaPercent, zAreaPercentConfig, zAreaRange, zAreaRangeConfig, zAreaStyle, zAxis, zBackgroundColor, zBar, zBarConfig, zBarParallel, zBarParallelConfig, zBarPercent, zBarPercentConfig, zBarStyle, zChartType, zColor, zColumn, zColumnConfig, zColumnParallel, zColumnParallelConfig, zColumnPercent, zColumnPercentConfig, zConfig, zCrosshairLine, zCrosshairRect, zCustomTheme, zCustomThemeConfig, zDataset, zDatasetReshapeInfo, zDatum, zDimension, zDimensionGroup, zDimensionTree, zDimensions, zDonut, zDonutConfig, zDualAxisConfig, zEncoding, zFoldInfo, zFunnel, zFunnelConfig, zLabel, zLegend, zLine, zLineConfig, zLineStyle, zLocale, zMarkStyle, zMeasure, zMeasureGroup, zMeasureTree, zMeasures, zNumFormat, zPie, zPieConfig, zPivotTable, zPivotTableConfig, zPointStyle, zRose, zRoseConfig, zRoseParallel, zRoseParallelConfig, zScatter, zScatterConfig, zSortAxis, zSortLegend, zStackCornerRadius, zTable, zTableConfig, zTheme, zTooltip, zUnfoldInfo, zVSeed, zXBandAxis, zXLinearAxis, zYBandAxis, zYLinearAxis };
|
6864
7483
|
|
6865
7484
|
//# sourceMappingURL=index.js.map
|