@platox/pivot-table 0.0.35 → 0.0.37

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 (123) hide show
  1. package/es/dashboard-workbench/components/add-module-btn/index.js +14 -5
  2. package/es/dashboard-workbench/components/add-module-btn/index.js.map +1 -1
  3. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.d.ts +3 -3
  4. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js +3 -3
  5. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js.map +1 -1
  6. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js +4 -4
  7. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js.map +1 -1
  8. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.d.ts +18 -0
  9. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.js +103 -0
  10. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.js.map +1 -0
  11. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.d.ts +14 -0
  12. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.js +79 -0
  13. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.js.map +1 -0
  14. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/index.module.less.js +11 -0
  15. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/index.module.less.js.map +1 -0
  16. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.d.ts +14 -0
  17. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.js +153 -0
  18. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.js.map +1 -0
  19. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.d.ts +1 -21
  20. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js +132 -101
  21. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -1
  22. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.d.ts +0 -6
  23. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js +2 -4
  24. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js.map +1 -1
  25. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +4 -4
  26. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -1
  27. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.module.less.js +7 -0
  28. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.module.less.js.map +1 -0
  29. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.d.ts +62 -0
  30. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.js +31 -0
  31. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.js.map +1 -0
  32. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.d.ts +3 -3
  33. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js +2 -2
  34. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js.map +1 -1
  35. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js +16 -11
  36. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js.map +1 -1
  37. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js +4 -4
  38. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map +1 -1
  39. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.d.ts +30 -0
  40. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.js +132 -0
  41. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.js.map +1 -0
  42. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js.map +1 -1
  43. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.d.ts +4 -12
  44. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js +6 -200
  45. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js.map +1 -1
  46. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/interface.d.ts +14 -0
  47. package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.d.ts +9 -0
  48. package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.js +90 -0
  49. package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.js.map +1 -0
  50. package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.d.ts +15 -0
  51. package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js +218 -0
  52. package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js.map +1 -0
  53. package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.d.ts +13 -0
  54. package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.js +56 -0
  55. package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.js.map +1 -0
  56. package/es/dashboard-workbench/components/global-filter-condition/index.d.ts +13 -0
  57. package/es/dashboard-workbench/components/global-filter-condition/index.js +311 -0
  58. package/es/dashboard-workbench/components/global-filter-condition/index.js.map +1 -0
  59. package/es/dashboard-workbench/components/global-filter-condition/index.module.less.js +8 -0
  60. package/es/dashboard-workbench/components/global-filter-condition/index.module.less.js.map +1 -0
  61. package/es/dashboard-workbench/components/global-filter-condition/interface.d.ts +9 -0
  62. package/es/dashboard-workbench/components/global-filter-condition/useContext.d.ts +13 -0
  63. package/es/dashboard-workbench/components/global-filter-condition/useContext.js +10 -0
  64. package/es/dashboard-workbench/components/global-filter-condition/useContext.js.map +1 -0
  65. package/es/dashboard-workbench/components/global-filter-condition/util.d.ts +1 -0
  66. package/es/dashboard-workbench/components/global-filter-condition/util.js +7 -0
  67. package/es/dashboard-workbench/components/global-filter-condition/util.js.map +1 -0
  68. package/es/dashboard-workbench/components/{ui/modal/editor-header.js → modal-editor-header/index.js} +4 -4
  69. package/es/dashboard-workbench/components/modal-editor-header/index.js.map +1 -0
  70. package/es/dashboard-workbench/components/modal-editor-header/index.module.less.js +9 -0
  71. package/es/dashboard-workbench/components/module-content/calendar-module/index.js +33 -19
  72. package/es/dashboard-workbench/components/module-content/calendar-module/index.js.map +1 -1
  73. package/es/dashboard-workbench/components/module-content/chart-module/Empty.js +1 -1
  74. package/es/dashboard-workbench/components/module-content/chart-module/Empty.js.map +1 -1
  75. package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js +1 -1
  76. package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js.map +1 -1
  77. package/es/dashboard-workbench/components/module-content/chart-module/index.d.ts +3 -4
  78. package/es/dashboard-workbench/components/module-content/chart-module/index.js +239 -158
  79. package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -1
  80. package/es/dashboard-workbench/components/module-content/chart-module/utils.d.ts +100 -2
  81. package/es/dashboard-workbench/components/module-content/chart-module/utils.js +66 -13
  82. package/es/dashboard-workbench/components/module-content/chart-module/utils.js.map +1 -1
  83. package/es/dashboard-workbench/components/module-content/index.js +3 -3
  84. package/es/dashboard-workbench/components/module-content/index.js.map +1 -1
  85. package/es/dashboard-workbench/components/module-content/statistics-module/index.d.ts +1 -1
  86. package/es/dashboard-workbench/components/module-content/statistics-module/index.js +17 -7
  87. package/es/dashboard-workbench/components/module-content/statistics-module/index.js.map +1 -1
  88. package/es/dashboard-workbench/components/module-content/text-module/editor/index.js +5 -5
  89. package/es/dashboard-workbench/components/module-content/text-module/editor/index.js.map +1 -1
  90. package/es/dashboard-workbench/components/module-content/utils.d.ts +2 -15
  91. package/es/dashboard-workbench/components/module-content/utils.js.map +1 -1
  92. package/es/dashboard-workbench/components/module-header/index.d.ts +1 -1
  93. package/es/dashboard-workbench/components/module-header/index.js +3 -3
  94. package/es/dashboard-workbench/components/module-header/index.js.map +1 -1
  95. package/es/dashboard-workbench/context.d.ts +21 -9
  96. package/es/dashboard-workbench/context.js +2 -9
  97. package/es/dashboard-workbench/context.js.map +1 -1
  98. package/es/dashboard-workbench/icon/icon-chart-combination.d.ts +3 -0
  99. package/es/dashboard-workbench/icon/icon-chart-combination.js +36 -0
  100. package/es/dashboard-workbench/icon/icon-chart-combination.js.map +1 -0
  101. package/es/dashboard-workbench/index.d.ts +2 -2
  102. package/es/dashboard-workbench/index.js +60 -30
  103. package/es/dashboard-workbench/index.js.map +1 -1
  104. package/es/dashboard-workbench/lang/en-US.d.ts +37 -0
  105. package/es/dashboard-workbench/lang/en-US.js +30 -3
  106. package/es/dashboard-workbench/lang/en-US.js.map +1 -1
  107. package/es/dashboard-workbench/lang/index.js +2 -2
  108. package/es/dashboard-workbench/lang/index.js.map +1 -1
  109. package/es/dashboard-workbench/lang/zh-CN.d.ts +37 -0
  110. package/es/dashboard-workbench/lang/zh-CN.js +30 -3
  111. package/es/dashboard-workbench/lang/zh-CN.js.map +1 -1
  112. package/es/dashboard-workbench/types.d.ts +18 -5
  113. package/es/dashboard-workbench/utils/index.d.ts +6 -4
  114. package/es/dashboard-workbench/utils/index.js +24 -3
  115. package/es/dashboard-workbench/utils/index.js.map +1 -1
  116. package/es/style.css +1 -1
  117. package/package.json +27 -24
  118. package/umd/pivot-table.umd.cjs +75 -75
  119. package/umd/style.css +1 -1
  120. package/es/dashboard-workbench/components/ui/modal/editor-header.js.map +0 -1
  121. package/es/dashboard-workbench/components/ui/modal/index.module.less.js +0 -9
  122. /package/es/dashboard-workbench/components/{ui/modal/editor-header.d.ts → modal-editor-header/index.d.ts} +0 -0
  123. /package/es/dashboard-workbench/components/{ui/modal → modal-editor-header}/index.module.less.js.map +0 -0
