@xq-labs/data-ui-v2 0.3.0 → 0.5.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/docs/api/overview.md +60 -5
- package/docs/examples/bar-line-chart.md +47 -4
- package/docs/examples/pie-chart.md +9 -3
- package/es/bar-line-chart/index.js +1 -1
- package/es/{index-d01ce220.js → index-1e113c13.js} +374 -41
- package/es/{index-78b6b881.js → index-bf133030.js} +21 -3
- package/es/index.js +2 -2
- package/es/pie-chart/index.js +1 -1
- package/lib/bar-line-chart/index.js +1 -1
- package/lib/{index-cc49894a.js → index-3dcce54f.js} +374 -41
- package/lib/{index-a0ecafa1.js → index-812cae02.js} +21 -3
- package/lib/index.js +2 -2
- package/lib/pie-chart/index.js +1 -1
- package/package.json +1 -1
|
@@ -12,7 +12,8 @@ var DEFAULT_SERIES = {
|
|
|
12
12
|
kind: 'bar',
|
|
13
13
|
stack: '',
|
|
14
14
|
yAxisIndex: 0,
|
|
15
|
-
colors: []
|
|
15
|
+
colors: [],
|
|
16
|
+
cubeGradientColors: []
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -63,7 +64,8 @@ function normalizeBarLineInput(_ref) {
|
|
|
63
64
|
kind: normalizeKind(item.kind),
|
|
64
65
|
stack: typeof item.stack === 'string' ? item.stack : '',
|
|
65
66
|
yAxisIndex: normalizeYAxisIndex(item.yAxisIndex),
|
|
66
|
-
colors: normalizeColors(item.colors)
|
|
67
|
+
colors: normalizeColors(item.colors),
|
|
68
|
+
cubeGradientColors: normalizeColors(item.cubeGradientColors)
|
|
67
69
|
});
|
|
68
70
|
}),
|
|
69
71
|
rawData: rawData
|
|
@@ -129,6 +131,19 @@ function resolveSeriesColor$1(item, index) {
|
|
|
129
131
|
}
|
|
130
132
|
return DEFAULT_COLORS[index % DEFAULT_COLORS.length];
|
|
131
133
|
}
|
|
134
|
+
function collectBarSeries(normalizedSeries) {
|
|
135
|
+
return normalizedSeries.map(function (item, originalIndex) {
|
|
136
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
137
|
+
originalIndex: originalIndex
|
|
138
|
+
});
|
|
139
|
+
}).filter(function (item) {
|
|
140
|
+
return item.kind === 'bar';
|
|
141
|
+
}).map(function (item, barSeriesIndex) {
|
|
142
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
143
|
+
barSeriesIndex: barSeriesIndex
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
132
147
|
|
|
133
148
|
/**
|
|
134
149
|
* 归一化颜色入参。
|
|
@@ -479,6 +494,53 @@ function createBarLayout(barSeries, barWidth, barGap) {
|
|
|
479
494
|
barGap: resolvedBarGap
|
|
480
495
|
};
|
|
481
496
|
}
|
|
497
|
+
function pickBackgroundSlotSeries(barSeries) {
|
|
498
|
+
var renderedStacks = new Set();
|
|
499
|
+
return barSeries.filter(function (item) {
|
|
500
|
+
if (!item.stack) {
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
if (renderedStacks.has(item.stack)) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
renderedStacks.add(item.stack);
|
|
507
|
+
return true;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function createBackgroundSeriesData(rawData) {
|
|
511
|
+
return rawData.map(function (row, rowIndex) {
|
|
512
|
+
return {
|
|
513
|
+
value: [rowIndex]
|
|
514
|
+
};
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function resolveBackgroundFaceAlpha(key, opacity) {
|
|
518
|
+
var alphaMap = {
|
|
519
|
+
left: 0.82,
|
|
520
|
+
right: 1,
|
|
521
|
+
top: 1.8,
|
|
522
|
+
middle: 0.82,
|
|
523
|
+
bottom: 1.28,
|
|
524
|
+
legend: 1
|
|
525
|
+
};
|
|
526
|
+
var ratio = alphaMap[key] || 1;
|
|
527
|
+
return Math.max(0, Math.min(1, opacity * ratio));
|
|
528
|
+
}
|
|
529
|
+
function applyBackgroundFaceAlphaToColorMap(colorMap, opacity) {
|
|
530
|
+
return Object.keys(colorMap || {}).reduce(function (result, key) {
|
|
531
|
+
result[key] = applyAlphaToColor(colorMap[key], resolveBackgroundFaceAlpha(key, opacity));
|
|
532
|
+
return result;
|
|
533
|
+
}, {});
|
|
534
|
+
}
|
|
535
|
+
function normalizeBackgroundColors(barBackground, item) {
|
|
536
|
+
if (Array.isArray(barBackground && barBackground.colors) && barBackground.colors.length > 0) {
|
|
537
|
+
return barBackground.colors;
|
|
538
|
+
}
|
|
539
|
+
if (Array.isArray(item && item.colors) && item.colors.length > 0) {
|
|
540
|
+
return item.colors;
|
|
541
|
+
}
|
|
542
|
+
return undefined;
|
|
543
|
+
}
|
|
482
544
|
|
|
483
545
|
/**
|
|
484
546
|
* 创建堆叠累加器。
|
|
@@ -607,13 +669,7 @@ function buildCustomBarSeries(_ref) {
|
|
|
607
669
|
barGap = _ref.barGap,
|
|
608
670
|
createRenderItem = _ref.createRenderItem,
|
|
609
671
|
resolveColorMap = _ref.resolveColorMap;
|
|
610
|
-
var barSeries = normalizedSeries
|
|
611
|
-
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
612
|
-
originalIndex: originalIndex
|
|
613
|
-
});
|
|
614
|
-
}).filter(function (item) {
|
|
615
|
-
return item.kind === 'bar';
|
|
616
|
-
});
|
|
672
|
+
var barSeries = collectBarSeries(normalizedSeries);
|
|
617
673
|
var layout = createBarLayout(barSeries, barWidth, barGap);
|
|
618
674
|
var barSeriesWithData = buildBarSeriesData(rawData, barSeries);
|
|
619
675
|
return barSeriesWithData.map(function (item, index) {
|
|
@@ -642,6 +698,57 @@ function buildCustomBarSeries(_ref) {
|
|
|
642
698
|
};
|
|
643
699
|
});
|
|
644
700
|
}
|
|
701
|
+
function buildBackgroundCustomBarSeries(_ref2) {
|
|
702
|
+
var rawData = _ref2.rawData,
|
|
703
|
+
normalizedSeries = _ref2.normalizedSeries,
|
|
704
|
+
barWidth = _ref2.barWidth,
|
|
705
|
+
barGap = _ref2.barGap,
|
|
706
|
+
_ref2$barBackground = _ref2.barBackground,
|
|
707
|
+
barBackground = _ref2$barBackground === void 0 ? {} : _ref2$barBackground,
|
|
708
|
+
createRenderItem = _ref2.createRenderItem,
|
|
709
|
+
resolveColorMap = _ref2.resolveColorMap;
|
|
710
|
+
if (!barBackground.show) {
|
|
711
|
+
return [];
|
|
712
|
+
}
|
|
713
|
+
var barSeries = collectBarSeries(normalizedSeries);
|
|
714
|
+
if (!barSeries.length) {
|
|
715
|
+
return [];
|
|
716
|
+
}
|
|
717
|
+
var layout = createBarLayout(barSeries, barWidth, barGap);
|
|
718
|
+
var backgroundSeriesData = createBackgroundSeriesData(rawData);
|
|
719
|
+
return pickBackgroundSlotSeries(barSeries).map(function (item) {
|
|
720
|
+
var slotKey = item.stack || "__slot_".concat(item.barSeriesIndex);
|
|
721
|
+
var slotIndex = layout.slotMap[slotKey];
|
|
722
|
+
var fallbackColor = resolveSeriesColor$1(item, item.originalIndex);
|
|
723
|
+
var palette = normalizeBackgroundColors(barBackground, item);
|
|
724
|
+
var baseColorMap = resolveColorMap ? resolveColorMap(palette, fallbackColor) : {
|
|
725
|
+
legend: fallbackColor
|
|
726
|
+
};
|
|
727
|
+
var backgroundColorMap = applyBackgroundFaceAlphaToColorMap(baseColorMap, barBackground.opacity);
|
|
728
|
+
return {
|
|
729
|
+
name: item.name,
|
|
730
|
+
type: 'custom',
|
|
731
|
+
stack: item.stack,
|
|
732
|
+
yAxisIndex: item.yAxisIndex || 0,
|
|
733
|
+
isBackground: true,
|
|
734
|
+
silent: true,
|
|
735
|
+
tooltip: {
|
|
736
|
+
show: false
|
|
737
|
+
},
|
|
738
|
+
renderItem: createRenderItem(layout, slotIndex, backgroundColorMap, _objectSpread2(_objectSpread2({}, item), {}, {
|
|
739
|
+
isBackground: true
|
|
740
|
+
})),
|
|
741
|
+
encode: {
|
|
742
|
+
x: 0
|
|
743
|
+
},
|
|
744
|
+
itemStyle: {
|
|
745
|
+
color: backgroundColorMap.legend || applyAlphaToColor(fallbackColor, barBackground.opacity)
|
|
746
|
+
},
|
|
747
|
+
data: backgroundSeriesData,
|
|
748
|
+
z: 0
|
|
749
|
+
};
|
|
750
|
+
});
|
|
751
|
+
}
|
|
645
752
|
|
|
646
753
|
/**
|
|
647
754
|
* 归一化 flat 模式下的 `barGap`。
|
|
@@ -705,6 +812,27 @@ function resolveFlatBarColors(item, index) {
|
|
|
705
812
|
end: darkenColor(fallbackColor, 0.12)
|
|
706
813
|
};
|
|
707
814
|
}
|
|
815
|
+
function resolveFlatBackgroundColors(item, index, barBackground) {
|
|
816
|
+
var paletteSource = Array.isArray(barBackground.colors) && barBackground.colors.length > 0 ? {
|
|
817
|
+
colors: barBackground.colors
|
|
818
|
+
} : item;
|
|
819
|
+
var colorMap = resolveFlatBarColors(paletteSource, index);
|
|
820
|
+
return {
|
|
821
|
+
start: applyAlphaToColor(colorMap.start, barBackground.opacity),
|
|
822
|
+
middle: applyAlphaToColor(colorMap.middle, barBackground.opacity),
|
|
823
|
+
end: applyAlphaToColor(colorMap.end, barBackground.opacity)
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
function shouldEnableBackground(item, renderedStacks) {
|
|
827
|
+
if (!item.stack) {
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
if (renderedStacks.has(item.stack)) {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
renderedStacks.add(item.stack);
|
|
834
|
+
return true;
|
|
835
|
+
}
|
|
708
836
|
|
|
709
837
|
/**
|
|
710
838
|
* 创建柱体纵向渐变。
|
|
@@ -736,9 +864,12 @@ function createFlatBarLineSeries(_ref) {
|
|
|
736
864
|
var normalizedSeries = _ref.normalizedSeries,
|
|
737
865
|
rawData = _ref.rawData,
|
|
738
866
|
barWidth = _ref.barWidth,
|
|
739
|
-
barGap = _ref.barGap
|
|
867
|
+
barGap = _ref.barGap,
|
|
868
|
+
_ref$barBackground = _ref.barBackground,
|
|
869
|
+
barBackground = _ref$barBackground === void 0 ? {} : _ref$barBackground;
|
|
740
870
|
var resolvedBarWidth = Number.isFinite(Number(barWidth)) ? Number(barWidth) : 18;
|
|
741
871
|
var resolvedBarGap = toBarGapValue(barGap);
|
|
872
|
+
var renderedStacks = new Set();
|
|
742
873
|
return normalizedSeries.map(function (item, index) {
|
|
743
874
|
var isLine = item.kind === 'line';
|
|
744
875
|
var color = resolveSeriesColor(item, index);
|
|
@@ -759,11 +890,18 @@ function createFlatBarLineSeries(_ref) {
|
|
|
759
890
|
yAxisIndex: item.yAxisIndex
|
|
760
891
|
});
|
|
761
892
|
}
|
|
893
|
+
var showBackground = barBackground.show && shouldEnableBackground(item, renderedStacks);
|
|
894
|
+
var backgroundColors = resolveFlatBackgroundColors(item, index, barBackground);
|
|
762
895
|
return _objectSpread2(_objectSpread2({}, baseSeries), {}, {
|
|
763
896
|
stack: item.stack,
|
|
764
897
|
barWidth: resolvedBarWidth,
|
|
765
|
-
barGap: resolvedBarGap
|
|
766
|
-
|
|
898
|
+
barGap: resolvedBarGap,
|
|
899
|
+
showBackground: showBackground
|
|
900
|
+
}, showBackground ? {
|
|
901
|
+
backgroundStyle: {
|
|
902
|
+
color: createBarGradient(backgroundColors)
|
|
903
|
+
}
|
|
904
|
+
} : {});
|
|
767
905
|
});
|
|
768
906
|
}
|
|
769
907
|
|
|
@@ -822,14 +960,80 @@ function createFaceGradient(x0, y0, x1, y1, startColor, endColor) {
|
|
|
822
960
|
color: endColor
|
|
823
961
|
}]);
|
|
824
962
|
}
|
|
963
|
+
function resolveCubeGradientFaceColors(seriesItem, colorMap) {
|
|
964
|
+
var gradientColors = seriesItem && Array.isArray(seriesItem.cubeGradientColors) ? seriesItem.cubeGradientColors : [];
|
|
965
|
+
return {
|
|
966
|
+
left: gradientColors[0] || colorMap.left,
|
|
967
|
+
right: gradientColors[1] || colorMap.right,
|
|
968
|
+
top: gradientColors[2] || colorMap.top
|
|
969
|
+
};
|
|
970
|
+
}
|
|
825
971
|
|
|
826
972
|
/**
|
|
827
973
|
* 创建方柱渲染器。
|
|
828
974
|
* 参考案例使用三块 polygon 拼接成立方体,而不是“正面 rect + 顶面/侧面”。
|
|
829
975
|
*/
|
|
830
|
-
function createCubeRenderItem(layout, slotIndex, colorMap) {
|
|
976
|
+
function createCubeRenderItem(layout, slotIndex, colorMap, seriesItem) {
|
|
831
977
|
return function renderItem(params, api) {
|
|
832
978
|
var rowIndex = api.value(0);
|
|
979
|
+
var offsetX = getBarOffset(layout, slotIndex);
|
|
980
|
+
var centerPoint = api.coord([rowIndex, 0]);
|
|
981
|
+
var centerX = centerPoint[0] + offsetX;
|
|
982
|
+
var halfWidth = layout.barWidth / 2;
|
|
983
|
+
var offsetY = Math.tan(Math.PI / 9) * halfWidth;
|
|
984
|
+
if (seriesItem && seriesItem.isBackground === true) {
|
|
985
|
+
var _leftFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.left, colorMap.left);
|
|
986
|
+
var _rightFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.right, colorMap.right);
|
|
987
|
+
var _topFaceGradient = createFaceGradient(0, 0, 1, 0, colorMap.top, colorMap.top);
|
|
988
|
+
var coordSys = params.coordSys || {};
|
|
989
|
+
var clipX = coordSys.x || 0;
|
|
990
|
+
var _topY = coordSys.y || 0;
|
|
991
|
+
var width = coordSys.width || 0;
|
|
992
|
+
var _baseY = _topY + (coordSys.height || 0);
|
|
993
|
+
var _topSurfaceY = _topY + Math.abs(offsetY - 1);
|
|
994
|
+
return {
|
|
995
|
+
type: 'group',
|
|
996
|
+
clipPath: {
|
|
997
|
+
type: 'rect',
|
|
998
|
+
shape: {
|
|
999
|
+
x: clipX,
|
|
1000
|
+
y: _topY,
|
|
1001
|
+
width: width,
|
|
1002
|
+
height: coordSys.height || 0
|
|
1003
|
+
}
|
|
1004
|
+
},
|
|
1005
|
+
children: [{
|
|
1006
|
+
type: 'polygon',
|
|
1007
|
+
shape: {
|
|
1008
|
+
points: [[centerX, _topSurfaceY + offsetY - 1], [centerX - halfWidth, _topSurfaceY], [centerX - halfWidth, _baseY - offsetY], [centerX, _baseY - 1]]
|
|
1009
|
+
},
|
|
1010
|
+
style: {
|
|
1011
|
+
fill: _leftFaceGradient
|
|
1012
|
+
}
|
|
1013
|
+
}, {
|
|
1014
|
+
type: 'polygon',
|
|
1015
|
+
shape: {
|
|
1016
|
+
points: [[centerX, _topSurfaceY + offsetY - 1], [centerX + halfWidth, _topSurfaceY], [centerX + halfWidth, _baseY - offsetY], [centerX, _baseY - 1]]
|
|
1017
|
+
},
|
|
1018
|
+
style: {
|
|
1019
|
+
fill: _rightFaceGradient
|
|
1020
|
+
}
|
|
1021
|
+
}, {
|
|
1022
|
+
type: 'polygon',
|
|
1023
|
+
shape: {
|
|
1024
|
+
points: [[centerX, _topSurfaceY + offsetY - 1], [centerX + halfWidth, _topSurfaceY], [centerX, _topSurfaceY - offsetY + 1], [centerX - halfWidth, _topSurfaceY]]
|
|
1025
|
+
},
|
|
1026
|
+
style: {
|
|
1027
|
+
fill: _topFaceGradient
|
|
1028
|
+
},
|
|
1029
|
+
z2: 2
|
|
1030
|
+
}]
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
var gradientFaceColors = resolveCubeGradientFaceColors(seriesItem, colorMap);
|
|
1034
|
+
var leftFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.left, gradientFaceColors.left);
|
|
1035
|
+
var rightFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.right, gradientFaceColors.right);
|
|
1036
|
+
var topFaceGradient = createFaceGradient(0, 0, 1, 0, colorMap.top, gradientFaceColors.top);
|
|
833
1037
|
var endValue = api.value(1);
|
|
834
1038
|
var baseValue = api.value(2);
|
|
835
1039
|
var rawValue = api.value(3);
|
|
@@ -840,20 +1044,13 @@ function createCubeRenderItem(layout, slotIndex, colorMap) {
|
|
|
840
1044
|
}
|
|
841
1045
|
var endPoint = api.coord([rowIndex, endValue]);
|
|
842
1046
|
var basePoint = api.coord([rowIndex, baseValue]);
|
|
843
|
-
var offsetX = getBarOffset(layout, slotIndex);
|
|
844
|
-
var centerX = endPoint[0] + offsetX;
|
|
845
1047
|
var topY = endPoint[1];
|
|
846
1048
|
var baseY = basePoint[1];
|
|
847
|
-
var halfWidth = layout.barWidth / 2;
|
|
848
|
-
var offsetY = Math.tan(Math.PI / 9) * halfWidth;
|
|
849
1049
|
var isPositive = rawValue >= 0;
|
|
850
1050
|
var connectorOverlap = stackStart ? 0 : Math.max(2, Math.round(offsetY));
|
|
851
1051
|
var connectorCapOffset = stackEnd ? 0 : Math.min(2, offsetY * 0.45);
|
|
852
1052
|
var connectBaseY = isPositive ? baseY + connectorOverlap : baseY - connectorOverlap;
|
|
853
1053
|
var topSurfaceY = topY + connectorCapOffset;
|
|
854
|
-
var leftFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.left, colorMap.left);
|
|
855
|
-
var rightFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.right, colorMap.right);
|
|
856
|
-
var topFaceGradient = createFaceGradient(0, 0, 1, 0, colorMap.top, colorMap.top);
|
|
857
1054
|
return {
|
|
858
1055
|
type: 'group',
|
|
859
1056
|
children: [{
|
|
@@ -899,6 +1096,15 @@ function createCubeRenderItem(layout, slotIndex, colorMap) {
|
|
|
899
1096
|
function createCubeBarLineOption(normalizedInput) {
|
|
900
1097
|
var flatOption = createFlatBarLineOption(normalizedInput);
|
|
901
1098
|
var flatSeries = createFlatBarLineSeries(normalizedInput);
|
|
1099
|
+
var backgroundSeries = buildBackgroundCustomBarSeries({
|
|
1100
|
+
rawData: normalizedInput.rawData,
|
|
1101
|
+
normalizedSeries: normalizedInput.normalizedSeries,
|
|
1102
|
+
barWidth: normalizedInput.barWidth,
|
|
1103
|
+
barGap: normalizedInput.barGap,
|
|
1104
|
+
barBackground: normalizedInput.barBackground,
|
|
1105
|
+
createRenderItem: createCubeRenderItem,
|
|
1106
|
+
resolveColorMap: resolveCubeColors
|
|
1107
|
+
});
|
|
902
1108
|
var customBarSeries = buildCustomBarSeries({
|
|
903
1109
|
rawData: normalizedInput.rawData,
|
|
904
1110
|
normalizedSeries: normalizedInput.normalizedSeries,
|
|
@@ -917,7 +1123,7 @@ function createCubeBarLineOption(normalizedInput) {
|
|
|
917
1123
|
return flatSeries[index];
|
|
918
1124
|
});
|
|
919
1125
|
return _objectSpread2(_objectSpread2({}, flatOption), {}, {
|
|
920
|
-
series: series
|
|
1126
|
+
series: [].concat(_toConsumableArray(series), _toConsumableArray(backgroundSeries))
|
|
921
1127
|
});
|
|
922
1128
|
}
|
|
923
1129
|
|
|
@@ -941,6 +1147,20 @@ function createEllipsePolygon(cx, cy, rx, ry) {
|
|
|
941
1147
|
}
|
|
942
1148
|
return polygonPoints;
|
|
943
1149
|
}
|
|
1150
|
+
function createEllipseArcPoints(cx, cy, rx, ry, startAngle, endAngle) {
|
|
1151
|
+
var points = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 12;
|
|
1152
|
+
var arcPoints = [];
|
|
1153
|
+
for (var index = 0; index <= points; index += 1) {
|
|
1154
|
+
var angle = startAngle + (endAngle - startAngle) * index / points;
|
|
1155
|
+
arcPoints.push([cx + Math.cos(angle) * rx, cy + Math.sin(angle) * ry]);
|
|
1156
|
+
}
|
|
1157
|
+
return arcPoints;
|
|
1158
|
+
}
|
|
1159
|
+
function createCylinderSidePolygon(cx, topCy, bottomCy, rx, ry) {
|
|
1160
|
+
var topLowerArc = createEllipseArcPoints(cx, topCy, rx, ry, Math.PI, 0);
|
|
1161
|
+
var bottomUpperArc = createEllipseArcPoints(cx, bottomCy, rx, ry, 0, -Math.PI);
|
|
1162
|
+
return [].concat(_toConsumableArray(topLowerArc), _toConsumableArray(bottomUpperArc));
|
|
1163
|
+
}
|
|
944
1164
|
|
|
945
1165
|
/**
|
|
946
1166
|
* 创建圆柱渲染器。
|
|
@@ -949,9 +1169,76 @@ function createEllipsePolygon(cx, cy, rx, ry) {
|
|
|
949
1169
|
* 2. 主体用纵向渐变矩形模拟曲面;
|
|
950
1170
|
* 3. 堆叠连接处保留底片,但不绘制深色描边和弧线,避免形成脏色带。
|
|
951
1171
|
*/
|
|
952
|
-
function createCylinderRenderItem(layout, slotIndex, colorMap) {
|
|
1172
|
+
function createCylinderRenderItem(layout, slotIndex, colorMap, seriesItem) {
|
|
953
1173
|
return function renderItem(params, api) {
|
|
954
1174
|
var rowIndex = api.value(0);
|
|
1175
|
+
var offsetX = getBarOffset(layout, slotIndex);
|
|
1176
|
+
var centerPoint = api.coord([rowIndex, 0]);
|
|
1177
|
+
var centerX = centerPoint[0] + offsetX;
|
|
1178
|
+
var radiusX = layout.barWidth / 2;
|
|
1179
|
+
var radiusY = radiusX * 0.4;
|
|
1180
|
+
var createSideGradient = function createSideGradient(topColor, middleColor, bottomColor) {
|
|
1181
|
+
var opacity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : CYLINDER_SIDE_OPACITY;
|
|
1182
|
+
return new graphic.LinearGradient(0, 0, 0, 1, [{
|
|
1183
|
+
offset: 0,
|
|
1184
|
+
color: opacity === null ? topColor : applyAlphaToColor(topColor, opacity)
|
|
1185
|
+
}, {
|
|
1186
|
+
offset: 0.55,
|
|
1187
|
+
color: opacity === null ? middleColor : applyAlphaToColor(middleColor, opacity)
|
|
1188
|
+
}, {
|
|
1189
|
+
offset: 1,
|
|
1190
|
+
color: opacity === null ? bottomColor : applyAlphaToColor(bottomColor, opacity)
|
|
1191
|
+
}]);
|
|
1192
|
+
};
|
|
1193
|
+
if (seriesItem && seriesItem.isBackground === true) {
|
|
1194
|
+
var coordSys = params.coordSys || {};
|
|
1195
|
+
var clipX = coordSys.x || 0;
|
|
1196
|
+
var topY = coordSys.y || 0;
|
|
1197
|
+
var width = coordSys.width || 0;
|
|
1198
|
+
var height = coordSys.height || 0;
|
|
1199
|
+
var _topEllipseY = topY + radiusY;
|
|
1200
|
+
var bottomEllipseY = topY + height - radiusY;
|
|
1201
|
+
return {
|
|
1202
|
+
type: 'group',
|
|
1203
|
+
clipPath: {
|
|
1204
|
+
type: 'rect',
|
|
1205
|
+
shape: {
|
|
1206
|
+
x: clipX,
|
|
1207
|
+
y: topY,
|
|
1208
|
+
width: width,
|
|
1209
|
+
height: height
|
|
1210
|
+
}
|
|
1211
|
+
},
|
|
1212
|
+
children: [{
|
|
1213
|
+
type: 'polygon',
|
|
1214
|
+
shape: {
|
|
1215
|
+
points: createEllipsePolygon(centerX, bottomEllipseY, radiusX, radiusY)
|
|
1216
|
+
},
|
|
1217
|
+
style: {
|
|
1218
|
+
fill: colorMap.bottom
|
|
1219
|
+
},
|
|
1220
|
+
z: 0
|
|
1221
|
+
}, {
|
|
1222
|
+
type: 'polygon',
|
|
1223
|
+
shape: {
|
|
1224
|
+
points: createCylinderSidePolygon(centerX, _topEllipseY, bottomEllipseY, radiusX, radiusY)
|
|
1225
|
+
},
|
|
1226
|
+
style: {
|
|
1227
|
+
fill: createSideGradient(colorMap.middle, colorMap.middle, colorMap.bottom, null)
|
|
1228
|
+
},
|
|
1229
|
+
z: 1
|
|
1230
|
+
}, {
|
|
1231
|
+
type: 'polygon',
|
|
1232
|
+
shape: {
|
|
1233
|
+
points: createEllipsePolygon(centerX, _topEllipseY, radiusX, radiusY)
|
|
1234
|
+
},
|
|
1235
|
+
style: {
|
|
1236
|
+
fill: colorMap.top
|
|
1237
|
+
},
|
|
1238
|
+
z2: 2
|
|
1239
|
+
}]
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
955
1242
|
var endValue = api.value(1);
|
|
956
1243
|
var baseValue = api.value(2);
|
|
957
1244
|
var rawValue = api.value(3);
|
|
@@ -962,10 +1249,6 @@ function createCylinderRenderItem(layout, slotIndex, colorMap) {
|
|
|
962
1249
|
}
|
|
963
1250
|
var endPoint = api.coord([rowIndex, endValue]);
|
|
964
1251
|
var basePoint = api.coord([rowIndex, baseValue]);
|
|
965
|
-
var offsetX = getBarOffset(layout, slotIndex);
|
|
966
|
-
var centerX = endPoint[0] + offsetX;
|
|
967
|
-
var radiusX = layout.barWidth / 2;
|
|
968
|
-
var radiusY = radiusX * 0.4;
|
|
969
1252
|
var isPositive = rawValue >= 0;
|
|
970
1253
|
var barHeight = Math.abs(endPoint[1] - basePoint[1]);
|
|
971
1254
|
var visibleEllipseY = endPoint[1];
|
|
@@ -980,16 +1263,7 @@ function createCylinderRenderItem(layout, slotIndex, colorMap) {
|
|
|
980
1263
|
var gradientTopColor = isPositive ? colorMap.middle : darkenColor(colorMap.bottom, 0.05);
|
|
981
1264
|
var gradientMiddleColor = colorMap.middle;
|
|
982
1265
|
var gradientBottomColor = isPositive ? colorMap.bottom : colorMap.middle;
|
|
983
|
-
var sideGradient =
|
|
984
|
-
offset: 0,
|
|
985
|
-
color: applyAlphaToColor(gradientTopColor, CYLINDER_SIDE_OPACITY)
|
|
986
|
-
}, {
|
|
987
|
-
offset: 0.55,
|
|
988
|
-
color: applyAlphaToColor(gradientMiddleColor, CYLINDER_SIDE_OPACITY)
|
|
989
|
-
}, {
|
|
990
|
-
offset: 1,
|
|
991
|
-
color: applyAlphaToColor(gradientBottomColor, CYLINDER_SIDE_OPACITY)
|
|
992
|
-
}]);
|
|
1266
|
+
var sideGradient = createSideGradient(gradientTopColor, gradientMiddleColor, gradientBottomColor);
|
|
993
1267
|
return {
|
|
994
1268
|
type: 'group',
|
|
995
1269
|
children: [].concat(_toConsumableArray(showBottomPlate ? [{
|
|
@@ -1036,6 +1310,15 @@ function createCylinderRenderItem(layout, slotIndex, colorMap) {
|
|
|
1036
1310
|
function createCylinderBarLineOption(normalizedInput) {
|
|
1037
1311
|
var flatOption = createFlatBarLineOption(normalizedInput);
|
|
1038
1312
|
var flatSeries = createFlatBarLineSeries(normalizedInput);
|
|
1313
|
+
var backgroundSeries = buildBackgroundCustomBarSeries({
|
|
1314
|
+
rawData: normalizedInput.rawData,
|
|
1315
|
+
normalizedSeries: normalizedInput.normalizedSeries,
|
|
1316
|
+
barWidth: normalizedInput.barWidth,
|
|
1317
|
+
barGap: normalizedInput.barGap,
|
|
1318
|
+
barBackground: normalizedInput.barBackground,
|
|
1319
|
+
createRenderItem: createCylinderRenderItem,
|
|
1320
|
+
resolveColorMap: resolveCylinderColors
|
|
1321
|
+
});
|
|
1039
1322
|
var customBarSeries = buildCustomBarSeries({
|
|
1040
1323
|
rawData: normalizedInput.rawData,
|
|
1041
1324
|
normalizedSeries: normalizedInput.normalizedSeries,
|
|
@@ -1054,13 +1337,18 @@ function createCylinderBarLineOption(normalizedInput) {
|
|
|
1054
1337
|
return flatSeries[index];
|
|
1055
1338
|
});
|
|
1056
1339
|
return _objectSpread2(_objectSpread2({}, flatOption), {}, {
|
|
1057
|
-
series: series
|
|
1340
|
+
series: [].concat(_toConsumableArray(series), _toConsumableArray(backgroundSeries))
|
|
1058
1341
|
});
|
|
1059
1342
|
}
|
|
1060
1343
|
|
|
1061
1344
|
var DEFAULT_VARIANT = 'flat';
|
|
1062
1345
|
var DEFAULT_X_AXIS_SCROLL_VISIBLE_COUNT = 8;
|
|
1063
1346
|
var DEFAULT_X_AXIS_SCROLL_GRID_BOTTOM = 56;
|
|
1347
|
+
var DEFAULT_BAR_BACKGROUND = {
|
|
1348
|
+
show: false,
|
|
1349
|
+
colors: [],
|
|
1350
|
+
opacity: 1
|
|
1351
|
+
};
|
|
1064
1352
|
var BAR_LINE_PUBLIC_VARIANTS = ['flat', 'cylinder', 'cube'];
|
|
1065
1353
|
|
|
1066
1354
|
// 公开 variant 能力在此处收口:只允许 flat / cylinder / cube。
|
|
@@ -1144,6 +1432,21 @@ function normalizeXAxisScrollConfig() {
|
|
|
1144
1432
|
};
|
|
1145
1433
|
}
|
|
1146
1434
|
|
|
1435
|
+
/**
|
|
1436
|
+
* 归一化柱形背景配置。
|
|
1437
|
+
* 这里统一收敛开关、颜色数量和透明度范围,避免变体层重复兜底。
|
|
1438
|
+
*/
|
|
1439
|
+
function normalizeBarBackgroundConfig() {
|
|
1440
|
+
var barBackground = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1441
|
+
var config = barBackground && _typeof(barBackground) === 'object' ? barBackground : {};
|
|
1442
|
+
var opacity = Number(config.opacity);
|
|
1443
|
+
return _objectSpread2(_objectSpread2({}, DEFAULT_BAR_BACKGROUND), {}, {
|
|
1444
|
+
show: config.show === true,
|
|
1445
|
+
colors: Array.isArray(config.colors) ? config.colors.filter(Boolean).slice(0, 3) : [],
|
|
1446
|
+
opacity: Number.isFinite(opacity) ? Math.max(0, Math.min(1, opacity)) : 1
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1147
1450
|
/**
|
|
1148
1451
|
* 根据横轴类目数量生成 ECharts dataZoom。
|
|
1149
1452
|
* 默认从末尾向前取 `visibleCount` 个类目,满足“最新数据优先展示”的看板诉求。
|
|
@@ -1214,6 +1517,7 @@ function buildBarLineOption() {
|
|
|
1214
1517
|
variant = _ref$variant === void 0 ? 'flat' : _ref$variant,
|
|
1215
1518
|
barWidth = _ref.barWidth,
|
|
1216
1519
|
barGap = _ref.barGap,
|
|
1520
|
+
barBackground = _ref.barBackground,
|
|
1217
1521
|
xAxisScroll = _ref.xAxisScroll,
|
|
1218
1522
|
customOption = _ref.customOption;
|
|
1219
1523
|
var normalizedInput = normalizeBarLineInput({
|
|
@@ -1225,10 +1529,12 @@ function buildBarLineOption() {
|
|
|
1225
1529
|
var presetOption = getBarLinePreset(preset);
|
|
1226
1530
|
var resolvedVariant = resolveVariantName(variant);
|
|
1227
1531
|
var createVariantOption = variantFactory[resolvedVariant] || variantFactory[DEFAULT_VARIANT];
|
|
1532
|
+
var normalizedBarBackground = normalizeBarBackgroundConfig(barBackground);
|
|
1228
1533
|
var variantOption = createVariantOption(_objectSpread2(_objectSpread2({}, normalizedInput), {}, {
|
|
1229
1534
|
includeXAxis: false,
|
|
1230
1535
|
barWidth: barWidth,
|
|
1231
|
-
barGap: barGap
|
|
1536
|
+
barGap: barGap,
|
|
1537
|
+
barBackground: normalizedBarBackground
|
|
1232
1538
|
}));
|
|
1233
1539
|
var xAxisScrollOption = createXAxisScrollOption(normalizedInput.categories, xAxisScroll);
|
|
1234
1540
|
return mergeChartOption(mergeChartOption(mergeChartOption(baseOption, presetOption, variantOption), xAxisScrollOption), customOption);
|
|
@@ -1285,6 +1591,7 @@ var script = {
|
|
|
1285
1591
|
* - name: 系列名称
|
|
1286
1592
|
* - kind: bar / line
|
|
1287
1593
|
* - stack / yAxisIndex / colors: 可选增强配置
|
|
1594
|
+
* - cubeGradientColors: 仅在 `variant="cube"` 时用于前景方柱三个面的渐变终点色
|
|
1288
1595
|
*/
|
|
1289
1596
|
series: {
|
|
1290
1597
|
type: Array,
|
|
@@ -1330,6 +1637,17 @@ var script = {
|
|
|
1330
1637
|
type: [Number, String],
|
|
1331
1638
|
"default": 8
|
|
1332
1639
|
},
|
|
1640
|
+
/**
|
|
1641
|
+
* 柱形背景配置。
|
|
1642
|
+
* 仅对支持背景柱的柱系列生效,builder 会负责归一化 `show/colors/opacity`
|
|
1643
|
+
* 并交由具体变体决定最终渲染策略。
|
|
1644
|
+
*/
|
|
1645
|
+
barBackground: {
|
|
1646
|
+
type: Object,
|
|
1647
|
+
"default": function _default() {
|
|
1648
|
+
return {};
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1333
1651
|
/**
|
|
1334
1652
|
* 额外透传给 ECharts option 的自定义配置。
|
|
1335
1653
|
* 会在 base / preset / variant option 合并完成后再覆盖。
|
|
@@ -1364,6 +1682,14 @@ var script = {
|
|
|
1364
1682
|
type: Boolean,
|
|
1365
1683
|
"default": false
|
|
1366
1684
|
},
|
|
1685
|
+
/**
|
|
1686
|
+
* 是否在数据为空时展示统一空状态。
|
|
1687
|
+
* 关闭后仍会保留图表容器与坐标系渲染,只是不再替换成 BaseEmpty。
|
|
1688
|
+
*/
|
|
1689
|
+
showEmptyState: {
|
|
1690
|
+
type: Boolean,
|
|
1691
|
+
"default": true
|
|
1692
|
+
},
|
|
1367
1693
|
/**
|
|
1368
1694
|
* 统一状态展示配置。
|
|
1369
1695
|
* 组件层只负责原样透传给 BaseChart,不参与文案计算。
|
|
@@ -1390,6 +1716,12 @@ var script = {
|
|
|
1390
1716
|
isEmpty: function isEmpty() {
|
|
1391
1717
|
return isEmptyData(this.data);
|
|
1392
1718
|
},
|
|
1719
|
+
/**
|
|
1720
|
+
* 对 BaseChart 的空态展示做一层显式开关控制。
|
|
1721
|
+
*/
|
|
1722
|
+
chartEmpty: function chartEmpty() {
|
|
1723
|
+
return this.showEmptyState && this.isEmpty;
|
|
1724
|
+
},
|
|
1393
1725
|
/**
|
|
1394
1726
|
* 将公开 props 汇总为 builder 所需输入。
|
|
1395
1727
|
* 组件层不做类型分发,只负责把标准公开参数交给构建层。
|
|
@@ -1404,6 +1736,7 @@ var script = {
|
|
|
1404
1736
|
preset: this.preset,
|
|
1405
1737
|
barWidth: this.barWidth,
|
|
1406
1738
|
barGap: this.barGap,
|
|
1739
|
+
barBackground: this.barBackground,
|
|
1407
1740
|
xAxisScroll: this.xAxisScroll,
|
|
1408
1741
|
customOption: this.customOption
|
|
1409
1742
|
});
|
|
@@ -1411,7 +1744,7 @@ var script = {
|
|
|
1411
1744
|
}
|
|
1412
1745
|
};
|
|
1413
1746
|
|
|
1414
|
-
var css_248z = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
|
|
1747
|
+
var css_248z = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
|
|
1415
1748
|
styleInject(css_248z);
|
|
1416
1749
|
|
|
1417
1750
|
/* script */
|
|
@@ -1425,7 +1758,7 @@ var __vue_render__ = function __vue_render__() {
|
|
|
1425
1758
|
attrs: {
|
|
1426
1759
|
option: _vm.chartOption,
|
|
1427
1760
|
loading: _vm.loading,
|
|
1428
|
-
empty: _vm.
|
|
1761
|
+
empty: _vm.chartEmpty,
|
|
1429
1762
|
"state-config": _vm.stateConfig,
|
|
1430
1763
|
height: _vm.height
|
|
1431
1764
|
},
|
|
@@ -1445,7 +1778,7 @@ __vue_render__._withStripped = true;
|
|
|
1445
1778
|
/* style */
|
|
1446
1779
|
var __vue_inject_styles__ = undefined;
|
|
1447
1780
|
/* scoped */
|
|
1448
|
-
var __vue_scope_id__ = "data-v-
|
|
1781
|
+
var __vue_scope_id__ = "data-v-38c7a21f";
|
|
1449
1782
|
/* module identifier */
|
|
1450
1783
|
var __vue_module_identifier__ = undefined;
|
|
1451
1784
|
/* functional template */
|