@platox/pivot-table 0.0.34 → 0.0.36

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 (134) 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 +73 -82
  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.d.ts +1 -5
  7. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js +13 -22
  8. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js.map +1 -1
  9. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.d.ts +18 -0
  10. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.js +103 -0
  11. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/CombinationChartOptionPicker.js.map +1 -0
  12. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.d.ts +14 -0
  13. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.js +79 -0
  14. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/GroupFieldConfigPicker.js.map +1 -0
  15. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/index.module.less.js +11 -0
  16. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/components/index.module.less.js.map +1 -0
  17. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.d.ts +14 -0
  18. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.js +153 -0
  19. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/config.js.map +1 -0
  20. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.d.ts +1 -19
  21. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js +132 -101
  22. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -1
  23. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.d.ts +0 -6
  24. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js +2 -4
  25. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js.map +1 -1
  26. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.d.ts +1 -8
  27. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +13 -22
  28. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -1
  29. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.module.less.js +7 -0
  30. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.module.less.js.map +1 -0
  31. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.d.ts +62 -0
  32. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.js +31 -0
  33. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/interface.js.map +1 -0
  34. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.d.ts +3 -3
  35. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js +2 -2
  36. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js.map +1 -1
  37. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js +16 -11
  38. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js.map +1 -1
  39. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.d.ts +1 -7
  40. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js +13 -22
  41. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map +1 -1
  42. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.d.ts +30 -0
  43. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.js +132 -0
  44. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/config.js.map +1 -0
  45. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js.map +1 -1
  46. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.d.ts +4 -12
  47. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js +6 -200
  48. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js.map +1 -1
  49. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/interface.d.ts +14 -0
  50. package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.d.ts +9 -0
  51. package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.js +90 -0
  52. package/es/dashboard-workbench/components/global-filter-condition/ConditionRowItem.js.map +1 -0
  53. package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.d.ts +15 -0
  54. package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js +218 -0
  55. package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js.map +1 -0
  56. package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.d.ts +13 -0
  57. package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.js +56 -0
  58. package/es/dashboard-workbench/components/global-filter-condition/FieldPicker.js.map +1 -0
  59. package/es/dashboard-workbench/components/global-filter-condition/index.d.ts +13 -0
  60. package/es/dashboard-workbench/components/global-filter-condition/index.js +311 -0
  61. package/es/dashboard-workbench/components/global-filter-condition/index.js.map +1 -0
  62. package/es/dashboard-workbench/components/global-filter-condition/index.module.less.js +8 -0
  63. package/es/dashboard-workbench/components/global-filter-condition/index.module.less.js.map +1 -0
  64. package/es/dashboard-workbench/components/global-filter-condition/interface.d.ts +9 -0
  65. package/es/dashboard-workbench/components/global-filter-condition/useContext.d.ts +13 -0
  66. package/es/dashboard-workbench/components/global-filter-condition/useContext.js +10 -0
  67. package/es/dashboard-workbench/components/global-filter-condition/useContext.js.map +1 -0
  68. package/es/dashboard-workbench/components/global-filter-condition/util.d.ts +1 -0
  69. package/es/dashboard-workbench/components/global-filter-condition/util.js +7 -0
  70. package/es/dashboard-workbench/components/global-filter-condition/util.js.map +1 -0
  71. package/es/dashboard-workbench/components/modal-editor-header/index.d.ts +12 -0
  72. package/es/dashboard-workbench/components/modal-editor-header/index.js +59 -0
  73. package/es/dashboard-workbench/components/modal-editor-header/index.js.map +1 -0
  74. package/es/dashboard-workbench/components/modal-editor-header/index.module.less.js +9 -0
  75. package/es/dashboard-workbench/components/modal-editor-header/index.module.less.js.map +1 -0
  76. package/es/dashboard-workbench/components/module-content/calendar-module/index.js +38 -26
  77. package/es/dashboard-workbench/components/module-content/calendar-module/index.js.map +1 -1
  78. package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.d.ts +7 -0
  79. package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js +10 -0
  80. package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js.map +1 -0
  81. package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.d.ts +22 -0
  82. package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js +29 -0
  83. package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js.map +1 -0
  84. package/es/dashboard-workbench/components/module-content/chart-module/Empty.d.ts +5 -0
  85. package/es/dashboard-workbench/components/module-content/chart-module/Empty.js +30 -0
  86. package/es/dashboard-workbench/components/module-content/chart-module/Empty.js.map +1 -0
  87. package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js +1 -1
  88. package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js.map +1 -1
  89. package/es/dashboard-workbench/components/module-content/chart-module/index.d.ts +3 -4
  90. package/es/dashboard-workbench/components/module-content/chart-module/index.js +263 -160
  91. package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -1
  92. package/es/dashboard-workbench/components/module-content/chart-module/utils.d.ts +100 -2
  93. package/es/dashboard-workbench/components/module-content/chart-module/utils.js +66 -13
  94. package/es/dashboard-workbench/components/module-content/chart-module/utils.js.map +1 -1
  95. package/es/dashboard-workbench/components/module-content/index.js +3 -3
  96. package/es/dashboard-workbench/components/module-content/index.js.map +1 -1
  97. package/es/dashboard-workbench/components/module-content/statistics-module/index.d.ts +1 -1
  98. package/es/dashboard-workbench/components/module-content/statistics-module/index.js +17 -7
  99. package/es/dashboard-workbench/components/module-content/statistics-module/index.js.map +1 -1
  100. package/es/dashboard-workbench/components/module-content/text-module/editor/index.js +5 -5
  101. package/es/dashboard-workbench/components/module-content/text-module/editor/index.js.map +1 -1
  102. package/es/dashboard-workbench/components/module-content/utils.d.ts +2 -15
  103. package/es/dashboard-workbench/components/module-content/utils.js.map +1 -1
  104. package/es/dashboard-workbench/components/module-header/index.d.ts +1 -1
  105. package/es/dashboard-workbench/components/module-header/index.js +3 -3
  106. package/es/dashboard-workbench/components/module-header/index.js.map +1 -1
  107. package/es/dashboard-workbench/context.d.ts +21 -9
  108. package/es/dashboard-workbench/context.js +2 -9
  109. package/es/dashboard-workbench/context.js.map +1 -1
  110. package/es/dashboard-workbench/icon/icon-chart-combination.d.ts +3 -0
  111. package/es/dashboard-workbench/icon/icon-chart-combination.js +36 -0
  112. package/es/dashboard-workbench/icon/icon-chart-combination.js.map +1 -0
  113. package/es/dashboard-workbench/icon/icon-empty.d.ts +2 -0
  114. package/es/dashboard-workbench/icon/icon-empty.js +139 -0
  115. package/es/dashboard-workbench/icon/icon-empty.js.map +1 -0
  116. package/es/dashboard-workbench/index.d.ts +2 -2
  117. package/es/dashboard-workbench/index.js +92 -83
  118. package/es/dashboard-workbench/index.js.map +1 -1
  119. package/es/dashboard-workbench/lang/en-US.d.ts +38 -0
  120. package/es/dashboard-workbench/lang/en-US.js +32 -4
  121. package/es/dashboard-workbench/lang/en-US.js.map +1 -1
  122. package/es/dashboard-workbench/lang/index.js +2 -2
  123. package/es/dashboard-workbench/lang/index.js.map +1 -1
  124. package/es/dashboard-workbench/lang/zh-CN.d.ts +38 -0
  125. package/es/dashboard-workbench/lang/zh-CN.js +31 -3
  126. package/es/dashboard-workbench/lang/zh-CN.js.map +1 -1
  127. package/es/dashboard-workbench/types.d.ts +18 -5
  128. package/es/dashboard-workbench/utils/index.d.ts +6 -4
  129. package/es/dashboard-workbench/utils/index.js +24 -3
  130. package/es/dashboard-workbench/utils/index.js.map +1 -1
  131. package/es/style.css +1 -1
  132. package/package.json +28 -20
  133. package/umd/pivot-table.umd.cjs +74 -74
  134. package/umd/style.css +1 -1