@@ -1,14 +1,15 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import React, { useState, useEffect, useMemo, useRef } from "react";
3
- import Chart from "./base-chart/index.js";
4
- import { useAppContext } from "../../../context.js";
2
+ import React, { useMemo, useState, useRef, useEffect } from "react";
5
3
  import { message, Spin } from "antd";
6
- import { mapConditionsToPostgrest } from "../utils.js";
4
+ import { useMemoizedFn, useDebounceEffect, useSize } from "ahooks";
7
5
  import { t } from "i18next";
8
- import { getChartConfig, getSerie, getGrid } from "./utils.js";
6
+ import { useAppContext } from "../../../context.js";
9
7
  import { getTransformValue } from "../../../utils/index.js";
10
- import { useMemoizedFn, useSize } from "ahooks";
8
+ import { ChartType } from "../../add-module-modal/add-chart-modal/interface.js";
9
+ import { mapConditionsToPostgrest } from "../utils.js";
10
+ import Chart from "./base-chart/index.js";
11
11
  import { Empty } from "./Empty.js";
12
+ import { getChartConfig, getSerie, getGrid } from "./utils.js";
12
13
  const ChartModule = ({
13
14
  moduleDataApi,
14
15
  customData,
@@ -16,7 +17,13 @@ const ChartModule = ({
16
17
  width = 2,
17
18
  height = 2
18
19
  }) => {
19
- const { globalData } = useAppContext();
20
+ const { globalData, globalFilterCondition } = useAppContext();
21
+ let matchGlobalFilterCondition = useMemo(() => {
22
+ let matchGlobalFilterCondition2 = globalFilterCondition == null ? void 0 : globalFilterCondition.find(
23
+ (item) => (item == null ? void 0 : item.dataSourceId) === (customData == null ? void 0 : customData.dataSourceId)
24
+ );
25
+ return matchGlobalFilterCondition2;
26
+ }, [globalFilterCondition, customData == null ? void 0 : customData.dataSourceId]);
20
27
  const [chartData, setChartData] = useState();
21
28
  const [loading, setloading] = useState();
22
29
  const fetchChartData = useMemoizedFn(async () => {
@@ -45,6 +52,9 @@ const ChartModule = ({
45
52
  if ((customData == null ? void 0 : customData.conditionData) && ((_b = (_a = customData == null ? void 0 : customData.conditionData) == null ? void 0 : _a.conditionList) == null ? void 0 : _b.length) > 0) {
46
53
  queryString += `&${mapConditionsToPostgrest(customData == null ? void 0 : customData.conditionData)}`;
47
54
  }
55
+ if (matchGlobalFilterCondition) {
56
+ queryString += `&${mapConditionsToPostgrest(matchGlobalFilterCondition)}`;
57
+ }
48
58
  if (customData == null ? void 0 : customData.dataSourceId) {
49
59
  moduleDataApi == null ? void 0 : moduleDataApi({
50
60
  id: customData == null ? void 0 : customData.dataSourceId,
@@ -63,116 +73,88 @@ const ChartModule = ({
63
73
  setChartData([]);
64
74
  }
65
75
  });
66
- useEffect(() => {
67
- if (customData) {
68
- fetchChartData();
69
- }
70
- }, [
71
- customData == null ? void 0 : customData.dataSourceId,
72
- customData == null ? void 0 : customData.conditionData,
73
- customData == null ? void 0 : customData.xAxis,
74
- customData == null ? void 0 : customData.yAxis,
75
- customData == null ? void 0 : customData.yAxisField,
76
- customData == null ? void 0 : customData.yAxisFieldType,
77
- customData == null ? void 0 : customData.isGroup,
78
- customData == null ? void 0 : customData.groupField
79
- ]);
76
+ useDebounceEffect(
77
+ () => {
78
+ if (customData) {
79
+ fetchChartData();
80
+ }
81
+ },
82
+ [
83
+ customData == null ? void 0 : customData.dataSourceId,
84
+ customData == null ? void 0 : customData.conditionData,
85
+ customData == null ? void 0 : customData.xAxis,
86
+ customData == null ? void 0 : customData.yAxis,
87
+ customData == null ? void 0 : customData.yAxisField,
88
+ customData == null ? void 0 : customData.yAxisFieldType,
89
+ customData == null ? void 0 : customData.isGroup,
90
+ customData == null ? void 0 : customData.groupField,
91
+ matchGlobalFilterCondition
92
+ ],
93
+ { wait: 60 }
94
+ );
80
95
  const fieldOptions = useMemo(() => {
81
96
  var _a, _b;
82
97
  let ret = (_b = (_a = globalData == null ? void 0 : globalData.sourceData) == null ? void 0 : _a.find((item) => item.value === (customData == null ? void 0 : customData.dataSourceId))) == null ? void 0 : _b.fields;
83
98
  return ret;
84
99
  }, [globalData, customData == null ? void 0 : customData.dataSourceId]);
85
- const [chartOptions, setChartOptions] = useState();
86
- const initChartOptions = useMemoizedFn(() => {
87
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
100
+ const chartOptions = useMemo(() => {
101
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
88
102
  if (customData && chartData && customData.type && chartData.length > 0) {
89
- const formatter = (data) => {
90
- if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
91
- return (data == null ? void 0 : data.value) == 0 ? "" : `${data == null ? void 0 : data.value}`;
92
- } else {
93
- return `${data == null ? void 0 : data.value}`;
94
- }
95
- };
96
- const label = {
97
- show: ((_a = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _a.includes("label")) || ((_b = customeStyle == null ? void 0 : customeStyle.xchartOptions) == null ? void 0 : _b.includes("label")),
98
- position: "top",
99
- // formatter: '{c}',
100
- formatter
101
- };
102
- const newXAxisField = (customData == null ? void 0 : customData.xAxis) === "tags" ? "tag" : customData == null ? void 0 : customData.xAxis;
103
- const newGroupField = (customData == null ? void 0 : customData.groupField) === "tags" ? "tag" : customData == null ? void 0 : customData.groupField;
104
- const isShowLegend = (_c = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _c.includes("legend");
105
- const getFieldLabel = (field) => {
106
- const fieldData = fieldOptions == null ? void 0 : fieldOptions.find((item) => item.value === field);
107
- return fieldData == null ? void 0 : fieldData.label;
108
- };
109
- const getFieldVal = ({ item, field }) => {
103
+ const getFieldVal = ({
104
+ item,
105
+ field,
106
+ timeGroupInterval
107
+ }) => {
110
108
  return getTransformValue({
111
109
  fieldOptions,
112
110
  val: item[field],
113
111
  field,
114
- fieldMap: globalData == null ? void 0 : globalData.fieldMap
112
+ fieldMap: globalData == null ? void 0 : globalData.fieldMap,
113
+ timeGroupInterval
115
114
  });
116
115
  };
117
- const sortChartData = (data, sortField, sortOrder) => {
118
- const orderMultiplier = sortOrder === "asc" ? 1 : -1;
119
- return [...data].sort((a, b) => {
120
- let valA, valB;
121
- switch (sortField) {
122
- case "xAxis":
123
- valA = getFieldVal({
124
- item: a,
125
- field: newXAxisField
126
- });
127
- valB = getFieldVal({
128
- item: b,
129
- field: newXAxisField
130
- });
131
- break;
132
- case "yAxisField":
133
- valA = a[customData == null ? void 0 : customData.yAxisFieldType] || 0;
134
- valB = b[customData == null ? void 0 : customData.yAxisFieldType] || 0;
135
- break;
136
- case "recordValue":
137
- default:
138
- valA = customData.yAxis === "recordTotal" ? a == null ? void 0 : a.count : a[customData == null ? void 0 : customData.yAxisFieldType] || 0;
139
- valB = customData.yAxis === "recordTotal" ? b == null ? void 0 : b.count : b[customData == null ? void 0 : customData.yAxisFieldType] || 0;
140
- break;
141
- }
142
- if (valA > valB) return 1 * orderMultiplier;
143
- if (valA < valB) return -1 * orderMultiplier;
144
- return 0;
145
- });
116
+ const getFieldLabel = (field) => {
117
+ const fieldData = fieldOptions == null ? void 0 : fieldOptions.find((item) => item.value === field);
118
+ return fieldData == null ? void 0 : fieldData.label;
146
119
  };
147
- const valueCounts = {};
148
- const valuePercentages = {};
149
- const valueGroups = {};
150
- const valueGroupPercentages = {};
120
+ const isTimeField = (fieldName) => {
121
+ var _a2;
122
+ return ((_a2 = fieldOptions == null ? void 0 : fieldOptions.find((item) => item.value === fieldName)) == null ? void 0 : _a2.type) === "timestamp";
123
+ };
124
+ const mapping = {
125
+ tags: "tag"
126
+ //后端数据名不一致
127
+ };
128
+ const newXAxisField = mapping[customData == null ? void 0 : customData.xAxis] ?? (customData == null ? void 0 : customData.xAxis);
129
+ const newGroupField = mapping[customData == null ? void 0 : customData.groupField] ?? (customData == null ? void 0 : customData.groupField);
151
130
  const categories = /* @__PURE__ */ new Set();
152
131
  const stackCategories = /* @__PURE__ */ new Set();
132
+ const valueGroups = {};
133
+ const valueCounts = {};
153
134
  chartData.forEach((item) => {
154
135
  const category = getFieldVal({
155
136
  item,
156
- field: newXAxisField
137
+ field: newXAxisField,
138
+ timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
157
139
  });
158
- categories.add(category);
159
140
  const val = customData.yAxis === "recordTotal" ? item == null ? void 0 : item.count : item[customData == null ? void 0 : customData.yAxisFieldType] || 0;
141
+ const key = category ?? t("unknown");
142
+ valueCounts[key] = val;
160
143
  if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
161
144
  const stackCategory = getFieldVal({
162
145
  item,
163
146
  field: newGroupField
164
147
  });
165
- const key = category ?? t("unknown");
148
+ const key2 = category ?? t("unknown");
166
149
  stackCategories.add(stackCategory);
167
150
  if (!valueGroups[stackCategory]) {
168
151
  valueGroups[stackCategory] = {};
169
152
  }
170
- valueGroups[stackCategory][key] = val;
171
- } else {
172
- const key = category ?? t("unknown");
173
- valueCounts[key] = val;
153
+ valueGroups[stackCategory][key2] = val;
174
154
  }
175
155
  });
156
+ const valuePercentages = {};
157
+ const valueGroupPercentages = {};
176
158
  if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
177
159
  const totalPerCategory = {};
178
160
  Object.keys(valueGroups).forEach((stackCategory) => {
@@ -193,57 +175,170 @@ const ChartModule = ({
193
175
  valuePercentages[key] = val / total * 100;
194
176
  });
195
177
  }
196
- if ((customData == null ? void 0 : customData.sortField) && (customData == null ? void 0 : customData.sortOrder)) {
197
- const sortedChartData = sortChartData(chartData, customData.sortField, customData.sortOrder);
198
- const sortedCategories = sortedChartData.map(
199
- (item) => getFieldVal({
200
- item,
201
- field: newXAxisField
202
- })
203
- );
204
- categories.clear();
205
- sortedCategories.forEach((cat) => categories.add(cat));
178
+ let sortField = (customData == null ? void 0 : customData.sortField) ?? "xAxis";
179
+ let sortOrder = (customData == null ? void 0 : customData.sortOrder) ?? "asc";
180
+ const sortedChartData = [...chartData].sort((a, b) => {
181
+ let valA, valB;
182
+ switch (sortField) {
183
+ case "xAxis":
184
+ valA = getFieldVal({
185
+ item: a,
186
+ field: newXAxisField,
187
+ timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
188
+ });
189
+ valB = getFieldVal({
190
+ item: b,
191
+ field: newXAxisField,
192
+ timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
193
+ });
194
+ break;
195
+ case "yAxisField":
196
+ valA = a[customData == null ? void 0 : customData.yAxisFieldType] || 0;
197
+ valB = b[customData == null ? void 0 : customData.yAxisFieldType] || 0;
198
+ break;
199
+ case "recordValue":
200
+ default:
201
+ valA = customData.yAxis === "recordTotal" ? a == null ? void 0 : a.count : a[customData == null ? void 0 : customData.yAxisFieldType] || 0;
202
+ valB = customData.yAxis === "recordTotal" ? b == null ? void 0 : b.count : b[customData == null ? void 0 : customData.yAxisFieldType] || 0;
203
+ break;
204
+ }
205
+ const orderMultiplier = sortOrder === "asc" ? 1 : -1;
206
+ if (valA > valB) return 1 * orderMultiplier;
207
+ if (valA < valB) return -1 * orderMultiplier;
208
+ return 0;
209
+ });
210
+ const sortedCategories = sortedChartData.map(
211
+ (item) => getFieldVal({
212
+ item,
213
+ field: newXAxisField,
214
+ timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
215
+ })
216
+ );
217
+ categories.clear();
218
+ sortedCategories.forEach((cat) => categories.add(cat));
219
+ if (!isTimeField(customData == null ? void 0 : customData.xAxis) && customData.displayRange !== "ALL" && !!customData.displayRange) {
220
+ let sortedByCountCategories = Array.from(categories).sort((a, b) => {
221
+ return valueCounts[b] - valueCounts[a];
222
+ });
223
+ let ableCategories = [];
224
+ let [pos, count] = customData.displayRange.split("_");
225
+ if (pos === "TOP") {
226
+ ableCategories = sortedByCountCategories.slice(0, Number(count));
227
+ } else {
228
+ ableCategories = sortedByCountCategories.slice(-Number(count));
229
+ }
230
+ Array.from(categories).forEach((item) => {
231
+ if (!ableCategories.includes(item)) {
232
+ categories.delete(item);
233
+ }
234
+ return item;
235
+ });
206
236
  }
237
+ const formatter = (data) => {
238
+ if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
239
+ return (data == null ? void 0 : data.value) == 0 ? "" : `${data == null ? void 0 : data.value}`;
240
+ } else {
241
+ return `${data == null ? void 0 : data.value}`;
242
+ }
243
+ };
244
+ const label = {
245
+ show: (_a = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _a.includes("label"),
246
+ position: "top",
247
+ formatter
248
+ };
207
249
  const labels = Array.from(categories);
208
250
  const stackLabels = Array.from(stackCategories);
209
- const chartConfig = getChartConfig(customData.type, labels);
210
251
  const series = [];
252
+ const chartConfig = getChartConfig({
253
+ type: customData == null ? void 0 : customData.type,
254
+ categories: labels
255
+ });
211
256
  if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
212
257
  stackLabels.forEach((stackCategory) => {
213
- const data = customData.type === "chart-bar-percentage" || customData.type === "chart-strip-bar-percentage" ? labels.map((label2) => {
214
- var _a2;
215
- return ((_a2 = valueGroupPercentages[stackCategory][label2]) == null ? void 0 : _a2.toFixed(2)) || 0;
258
+ var _a2, _b2;
259
+ const data = ["chart-bar-percentage", "chart-strip-bar-percentage"].includes(
260
+ customData.type
261
+ ) ? labels.map((label2) => {
262
+ var _a3;
263
+ return ((_a3 = valueGroupPercentages[stackCategory][label2]) == null ? void 0 : _a3.toFixed(2)) || 0;
216
264
  }) : labels.map((label2) => valueGroups[stackCategory][label2] || 0);
217
- series.push(
218
- getSerie({
219
- type: customData.type,
220
- data,
221
- label,
222
- name: stackCategory,
223
- isGroup: customData == null ? void 0 : customData.isGroup,
224
- groupField: customData == null ? void 0 : customData.groupField,
225
- labels
226
- })
227
- );
228
- });
229
- } else {
230
- const data = customData.type === "chart-bar-percentage" || customData.type === "chart-strip-bar-percentage" ? labels.map((label2) => {
231
- var _a2;
232
- return ((_a2 = valuePercentages[label2]) == null ? void 0 : _a2.toFixed(2)) || 0;
233
- }) : labels.map((label2) => valueCounts[label2] || 0);
234
- series.push(
235
- getSerie({
236
- type: customData.type,
265
+ let type = customData.type;
266
+ let yAxisPos = "left";
267
+ if (type == ChartType["chartCombination"]) {
268
+ let matchCombinationChartConfig = ((customData == null ? void 0 : customData.groupFieldConfig) ?? []).find(
269
+ (item) => getFieldVal({
270
+ item: {
271
+ [newGroupField]: item == null ? void 0 : item.value
272
+ },
273
+ field: newGroupField
274
+ }) == stackCategory
275
+ );
276
+ type = ((_a2 = matchCombinationChartConfig == null ? void 0 : matchCombinationChartConfig.config) == null ? void 0 : _a2.chartType) ?? ChartType["ChartBar"];
277
+ yAxisPos = ((_b2 = matchCombinationChartConfig == null ? void 0 : matchCombinationChartConfig.config) == null ? void 0 : _b2.yAxisPos) ?? "left";
278
+ }
279
+ let seriesItem = getSerie({
280
+ type,
237
281
  data,
238
282
  label,
239
- name: customData.yAxis === "recordTotal" ? t("pb.statisticsText") : getFieldLabel(customData == null ? void 0 : customData.yAxisField),
283
+ name: stackCategory,
240
284
  isGroup: customData == null ? void 0 : customData.isGroup,
241
285
  groupField: customData == null ? void 0 : customData.groupField,
242
286
  labels
243
- })
244
- );
287
+ });
288
+ seriesItem.yAxisIndex = yAxisPos == "left" ? 0 : 1;
289
+ series.push(seriesItem);
290
+ });
291
+ } else {
292
+ const data = ["chart-bar-percentage", "chart-strip-bar-percentage"].includes(
293
+ customData.type
294
+ ) ? labels.map((label2) => {
295
+ var _a2;
296
+ return ((_a2 = valuePercentages[label2]) == null ? void 0 : _a2.toFixed(2)) || 0;
297
+ }) : labels.map((label2) => valueCounts[label2] || 0);
298
+ let type = customData.type;
299
+ let yAxisPos = "left";
300
+ if (type == ChartType["chartCombination"]) {
301
+ type = ((_b = customData == null ? void 0 : customData.yAxisFieldConfig) == null ? void 0 : _b.chartType) ?? ChartType["ChartBar"];
302
+ } else {
303
+ yAxisPos = ((_c = customData == null ? void 0 : customData.yAxisFieldConfig) == null ? void 0 : _c.yAxisPos) ?? "left";
304
+ }
305
+ let seriesItem = getSerie({
306
+ type: customData.type,
307
+ data,
308
+ label,
309
+ name: customData.yAxis === "recordTotal" ? t("pb.statisticsText") : getFieldLabel(customData == null ? void 0 : customData.yAxisField),
310
+ isGroup: customData == null ? void 0 : customData.isGroup,
311
+ groupField: customData == null ? void 0 : customData.groupField,
312
+ labels
313
+ });
314
+ seriesItem.yAxisIndex = yAxisPos == "left" ? 0 : 1;
315
+ series.push(seriesItem);
245
316
  }
246
- const grids = getGrid({ series, chartConfig, width });
317
+ const grids = getGrid({ series, chartConfig, width, customeStyle });
318
+ const isShowLegend = (_d = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _d.includes("legend");
319
+ let isLeftYAxisShow = series.some((item) => (item == null ? void 0 : item.yAxisIndex) == 0);
320
+ let isRightYAxisShow = series.some((item) => (item == null ? void 0 : item.yAxisIndex) == 1);
321
+ let yAxisConfig = {
322
+ ...chartConfig.yAxis,
323
+ axisTick: {
324
+ show: (_e = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _e.includes("axis")
325
+ },
326
+ axisLine: {
327
+ show: (_f = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _f.includes("axis")
328
+ },
329
+ axisLabel: {
330
+ show: (_g = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _g.includes("label"),
331
+ formatter: (value) => {
332
+ return value.length > 15 ? `${value.slice(0, 15)}...` : value;
333
+ },
334
+ hideOverlap: true,
335
+ ...(_h = chartConfig.yAxis) == null ? void 0 : _h.axisLabel
336
+ },
337
+ splitLine: {
338
+ show: (_i = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _i.includes("splitLine")
339
+ // 不显示x轴网格线
340
+ }
341
+ };
247
342
  const options = {
248
343
  legend: {
249
344
  type: "scroll",
@@ -293,13 +388,13 @@ const ChartModule = ({
293
388
  xAxis: {
294
389
  ...chartConfig.xAxis,
295
390
  axisTick: {
296
- show: (_d = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _d.includes("axis")
391
+ show: (_j = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _j.includes("axis")
297
392
  },
298
393
  axisLine: {
299
- show: ((_e = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _e.includes("axis")) || ((_f = customeStyle == null ? void 0 : customeStyle.xchartOptions) == null ? void 0 : _f.includes("axisLine"))
394
+ show: (_k = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _k.includes("axis")
300
395
  },
301
396
  axisLabel: {
302
- show: ((_g = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _g.includes("label")) || ((_h = customeStyle == null ? void 0 : customeStyle.xchartOptions) == null ? void 0 : _h.includes("label")),
397
+ show: (_l = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _l.includes("label"),
303
398
  rotate: grids.axisLabelRotate,
304
399
  // 使标签倾斜,调整为合适的角度
305
400
  interval: "auto",
@@ -307,34 +402,23 @@ const ChartModule = ({
307
402
  formatter: (value) => {
308
403
  return value.length > 15 ? `${value.slice(0, 15)}...` : value;
309
404
  },
310
- ...(_i = chartConfig.xAxis) == null ? void 0 : _i.axisLabel
405
+ ...((_m = chartConfig.xAxis) == null ? void 0 : _m.axisLabel) ?? {}
311
406
  },
312
407
  splitLine: {
313
- show: (_j = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _j.includes("splitLine")
408
+ show: (_n = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _n.includes("splitLine")
314
409
  // 不显示x轴网格线
315
410
  }
316
411
  },
317
- yAxis: {
318
- ...chartConfig.yAxis,
319
- axisTick: {
320
- show: (_k = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _k.includes("axis")
412
+ yAxis: [
413
+ {
414
+ show: isLeftYAxisShow,
415
+ ...yAxisConfig
321
416
  },
322
- axisLine: {
323
- show: ((_l = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _l.includes("axis")) || ((_m = customeStyle == null ? void 0 : customeStyle.ychartOptions) == null ? void 0 : _m.includes("axisLine"))
324
- },
325
- axisLabel: {
326
- show: ((_n = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _n.includes("label")) || ((_o = customeStyle == null ? void 0 : customeStyle.ychartOptions) == null ? void 0 : _o.includes("label")),
327
- formatter: (value) => {
328
- return value.length > 15 ? `${value.slice(0, 15)}...` : value;
329
- },
330
- hideOverlap: true,
331
- ...(_p = chartConfig.yAxis) == null ? void 0 : _p.axisLabel
332
- },
333
- splitLine: {
334
- show: (_q = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _q.includes("splitLine")
335
- // 不显示x轴网格线
417
+ {
418
+ show: isRightYAxisShow,
419
+ ...yAxisConfig
336
420
  }
337
- },
421
+ ],
338
422
  series,
339
423
  tooltip: {
340
424
  trigger: "item",
@@ -346,18 +430,20 @@ const ChartModule = ({
346
430
  appendTo: "body"
347
431
  }
348
432
  };
349
- setChartOptions(options);
433
+ return options;
350
434
  } else {
351
- setChartOptions(void 0);
435
+ return {};
352
436
  }
353
- });
354
- useEffect(() => {
355
- initChartOptions();
356
437
  }, [
357
438
  customData == null ? void 0 : customData.sortField,
358
439
  customData == null ? void 0 : customData.sortOrder,
359
440
  customData == null ? void 0 : customData.type,
360
441
  customData == null ? void 0 : customData.chartOptions,
442
+ customData == null ? void 0 : customData.timeGroupInterval,
443
+ customData == null ? void 0 : customData.groupFieldConfig,
444
+ customData == null ? void 0 : customData.yAxisFieldConfig,
445
+ customData == null ? void 0 : customData.displayRange,
446
+ // customData,
361
447
  customeStyle,
362
448
  chartData,
363
449
  width,
@@ -376,11 +462,6 @@ const ChartModule = ({
376
462
  const isLoading = loading && !chartOptions;
377
463
  const isEmpyt = !loading && !chartOptions;
378
464
  const isOk = !isLoading && !isEmpyt;
379
- console.log("asd", {
380
- isLoading,
381
- isEmpyt,
382
- isOk
383
- });
384
465
  return /* @__PURE__ */ jsxs("div", { style: { width: "100%", height: "100%" }, ref: containerRef, children: [
385
466
  isLoading && /* @__PURE__ */ jsx(
386
467
  Spin,