@ant-design/agentic-ui 2.30.2 → 2.30.3

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.
Files changed (52) hide show
  1. package/dist/Hooks/useLanguage.d.ts +3 -0
  2. package/dist/I18n/locales.d.ts +3 -0
  3. package/dist/I18n/locales.js +6 -0
  4. package/dist/MarkdownRenderer/useMarkdownToReact.js +3 -1
  5. package/dist/Plugins/chart/AreaChart/index.js +4 -3
  6. package/dist/Plugins/chart/BarChart/index.js +3 -3
  7. package/dist/Plugins/chart/BoxPlotChart/index.d.ts +65 -0
  8. package/dist/Plugins/chart/BoxPlotChart/index.js +665 -0
  9. package/dist/Plugins/chart/BoxPlotChart/style.d.ts +8 -0
  10. package/dist/Plugins/chart/BoxPlotChart/style.js +118 -0
  11. package/dist/Plugins/chart/ChartAttrToolBar/index.js +5 -16
  12. package/dist/Plugins/chart/ChartMark/Area.d.ts +2 -1
  13. package/dist/Plugins/chart/ChartMark/Area.js +5 -4
  14. package/dist/Plugins/chart/ChartMark/Bar.d.ts +2 -1
  15. package/dist/Plugins/chart/ChartMark/Bar.js +5 -4
  16. package/dist/Plugins/chart/ChartMark/Column.d.ts +2 -1
  17. package/dist/Plugins/chart/ChartMark/Column.js +5 -4
  18. package/dist/Plugins/chart/ChartMark/Line.d.ts +2 -1
  19. package/dist/Plugins/chart/ChartMark/Line.js +5 -4
  20. package/dist/Plugins/chart/ChartMark/Pie.d.ts +2 -1
  21. package/dist/Plugins/chart/ChartMark/Pie.js +5 -4
  22. package/dist/Plugins/chart/ChartRender.d.ts +1 -1
  23. package/dist/Plugins/chart/ChartRender.js +188 -12
  24. package/dist/Plugins/chart/DonutChart/Legend.d.ts +5 -3
  25. package/dist/Plugins/chart/DonutChart/Legend.js +30 -38
  26. package/dist/Plugins/chart/DonutChart/index.js +82 -23
  27. package/dist/Plugins/chart/DonutChart/plugins.d.ts +2 -2
  28. package/dist/Plugins/chart/DonutChart/plugins.js +5 -5
  29. package/dist/Plugins/chart/DonutChart/types.d.ts +2 -0
  30. package/dist/Plugins/chart/FunnelChart/index.js +24 -14
  31. package/dist/Plugins/chart/HistogramChart/index.d.ts +65 -0
  32. package/dist/Plugins/chart/HistogramChart/index.js +665 -0
  33. package/dist/Plugins/chart/HistogramChart/style.d.ts +8 -0
  34. package/dist/Plugins/chart/HistogramChart/style.js +118 -0
  35. package/dist/Plugins/chart/LineChart/index.js +4 -3
  36. package/dist/Plugins/chart/RadarChart/index.d.ts +2 -0
  37. package/dist/Plugins/chart/RadarChart/index.js +28 -26
  38. package/dist/Plugins/chart/ScatterChart/index.d.ts +2 -0
  39. package/dist/Plugins/chart/ScatterChart/index.js +43 -28
  40. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.d.ts +1 -0
  41. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +14 -0
  42. package/dist/Plugins/chart/components/ChartContainer/ChartDarkAntdContext.d.ts +7 -0
  43. package/dist/Plugins/chart/components/ChartContainer/ChartDarkAntdContext.js +8 -0
  44. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +8 -2
  45. package/dist/Plugins/chart/components/ChartContainer/style.js +3 -3
  46. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.d.ts +2 -0
  47. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +23 -32
  48. package/dist/Plugins/chart/index.d.ts +4 -0
  49. package/dist/Plugins/chart/index.js +2 -0
  50. package/dist/Plugins/chart/loadChartRuntime.d.ts +4 -0
  51. package/dist/Plugins/chart/loadChartRuntime.js +5 -1
  52. package/package.json +3 -1