@@ -1,13 +1,15 @@
1
- import { 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";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
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
+ import { Empty } from "./Empty.js";
12
+ import { getChartConfig, getSerie, getGrid } from "./utils.js";
11
13
  const ChartModule = ({
12
14
  moduleDataApi,
13
15
  customData,
@@ -15,7 +17,13 @@ const ChartModule = ({
15
17
  width = 2,
16
18
  height = 2
17
19
  }) => {
18
- 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]);
19
27
  const [chartData, setChartData] = useState();
20
28
  const [loading, setloading] = useState();
21
29
  const fetchChartData = useMemoizedFn(async () => {
@@ -44,6 +52,9 @@ const ChartModule = ({
44
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) {
45
53
  queryString += `&${mapConditionsToPostgrest(customData == null ? void 0 : customData.conditionData)}`;
46
54
  }
55
+ if (matchGlobalFilterCondition) {
56
+ queryString += `&${mapConditionsToPostgrest(matchGlobalFilterCondition)}`;
57
+ }
47
58
  if (customData == null ? void 0 : customData.dataSourceId) {
48
59
  moduleDataApi == null ? void 0 : moduleDataApi({
49
60
  id: customData == null ? void 0 : customData.dataSourceId,
@@ -62,108 +73,88 @@ const ChartModule = ({
62
73
  setChartData([]);
63
74
  }
64
75
  });
65
- useEffect(() => {
66
- if (customData) {
67
- fetchChartData();
68
- }
69
- }, [
70
- customData == null ? void 0 : customData.dataSourceId,
71
- customData == null ? void 0 : customData.conditionData,
72
- customData == null ? void 0 : customData.xAxis,
73
- customData == null ? void 0 : customData.yAxis,
74
- customData == null ? void 0 : customData.yAxisField,
75
- customData == null ? void 0 : customData.yAxisFieldType,
76
- customData == null ? void 0 : customData.isGroup,
77
- customData == null ? void 0 : customData.groupField
78
- ]);
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
+ );
79
95
  const fieldOptions = useMemo(() => {
80
96
  var _a, _b;
81
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;
82
98
  return ret;
83
99
  }, [globalData, customData == null ? void 0 : customData.dataSourceId]);
84
- const [chartOptions, setChartOptions] = useState();
85
- const initChartOptions = useMemoizedFn(() => {
86
- 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;
87
102
  if (customData && chartData && customData.type && chartData.length > 0) {
88
- const label = {
89
- 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")),
90
- position: "top",
91
- formatter: "{c}"
92
- };
93
- const newXAxisField = (customData == null ? void 0 : customData.xAxis) === "tags" ? "tag" : customData == null ? void 0 : customData.xAxis;
94
- const newGroupField = (customData == null ? void 0 : customData.groupField) === "tags" ? "tag" : customData == null ? void 0 : customData.groupField;
95
- const isShowLegend = (_c = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _c.includes("legend");
96
- const getFieldLabel = (field) => {
97
- const fieldData = fieldOptions == null ? void 0 : fieldOptions.find((item) => item.value === field);
98
- return fieldData == null ? void 0 : fieldData.label;
99
- };
100
- const getFieldVal = ({ item, field }) => {
103
+ const getFieldVal = ({
104
+ item,
105
+ field,
106
+ timeGroupInterval
107
+ }) => {
101
108
  return getTransformValue({
102
109
  fieldOptions,
103
110
  val: item[field],
104
111
  field,
105
- fieldMap: globalData == null ? void 0 : globalData.fieldMap
112
+ fieldMap: globalData == null ? void 0 : globalData.fieldMap,
113
+ timeGroupInterval
106
114
  });
107
115
  };
108
- const sortChartData = (data, sortField, sortOrder) => {
109
- const orderMultiplier = sortOrder === "asc" ? 1 : -1;
110
- return [...data].sort((a, b) => {
111
- let valA, valB;
112
- switch (sortField) {
113
- case "xAxis":
114
- valA = getFieldVal({
115
- item: a,
116
- field: newXAxisField
117
- });
118
- valB = getFieldVal({
119
- item: b,
120
- field: newXAxisField
121
- });
122
- break;
123
- case "yAxisField":
124
- valA = a[customData == null ? void 0 : customData.yAxisFieldType] || 0;
125
- valB = b[customData == null ? void 0 : customData.yAxisFieldType] || 0;
126
- break;
127
- case "recordValue":
128
- default:
129
- valA = customData.yAxis === "recordTotal" ? a == null ? void 0 : a.count : a[customData == null ? void 0 : customData.yAxisFieldType] || 0;
130
- valB = customData.yAxis === "recordTotal" ? b == null ? void 0 : b.count : b[customData == null ? void 0 : customData.yAxisFieldType] || 0;
131
- break;
132
- }
133
- if (valA > valB) return 1 * orderMultiplier;
134
- if (valA < valB) return -1 * orderMultiplier;
135
- return 0;
136
- });
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;
137
119
  };
138
- const valueCounts = {};
139
- const valuePercentages = {};
140
- const valueGroups = {};
141
- 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);
142
130
  const categories = /* @__PURE__ */ new Set();
143
131
  const stackCategories = /* @__PURE__ */ new Set();
132
+ const valueGroups = {};
133
+ const valueCounts = {};
144
134
  chartData.forEach((item) => {
145
135
  const category = getFieldVal({
146
136
  item,
147
- field: newXAxisField
137
+ field: newXAxisField,
138
+ timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
148
139
  });
149
- categories.add(category);
150
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;
151
143
  if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
152
144
  const stackCategory = getFieldVal({
153
145
  item,
154
146
  field: newGroupField
155
147
  });
156
- const key = category ?? t("unknown");
148
+ const key2 = category ?? t("unknown");
157
149
  stackCategories.add(stackCategory);
158
150
  if (!valueGroups[stackCategory]) {
159
151
  valueGroups[stackCategory] = {};
160
152
  }
161
- valueGroups[stackCategory][key] = val;
162
- } else {
163
- const key = category ?? t("unknown");
164
- valueCounts[key] = val;
153
+ valueGroups[stackCategory][key2] = val;
165
154
  }
166
155
  });
156
+ const valuePercentages = {};
157
+ const valueGroupPercentages = {};
167
158
  if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
168
159
  const totalPerCategory = {};
169
160
  Object.keys(valueGroups).forEach((stackCategory) => {
@@ -184,57 +175,170 @@ const ChartModule = ({
184
175
  valuePercentages[key] = val / total * 100;
185
176
  });
186
177
  }
187
- if ((customData == null ? void 0 : customData.sortField) && (customData == null ? void 0 : customData.sortOrder)) {
188
- const sortedChartData = sortChartData(chartData, customData.sortField, customData.sortOrder);
189
- const sortedCategories = sortedChartData.map(
190
- (item) => getFieldVal({
191
- item,
192
- field: newXAxisField
193
- })
194
- );
195
- categories.clear();
196
- 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
+ });
197
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
+ };
198
249
  const labels = Array.from(categories);
199
250
  const stackLabels = Array.from(stackCategories);
200
- const chartConfig = getChartConfig(customData.type, labels);
201
251
  const series = [];
252
+ const chartConfig = getChartConfig({
253
+ type: customData == null ? void 0 : customData.type,
254
+ categories: labels
255
+ });
202
256
  if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
203
257
  stackLabels.forEach((stackCategory) => {
204
- const data = customData.type === "chart-bar-percentage" || customData.type === "chart-strip-bar-percentage" ? labels.map((label2) => {
205
- var _a2;
206
- 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;
207
264
  }) : labels.map((label2) => valueGroups[stackCategory][label2] || 0);
208
- series.push(
209
- getSerie({
210
- type: customData.type,
211
- data,
212
- label,
213
- name: stackCategory,
214
- isGroup: customData == null ? void 0 : customData.isGroup,
215
- groupField: customData == null ? void 0 : customData.groupField,
216
- labels
217
- })
218
- );
219
- });
220
- } else {
221
- const data = customData.type === "chart-bar-percentage" || customData.type === "chart-strip-bar-percentage" ? labels.map((label2) => {
222
- var _a2;
223
- return ((_a2 = valuePercentages[label2]) == null ? void 0 : _a2.toFixed(2)) || 0;
224
- }) : labels.map((label2) => valueCounts[label2] || 0);
225
- series.push(
226
- getSerie({
227
- 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,
228
281
  data,
229
282
  label,
230
- name: customData.yAxis === "recordTotal" ? t("pb.statisticsText") : getFieldLabel(customData == null ? void 0 : customData.yAxisField),
283
+ name: stackCategory,
231
284
  isGroup: customData == null ? void 0 : customData.isGroup,
232
285
  groupField: customData == null ? void 0 : customData.groupField,
233
286
  labels
234
- })
235
- );
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);
236
316
  }
237
- 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
+ };
238
342
  const options = {
239
343
  legend: {
240
344
  type: "scroll",
@@ -284,47 +388,37 @@ const ChartModule = ({
284
388
  xAxis: {
285
389
  ...chartConfig.xAxis,
286
390
  axisTick: {
287
- 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")
288
392
  },
289
393
  axisLine: {
290
- 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")
291
395
  },
292
396
  axisLabel: {
293
- 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"),
294
398
  rotate: grids.axisLabelRotate,
295
399
  // 使标签倾斜,调整为合适的角度
296
- // interval: 0, // 保证所有标签都显示
400
+ interval: "auto",
401
+ // 自动隐藏
297
402
  formatter: (value) => {
298
403
  return value.length > 15 ? `${value.slice(0, 15)}...` : value;
299
404
  },
300
- ...(_i = chartConfig.xAxis) == null ? void 0 : _i.axisLabel
405
+ ...((_m = chartConfig.xAxis) == null ? void 0 : _m.axisLabel) ?? {}
301
406
  },
302
407
  splitLine: {
303
- 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")
304
409
  // 不显示x轴网格线
305
410
  }
306
411
  },
307
- yAxis: {
308
- ...chartConfig.yAxis,
309
- axisTick: {
310
- show: (_k = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _k.includes("axis")
311
- },
312
- axisLine: {
313
- 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"))
314
- },
315
- axisLabel: {
316
- 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")),
317
- formatter: (value) => {
318
- return value.length > 15 ? `${value.slice(0, 15)}...` : value;
319
- },
320
- hideOverlap: true,
321
- ...(_p = chartConfig.yAxis) == null ? void 0 : _p.axisLabel
412
+ yAxis: [
413
+ {
414
+ show: isLeftYAxisShow,
415
+ ...yAxisConfig
322
416
  },
323
- splitLine: {
324
- show: (_q = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _q.includes("splitLine")
325
- // 不显示x轴网格线
417
+ {
418
+ show: isRightYAxisShow,
419
+ ...yAxisConfig
326
420
  }
327
- },
421
+ ],
328
422
  series,
329
423
  tooltip: {
330
424
  trigger: "item",
@@ -336,18 +430,20 @@ const ChartModule = ({
336
430
  appendTo: "body"
337
431
  }
338
432
  };
339
- setChartOptions(options);
433
+ return options;
340
434
  } else {
341
- setChartOptions({});
435
+ return {};
342
436
  }
343
- });
344
- useEffect(() => {
345
- initChartOptions();
346
437
  }, [
347
438
  customData == null ? void 0 : customData.sortField,
348
439
  customData == null ? void 0 : customData.sortOrder,
349
440
  customData == null ? void 0 : customData.type,
350
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,
351
447
  customeStyle,
352
448
  chartData,
353
449
  width,
@@ -363,19 +459,26 @@ const ChartModule = ({
363
459
  (_a = echartRef == null ? void 0 : echartRef.current) == null ? void 0 : _a.resize();
364
460
  }
365
461
  }, [size]);
366
- return /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%" }, ref: containerRef, children: !loading && chartOptions ? /* @__PURE__ */ jsx(Chart, { echartRef, options: chartOptions }) : /* @__PURE__ */ jsx(
367
- Spin,
368
- {
369
- style: {
370
- width: "100%",
371
- height: "100%",
372
- display: "flex",
373
- justifyContent: "center",
374
- alignItems: "center"
375
- },
376
- spinning: loading
377
- }
378
- ) });
462
+ const isLoading = loading && !chartOptions;
463
+ const isEmpyt = !loading && !chartOptions;
464
+ const isOk = !isLoading && !isEmpyt;
465
+ return /* @__PURE__ */ jsxs("div", { style: { width: "100%", height: "100%" }, ref: containerRef, children: [
466
+ isLoading && /* @__PURE__ */ jsx(
467
+ Spin,
468
+ {
469
+ style: {
470
+ width: "100%",
471
+ height: "100%",
472
+ display: "flex",
473
+ justifyContent: "center",
474
+ alignItems: "center"
475
+ },
476
+ spinning: loading
477
+ }
478
+ ),
479
+ isEmpyt && /* @__PURE__ */ jsx(Empty, {}),
480
+ isOk && /* @__PURE__ */ jsx(Chart, { echartRef, options: chartOptions })
481
+ ] });
379
482
  };
380
483
  const ChartModule$1 = React.memo(ChartModule);
381
484
  export {