@ant-design/agentic-ui 2.30.2 → 2.30.4

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 (55) 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/CharacterQueue.js +9 -1
  5. package/dist/MarkdownRenderer/MarkdownRenderer.js +11 -3
  6. package/dist/MarkdownRenderer/types.d.ts +6 -0
  7. package/dist/MarkdownRenderer/useMarkdownToReact.js +3 -1
  8. package/dist/Plugins/chart/AreaChart/index.js +4 -3
  9. package/dist/Plugins/chart/BarChart/index.js +3 -3
  10. package/dist/Plugins/chart/BoxPlotChart/index.d.ts +65 -0
  11. package/dist/Plugins/chart/BoxPlotChart/index.js +665 -0
  12. package/dist/Plugins/chart/BoxPlotChart/style.d.ts +8 -0
  13. package/dist/Plugins/chart/BoxPlotChart/style.js +118 -0
  14. package/dist/Plugins/chart/ChartAttrToolBar/index.js +5 -16
  15. package/dist/Plugins/chart/ChartMark/Area.d.ts +2 -1
  16. package/dist/Plugins/chart/ChartMark/Area.js +5 -4
  17. package/dist/Plugins/chart/ChartMark/Bar.d.ts +2 -1
  18. package/dist/Plugins/chart/ChartMark/Bar.js +5 -4
  19. package/dist/Plugins/chart/ChartMark/Column.d.ts +2 -1
  20. package/dist/Plugins/chart/ChartMark/Column.js +5 -4
  21. package/dist/Plugins/chart/ChartMark/Line.d.ts +2 -1
  22. package/dist/Plugins/chart/ChartMark/Line.js +5 -4
  23. package/dist/Plugins/chart/ChartMark/Pie.d.ts +2 -1
  24. package/dist/Plugins/chart/ChartMark/Pie.js +5 -4
  25. package/dist/Plugins/chart/ChartRender.d.ts +1 -1
  26. package/dist/Plugins/chart/ChartRender.js +188 -12
  27. package/dist/Plugins/chart/DonutChart/Legend.d.ts +5 -3
  28. package/dist/Plugins/chart/DonutChart/Legend.js +30 -38
  29. package/dist/Plugins/chart/DonutChart/index.js +82 -23
  30. package/dist/Plugins/chart/DonutChart/plugins.d.ts +2 -2
  31. package/dist/Plugins/chart/DonutChart/plugins.js +5 -5
  32. package/dist/Plugins/chart/DonutChart/types.d.ts +2 -0
  33. package/dist/Plugins/chart/FunnelChart/index.js +24 -14
  34. package/dist/Plugins/chart/HistogramChart/index.d.ts +65 -0
  35. package/dist/Plugins/chart/HistogramChart/index.js +665 -0
  36. package/dist/Plugins/chart/HistogramChart/style.d.ts +8 -0
  37. package/dist/Plugins/chart/HistogramChart/style.js +118 -0
  38. package/dist/Plugins/chart/LineChart/index.js +4 -3
  39. package/dist/Plugins/chart/RadarChart/index.d.ts +2 -0
  40. package/dist/Plugins/chart/RadarChart/index.js +28 -26
  41. package/dist/Plugins/chart/ScatterChart/index.d.ts +2 -0
  42. package/dist/Plugins/chart/ScatterChart/index.js +43 -28
  43. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.d.ts +1 -0
  44. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +14 -0
  45. package/dist/Plugins/chart/components/ChartContainer/ChartDarkAntdContext.d.ts +7 -0
  46. package/dist/Plugins/chart/components/ChartContainer/ChartDarkAntdContext.js +8 -0
  47. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +8 -2
  48. package/dist/Plugins/chart/components/ChartContainer/style.js +3 -3
  49. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.d.ts +2 -0
  50. package/dist/Plugins/chart/components/ChartToolBar/ChartToolBar.js +23 -32
  51. package/dist/Plugins/chart/index.d.ts +4 -0
  52. package/dist/Plugins/chart/index.js +2 -0
  53. package/dist/Plugins/chart/loadChartRuntime.d.ts +4 -0
  54. package/dist/Plugins/chart/loadChartRuntime.js +5 -1
  55. package/package.json +2 -1
@@ -154,10 +154,11 @@ import { useLocale } from "../../../I18n";
154
154
  import { ChartContainer, ChartFilter, ChartStatistic, ChartToolBar, downloadChart } from "../components";
