@xq-labs/data-ui-v2 0.2.1 → 0.4.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.
@@ -1,10 +1,10 @@
1
1
  import * as echarts from 'echarts/core';
2
2
  import { graphic } from 'echarts/core';
3
3
  import { BarChart, LineChart, CustomChart } from 'echarts/charts';
4
- import { TooltipComponent, LegendComponent, GridComponent, TitleComponent } from 'echarts/components';
4
+ import { TooltipComponent, LegendComponent, GridComponent, TitleComponent, DataZoomComponent } from 'echarts/components';
5
5
  import { CanvasRenderer } from 'echarts/renderers';
6
6
  import { B as BaseChart, s as styleInject, n as normalizeComponent } from './with-install-e405b463.js';
7
- import { _ as _objectSpread2, D as DEFAULT_COLORS, a as _toConsumableArray, m as mergeChartOption, i as isEmptyData } from './colors-ca059479.js';
7
+ import { _ as _objectSpread2, D as DEFAULT_COLORS, a as _toConsumableArray, m as mergeChartOption, b as _typeof, i as isEmptyData } from './colors-ec0ad9ce.js';
8
8
 
9
9
  var DEFAULT_SERIES = {
10
10
  key: 'value',
@@ -129,6 +129,19 @@ function resolveSeriesColor$1(item, index) {
129
129
  }
130
130
  return DEFAULT_COLORS[index % DEFAULT_COLORS.length];
131
131
  }
132
+ function collectBarSeries(normalizedSeries) {
133
+ return normalizedSeries.map(function (item, originalIndex) {
134
+ return _objectSpread2(_objectSpread2({}, item), {}, {
135
+ originalIndex: originalIndex
136
+ });
137
+ }).filter(function (item) {
138
+ return item.kind === 'bar';
139
+ }).map(function (item, barSeriesIndex) {
140
+ return _objectSpread2(_objectSpread2({}, item), {}, {
141
+ barSeriesIndex: barSeriesIndex
142
+ });
143
+ });
144
+ }
132
145
 
