@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.
@@ -193,7 +193,7 @@ const stateConfig = {
193
193
  ### 7.1 组件定位
194
194
 
195
195
  `BarLineChart` 用于承接大多数柱线组合场景。
196
- 推荐先通过 `data + xAxisKey + series` 表达业务数据,再用 `variant`、`preset`、`customOption` 做增强。
196
+ 推荐先通过 `data + xAxisKey + series` 表达业务数据,再用 `variant`、`preset`、`barBackground`、`customOption` 做增强。
197
197
 
198
198
  ### 7.2 Props
199
199
 
@@ -201,17 +201,36 @@ const stateConfig = {
201
201
  | --- | --- | --- | --- |
202
202
  | `data` | `Array` | `[]` | 原始业务数据数组 |
203
203
  | `xAxisKey` | `String` | `'name'` | 横轴类目字段名 |
204
- | `series` | `Array` | `[]` | 系列定义数组,推荐包含 `key`、`name`、`kind` |
204
+ | `series` | `Array` | `[]` | 系列定义数组,推荐包含 `key`、`name`、`kind`、`colors`,`cube` 方柱可额外传 `cubeGradientColors` |
205
205
  | `variant` | `String` | `'flat'` | 图形风格:`flat` / `cylinder` / `cube` |
206
206
  | `preset` | `String` | `'compare'` | 预设:`compare` / `trend` / `rank` |
207
207
  | `barWidth` | `Number` | `18` | 柱体宽度 |
208
208
  | `barGap` | `Number \| String` | `8` | 柱间距 |
209
+ | `barBackground` | `Object` | `{}` | 柱形背景配置,为当前图中的柱系列渲染整列高度背景柱 |
209
210
  | `xAxisScroll` | `Object` | `{}` | X 轴类目滚动配置,只作用于横轴 |
210
211
  | `customOption` | `Object` | `{}` | 对 ECharts option 的补充覆盖 |
211
212
  | `loading` | `Boolean` | `false` | 是否显示统一遮罩式 loading(非 ECharts 原生 loading) |
213
+ | `showEmptyState` | `Boolean` | `true` | 数据为空时是否展示统一空状态;关闭后仍保留图表容器与坐标系渲染 |
212
214
  | `stateConfig` | `Object` | `{}` | 统一状态配置,原样透传给 `BaseChart` |
213
215
  | `height` | `String \| Number` | `320` | 容器高度 |
214
216
 
217
+ `barBackground` 推荐写法:
218
+
219
+ ```js
220
+ const barBackground = {
221
+ show: true,
222
+ colors: ['#FFFFFF', '#D8E4FF'],
223
+ opacity: 0.2
224
+ }
225
+ ```
226
+
227
+ 说明:
228
+
229
+ - `show`:是否开启柱形背景。
230
+ - `colors`:可选背景色板,支持 1~3 个色值;建议传不带 alpha 的颜色值,不传时按当前柱形默认背景色推导。
231
+ - `opacity`:背景柱透明度,推荐传 `0 ~ 1` 之间的小数。
232
+ - 背景高度语义:按当前坐标轴整列高度铺满,用来强化柱槽轮廓,不跟随单个数据值缩放。
233
+
215
234
  ### 7.3 BarLineChart 数据格式
216
235
 
217
236
  `BarLineChart` 的数据通常拆成两部分:
@@ -280,6 +299,13 @@ const series = [
280
299
  kind: 'bar',
281
300
  colors: ['#6B98F8']
282
301
  },
302
+ {
303
+ key: 'delivery',
304
+ name: '交付',
305
+ kind: 'bar',
306
+ colors: ['#6B8AF7', '#5B7CF0', '#8FA6FF'],
307
+ cubeGradientColors: ['#B8C8FF', '#8EA7FF', '#DCE5FF']
308
+ },
283
309
  {
284
310
  key: 'rate',
285
311
  name: '完成率',
@@ -319,6 +345,33 @@ const series = [
319
345
  - 传 `2` 个色值:按“左侧面 / 右侧面”解释,顶面自动提亮。
320
346
  - 传 `3` 个色值:按“左侧面 / 右侧面 / 顶面”解释。
321
347
 
348
+ ### 7.6 `cubeGradientColors` 配置规则
349
+
350
+ `cubeGradientColors` 只在 `variant="cube"` 且当前系列是前景 `bar` 时生效,用来补充三面的渐变终点色。
351
+
352
+ 规则说明:
353
+
354
+ - 类型要求是 `Array`,非数组会被忽略。
355
+ - 最多读取前 `1~3 个色值`,顺序固定为“左侧面 / 右侧面 / 顶面”。
356
+ - 未传某一面的终点色时,会回退到该面的主色。
357
+ - 只影响前景方柱的 `fill` 渐变,不改变 `stroke / legend / tooltip` 的主色语义。
358
+ - 背景方柱不读取 `cubeGradientColors`,继续保持纯色 + 透明度的柱槽视觉。
359
+ - `flat / cylinder / line` 会忽略该字段。
360
+
361
+ 推荐示例:
362
+
363
+ ```js
364
+ const series = [
365
+ {
366
+ key: 'delivery',
367
+ name: '交付',
368
+ kind: 'bar',
369
+ colors: ['#6B8AF7', '#5B7CF0', '#8FA6FF'],
370
+ cubeGradientColors: ['#B8C8FF', '#8EA7FF', '#DCE5FF']
371
+ }
372
+ ]
373
+ ```
374
+
322
375
  示例:
323
376
 
324
377
  ```js
@@ -327,7 +380,7 @@ colors: ['#A8BEFA', '#6B98F8']
327
380
  colors: ['#A8BEFA', '#6B98F8', '#3EE8FE']
328
381
  ```
329
382
 
330
- ### 7.6 `xAxisScroll` 字段说明
383
+ ### 7.7 `xAxisScroll` 字段说明
331
384
 
332
385
  `xAxisScroll` 用于横轴类目较多的场景。
333
386
  它底层使用 ECharts `dataZoom`,只控制 X 轴,不会影响 Y 轴。
@@ -361,14 +414,14 @@ const xAxisScroll = {
361
414
  4. 开启底部滚动条时,组件默认把 `grid.bottom` 提升到 `56`,避免滚动条挤压坐标轴。
362
415
  5. `customOption.dataZoom` 与 `customOption.grid.bottom` 优先级最高,可覆盖组件生成结果。
363
416
 
364
- ### 7.7 Events
417
+ ### 7.8 Events
365
418
 
366
419
  | 事件名 | 参数 | 说明 |
367
420
  | --- | --- | --- |
368
421
  | `ready` | `chart` | 底层 ECharts 实例 |
369
422
  | `chart-click` | `params` | 点击图形元素时触发 |
370
423
 
371
- ### 7.8 常见场景
424
+ ### 7.9 常见场景
372
425
 
373
426
  1. **基础柱线组合**:销售额 + 完成率双轴。
374
427
  2. **圆柱视觉**:看板类数据强调“柱体感”。
@@ -412,6 +465,7 @@ const xAxisScroll = {
412
465
  | `hideZeroValueSlices` | `Boolean` | `true` | 3D 下是否过滤 0 值扇区 |
413
466
  | `customOption` | `Object` | `{}` | 对 ECharts option 的补充覆盖 |
414
467
  | `loading` | `Boolean` | `false` | 是否显示统一遮罩式 loading(非 ECharts 原生 loading) |
468
+ | `showEmptyState` | `Boolean` | `true` | 是否在普通空数据场景展示统一空状态;不影响 3D 运行时失败等必须提示的错误场景 |
415
469
  | `stateConfig` | `Object` | `{}` | 统一状态配置;3D 运行时失败时内部错误文案优先级更高 |
416
470
  | `height` | `String \| Number` | `320` | 容器高度 |
417
471
 
@@ -742,6 +796,7 @@ const data = [
742
796
  series,
743
797
  variant: 'cylinder',
744
798
  preset: 'compare',
799
+ barBackground,
745
800
  xAxisScroll,
746
801
  stateConfig,
747
802
  customOption
@@ -27,8 +27,10 @@ Playground 中 `BarLineChart` 按分组路由组织:
27
27
  preset,
28
28
  barWidth,
29
29
  barGap,
30
+ barBackground,
30
31
  xAxisScroll,
31
32
  customOption,
33
+ showEmptyState,
32
34
  stateConfig
33
35
  }"
34
36
  />
@@ -42,8 +44,10 @@ Playground 中 `BarLineChart` 按分组路由组织:
42
44
  - `variant`:`flat` / `cylinder` / `cube`。
43
45
  - `preset`:展示预设。
44
46
  - `barWidth`、`barGap`:柱体宽度与间距。
47
+ - `barBackground`:柱形背景配置,用于为当前图中的柱系列补整列高度背景柱。
45
48
  - `xAxisScroll`:X 轴滚动配置,用于类目过多时默认展示最新数据窗口。
46
49
  - `customOption`:ECharts 展示细节覆盖。
50
+ - `showEmptyState`:数据为空时是否展示统一空状态;关闭后保留图表容器与坐标系本身。
47
51
  - `stateConfig`:统一收拢空态文案、空态图和 loading 文案。
48
52
 
49
53
  推荐结构:
@@ -57,6 +61,12 @@ const xAxisScroll = {
57
61
  inside: true
58
62
  }
59
63
 
64
+ const barBackground = {
65
+ show: true,
66
+ colors: ['#FFFFFF', '#D8E4FF'],
67
+ opacity: 0.2
68
+ }
69
+
60
70
  const stateConfig = {
61
71
  empty: {
62
72
  text: '暂无柱线图数据',
@@ -66,6 +76,8 @@ const stateConfig = {
66
76
  text: '柱线图加载中...'
67
77
  }
68
78
  }
79
+
80
+ const showEmptyState = false
69
81
  ```
70
82
 
71
83
  `xAxisScroll` 字段说明:
@@ -77,13 +89,44 @@ const stateConfig = {
77
89
  - `showSlider`:是否显示底部滚动条。
78
90
  - `inside`:是否允许鼠标滚轮 / 触控板在图表内部滚动。
79
91
 
92
+ `barBackground` 字段说明:
93
+
94
+ - `show`:是否开启柱形背景。
95
+ - `colors`:可选背景色板,支持 1~3 个色值;建议传不带 alpha 的颜色值,不传时按当前柱形默认背景色推导。
96
+ - `opacity`:背景柱透明度,推荐传 `0 ~ 1` 之间的小数。
97
+
98
+ `cube` 方柱补充字段:
99
+
100
+ - `series.colors`:继续按左/右/顶顺序提供三面的主色,兼容现有 1~3 个色值写法。
101
+ - `cubeGradientColors`:仅 `cube` 前景柱生效,按左/右/顶顺序提供三面的渐变终点色;缺失某一面时会回退到该面的主色。
102
+ - 背景方柱不读取 `cubeGradientColors`,继续保持纯色 + 透明度的柱槽视觉。
103
+
104
+ ```js
105
+ const series = [
106
+ {
107
+ key: 'delivery',
108
+ name: '交付',
109
+ kind: 'bar',
110
+ colors: ['#6B8AF7', '#5B7CF0', '#8FA6FF'],
111
+ cubeGradientColors: ['#B8C8FF', '#8EA7FF', '#DCE5FF']
112
+ }
113
+ ]
114
+ ```
115
+
116
+ 背景高度语义:
117
+
118
+ - `barBackground` 渲染的是当前坐标轴下的整列高度背景柱,不跟随单个数据值缩放。
119
+
80
120
  ## 3. 如何自定义(推荐顺序)
81
121
 
82
122
  1. **优先 `series` 表达业务语义**:先确定字段、柱线类型、双轴和堆叠关系。
83
123
  2. **用 `series.colors` 控制系列配色**:把业务色板放在系列层。
84
- 3. **用 `xAxisScroll` 控制横轴窗口**:类目较多时默认展示最新 `visibleCount` 个类目。
85
- 4. **`stateConfig` 收拢状态文案**:空态图、空态文案、loading 文案统一从这里传。
86
- 5. **`customOption` 补充细节**:用于 tooltip、legend、grid、坐标轴样式、dataZoom 等展示项。
124
+ 3. **`cube` 方柱可再传 `cubeGradientColors`**:只补前景三面的渐变终点色,不影响背景方柱。
125
+ 4. **用 `barBackground` 强化柱槽轮廓**:需要整列高度背景时,再开启背景柱并调透明度。
126
+ 5. **用 `xAxisScroll` 控制横轴窗口**:类目较多时默认展示最新 `visibleCount` 个类目。
127
+ 6. **按需关闭 `showEmptyState`**:需要保留空图表骨架时可传 `false`,否则默认展示统一空态。
128
+ 7. **`stateConfig` 收拢状态文案**:空态图、空态文案、loading 文案统一从这里传。
129
+ 8. **`customOption` 补充细节**:用于 tooltip、legend、grid、坐标轴样式、dataZoom 等展示项。
87
130
 
88
131
  不建议用 `customOption` 直接整体替换关键业务结构。
89
132
  如果必须完全自定义滚动条,可通过 `customOption.dataZoom` 覆盖 `xAxisScroll` 生成结果。
@@ -91,5 +134,5 @@ const stateConfig = {
91
134
  ## 4. 可执行验收要点
92
135
 
93
136
  - 页面分组名称与路由一致:基础用法、圆柱样式、方柱样式、进阶配置、customOption 与自定义、实验室。
94
- - 文档示例包含 `series.colors`、`xAxisScroll`、`stateConfig` 与 `customOption`。
137
+ - 文档示例包含 `series.colors`、`cubeGradientColors`、`barBackground`、`xAxisScroll`、`showEmptyState`、`stateConfig` 与 `customOption`。
95
138
  - 文档明确实验室边界与推荐自定义顺序。
@@ -30,6 +30,7 @@ Playground 中 `PieChart` 采用分组路由组织,按能力查阅:
30
30
  hideZeroValueSlices,
31
31
  labelOptions,
32
32
  customOption,
33
+ showEmptyState,
33
34
  stateConfig
34
35
  }"
35
36
  />
@@ -45,6 +46,7 @@ Playground 中 `PieChart` 采用分组路由组织,按能力查阅:
45
46
  - `hideZeroValueSlices`:3D 下是否隐藏 0 值扇区。
46
47
  - `labelOptions`:标签与引导线细节(格式、线长、颜色等)。
47
48
  - `customOption`:ECharts 细节覆盖(标题、提示、图例等)。
49
+ - `showEmptyState`:普通空数据时是否展示统一空状态。
48
50
  - `stateConfig`:统一收拢空态文案、空态图和 loading 文案。
49
51
 
50
52
  推荐结构:
@@ -59,6 +61,8 @@ const stateConfig = {
59
61
  text: '饼图加载中...'
60
62
  }
61
63
  }
64
+
65
+ const showEmptyState = false
62
66
  ```
63
67
 
64
68
  ## 2.1 3D 依赖说明
@@ -83,8 +87,9 @@ import '@xq-labs/data-ui-v2/pie-chart/3d-runtime'
83
87
 
84
88
  1. **优先公开 props**:先用 `variant`、`dimension`、`preset`、高度参数表达业务语义。
85
89
  2. **其次 `labelOptions`**:标签文案、引导线样式优先在这里完成。
86
- 3. **状态文案统一交给 `stateConfig`**:空态图、空态文案、loading 文案不要分散到多个字段。
87
- 4. **最后 `customOption`**:仅用于补充 ECharts 展示细节。
90
+ 3. **按需控制 `showEmptyState`**:需要保留空画布时传 `false`;默认继续展示统一空态。
91
+ 4. **状态文案统一交给 `stateConfig`**:空态图、空态文案、loading 文案不要分散到多个字段。
92
+ 5. **最后 `customOption`**:仅用于补充 ECharts 展示细节。
88
93
 
89
94
  不建议业务侧直接拼接或重写内部 `series`,避免覆盖组件内置能力与升级兼容性。
90
95
 
@@ -99,6 +104,7 @@ import '@xq-labs/data-ui-v2/pie-chart/3d-runtime'
99
104
  1. `PieChart` 会优先显示组件内部错误文案。
100
105
  2. `stateConfig.empty.image` 仍然生效。
101
106
  3. `stateConfig.loading.text` 仍然生效。
107
+ 4. `showEmptyState=false` 也不会关闭这类接入错误提示。
102
108
 
103
109
  也就是说,业务可以继续自定义空态图,但不能覆盖这类
104
110
  “请先在业务页面中执行 `import '@xq-labs/data-ui-v2/pie-chart/3d-runtime'`”提示。
@@ -106,5 +112,5 @@ import '@xq-labs/data-ui-v2/pie-chart/3d-runtime'
106
112
  ## 4. 可执行验收要点
107
113
 
108
114
  - 页面分组名称与路由一致:基础用法、2D 形态、3D 能力、标签与引导线、customOption 与自定义、实验室。
109
- - 文档示例包含 `hideZeroValueSlices`、`stateConfig` 与 `customOption`。
115
+ - 文档示例包含 `hideZeroValueSlices`、`showEmptyState`、`stateConfig` 与 `customOption`。
110
116
  - 文档明确实验室边界与推荐自定义顺序。
@@ -1,5 +1,5 @@
1
1
  import '../../theme-chalk/index.css';
2
- import { B as BarLineChart } from '../index-d01ce220.js';
2
+ import { B as BarLineChart } from '../index-1e113c13.js';
3
3
  import { w as withInstall } from '../with-install-e405b463.js';
4
4
  import 'echarts/core';
5
5
  import 'echarts/charts';