@@ -0,0 +1,665 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
25
+ function _iterable_to_array(iter) {
26
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27
+ }
28
+ function _iterable_to_array_limit(arr, i) {
29
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
30
+ if (_i == null) return;
31
+ var _arr = [];
32
+ var _n = true;
33
+ var _d = false;
34
+ var _s, _e;
35
+ try {
36
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
37
+ _arr.push(_s.value);
38
+ if (i && _arr.length === i) break;
39
+ }
40
+ } catch (err) {
41
+ _d = true;
42
+ _e = err;
43
+ } finally{
44
+ try {
45
+ if (!_n && _i["return"] != null) _i["return"]();
46
+ } finally{
47
+ if (_d) throw _e;
48
+ }
49
+ }
50
+ return _arr;
51
+ }
52
+ function _non_iterable_rest() {
53
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
54
+ }
55
+ function _non_iterable_spread() {
56
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
57
+ }
58
+ function _object_spread(target) {
59
+ for(var i = 1; i < arguments.length; i++){
60
+ var source = arguments[i] != null ? arguments[i] : {};
61
+ var ownKeys = Object.keys(source);
62
+ if (typeof Object.getOwnPropertySymbols === "function") {
63
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
65
+ }));
66
+ }
67
+ ownKeys.forEach(function(key) {
68
+ _define_property(target, key, source[key]);
69
+ });
70
+ }
71
+ return target;
72
+ }
73
+ function ownKeys(object, enumerableOnly) {
74
+ var keys = Object.keys(object);
75
+ if (Object.getOwnPropertySymbols) {
76
+ var symbols = Object.getOwnPropertySymbols(object);
77
+ if (enumerableOnly) {
78
+ symbols = symbols.filter(function(sym) {
79
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
80
+ });
81
+ }
82
+ keys.push.apply(keys, symbols);
83
+ }
84
+ return keys;
85
+ }
86
+ function _object_spread_props(target, source) {
87
+ source = source != null ? source : {};
88
+ if (Object.getOwnPropertyDescriptors) {
89
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
90
+ } else {
91
+ ownKeys(Object(source)).forEach(function(key) {
92
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
93
+ });
94
+ }
95
+ return target;
96
+ }
97
+ function _object_without_properties(source, excluded) {
98
+ if (source == null) return {};
99
+ var target = {}, sourceKeys, key, i;
100
+ if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
101
+ sourceKeys = Reflect.ownKeys(source);
102
+ for(i = 0; i < sourceKeys.length; i++){
103
+ key = sourceKeys[i];
104
+ if (excluded.indexOf(key) >= 0) continue;
105
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
106
+ target[key] = source[key];
107
+ }
108
+ return target;
109
+ }
110
+ target = _object_without_properties_loose(source, excluded);
111
+ if (Object.getOwnPropertySymbols) {
112
+ sourceKeys = Object.getOwnPropertySymbols(source);
113
+ for(i = 0; i < sourceKeys.length; i++){
114
+ key = sourceKeys[i];
115
+ if (excluded.indexOf(key) >= 0) continue;
116
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
117
+ target[key] = source[key];
118
+ }
119
+ }
120
+ return target;
121
+ }
122
+ function _object_without_properties_loose(source, excluded) {
123
+ if (source == null) return {};
124
+ var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
125
+ for(i = 0; i < sourceKeys.length; i++){
126
+ key = sourceKeys[i];
127
+ if (excluded.indexOf(key) >= 0) continue;
128
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
129
+ target[key] = source[key];
130
+ }
131
+ return target;
132
+ }
133
+ function _sliced_to_array(arr, i) {
134
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
135
+ }
136
+ function _to_consumable_array(arr) {
137
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
138
+ }
139
+ function _unsupported_iterable_to_array(o, minLen) {
140
+ if (!o) return;
141
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
142
+ var n = Object.prototype.toString.call(o).slice(8, -1);
143
+ if (n === "Object" && o.constructor) n = o.constructor.name;
144
+ if (n === "Map" || n === "Set") return Array.from(n);
145
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
146
+ }
147
+ import { BoxAndWiskers, BoxPlotController } from "@sgratzl/chartjs-chart-boxplot";
148
+ import { ConfigProvider } from "antd";
149
+ import { CategoryScale, Chart as ChartJS, Legend, LinearScale, Tooltip } from "chart.js";
150
+ import classNames from "clsx";
151
+ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
152
+ import { Chart } from "react-chartjs-2";
153
+ import ChartStatistic from "../ChartStatistic";
154
+ import { ChartContainer, ChartFilter, ChartToolBar, downloadChart } from "../components";
155
+ import { defaultColorList } from "../const";
156
+ import { hexToRgba, resolveCssVariable } from "../utils";
157
+ import { useStyle } from "./style";
158
+ var boxPlotChartComponentsRegistered = false;
159
+ /**
160
+ * 计算箱线图统计值
161
+ */ function calculateBoxPlotStats(values) {
162
+ var _Math, _Math1;
163
+ if (!values || values.length === 0) {
164
+ return {
165
+ min: 0,
166
+ q1: 0,
167
+ median: 0,
168
+ q3: 0,
169
+ max: 0,
170
+ mean: 0,
171
+ outliers: []
172
+ };
173
+ }
174
+ // 过滤有效数值并排序
175
+ var sorted = values.filter(function(v) {
176
+ return typeof v === 'number' && Number.isFinite(v);
177
+ }).sort(function(a, b) {
178
+ return a - b;
179
+ });
180
+ if (sorted.length === 0) {
181
+ return {
182
+ min: 0,
183
+ q1: 0,
184
+ median: 0,
185
+ q3: 0,
186
+ max: 0,
187
+ mean: 0,
188
+ outliers: []
189
+ };
190
+ }
191
+ var n = sorted.length;
192
+ var mean = sorted.reduce(function(a, b) {
193
+ return a + b;
194
+ }, 0) / n;
195
+ // 计算四分位数
196
+ var q1Index = Math.floor(n * 0.25);
197
+ var medianIndex = Math.floor(n * 0.5);
198
+ var q3Index = Math.floor(n * 0.75);
199
+ var q1 = sorted[q1Index];
200
+ var median = sorted[medianIndex];
201
+ var q3 = sorted[q3Index];
202
+ // 计算 IQR 和异常值边界
203
+ var iqr = q3 - q1;
204
+ var lowerBound = q1 - 1.5 * iqr;
205
+ var upperBound = q3 + 1.5 * iqr;
206
+ // 找出非异常值的范围
207
+ var nonOutliers = sorted.filter(function(v) {
208
+ return v >= lowerBound && v <= upperBound;
209
+ });
210
+ var outliers = sorted.filter(function(v) {
211
+ return v < lowerBound || v > upperBound;
212
+ });
213
+ var min = nonOutliers.length > 0 ? (_Math = Math).min.apply(_Math, _to_consumable_array(nonOutliers)) : sorted[0];
214
+ var max = nonOutliers.length > 0 ? (_Math1 = Math).max.apply(_Math1, _to_consumable_array(nonOutliers)) : sorted[n - 1];
215
+ return {
216
+ min: min,
217
+ q1: q1,
218
+ median: median,
219
+ q3: q3,
220
+ max: max,
221
+ mean: mean,
222
+ outliers: outliers
223
+ };
224
+ }
225
+ var BoxPlotChart = function BoxPlotChart(_0) {
226
+ var title = _0.title, data = _0.data, _0_width = _0.width, width = _0_width === void 0 ? 600 : _0_width, _0_height = _0.height, height = _0_height === void 0 ? 400 : _0_height, className = _0.className, classNamesProp = _0.classNames, style = _0.style, styles = _0.styles, dataTime = _0.dataTime, _0_theme = _0.theme, theme = _0_theme === void 0 ? 'light' : _0_theme, color = _0.color, _0_showLegend = _0.showLegend, showLegend = _0_showLegend === void 0 ? true : _0_showLegend, _0_legendPosition = _0.legendPosition, legendPosition = _0_legendPosition === void 0 ? 'bottom' : _0_legendPosition, _0_showGrid = _0.showGrid, showGrid = _0_showGrid === void 0 ? true : _0_showGrid, xAxisLabel = _0.xAxisLabel, yAxisLabel = _0.yAxisLabel, _0_showOutliers = _0.showOutliers, showOutliers = _0_showOutliers === void 0 ? true : _0_showOutliers, toolbarExtra = _0.toolbarExtra, _0_renderFilterInToolbar = _0.renderFilterInToolbar, renderFilterInToolbar = _0_renderFilterInToolbar === void 0 ? false : _0_renderFilterInToolbar, statisticConfig = _0.statistic, _0_loading = _0.loading, loading = _0_loading === void 0 ? false : _0_loading, props = _object_without_properties(_0, [
227
+ "title",
228
+ "data",
229
+ "width",
230
+ "height",
231
+ "className",
232
+ "classNames",
233
+ "style",
234
+ "styles",
235
+ "dataTime",
236
+ "theme",
237
+ "color",
238
+ "showLegend",
239
+ "legendPosition",
240
+ "showGrid",
241
+ "xAxisLabel",
242
+ "yAxisLabel",
243
+ "showOutliers",
244
+ "toolbarExtra",
245
+ "renderFilterInToolbar",
246
+ "statistic",
247
+ "loading"
248
+ ]);
249
+ // 注册 Chart.js 组件
250
+ useMemo(function() {
251
+ if (boxPlotChartComponentsRegistered) {
252
+ return undefined;
253
+ }
254
+ if (typeof window === 'undefined') {
255
+ return undefined;
256
+ }
257
+ ChartJS.register(CategoryScale, LinearScale, Tooltip, Legend, BoxPlotController, BoxAndWiskers);
258
+ boxPlotChartComponentsRegistered = true;
259
+ return undefined;
260
+ }, []);
261
+ var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
262
+ var prefixCls = getPrefixCls('boxplot-chart');
263
+ var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
264
+ // 处理 ChartStatistic 组件配置
265
+ var statistics = useMemo(function() {
266
+ if (!statisticConfig) return null;
267
+ if (Array.isArray(statisticConfig) && statisticConfig.length === 0) return null;
268
+ return Array.isArray(statisticConfig) ? statisticConfig : [
269
+ statisticConfig
270
+ ];
271
+ }, [
272
+ statisticConfig
273
+ ]);
274
+ // 响应式尺寸计算
275
+ var _useState = _sliced_to_array(useState(typeof window !== 'undefined' ? window.innerWidth : 768), 2), windowWidth = _useState[0], setWindowWidth = _useState[1];
276
+ var isMobile = windowWidth <= 768;
277
+ var responsiveWidth = isMobile ? '100%' : width;
278
+ var responsiveHeight = isMobile ? Math.min(windowWidth * 0.8, 400) : height;
279
+ // 监听窗口大小变化
280
+ useEffect(function() {
281
+ var handleResize = function handleResize() {
282
+ setWindowWidth(window.innerWidth);
283
+ };
284
+ if (typeof window !== 'undefined') {
285
+ window.addEventListener('resize', handleResize);
286
+ return function() {
287
+ return window.removeEventListener('resize', handleResize);
288
+ };
289
+ }
290
+ }, []);
291
+ var chartRef = useRef(null);
292
+ // 数据安全检查
293
+ var safeData = Array.isArray(data) ? data : [];
294
+ // 从数据中提取分类
295
+ var categories = useMemo(function() {
296
+ var uniqueCategories = _to_consumable_array(new Set(safeData.map(function(item) {
297
+ return item === null || item === void 0 ? void 0 : item.category;
298
+ }))).filter(Boolean);
299
+ return uniqueCategories;
300
+ }, [
301
+ safeData
302
+ ]);
303
+ // 从数据中提取 filterLabel
304
+ var validFilterLabels = useMemo(function() {
305
+ return safeData.map(function(item) {
306
+ return item === null || item === void 0 ? void 0 : item.filterLabel;
307
+ }).filter(function(filterLabel) {
308
+ return filterLabel !== undefined;
309
+ });
310
+ }, [
311
+ safeData
312
+ ]);
313
+ var filterLabels = useMemo(function() {
314
+ return validFilterLabels.length > 0 ? _to_consumable_array(new Set(validFilterLabels)) : undefined;
315
+ }, [
316
+ validFilterLabels
317
+ ]);
318
+ // 状态管理
319
+ var _useState1 = _sliced_to_array(useState(categories.find(Boolean) || ''), 2), selectedFilter = _useState1[0], setSelectedFilter = _useState1[1];
320
+ var _useState2 = _sliced_to_array(useState(filterLabels && filterLabels.length > 0 ? filterLabels[0] : undefined), 2), selectedFilterLabel = _useState2[0], setSelectedFilterLabel = _useState2[1];
321
+ // 当数据变化导致当前选中分类失效时,自动回退
322
+ useEffect(function() {
323
+ if (selectedFilter && !categories.includes(selectedFilter)) {
324
+ setSelectedFilter(categories.find(Boolean) || '');
325
+ }
326
+ }, [
327
+ categories,
328
+ selectedFilter
329
+ ]);
330
+ // 筛选数据
331
+ var filteredData = useMemo(function() {
332
+ var base = selectedFilter ? safeData.filter(function(item) {
333
+ return item.category === selectedFilter;
334
+ }) : safeData;
335
+ var withFilterLabel = !filterLabels || !selectedFilterLabel ? base : base.filter(function(item) {
336
+ return item.filterLabel === selectedFilterLabel;
337
+ });
338
+ return withFilterLabel.filter(function(item) {
339
+ return item && item.label !== null && item.label !== undefined && item.label !== '';
340
+ });
341
+ }, [
342
+ safeData,
343
+ selectedFilter,
344
+ filterLabels,
345
+ selectedFilterLabel
346
+ ]);
347
+ // 从数据中提取唯一的类型
348
+ var types = useMemo(function() {
349
+ return _to_consumable_array(new Set(filteredData.map(function(item) {
350
+ return item.type;
351
+ }))).filter(Boolean);
352
+ }, [
353
+ filteredData
354
+ ]);
355
+ // 从数据中提取唯一的标签
356
+ var labels = useMemo(function() {
357
+ return _to_consumable_array(new Set(filteredData.map(function(item) {
358
+ return item.label;
359
+ })));
360
+ }, [
361
+ filteredData
362
+ ]);
363
+ // 构建 Chart.js 数据结构
364
+ var processedData = useMemo(function() {
365
+ var datasets = types.map(function(type, index) {
366
+ var provided = color;
367
+ var pickByIndex = function pickByIndex(i) {
368
+ return Array.isArray(provided) ? provided[i] || provided[0] || defaultColorList[i % defaultColorList.length] : provided || defaultColorList[i % defaultColorList.length];
369
+ };
370
+ var baseColor = pickByIndex(index);
371
+ // 解析 CSS 变量为实际颜色值
372
+ var resolvedBaseColor = resolveCssVariable(baseColor);
373
+ // 为每个标签收集数据
374
+ var typeData = labels.map(function(label) {
375
+ var dataPoint = filteredData.find(function(item) {
376
+ return item.label === label && item.type === type;
377
+ });
378
+ if (!dataPoint || !dataPoint.values || dataPoint.values.length === 0) {
379
+ return null;
380
+ }
381
+ var stats = calculateBoxPlotStats(dataPoint.values);
382
+ return _object_spread({
383
+ min: stats.min,
384
+ q1: stats.q1,
385
+ median: stats.median,
386
+ q3: stats.q3,
387
+ max: stats.max,
388
+ mean: stats.mean
389
+ }, showOutliers && stats.outliers.length > 0 ? {
390
+ outliers: stats.outliers
391
+ } : {});
392
+ });
393
+ return {
394
+ label: type || '默认',
395
+ data: typeData,
396
+ backgroundColor: hexToRgba(resolvedBaseColor, 0.5),
397
+ borderColor: resolvedBaseColor,
398
+ borderWidth: 1,
399
+ outlierColor: hexToRgba(resolvedBaseColor, 0.8),
400
+ padding: 10,
401
+ itemRadius: showOutliers ? 3 : 0
402
+ };
403
+ });
404
+ // 如果没有类型分组,创建默认数据集
405
+ if (datasets.length === 0) {
406
+ var boxplotData = labels.map(function(label) {
407
+ var dataPoint = filteredData.find(function(item) {
408
+ return item.label === label;
409
+ });
410
+ if (!dataPoint || !dataPoint.values || dataPoint.values.length === 0) {
411
+ return null;
412
+ }
413
+ var stats = calculateBoxPlotStats(dataPoint.values);
414
+ return _object_spread({
415
+ min: stats.min,
416
+ q1: stats.q1,
417
+ median: stats.median,
418
+ q3: stats.q3,
419
+ max: stats.max,
420
+ mean: stats.mean
421
+ }, showOutliers && stats.outliers.length > 0 ? {
422
+ outliers: stats.outliers
423
+ } : {});
424
+ });
425
+ var resolvedColor = resolveCssVariable(defaultColorList[0]);
426
+ datasets.push({
427
+ label: '默认',
428
+ data: boxplotData,
429
+ backgroundColor: hexToRgba(resolvedColor, 0.5),
430
+ borderColor: resolvedColor,
431
+ borderWidth: 1,
432
+ outlierColor: hexToRgba(resolvedColor, 0.8),
433
+ padding: 10,
434
+ itemRadius: showOutliers ? 3 : 0
435
+ });
436
+ }
437
+ return {
438
+ labels: labels,
439
+ datasets: datasets
440
+ };
441
+ }, [
442
+ filteredData,
443
+ types,
444
+ labels,
445
+ color,
446
+ showOutliers
447
+ ]);
448
+ var isLight = theme === 'light';
449
+ var axisTextColor = isLight ? 'rgba(0, 25, 61, 0.3255)' : 'rgba(255, 255, 255, 0.8)';
450
+ var gridColor = isLight ? 'rgba(0,0,0,0.08)' : 'rgba(255,255,255,0.2)';
451
+ // 图表配置选项
452
+ var options = {
453
+ responsive: true,
454
+ maintainAspectRatio: false,
455
+ plugins: {
456
+ legend: {
457
+ display: showLegend && types.length > 1,
458
+ position: legendPosition,
459
+ labels: {
460
+ color: axisTextColor,
461
+ font: {
462
+ size: isMobile ? 10 : 12,
463
+ weight: 'normal'
464
+ },
465
+ padding: isMobile ? 10 : 12,
466
+ usePointStyle: true,
467
+ pointStyle: 'rectRounded'
468
+ }
469
+ },
470
+ tooltip: {
471
+ backgroundColor: isLight ? 'rgba(255,255,255,0.95)' : 'rgba(0,0,0,0.85)',
472
+ titleColor: isLight ? '#333' : '#fff',
473
+ bodyColor: isLight ? '#333' : '#fff',
474
+ borderColor: isLight ? 'rgba(0,0,0,0.12)' : 'rgba(255,255,255,0.2)',
475
+ borderWidth: 1,
476
+ cornerRadius: isMobile ? 6 : 8,
477
+ displayColors: true,
478
+ callbacks: {
479
+ label: function label(context) {
480
+ var _ref, _ref1, _ref2, _ref3, _ref4;
481
+ var _raw_max, _raw_q3, _raw_median, _raw_q1, _raw_min;
482
+ var raw = context.raw;
483
+ if (!raw) return '';
484
+ var lines = [
485
+ "最大值: ".concat((_ref = (_raw_max = raw.max) === null || _raw_max === void 0 ? void 0 : _raw_max.toFixed(2)) !== null && _ref !== void 0 ? _ref : '-'),
486
+ "Q3: ".concat((_ref1 = (_raw_q3 = raw.q3) === null || _raw_q3 === void 0 ? void 0 : _raw_q3.toFixed(2)) !== null && _ref1 !== void 0 ? _ref1 : '-'),
487
+ "中位数: ".concat((_ref2 = (_raw_median = raw.median) === null || _raw_median === void 0 ? void 0 : _raw_median.toFixed(2)) !== null && _ref2 !== void 0 ? _ref2 : '-'),
488
+ "Q1: ".concat((_ref3 = (_raw_q1 = raw.q1) === null || _raw_q1 === void 0 ? void 0 : _raw_q1.toFixed(2)) !== null && _ref3 !== void 0 ? _ref3 : '-'),
489
+ "最小值: ".concat((_ref4 = (_raw_min = raw.min) === null || _raw_min === void 0 ? void 0 : _raw_min.toFixed(2)) !== null && _ref4 !== void 0 ? _ref4 : '-')
490
+ ];
491
+ if (raw.mean !== undefined) {
492
+ lines.push("均值: ".concat(raw.mean.toFixed(2)));
493
+ }
494
+ return lines;
495
+ }
496
+ }
497
+ }
498
+ },
499
+ scales: {
500
+ x: {
501
+ display: true,
502
+ title: {
503
+ display: !!xAxisLabel,
504
+ text: xAxisLabel || '',
505
+ color: axisTextColor,
506
+ font: {
507
+ size: isMobile ? 10 : 12,
508
+ weight: 'normal'
509
+ }
510
+ },
511
+ grid: {
512
+ display: showGrid,
513
+ color: gridColor,
514
+ lineWidth: 1
515
+ },
516
+ ticks: {
517
+ color: axisTextColor,
518
+ font: {
519
+ size: isMobile ? 10 : 12
520
+ }
521
+ }
522
+ },
523
+ y: {
524
+ display: true,
525
+ title: {
526
+ display: !!yAxisLabel,
527
+ text: yAxisLabel || '',
528
+ color: axisTextColor,
529
+ font: {
530
+ size: isMobile ? 10 : 12,
531
+ weight: 'normal'
532
+ }
533
+ },
534
+ grid: {
535
+ display: showGrid,
536
+ color: gridColor,
537
+ lineWidth: 1
538
+ },
539
+ ticks: {
540
+ color: axisTextColor,
541
+ font: {
542
+ size: isMobile ? 10 : 12
543
+ }
544
+ }
545
+ }
546
+ },
547
+ animation: {
548
+ duration: isMobile ? 200 : 400
549
+ }
550
+ };
551
+ var handleDownload = function handleDownload() {
552
+ downloadChart(chartRef.current, 'boxplot-chart');
553
+ };
554
+ // 筛选器选项
555
+ var filterOptions = useMemo(function() {
556
+ return categories.map(function(category) {
557
+ return {
558
+ label: category || '默认',
559
+ value: category || '默认'
560
+ };
561
+ });
562
+ }, [
563
+ categories
564
+ ]);
565
+ var filteredDataByFilterLabel = useMemo(function() {
566
+ return filterLabels === null || filterLabels === void 0 ? void 0 : filterLabels.map(function(item) {
567
+ return {
568
+ key: item,
569
+ label: item
570
+ };
571
+ });
572
+ }, [
573
+ filterLabels
574
+ ]);
575
+ // 空数据处理
576
+ if (safeData.length === 0 || labels.length === 0) {
577
+ return wrapSSR(/*#__PURE__*/ React.createElement(ChartContainer, {
578
+ baseClassName: classNames("".concat(prefixCls, "-container"), hashId),
579
+ theme: theme,
580
+ className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.root, className),
581
+ isMobile: isMobile,
582
+ variant: props.variant,
583
+ style: _object_spread({
584
+ width: responsiveWidth,
585
+ height: responsiveHeight
586
+ }, style, styles === null || styles === void 0 ? void 0 : styles.root)
587
+ }, /*#__PURE__*/ React.createElement(ChartToolBar, {
588
+ title: title || '箱线图',
589
+ onDownload: function onDownload() {},
590
+ extra: toolbarExtra,
591
+ dataTime: dataTime,
592
+ loading: loading
593
+ }), /*#__PURE__*/ React.createElement("div", {
594
+ className: classNames("".concat(prefixCls, "-empty-wrapper"), hashId),
595
+ style: {
596
+ display: 'flex',
597
+ alignItems: 'center',
598
+ justifyContent: 'center',
599
+ height: responsiveHeight,
600
+ color: '#999',
601
+ fontSize: '14px'
602
+ }
603
+ }, "暂无有效数据")));
604
+ }
605
+ return wrapSSR(/*#__PURE__*/ React.createElement(ChartContainer, {
606
+ baseClassName: classNames("".concat(prefixCls, "-container"), hashId),
607
+ theme: theme,
608
+ className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.root, className),
609
+ isMobile: isMobile,
610
+ variant: props.variant,
611
+ style: _object_spread({
612
+ width: responsiveWidth,
613
+ height: responsiveHeight
614
+ }, style, styles === null || styles === void 0 ? void 0 : styles.root)
615
+ }, /*#__PURE__*/ React.createElement(ChartToolBar, {
616
+ title: title || '箱线图',
617
+ theme: theme,
618
+ onDownload: handleDownload,
619
+ extra: toolbarExtra,
620
+ dataTime: dataTime,
621
+ loading: loading,
622
+ filter: renderFilterInToolbar && filterOptions.length > 1 ? /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
623
+ filterOptions: filterOptions,
624
+ selectedFilter: selectedFilter,
625
+ onFilterChange: setSelectedFilter
626
+ }, filterLabels && {
627
+ customOptions: filteredDataByFilterLabel,
628
+ selectedCustomSelection: selectedFilterLabel,
629
+ onSelectionChange: setSelectedFilterLabel
630
+ }), {
631
+ theme: theme,
632
+ variant: "compact"
633
+ })) : undefined
634
+ }), statistics && /*#__PURE__*/ React.createElement("div", {
635
+ className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.statisticContainer, "".concat(prefixCls, "-statistic-container")),
636
+ style: styles === null || styles === void 0 ? void 0 : styles.statisticContainer
637
+ }, statistics.map(function(config, index) {
638
+ return /*#__PURE__*/ React.createElement(ChartStatistic, _object_spread_props(_object_spread({
639
+ key: index
640
+ }, config), {
641
+ theme: theme
642
+ }));
643
+ })), !renderFilterInToolbar && filterOptions.length > 1 && /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
644
+ filterOptions: filterOptions,
645
+ selectedFilter: selectedFilter,
646
+ onFilterChange: setSelectedFilter
647
+ }, filterLabels && {
648
+ customOptions: filteredDataByFilterLabel,
649
+ selectedCustomSelection: selectedFilterLabel,
650
+ onSelectionChange: setSelectedFilterLabel
651
+ }), {
652
+ theme: theme
653
+ })), /*#__PURE__*/ React.createElement("div", {
654
+ className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.wrapper, "".concat(prefixCls, "-wrapper")),
655
+ style: _object_spread({
656
+ height: responsiveHeight
657
+ }, styles === null || styles === void 0 ? void 0 : styles.wrapper)
658
+ }, /*#__PURE__*/ React.createElement(Chart, {
659
+ ref: chartRef,
660
+ type: "boxplot",
661
+ data: processedData,
662
+ options: options
663
+ }))));
664
+ };
665
+ export default BoxPlotChart;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare function useStyle(prefixCls?: string): {
3
+ hashId: string;
4
+ wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
5
+ } | {
6
+ wrapSSR: (node: any) => any;
7
+ hashId: string;
8
+ };