133
146
  /**
134
147
  * 归一化颜色入参。
@@ -479,6 +492,53 @@ function createBarLayout(barSeries, barWidth, barGap) {
479
492
  barGap: resolvedBarGap
480
493
  };
481
494
  }
495
+ function pickBackgroundSlotSeries(barSeries) {
496
+ var renderedStacks = new Set();
497
+ return barSeries.filter(function (item) {
498
+ if (!item.stack) {
499
+ return true;
500
+ }
501
+ if (renderedStacks.has(item.stack)) {
502
+ return false;
503
+ }
504
+ renderedStacks.add(item.stack);
505
+ return true;
506
+ });
507
+ }
508
+ function createBackgroundSeriesData(rawData) {
509
+ return rawData.map(function (row, rowIndex) {
510
+ return {
511
+ value: [rowIndex]
512
+ };
513
+ });
514
+ }
515
+ function resolveBackgroundFaceAlpha(key, opacity) {
516
+ var alphaMap = {
517
+ left: 0.82,
518
+ right: 1,
519
+ top: 1.8,
520
+ middle: 0.82,
521
+ bottom: 1.28,
522
+ legend: 1
523
+ };
524
+ var ratio = alphaMap[key] || 1;
525
+ return Math.max(0, Math.min(1, opacity * ratio));
526
+ }
527
+ function applyBackgroundFaceAlphaToColorMap(colorMap, opacity) {
528
+ return Object.keys(colorMap || {}).reduce(function (result, key) {
529
+ result[key] = applyAlphaToColor(colorMap[key], resolveBackgroundFaceAlpha(key, opacity));
530
+ return result;
531
+ }, {});
532
+ }
533
+ function normalizeBackgroundColors(barBackground, item) {
534
+ if (Array.isArray(barBackground && barBackground.colors) && barBackground.colors.length > 0) {
535
+ return barBackground.colors;
536
+ }
537
+ if (Array.isArray(item && item.colors) && item.colors.length > 0) {
538
+ return item.colors;
539
+ }
540
+ return undefined;
541
+ }
482
542
 
483
543
  /**
484
544
  * 创建堆叠累加器。
@@ -607,13 +667,7 @@ function buildCustomBarSeries(_ref) {
607
667
  barGap = _ref.barGap,
608
668
  createRenderItem = _ref.createRenderItem,
609
669
  resolveColorMap = _ref.resolveColorMap;
610
- var barSeries = normalizedSeries.map(function (item, originalIndex) {
611
- return _objectSpread2(_objectSpread2({}, item), {}, {
612
- originalIndex: originalIndex
613
- });
614
- }).filter(function (item) {
615
- return item.kind === 'bar';
616
- });
670
+ var barSeries = collectBarSeries(normalizedSeries);
617
671
  var layout = createBarLayout(barSeries, barWidth, barGap);
618
672
  var barSeriesWithData = buildBarSeriesData(rawData, barSeries);
619
673
  return barSeriesWithData.map(function (item, index) {
@@ -642,6 +696,57 @@ function buildCustomBarSeries(_ref) {
642
696
  };
643
697
  });
644
698
  }
699
+ function buildBackgroundCustomBarSeries(_ref2) {
700
+ var rawData = _ref2.rawData,
701
+ normalizedSeries = _ref2.normalizedSeries,
702
+ barWidth = _ref2.barWidth,
703
+ barGap = _ref2.barGap,
704
+ _ref2$barBackground = _ref2.barBackground,
705
+ barBackground = _ref2$barBackground === void 0 ? {} : _ref2$barBackground,
706
+ createRenderItem = _ref2.createRenderItem,
707
+ resolveColorMap = _ref2.resolveColorMap;
708
+ if (!barBackground.show) {
709
+ return [];
710
+ }
711
+ var barSeries = collectBarSeries(normalizedSeries);
712
+ if (!barSeries.length) {
713
+ return [];
714
+ }
715
+ var layout = createBarLayout(barSeries, barWidth, barGap);
716
+ var backgroundSeriesData = createBackgroundSeriesData(rawData);
717
+ return pickBackgroundSlotSeries(barSeries).map(function (item) {
718
+ var slotKey = item.stack || "__slot_".concat(item.barSeriesIndex);
719
+ var slotIndex = layout.slotMap[slotKey];
720
+ var fallbackColor = resolveSeriesColor$1(item, item.originalIndex);
721
+ var palette = normalizeBackgroundColors(barBackground, item);
722
+ var baseColorMap = resolveColorMap ? resolveColorMap(palette, fallbackColor) : {
723
+ legend: fallbackColor
724
+ };
725
+ var backgroundColorMap = applyBackgroundFaceAlphaToColorMap(baseColorMap, barBackground.opacity);
726
+ return {
727
+ name: item.name,
728
+ type: 'custom',
729
+ stack: item.stack,
730
+ yAxisIndex: item.yAxisIndex || 0,
731
+ isBackground: true,
732
+ silent: true,
733
+ tooltip: {
734
+ show: false
735
+ },
736
+ renderItem: createRenderItem(layout, slotIndex, backgroundColorMap, _objectSpread2(_objectSpread2({}, item), {}, {
737
+ isBackground: true
738
+ })),
739
+ encode: {
740
+ x: 0
741
+ },
742
+ itemStyle: {
743
+ color: backgroundColorMap.legend || applyAlphaToColor(fallbackColor, barBackground.opacity)
744
+ },
745
+ data: backgroundSeriesData,
746
+ z: 0
747
+ };
748
+ });
749
+ }
645
750
 
646
751
  /**
647
752
  * 归一化 flat 模式下的 `barGap`。
@@ -705,6 +810,27 @@ function resolveFlatBarColors(item, index) {
705
810
  end: darkenColor(fallbackColor, 0.12)
706
811
  };
707
812
  }
813
+ function resolveFlatBackgroundColors(item, index, barBackground) {
814
+ var paletteSource = Array.isArray(barBackground.colors) && barBackground.colors.length > 0 ? {
815
+ colors: barBackground.colors
816
+ } : item;
817
+ var colorMap = resolveFlatBarColors(paletteSource, index);
818
+ return {
819
+ start: applyAlphaToColor(colorMap.start, barBackground.opacity),
820
+ middle: applyAlphaToColor(colorMap.middle, barBackground.opacity),
821
+ end: applyAlphaToColor(colorMap.end, barBackground.opacity)
822
+ };
823
+ }
824
+ function shouldEnableBackground(item, renderedStacks) {
825
+ if (!item.stack) {
826
+ return true;
827
+ }
828
+ if (renderedStacks.has(item.stack)) {
829
+ return false;
830
+ }
831
+ renderedStacks.add(item.stack);
832
+ return true;
833
+ }
708
834
 
709
835
  /**
710
836
  * 创建柱体纵向渐变。
@@ -736,9 +862,12 @@ function createFlatBarLineSeries(_ref) {
736
862
  var normalizedSeries = _ref.normalizedSeries,
737
863
  rawData = _ref.rawData,
738
864
  barWidth = _ref.barWidth,
739
- barGap = _ref.barGap;
865
+ barGap = _ref.barGap,
866
+ _ref$barBackground = _ref.barBackground,
867
+ barBackground = _ref$barBackground === void 0 ? {} : _ref$barBackground;
740
868
  var resolvedBarWidth = Number.isFinite(Number(barWidth)) ? Number(barWidth) : 18;
741
869
  var resolvedBarGap = toBarGapValue(barGap);
870
+ var renderedStacks = new Set();
742
871
  return normalizedSeries.map(function (item, index) {
743
872
  var isLine = item.kind === 'line';
744
873
  var color = resolveSeriesColor(item, index);
@@ -759,11 +888,18 @@ function createFlatBarLineSeries(_ref) {
759
888
  yAxisIndex: item.yAxisIndex
760
889
  });
761
890
  }
891
+ var showBackground = barBackground.show && shouldEnableBackground(item, renderedStacks);
892
+ var backgroundColors = resolveFlatBackgroundColors(item, index, barBackground);
762
893
  return _objectSpread2(_objectSpread2({}, baseSeries), {}, {
763
894
  stack: item.stack,
764
895
  barWidth: resolvedBarWidth,
765
- barGap: resolvedBarGap
766
- });
896
+ barGap: resolvedBarGap,
897
+ showBackground: showBackground
898
+ }, showBackground ? {
899
+ backgroundStyle: {
900
+ color: createBarGradient(backgroundColors)
901
+ }
902
+ } : {});
767
903
  });
768
904
  }
769
905
 
@@ -827,9 +963,63 @@ function createFaceGradient(x0, y0, x1, y1, startColor, endColor) {
827
963
  * 创建方柱渲染器。
828
964
  * 参考案例使用三块 polygon 拼接成立方体,而不是“正面 rect + 顶面/侧面”。
829
965
  */