155
155
  import { defaultColorList } from "../const";
156
156
  import { isWindowDefined } from "../env";
157
+ import { useChartTheme } from "../hooks";
157
158
  import { resolveCssVariable } from "../utils";
158
159
  import { SINGLE_MODE_DESKTOP_CUTOUT, SINGLE_MODE_MOBILE_CUTOUT } from "./constants";
159
160
  import { useAutoCategory, useFilterLabels, useMobile, useResponsiveDimensions } from "./hooks";
160
- import LegendView from "./Legend";
161
+ import DonutChartLegend from "./Legend";
161
162
  import { createBackgroundArcPlugin, createCenterTextPlugin, createDataLabelsLeaderLinePlugin } from "./plugins";
162
163
  import { useStyle } from "./style";
163
164
  /**
@@ -198,7 +199,7 @@ import { useStyle } from "./style";
198
199
  *
199
200
  * @since 1.0.0
200
201
  */ var DonutChart = function DonutChart(_0) {
201
- var data = _0.data, configs = _0.configs, _0_width = _0.width, width = _0_width === void 0 ? 200 : _0_width, _0_height = _0.height, height = _0_height === void 0 ? 200 : _0_height, className = _0.className, classNamesProp = _0.classNames, title = _0.title, _0_showToolbar = _0.showToolbar, showToolbar = _0_showToolbar === void 0 ? true : _0_showToolbar, onDownload = _0.onDownload, dataTime = _0.dataTime, filterList = _0.filterList, selectedFilter = _0.selectedFilter, onFilterChange = _0.onFilterChange, _0_enableAutoCategory = _0.enableAutoCategory, enableAutoCategory = _0_enableAutoCategory === void 0 ? true : _0_enableAutoCategory, _0_singleMode = _0.singleMode, singleMode = _0_singleMode === void 0 ? false : _0_singleMode, 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, [
202
+ var data = _0.data, configs = _0.configs, _0_width = _0.width, width = _0_width === void 0 ? 200 : _0_width, _0_height = _0.height, height = _0_height === void 0 ? 200 : _0_height, className = _0.className, classNamesProp = _0.classNames, title = _0.title, _0_showToolbar = _0.showToolbar, showToolbar = _0_showToolbar === void 0 ? true : _0_showToolbar, onDownload = _0.onDownload, _0_theme = _0.theme, theme = _0_theme === void 0 ? 'light' : _0_theme, dataTime = _0.dataTime, filterList = _0.filterList, selectedFilter = _0.selectedFilter, onFilterChange = _0.onFilterChange, _0_enableAutoCategory = _0.enableAutoCategory, enableAutoCategory = _0_enableAutoCategory === void 0 ? true : _0_enableAutoCategory, _0_singleMode = _0.singleMode, singleMode = _0_singleMode === void 0 ? false : _0_singleMode, 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, [
202
203
  "data",
203
204
  "configs",
204
205
  "width",
@@ -208,6 +209,7 @@ import { useStyle } from "./style";
208
209
  "title",
209
210
  "showToolbar",
210
211
  "onDownload",
212
+ "theme",
211
213
  "dataTime",
212
214
  "filterList",
213
215
  "selectedFilter",
@@ -219,7 +221,7 @@ import { useStyle } from "./style";
219
221
  "statistic",
220
222
  "loading"
221
223
  ]);
222
- var _finalConfigs_, _props_styles;
224
+ var _props_styles;
223
225
  useMemo(function() {
224
226
  if (donutChartComponentsRegistered) {
225
227
  return undefined;
@@ -233,6 +235,8 @@ import { useStyle } from "./style";
233
235
  }, []);
234
236
  var _useMobile = useMobile(), isMobile = _useMobile.isMobile, windowWidth = _useMobile.windowWidth;
235
237
  var locale = useLocale();
238
+ // 使用 useChartTheme hook 获取主题相关颜色
239
+ var isLight = useChartTheme(theme).isLight;
236
240
  // 默认配置:当 configs 不传时,使用默认配置,showLegend 默认为 true
237
241
  var defaultConfigs = [
238
242
  {
@@ -371,7 +375,8 @@ import { useStyle } from "./style";
371
375
  var finalFilterList = filterList || (autoCategoryData ? autoCategoryData.categories : []);
372
376
  var finalSelectedFilter = selectedFilter || internalSelectedCategory;
373
377
  var finalOnFilterChange = onFilterChange || handleInternalCategoryChange;
374
- var chartFilterTheme = ((_finalConfigs_ = finalConfigs[0]) === null || _finalConfigs_ === void 0 ? void 0 : _finalConfigs_.theme) || 'light';
378
+ // 使用组件级别的 theme prop,而不是从 configs 中获取
379
+ var chartFilterTheme = theme;
375
380
  var dimensions = useResponsiveDimensions(isMobile, windowWidth, width, height);
376
381
  var renderConfigs = singleMode && !configs ? Array.from({
377
382
  length: filteredData.length
@@ -389,12 +394,17 @@ import { useStyle } from "./style";
389
394
  baseClassName: baseClassName,
390
395
  className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.root, className),
391
396
  variant: props.variant,
397
+ theme: theme,
398
+ isMobile: isMobile,
392
399
  style: _object_spread(_define_property({}, '--donut-item-min-width', "".concat(dimensions.width, "px")), props.style, (_props_styles = props.styles) === null || _props_styles === void 0 ? void 0 : _props_styles.root)
393
400
  }, showToolbar && /*#__PURE__*/ React.createElement(ChartContainer, {
394
401
  baseClassName: "".concat(baseClassName, "-toolbar-wrapper"),
395
- variant: "borderless"
402
+ variant: "borderless",
403
+ theme: theme,
404
+ isMobile: isMobile
396
405
  }, title && /*#__PURE__*/ React.createElement(ChartToolBar, {
397
406
  title: title,
407
+ theme: chartFilterTheme,
398
408
  onDownload: handleDownload,
399
409
  extra: toolbarExtra,
400
410
  dataTime: dataTime,
@@ -444,7 +454,9 @@ import { useStyle } from "./style";
444
454
  theme: chartFilterTheme
445
455
  }))), /*#__PURE__*/ React.createElement(ChartContainer, {
446
456
  baseClassName: "".concat(baseClassName, "-content"),
447
- variant: "borderless"
457
+ variant: "borderless",
458
+ theme: theme,
459
+ isMobile: isMobile
448
460
  }, renderConfigs.map(function(cfg, idx) {
449
461
  var _ref;
450
462
  var _cfg_backgroundColor;
@@ -492,6 +504,51 @@ import { useStyle } from "./style";
492
504
  });
493
505
  var mainColor = (_ref = (_cfg_backgroundColor = cfg.backgroundColor) === null || _cfg_backgroundColor === void 0 ? void 0 : _cfg_backgroundColor[0]) !== null && _ref !== void 0 ? _ref : defaultColorList[idx % defaultColorList.length];
494
506
  var resolvedMainColor = resolveCssVariable(mainColor);
507
+ var isDarkTheme = !isLight;
508
+ /** 与 ChartContainer 暗色底一致,扇区描边融进背景,避免亮白描边突兀 */ var donutDarkSegmentBorder = '#1f1f1f';
509
+ var donutDarkSegmentBorderHover = 'rgba(255, 255, 255, 0.14)';
510
+ var chartBorderColor = function() {
511
+ if (isSingleValueMode) {
512
+ if (isDarkTheme) {
513
+ return [
514
+ cfg.borderColor || 'rgba(255, 255, 255, 0.14)',
515
+ 'transparent'
516
+ ];
517
+ }
518
+ return [
519
+ cfg.borderColor || '#fff',
520
+ 'transparent'
521
+ ];
522
+ }
523
+ if (cfg.chartStyle === 'pie') {
524
+ return cfg.borderColor || '#fff';
525
+ }
526
+ if (isDarkTheme) {
527
+ return donutDarkSegmentBorder;
528
+ }
529
+ return cfg.borderColor || '#fff';
530
+ }();
531
+ var chartHoverBorderColor = function() {
532
+ if (isSingleValueMode) {
533
+ if (isDarkTheme) {
534
+ return [
535
+ cfg.borderColor || 'rgba(255, 255, 255, 0.22)',
536
+ 'transparent'
537
+ ];
538
+ }
539
+ return [
540
+ cfg.borderColor || '#fff',
541
+ 'transparent'
542
+ ];
543
+ }
544
+ if (cfg.chartStyle === 'pie') {
545
+ return cfg.borderColor || '#fff';
546
+ }
547
+ if (isDarkTheme) {
548
+ return donutDarkSegmentBorderHover;
549
+ }
550
+ return cfg.borderColor || '#fff';
551
+ }();
495
552
  var chartJsData = {
496
553
  labels: labels,
497
554
  datasets: [
@@ -501,20 +558,14 @@ import { useStyle } from "./style";
501
558
  resolvedMainColor,
502
559
  'transparent'
503
560
  ] : resolvedBackgroundColors.slice(0, values.length),
504
- borderColor: isSingleValueMode ? [
505
- cfg.borderColor || '#fff',
506
- 'transparent'
507
- ] : cfg.borderColor || '#fff',
561
+ borderColor: chartBorderColor,
508
562
  hoverBackgroundColor: isSingleValueMode ? [
509
563
  resolvedMainColor,
510
564
  'transparent'
511
565
  ] : resolvedBackgroundColors.slice(0, values.length),
512
- hoverBorderColor: isSingleValueMode ? [
513
- cfg.borderColor || '#fff',
514
- 'transparent'
515
- ] : cfg.borderColor || '#fff',
566
+ hoverBorderColor: chartHoverBorderColor,
516
567
  borderWidth: cfg.chartStyle === 'pie' ? 0 : isMobile ? 1 : 1,
517
- spacing: isSingleValueMode ? 0 : cfg.chartStyle === 'pie' ? 0 : isMobile ? 3 : 6,
568
+ spacing: isSingleValueMode ? 0 : cfg.chartStyle === 'pie' ? 0 : isDarkTheme ? isMobile ? 4 : 8 : isMobile ? 3 : 6,
518
569
  borderRadius: cfg.chartStyle === 'pie' ? 0 : 4,
519
570
  hoverOffset: function hoverOffset(ctx) {
520
571
  return isSingleValueMode && (ctx === null || ctx === void 0 ? void 0 : ctx.dataIndex) === 1 ? 0 : isMobile ? 4 : 6;
@@ -536,7 +587,6 @@ import { useStyle } from "./style";
536
587
  }
537
588
  return (_cfg_cutout = cfg.cutout) !== null && _cfg_cutout !== void 0 ? _cfg_cutout : isSingleValueMode ? SINGLE_MODE_DESKTOP_CUTOUT : '75%';
538
589
  }();
539
- var isDarkTheme = cfg.theme === 'dark';
540
590
  var tooltipBackgroundColor = isDarkTheme ? '#1F2937' : '#FFFFFF';
541
591
  var tooltipBorderColor = isDarkTheme ? '#374151' : '#E5E7EB';
542
592
  var tooltipTitleColor = isDarkTheme ? '#F9FAFB' : '#111827';
@@ -617,7 +667,7 @@ import { useStyle } from "./style";
617
667
  var labelStr = label !== undefined && label !== null ? String(label) : '';
618
668
  return labelStr ? "".concat(labelStr, ": ").concat(pct, "%") : "".concat(value, " (").concat(pct, "%)");
619
669
  },
620
- color: isDarkTheme ? '#fff' : '#343A45',
670
+ color: isDarkTheme ? '#F9FAFB' : '#343A45',
621
671
  font: {
622
672
  size: isMobile ? 10 : 11,
623
673
  weight: 'normal'
@@ -634,10 +684,14 @@ import { useStyle } from "./style";
634
684
  return /*#__PURE__*/ React.createElement(ChartContainer, {
635
685
  key: idx,
636
686
  baseClassName: "".concat(baseClassName, "-chart-wrapper"),
637
- variant: "borderless"
687
+ variant: "borderless",
688
+ theme: theme,
689
+ isMobile: isMobile
638
690
  }, isSingleValueMode ? /*#__PURE__*/ React.createElement(ChartContainer, {
639
691
  baseClassName: "".concat(baseClassName, "-single"),
640
692
  variant: "borderless",
693
+ theme: theme,
694
+ isMobile: isMobile,
641
695
  style: _object_spread((_obj = {}, _define_property(_obj, '--donut-chart-height', "".concat(dimensions.height, "px")), _define_property(_obj, '--donut-chart-width', "".concat(dimensions.width, "px")), _define_property(_obj, "width", dimensions.width), _define_property(_obj, "height", dimensions.height), _define_property(_obj, "marginTop", '20px'), _obj), isMobile ? {
642
696
  margin: '0 auto'
643
697
  } : {})
@@ -649,12 +703,14 @@ import { useStyle } from "./style";
649
703
  options: options,
650
704
  plugins: // 只有环形图才显示中心文本和背景
651
705
  _to_consumable_array(cfg.chartStyle !== 'pie' ? [
652
- createCenterTextPlugin((typeof currentDataItem.value === 'number' ? currentDataItem.value : Number(currentDataItem.value)) / (total || 1) * 100, currentDataItem.label, isMobile),
653
- createBackgroundArcPlugin()
706
+ createCenterTextPlugin((typeof currentDataItem.value === 'number' ? currentDataItem.value : Number(currentDataItem.value)) / (total || 1) * 100, currentDataItem.label, isMobile, isDarkTheme),
707
+ createBackgroundArcPlugin(isDarkTheme ? 'rgba(255, 255, 255, 0.08)' : '#F7F8F9')
654
708
  ] : [])
655
709
  })) : /*#__PURE__*/ React.createElement(ChartContainer, {
656
710
  baseClassName: "".concat(baseClassName, "-row"),
657
711
  variant: "borderless",
712
+ theme: theme,
713
+ isMobile: isMobile,
658
714
  style: _object_spread({}, isMobile ? {
659
715
  flexDirection: 'column',
660
716
  alignItems: 'stretch'
@@ -662,6 +718,8 @@ import { useStyle } from "./style";
662
718
  }, /*#__PURE__*/ React.createElement(ChartContainer, {
663
719
  baseClassName: "".concat(baseClassName, "-chart"),
664
720
  variant: "borderless",
721
+ theme: theme,
722
+ isMobile: isMobile,
665
723
  style: (_obj1 = {}, _define_property(_obj1, '--donut-chart-width', "".concat(dimensions.chartWidth, "px")), _define_property(_obj1, '--donut-chart-height', "".concat(dimensions.chartHeight, "px")), _define_property(_obj1, "width", dimensions.chartWidth), _define_property(_obj1, "height", dimensions.chartHeight), _define_property(_obj1, "marginTop", '20px'), _obj1)
666
724
  }, /*#__PURE__*/ React.createElement(Doughnut, {
667
725
  ref: function ref(instance) {
@@ -670,10 +728,10 @@ import { useStyle } from "./style";
670
728
  data: chartJsData,
671
729
  options: optionsWithDataLabels,
672
730
  plugins: cfg.showDataLabels === true && !isSingleValueMode ? [
673
- createDataLabelsLeaderLinePlugin(dataLabelOffset),
731
+ createDataLabelsLeaderLinePlugin(dataLabelOffset, isDarkTheme),
674
732
  ChartDataLabels
675
733
  ] : []
676
- })), cfg.showLegend && /*#__PURE__*/ React.createElement(LegendView, {
734
+ })), cfg.showLegend && /*#__PURE__*/ React.createElement(DonutChartLegend, {
677
735
  chartData: chartData,
678
736
  backgroundColors: chartData.map(function(_, i) {
679
737
  return backgroundColors[i % backgroundColors.length];
@@ -686,7 +744,8 @@ import { useStyle } from "./style";
686
744
  total: total,
687
745
  baseClassName: baseClassName,
688
746
  hashId: hashId,
689
- isMobile: isMobile
747
+ isMobile: isMobile,
748
+ theme: theme
690
749
  })));
691
750
  })));
692
751
  };
@@ -3,6 +3,6 @@ import { Plugin } from 'chart.js';
3
3
  * 数据标签指示线插件:仅在会展示数据标签的扇区上绘制线(与 datalabels display 逻辑一致,避免无线无文案)。
4
4
  * 传入的 lineLength 应与 options.plugins.datalabels.offset 一致。
5
5
  */
6
- export declare const createDataLabelsLeaderLinePlugin: (lineLength?: number) => Plugin<'doughnut'>;
7
- export declare const createCenterTextPlugin: (value: number, label: string, isMobile?: boolean) => Plugin<'doughnut'>;
6
+ export declare const createDataLabelsLeaderLinePlugin: (lineLength?: number, darkMode?: boolean) => Plugin<'doughnut'>;
7
+ export declare const createCenterTextPlugin: (value: number, label: string, isMobile?: boolean, darkMode?: boolean) => Plugin<'doughnut'>;
8
8
  export declare const createBackgroundArcPlugin: (bgColor?: string, padding?: number) => Plugin<'doughnut'>;
@@ -5,7 +5,7 @@
5
5
  * 数据标签指示线插件:仅在会展示数据标签的扇区上绘制线(与 datalabels display 逻辑一致,避免无线无文案)。
6
6
  * 传入的 lineLength 应与 options.plugins.datalabels.offset 一致。
7
7
  */ export var createDataLabelsLeaderLinePlugin = function createDataLabelsLeaderLinePlugin() {
8
- var lineLength = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_LEADER_LINE_PX;
8
+ var lineLength = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_LEADER_LINE_PX, darkMode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
9
9
  return {
10
10
  id: 'datalabelsLeaderLine',
11
11
  afterDatasetDraw: function afterDatasetDraw(chart, args) {
@@ -20,7 +20,7 @@
20
20
  }, 0);
21
21
  if (total <= 0) return;
22
22
  ctx.save();
23
- ctx.strokeStyle = 'rgba(0, 25, 61, 0.16)';
23
+ ctx.strokeStyle = darkMode ? 'rgba(255, 255, 255, 0.22)' : 'rgba(0, 25, 61, 0.16)';
24
24
  ctx.lineWidth = 1;
25
25
  meta.data.forEach(function(element, i) {
26
26
  var val = Number(values[i]);
@@ -47,7 +47,7 @@
47
47
  };
48
48
  };
49
49
  export var createCenterTextPlugin = function createCenterTextPlugin(value, label) {
50
- var isMobile = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
50
+ var isMobile = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false, darkMode = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
51
51
  return {
52
52
  id: 'centerText',
53
53
  beforeDraw: function beforeDraw(chart) {
@@ -59,13 +59,13 @@ export var createCenterTextPlugin = function createCenterTextPlugin(value, label
59
59
  var labelFontSize = isMobile ? 10 : 12; // px
60
60
  // value 优先使用 Rubik
61
61
  ctx.font = "".concat(isMobile ? '400' : '500', " ").concat(percentFontSize, "px 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif");
62
- ctx.fillStyle = '#343A45';
62
+ ctx.fillStyle = darkMode ? 'rgba(255, 255, 255, 0.92)' : '#343A45';
63
63
  ctx.textAlign = 'center';
64
64
  ctx.textBaseline = 'middle';
65
65
  ctx.fillText("".concat(value, "%"), centerX, centerY - labelFontSize * 0.8);
66
66
  // label 优先使用 PingFang SC
67
67
  ctx.font = "300 ".concat(labelFontSize, "px 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif");
68
- ctx.fillStyle = '#767E8B';
68
+ ctx.fillStyle = darkMode ? 'rgba(255, 255, 255, 0.55)' : '#767E8B';
69
69
  ctx.fillText(label, centerX, centerY + labelFontSize * 0.6);
70
70
  ctx.restore();
71
71
  }
@@ -33,6 +33,8 @@ export interface DonutChartProps extends ChartContainerProps {
33
33
  title?: string;
34
34
  showToolbar?: boolean;
35
35
  onDownload?: () => void;
36
+ /** 图表主题 */
37
+ theme?: 'light' | 'dark';
36
38
  /** 数据时间 */
37
39
  dataTime?: string;
38
40
  /** 筛选项列表,不传时不显示筛选器 */
@@ -152,6 +152,7 @@ import { Bar } from "react-chartjs-2";
152
152
  import ChartStatistic from "../ChartStatistic";
153
153
  import { ChartContainer, ChartFilter, ChartToolBar, downloadChart } from "../components";
154
154
  import { defaultColorList } from "../const";
155
+ import { useChartTheme } from "../hooks";
155
156
  import { findDataPointByXValue, isXValueEqual, resolveCssVariable, toNumber } from "../utils";
156
157
  import { useStyle } from "./style";
157
158
  var funnelChartComponentsRegistered = false;
@@ -508,8 +509,8 @@ var FunnelChart = function FunnelChart(_0) {
508
509
  }, [
509
510
  filterLabels
510
511
  ]);
511
- var isLight = theme === 'light';
512
- var axisTextColor = isLight ? 'rgba(0, 25, 61, 0.3255)' : 'rgba(255, 255, 255, 0.8)';
512
+ // 使用 useChartTheme hook 获取主题相关颜色
513
+ var _useChartTheme = useChartTheme(theme), axisTextColor = _useChartTheme.axisTextColor, isLight = _useChartTheme.isLight;
513
514
  var options = {
514
515
  responsive: true,
515
516
  maintainAspectRatio: false,
@@ -561,11 +562,12 @@ var FunnelChart = function FunnelChart(_0) {
561
562
  return true;
562
563
  });
563
564
  if (!anyNonTopProvided) return base;
565
+ var trapezoidLegendFill = isLight ? '#F1F2F4' : 'rgba(255, 255, 255, 0.3)';
564
566
  return _to_consumable_array(base).concat([
565
567
  {
566
568
  text: (typeNames === null || typeNames === void 0 ? void 0 : typeNames.rate) || '转化率',
567
- fillStyle: '#F1F2F4',
568
- strokeStyle: '#F1F2F4',
569
+ fillStyle: trapezoidLegendFill,
570
+ strokeStyle: trapezoidLegendFill,
569
571
  lineWidth: 0,
570
572
  hidden: !showTrapezoid,
571
573
  datasetIndex: chart.data.datasets.length,
@@ -723,12 +725,17 @@ var FunnelChart = function FunnelChart(_0) {
723
725
  ctx.lineTo(botR, botY);
724
726
  ctx.lineTo(botL, botY);
725
727
  ctx.closePath();
726
- ctx.fillStyle = '#F1F2F4';
728
+ ctx.fillStyle = isLight ? '#F1F2F4' : 'rgba(255, 255, 255, 0.28)';
727
729
  ctx.fill();
730
+ if (!isLight) {
731
+ ctx.strokeStyle = 'rgba(255, 255, 255, 0.16)';
732
+ ctx.lineWidth = 1;
733
+ ctx.stroke();
734
+ }
728
735
  // 文本(展示该比率)
729
736
  var midY = (topY + botY) / 2;
730
737
  var cx = centerX !== null && centerX !== void 0 ? centerX : (Math.min(topL, botL) + Math.max(topR, botR)) / 2;
731
- ctx.fillStyle = '#626F86';
738
+ ctx.fillStyle = isLight ? '#626F86' : 'rgba(255, 255, 255, 0.95)';
732
739
  ctx.font = "".concat(isMobile ? 10 : 12, "px sans-serif");
733
740
  ctx.textAlign = 'center';
734
741
  ctx.textBaseline = 'middle';
@@ -738,6 +745,7 @@ var FunnelChart = function FunnelChart(_0) {
738
745
  }
739
746
  };
740
747
  }, [
748
+ isLight,
741
749
  isMobile,
742
750
  showTrapezoid,
743
751
  JSON.stringify(filteredData.map(function(d) {
@@ -756,11 +764,6 @@ var FunnelChart = function FunnelChart(_0) {
756
764
  if (!meta) return;
757
765
  var xScale = scales === null || scales === void 0 ? void 0 : scales.x;
758
766
  var labels = (data === null || data === void 0 ? void 0 : data.labels) || [];
759
- ctx.save();
760
- ctx.fillStyle = axisTextColor;
761
- ctx.font = "".concat(isMobile ? 10 : 12, "px sans-serif");
762
- ctx.textAlign = 'left';
763
- ctx.textBaseline = 'middle';
764
767
  var ds = (data === null || data === void 0 ? void 0 : (_data_datasets = data.datasets) === null || _data_datasets === void 0 ? void 0 : (_data_datasets_ = _data_datasets[0]) === null || _data_datasets_ === void 0 ? void 0 : _data_datasets_.data) || [];
765
768
  // 计算所有条末端的像素坐标,找最大值作为对齐基准
766
769
  var ends = meta.data.map(function(el, i) {
@@ -778,7 +781,13 @@ var FunnelChart = function FunnelChart(_0) {
778
781
  if (!raw || !Array.isArray(raw)) return;
779
782
  var y = el.y;
780
783
  var label = (_ref = labels === null || labels === void 0 ? void 0 : labels[i]) !== null && _ref !== void 0 ? _ref : '';
784
+ ctx.save();
785
+ ctx.fillStyle = axisTextColor;
786
+ ctx.font = "".concat(isMobile ? 10 : 12, "px sans-serif");
787
+ ctx.textAlign = 'left';
788
+ ctx.textBaseline = 'middle';
781
789
  ctx.fillText(label, maxEnd + padding, y);
790
+ ctx.restore();
782
791
  // 在柱体中心绘制数值文本(白色)- 使用原始值
783
792
  var start = Number((_raw_ = raw[0]) !== null && _raw_ !== void 0 ? _raw_ : 0);
784
793
  var end = Number((_raw_1 = raw[1]) !== null && _raw_1 !== void 0 ? _raw_1 : 0);
@@ -788,16 +797,17 @@ var FunnelChart = function FunnelChart(_0) {
788
797
  ctx.save();
789
798
  ctx.fillStyle = '#fff';
790
799
  ctx.textAlign = 'center';
800
+ ctx.textBaseline = 'middle';
791
801
  ctx.fillText(String(Math.round(originalValue)), cx, y);
792
802
  ctx.restore();
793
803
  });
794
- ctx.restore();
795
804
  }
796
805
  };
797
806
  }, [
798
807
  isMobile,
799
808
  axisTextColor,
800
- originalValues
809
+ originalValues,
810
+ theme
801
811
  ]);
802
812
  var containerClassName = useMemo(function() {
803
813
  if (isMobile) return 'w-full';
@@ -875,7 +885,7 @@ var FunnelChart = function FunnelChart(_0) {
875
885
  height: finalHeight
876
886
  }, (_props_styles3 = props.styles) === null || _props_styles3 === void 0 ? void 0 : _props_styles3.wrapper)
877
887
  }, /*#__PURE__*/ React.createElement(Bar, {
878
- key: "funnel-".concat(pluginToggleKey),
888
+ key: "funnel-".concat(theme, "-").concat(pluginToggleKey),
879
889
  ref: chartRef,
880
890
  data: processedData,
881
891
  options: options,
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { ChartContainerProps } from '../components';
3
+ import { StatisticConfigType } from '../hooks/useChartStatistic';
4
+ import type { ChartClassNames, ChartStyles } from '../types/classNames';
5
+ /**
6
+ * 直方图数据项接口
7
+ */
8
+ export interface HistogramChartDataItem {
9
+ /** 原始数据值 */
10
+ value: number;
11
+ /** 数据系列(用于分组显示) */
12
+ type?: string;
13
+ /** 分类(用于筛选) */
14
+ category?: string;
15
+ /** 筛选标签 */
16
+ filterLabel?: string;
17
+ }
18
+ export interface HistogramChartProps extends ChartContainerProps {
19
+ /** 扁平化数据数组 */
20
+ data: HistogramChartDataItem[];
21
+ /** 图表标题 */
22
+ title?: string;
23
+ /** 图表宽度,默认600px */
24
+ width?: number | string;
25
+ /** 图表高度,默认400px */
26
+ height?: number | string;
27
+ /** 自定义CSS类名 */
28
+ className?: string;
29
+ /** 自定义CSS类名(支持对象格式,为每层DOM设置类名) */
30
+ classNames?: ChartClassNames;
31
+ /** 数据时间 */
32
+ dataTime?: string;
33
+ /** 图表主题 */
34
+ theme?: 'dark' | 'light';
35
+ /** 自定义主色 */
36
+ color?: string | string[];
37
+ /** 是否显示图例,默认true */
38
+ showLegend?: boolean;
39
+ /** 图例位置 */
40
+ legendPosition?: 'top' | 'left' | 'bottom' | 'right';
41
+ /** 是否显示网格线,默认true */
42
+ showGrid?: boolean;
43
+ /** X轴标签 */
44
+ xAxisLabel?: string;
45
+ /** Y轴标签 */
46
+ yAxisLabel?: string;
47
+ /** 是否堆叠显示,默认true */
48
+ stacked?: boolean;
49
+ /** 自定义分箱数量(不设置则自动计算) */
50
+ binCount?: number;
51
+ /** 是否显示频率而非计数 */
52
+ showFrequency?: boolean;
53
+ /** 头部工具条额外按钮 */
54
+ toolbarExtra?: React.ReactNode;
55
+ /** 是否将过滤器渲染到工具栏 */
56
+ renderFilterInToolbar?: boolean;
57
+ /** ChartStatistic组件配置 */
58
+ statistic?: StatisticConfigType;
59
+ /** 是否显示加载状态 */
60
+ loading?: boolean;
61
+ /** 自定义样式对象 */
62
+ styles?: ChartStyles;
63
+ }
64
+ declare const HistogramChart: React.FC<HistogramChartProps>;
65
+ export default HistogramChart;