830
- function createCubeRenderItem(layout, slotIndex, colorMap) {
966
+ function createCubeRenderItem(layout, slotIndex, colorMap, seriesItem) {
831
967
  return function renderItem(params, api) {
832
968
  var rowIndex = api.value(0);
969
+ var offsetX = getBarOffset(layout, slotIndex);
970
+ var centerPoint = api.coord([rowIndex, 0]);
971
+ var centerX = centerPoint[0] + offsetX;
972
+ var halfWidth = layout.barWidth / 2;
973
+ var offsetY = Math.tan(Math.PI / 9) * halfWidth;
974
+ var leftFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.left, colorMap.left);
975
+ var rightFaceGradient = createFaceGradient(0, 0, 0, 1, colorMap.right, colorMap.right);
976
+ var topFaceGradient = createFaceGradient(0, 0, 1, 0, colorMap.top, colorMap.top);
977
+ if (seriesItem && seriesItem.isBackground === true) {
978
+ var coordSys = params.coordSys || {};
979
+ var clipX = coordSys.x || 0;
980
+ var _topY = coordSys.y || 0;
981
+ var width = coordSys.width || 0;
982
+ var _baseY = _topY + (coordSys.height || 0);
983
+ var _topSurfaceY = _topY + Math.abs(offsetY - 1);
984
+ return {
985
+ type: 'group',
986
+ clipPath: {
987
+ type: 'rect',
988
+ shape: {
989
+ x: clipX,
990
+ y: _topY,
991
+ width: width,
992
+ height: coordSys.height || 0
993
+ }
994
+ },
995
+ children: [{
996
+ type: 'polygon',
997
+ shape: {
998
+ points: [[centerX, _topSurfaceY + offsetY - 1], [centerX - halfWidth, _topSurfaceY], [centerX - halfWidth, _baseY - offsetY], [centerX, _baseY - 1]]
999
+ },
1000
+ style: {
1001
+ fill: leftFaceGradient
1002
+ }
1003
+ }, {
1004
+ type: 'polygon',
1005
+ shape: {
1006
+ points: [[centerX, _topSurfaceY + offsetY - 1], [centerX + halfWidth, _topSurfaceY], [centerX + halfWidth, _baseY - offsetY], [centerX, _baseY - 1]]
1007
+ },
1008
+ style: {
1009
+ fill: rightFaceGradient
1010
+ }
1011
+ }, {
1012
+ type: 'polygon',
1013
+ shape: {
1014
+ points: [[centerX, _topSurfaceY + offsetY - 1], [centerX + halfWidth, _topSurfaceY], [centerX, _topSurfaceY - offsetY + 1], [centerX - halfWidth, _topSurfaceY]]
1015
+ },
1016
+ style: {
1017
+ fill: topFaceGradient
1018
+ },
1019
+ z2: 2
1020
+ }]
1021
+ };
1022
+ }
833
1023
  var endValue = api.value(1);
834
1024
  var baseValue = api.value(2);
835
1025
  var rawValue = api.value(3);
@@ -840,20 +1030,13 @@ function createCubeRenderItem(layout, slotIndex, colorMap) {
840
1030
  }
841
1031
  var endPoint = api.coord([rowIndex, endValue]);
842
1032
  var basePoint = api.coord([rowIndex, baseValue]);
843
- var offsetX = getBarOffset(layout, slotIndex);
844
- var centerX = endPoint[0] + offsetX;
845
1033
  var topY = endPoint[1];
846
1034
  var baseY = basePoint[1];
847
- var halfWidth = layout.barWidth / 2;
848
- var offsetY = Math.tan(Math.PI / 9) * halfWidth;
849
1035
  var isPositive = rawValue >= 0;
850
1036
  var connectorOverlap = stackStart ? 0 : Math.max(2, Math.round(offsetY));
851
1037
  var connectorCapOffset = stackEnd ? 0 : Math.min(2, offsetY * 0.45);
852
1038
  var connectBaseY = isPositive ? baseY + connectorOverlap : baseY - connectorOverlap;
853
1039
  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
1040
  return {
858
1041
  type: 'group',
859
1042
  children: [{
@@ -899,6 +1082,15 @@ function createCubeRenderItem(layout, slotIndex, colorMap) {
899
1082
  function createCubeBarLineOption(normalizedInput) {
900
1083
  var flatOption = createFlatBarLineOption(normalizedInput);
901
1084
  var flatSeries = createFlatBarLineSeries(normalizedInput);
1085
+ var backgroundSeries = buildBackgroundCustomBarSeries({
1086
+ rawData: normalizedInput.rawData,
1087
+ normalizedSeries: normalizedInput.normalizedSeries,
1088
+ barWidth: normalizedInput.barWidth,
1089
+ barGap: normalizedInput.barGap,
1090
+ barBackground: normalizedInput.barBackground,
1091
+ createRenderItem: createCubeRenderItem,
1092
+ resolveColorMap: resolveCubeColors
1093
+ });
902
1094
  var customBarSeries = buildCustomBarSeries({
903
1095
  rawData: normalizedInput.rawData,
904
1096
  normalizedSeries: normalizedInput.normalizedSeries,
@@ -917,7 +1109,7 @@ function createCubeBarLineOption(normalizedInput) {
917
1109
  return flatSeries[index];
918
1110
  });
919
1111
  return _objectSpread2(_objectSpread2({}, flatOption), {}, {
920
- series: series
1112
+ series: [].concat(_toConsumableArray(series), _toConsumableArray(backgroundSeries))
921
1113
  });
922
1114
  }
923
1115
 
@@ -941,6 +1133,20 @@ function createEllipsePolygon(cx, cy, rx, ry) {
941
1133
  }
942
1134
  return polygonPoints;
943
1135
  }
1136
+ function createEllipseArcPoints(cx, cy, rx, ry, startAngle, endAngle) {
1137
+ var points = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 12;
1138
+ var arcPoints = [];
1139
+ for (var index = 0; index <= points; index += 1) {
1140
+ var angle = startAngle + (endAngle - startAngle) * index / points;
1141
+ arcPoints.push([cx + Math.cos(angle) * rx, cy + Math.sin(angle) * ry]);
1142
+ }
1143
+ return arcPoints;
1144
+ }
1145
+ function createCylinderSidePolygon(cx, topCy, bottomCy, rx, ry) {
1146
+ var topLowerArc = createEllipseArcPoints(cx, topCy, rx, ry, Math.PI, 0);
1147
+ var bottomUpperArc = createEllipseArcPoints(cx, bottomCy, rx, ry, 0, -Math.PI);
1148
+ return [].concat(_toConsumableArray(topLowerArc), _toConsumableArray(bottomUpperArc));
1149
+ }
944
1150
 
945
1151
  /**
946
1152
  * 创建圆柱渲染器。
@@ -949,9 +1155,76 @@ function createEllipsePolygon(cx, cy, rx, ry) {
949
1155
  * 2. 主体用纵向渐变矩形模拟曲面;
950
1156
  * 3. 堆叠连接处保留底片,但不绘制深色描边和弧线,避免形成脏色带。
951
1157
  */
952
- function createCylinderRenderItem(layout, slotIndex, colorMap) {
1158
+ function createCylinderRenderItem(layout, slotIndex, colorMap, seriesItem) {
953
1159
  return function renderItem(params, api) {
954
1160
  var rowIndex = api.value(0);
1161
+ var offsetX = getBarOffset(layout, slotIndex);
1162
+ var centerPoint = api.coord([rowIndex, 0]);
1163
+ var centerX = centerPoint[0] + offsetX;
1164
+ var radiusX = layout.barWidth / 2;
1165
+ var radiusY = radiusX * 0.4;
1166
+ var createSideGradient = function createSideGradient(topColor, middleColor, bottomColor) {
1167
+ var opacity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : CYLINDER_SIDE_OPACITY;
1168
+ return new graphic.LinearGradient(0, 0, 0, 1, [{
1169
+ offset: 0,
1170
+ color: opacity === null ? topColor : applyAlphaToColor(topColor, opacity)
1171
+ }, {
1172
+ offset: 0.55,
1173
+ color: opacity === null ? middleColor : applyAlphaToColor(middleColor, opacity)
1174
+ }, {
1175
+ offset: 1,
1176
+ color: opacity === null ? bottomColor : applyAlphaToColor(bottomColor, opacity)
1177
+ }]);
1178
+ };
1179
+ if (seriesItem && seriesItem.isBackground === true) {
1180
+ var coordSys = params.coordSys || {};
1181
+ var clipX = coordSys.x || 0;
1182
+ var topY = coordSys.y || 0;
1183
+ var width = coordSys.width || 0;
1184
+ var height = coordSys.height || 0;
1185
+ var _topEllipseY = topY + radiusY;
1186
+ var bottomEllipseY = topY + height - radiusY;
1187
+ return {
1188
+ type: 'group',
1189
+ clipPath: {
1190
+ type: 'rect',
1191
+ shape: {
1192
+ x: clipX,
1193
+ y: topY,
1194
+ width: width,
1195
+ height: height
1196
+ }
1197
+ },
1198
+ children: [{
1199
+ type: 'polygon',
1200
+ shape: {
1201
+ points: createEllipsePolygon(centerX, bottomEllipseY, radiusX, radiusY)
1202
+ },
1203
+ style: {
1204
+ fill: colorMap.bottom
1205
+ },
1206
+ z: 0
1207
+ }, {
1208
+ type: 'polygon',
1209
+ shape: {
1210
+ points: createCylinderSidePolygon(centerX, _topEllipseY, bottomEllipseY, radiusX, radiusY)
1211
+ },
1212
+ style: {
1213
+ fill: createSideGradient(colorMap.middle, colorMap.middle, colorMap.bottom, null)
1214
+ },
1215
+ z: 1
1216
+ }, {
1217
+ type: 'polygon',
1218
+ shape: {
1219
+ points: createEllipsePolygon(centerX, _topEllipseY, radiusX, radiusY)
1220
+ },
1221
+ style: {
1222
+ fill: colorMap.top
1223
+ },
1224
+ z2: 2
1225
+ }]
1226
+ };
1227
+ }
955
1228
  var endValue = api.value(1);
956
1229
  var baseValue = api.value(2);
957
1230
  var rawValue = api.value(3);
@@ -962,10 +1235,6 @@ function createCylinderRenderItem(layout, slotIndex, colorMap) {
962
1235
  }
963
1236
  var endPoint = api.coord([rowIndex, endValue]);
964
1237
  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
1238
  var isPositive = rawValue >= 0;
970
1239
  var barHeight = Math.abs(endPoint[1] - basePoint[1]);
971
1240
  var visibleEllipseY = endPoint[1];
@@ -980,16 +1249,7 @@ function createCylinderRenderItem(layout, slotIndex, colorMap) {
980
1249
  var gradientTopColor = isPositive ? colorMap.middle : darkenColor(colorMap.bottom, 0.05);
981
1250
  var gradientMiddleColor = colorMap.middle;
982
1251
  var gradientBottomColor = isPositive ? colorMap.bottom : colorMap.middle;
983
- var sideGradient = new graphic.LinearGradient(0, 0, 0, 1, [{
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
- }]);
1252
+ var sideGradient = createSideGradient(gradientTopColor, gradientMiddleColor, gradientBottomColor);
993
1253
  return {
994
1254
  type: 'group',
995
1255
  children: [].concat(_toConsumableArray(showBottomPlate ? [{
@@ -1036,6 +1296,15 @@ function createCylinderRenderItem(layout, slotIndex, colorMap) {
1036
1296
  function createCylinderBarLineOption(normalizedInput) {
1037
1297
  var flatOption = createFlatBarLineOption(normalizedInput);
1038
1298
  var flatSeries = createFlatBarLineSeries(normalizedInput);
1299
+ var backgroundSeries = buildBackgroundCustomBarSeries({
1300
+ rawData: normalizedInput.rawData,
1301
+ normalizedSeries: normalizedInput.normalizedSeries,
1302
+ barWidth: normalizedInput.barWidth,
1303
+ barGap: normalizedInput.barGap,
1304
+ barBackground: normalizedInput.barBackground,
1305
+ createRenderItem: createCylinderRenderItem,
1306
+ resolveColorMap: resolveCylinderColors
1307
+ });
1039
1308
  var customBarSeries = buildCustomBarSeries({
1040
1309
  rawData: normalizedInput.rawData,
1041
1310
  normalizedSeries: normalizedInput.normalizedSeries,
@@ -1054,11 +1323,18 @@ function createCylinderBarLineOption(normalizedInput) {
1054
1323
  return flatSeries[index];
1055
1324
  });
1056
1325
  return _objectSpread2(_objectSpread2({}, flatOption), {}, {
1057
- series: series
1326
+ series: [].concat(_toConsumableArray(series), _toConsumableArray(backgroundSeries))
1058
1327
  });
1059
1328
  }
1060
1329
 
1061
1330
  var DEFAULT_VARIANT = 'flat';
1331
+ var DEFAULT_X_AXIS_SCROLL_VISIBLE_COUNT = 8;
1332
+ var DEFAULT_X_AXIS_SCROLL_GRID_BOTTOM = 56;
1333
+ var DEFAULT_BAR_BACKGROUND = {
1334
+ show: false,
1335
+ colors: [],
1336
+ opacity: 1
1337
+ };
1062
1338
  var BAR_LINE_PUBLIC_VARIANTS = ['flat', 'cylinder', 'cube'];
1063
1339
 
1064
1340
  // 公开 variant 能力在此处收口:只允许 flat / cylinder / cube。
@@ -1104,6 +1380,108 @@ function createBaseOption(normalizedInput) {
1104
1380
  }
1105
1381
  };
1106
1382
  }
1383
+ function isValidNumber(value) {
1384
+ return Number.isFinite(Number(value));
1385
+ }
1386
+ function normalizePositiveInteger(value, fallback) {
1387
+ var normalizedValue = Number(value);
1388
+ if (!Number.isFinite(normalizedValue) || normalizedValue <= 0) {
1389
+ return fallback;
1390
+ }
1391
+ return Math.floor(normalizedValue);
1392
+ }
1393
+ function normalizeStartIndex(startIndex) {
1394
+ if (!isValidNumber(startIndex)) {
1395
+ return null;
1396
+ }
1397
+ var normalizedStartIndex = Math.floor(Number(startIndex));
1398
+ return normalizedStartIndex >= 0 ? normalizedStartIndex : null;
1399
+ }
1400
+ function toPercent(value, total) {
1401
+ return Number((value / total * 100).toFixed(2));
1402
+ }
1403
+
1404
+ /**
1405
+ * 归一化横轴滚动配置。
1406
+ * 该配置只服务 X 轴类目过多的场景,不扩展 Y 轴滚动,避免 API 语义变复杂。
1407
+ */
1408
+ function normalizeXAxisScrollConfig() {
1409
+ var xAxisScroll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1410
+ var scrollConfig = xAxisScroll && _typeof(xAxisScroll) === 'object' ? xAxisScroll : {};
1411
+ return {
1412
+ enabled: scrollConfig.enabled === true,
1413
+ visibleCount: normalizePositiveInteger(scrollConfig.visibleCount, DEFAULT_X_AXIS_SCROLL_VISIBLE_COUNT),
1414
+ startPosition: scrollConfig.startPosition === 'start' ? 'start' : 'end',
1415
+ startIndex: normalizeStartIndex(scrollConfig.startIndex),
1416
+ showSlider: scrollConfig.showSlider !== false,
1417
+ inside: scrollConfig.inside !== false
1418
+ };
1419
+ }
1420
+
1421
+ /**
1422
+ * 归一化柱形背景配置。
1423
+ * 这里统一收敛开关、颜色数量和透明度范围,避免变体层重复兜底。
1424
+ */
1425
+ function normalizeBarBackgroundConfig() {
1426
+ var barBackground = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1427
+ var config = barBackground && _typeof(barBackground) === 'object' ? barBackground : {};
1428
+ var opacity = Number(config.opacity);
1429
+ return _objectSpread2(_objectSpread2({}, DEFAULT_BAR_BACKGROUND), {}, {
1430
+ show: config.show === true,
1431
+ colors: Array.isArray(config.colors) ? config.colors.filter(Boolean).slice(0, 3) : [],
1432
+ opacity: Number.isFinite(opacity) ? Math.max(0, Math.min(1, opacity)) : 1
1433
+ });
1434
+ }
1435
+
1436
+ /**
1437
+ * 根据横轴类目数量生成 ECharts dataZoom。
1438
+ * 默认从末尾向前取 `visibleCount` 个类目,满足“最新数据优先展示”的看板诉求。
1439
+ */
1440
+ function createXAxisScrollOption() {
1441
+ var categories = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1442
+ var xAxisScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1443
+ var scrollConfig = normalizeXAxisScrollConfig(xAxisScroll);
1444
+ var totalCount = Array.isArray(categories) ? categories.length : 0;
1445
+ if (!scrollConfig.enabled || totalCount <= scrollConfig.visibleCount) {
1446
+ return {};
1447
+ }
1448
+ var windowSize = Math.min(scrollConfig.visibleCount, totalCount);
1449
+ var maxStartIndex = totalCount - windowSize;
1450
+ var resolvedStartIndex = scrollConfig.startIndex !== null ? Math.min(scrollConfig.startIndex, maxStartIndex) : scrollConfig.startPosition === 'start' ? 0 : maxStartIndex;
1451
+ var start = toPercent(resolvedStartIndex, totalCount);
1452
+ var end = toPercent(resolvedStartIndex + windowSize, totalCount);
1453
+ var dataZoom = [];
1454
+ if (scrollConfig.showSlider) {
1455
+ dataZoom.push({
1456
+ type: 'slider',
1457
+ xAxisIndex: 0,
1458
+ start: start,
1459
+ end: end,
1460
+ height: 14,
1461
+ bottom: 8,
1462
+ brushSelect: false
1463
+ });
1464
+ }
1465
+ if (scrollConfig.inside) {
1466
+ dataZoom.push({
1467
+ type: 'inside',
1468
+ xAxisIndex: 0,
1469
+ start: start,
1470
+ end: end,
1471
+ zoomLock: true
1472
+ });
1473
+ }
1474
+ if (dataZoom.length === 0) {
1475
+ return {};
1476
+ }
1477
+ return _objectSpread2(_objectSpread2({}, scrollConfig.showSlider ? {
1478
+ grid: {
1479
+ bottom: DEFAULT_X_AXIS_SCROLL_GRID_BOTTOM
1480
+ }
1481
+ } : {}), {}, {
1482
+ dataZoom: dataZoom
1483
+ });
1484
+ }
1107
1485
 
1108
1486
  /**
1109
1487
  * 构建 `BarLineChart` 最终 option。
@@ -1111,7 +1489,8 @@ function createBaseOption(normalizedInput) {
1111
1489
  * 1. 输入归一化
1112
1490
  * 2. preset 合并
1113
1491
  * 3. 变体分发
1114
- * 4. customOption 覆盖
1492
+ * 4. X 轴滚动配置合并
1493
+ * 5. customOption 覆盖
1115
1494
  */
1116
1495
  function buildBarLineOption() {
1117
1496
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
@@ -1124,6 +1503,8 @@ function buildBarLineOption() {
1124
1503
  variant = _ref$variant === void 0 ? 'flat' : _ref$variant,
1125
1504
  barWidth = _ref.barWidth,
1126
1505
  barGap = _ref.barGap,
1506
+ barBackground = _ref.barBackground,
1507
+ xAxisScroll = _ref.xAxisScroll,
1127
1508
  customOption = _ref.customOption;
1128
1509
  var normalizedInput = normalizeBarLineInput({
1129
1510
  data: data,
@@ -1134,12 +1515,15 @@ function buildBarLineOption() {
1134
1515
  var presetOption = getBarLinePreset(preset);
1135
1516
  var resolvedVariant = resolveVariantName(variant);
1136
1517
  var createVariantOption = variantFactory[resolvedVariant] || variantFactory[DEFAULT_VARIANT];
1518
+ var normalizedBarBackground = normalizeBarBackgroundConfig(barBackground);
1137
1519
  var variantOption = createVariantOption(_objectSpread2(_objectSpread2({}, normalizedInput), {}, {
1138
1520
  includeXAxis: false,
1139
1521
  barWidth: barWidth,
1140
- barGap: barGap
1522
+ barGap: barGap,
1523
+ barBackground: normalizedBarBackground
1141
1524
  }));
1142
- return mergeChartOption(mergeChartOption(baseOption, presetOption, variantOption), customOption);
1525
+ var xAxisScrollOption = createXAxisScrollOption(normalizedInput.categories, xAxisScroll);
1526
+ return mergeChartOption(mergeChartOption(mergeChartOption(baseOption, presetOption, variantOption), xAxisScrollOption), customOption);
1143
1527
  }
1144
1528
 
1145
1529
  //
@@ -1161,7 +1545,7 @@ function buildBarLineOption() {
1161
1545
  * 这里显式注册柱图、折线图、自定义系列以及笛卡尔坐标系常用组件,
1162
1546
  * 否则运行时虽然能生成 option,但对应主类型不会真正参与渲染。
1163
1547
  */
1164
- echarts.use([BarChart, LineChart, CustomChart, TooltipComponent, LegendComponent, GridComponent, TitleComponent, CanvasRenderer]);
1548
+ echarts.use([BarChart, LineChart, CustomChart, TooltipComponent, LegendComponent, GridComponent, TitleComponent, DataZoomComponent, CanvasRenderer]);
1165
1549
  var script = {
1166
1550
  name: 'BarLineChart',
1167
1551
  components: {
@@ -1238,6 +1622,17 @@ var script = {
1238
1622
  type: [Number, String],
1239
1623
  "default": 8
1240
1624
  },
1625
+ /**
1626
+ * 柱形背景配置。
1627
+ * 仅对支持背景柱的柱系列生效,builder 会负责归一化 `show/colors/opacity`
1628
+ * 并交由具体变体决定最终渲染策略。
1629
+ */
1630
+ barBackground: {
1631
+ type: Object,
1632
+ "default": function _default() {
1633
+ return {};
1634
+ }
1635
+ },
1241
1636
  /**
1242
1637
  * 额外透传给 ECharts option 的自定义配置。
1243
1638
  * 会在 base / preset / variant option 合并完成后再覆盖。
@@ -1248,6 +1643,22 @@ var script = {
1248
1643
  return {};
1249
1644
  }
1250
1645
  },
1646
+ /**
1647
+ * X 轴类目滚动配置。
1648
+ * 仅控制横轴,不扩展 Y 轴;适合月份、日期、地区等类目数量较多的看板场景。
1649
+ * 常用字段:
1650
+ * - enabled: 是否开启 X 轴滚动
1651
+ * - visibleCount: 初始窗口内展示的类目数量,默认按 8 个处理
1652
+ * - startPosition: 初始窗口位置,默认 end,即展示最新一段数据
1653
+ * - startIndex: 指定窗口起始索引;传入合法数字时优先级高于 startPosition
1654
+ * - showSlider / inside: 分别控制底部滚动条与图表内部滚轮/触控滚动
1655
+ */
1656
+ xAxisScroll: {
1657
+ type: Object,
1658
+ "default": function _default() {
1659
+ return {};
1660
+ }
1661
+ },
1251
1662
  /**
1252
1663
  * 图表 loading 状态。
1253
1664
  * 由 BaseChart 统一接管组件层遮罩式 loading UI。
@@ -1296,13 +1707,15 @@ var script = {
1296
1707
  preset: this.preset,
1297
1708
  barWidth: this.barWidth,
1298
1709
  barGap: this.barGap,
1710
+ barBackground: this.barBackground,
1711
+ xAxisScroll: this.xAxisScroll,
1299
1712
  customOption: this.customOption
1300
1713
  });
1301
1714
  }
1302
1715
  }
1303
1716
  };
1304
1717
 
1305
- 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";
1718
+ 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";
1306
1719
  styleInject(css_248z);
1307
1720
 
1308
1721
  /* script */
@@ -1336,7 +1749,7 @@ __vue_render__._withStripped = true;
1336
1749
  /* style */
1337
1750
  var __vue_inject_styles__ = undefined;
1338
1751
  /* scoped */
1339
- var __vue_scope_id__ = "data-v-1ad2414e";
1752
+ var __vue_scope_id__ = "data-v-4e3be95d";
1340
1753
  /* module identifier */
1341
1754
  var __vue_module_identifier__ = undefined;
1342
1755
  /* functional template */