@platox/pivot-table 0.0.33 → 0.0.35

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 (165) hide show
  1. package/es/dashboard-workbench/components/add-module-btn/index.d.ts +11 -0
  2. package/es/dashboard-workbench/components/add-module-btn/index.js +97 -0
  3. package/es/dashboard-workbench/components/add-module-btn/index.js.map +1 -0
  4. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.d.ts +20 -0
  5. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js +169 -0
  6. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js.map +1 -0
  7. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.d.ts +13 -0
  8. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js +82 -0
  9. package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js.map +1 -0
  10. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.d.ts +29 -0
  11. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js +328 -0
  12. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -0
  13. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.d.ts +15 -0
  14. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js +58 -0
  15. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js.map +1 -0
  16. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.d.ts +13 -0
  17. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +114 -0
  18. package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -0
  19. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.d.ts +20 -0
  20. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js +180 -0
  21. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js.map +1 -0
  22. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.d.ts +13 -0
  23. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js +119 -0
  24. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js.map +1 -0
  25. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.d.ts +13 -0
  26. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js +111 -0
  27. package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map +1 -0
  28. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.d.ts +12 -0
  29. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js +44 -0
  30. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js.map +1 -0
  31. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.d.ts +21 -0
  32. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js +510 -0
  33. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js.map +1 -0
  34. package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/utils.d.ts +25 -0
  35. package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.d.ts +12 -0
  36. package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.js +45 -0
  37. package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.js.map +1 -0
  38. package/es/dashboard-workbench/components/module-content/calendar-module/index.d.ts +14 -0
  39. package/es/dashboard-workbench/components/module-content/calendar-module/index.js +229 -0
  40. package/es/dashboard-workbench/components/module-content/calendar-module/index.js.map +1 -0
  41. package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.d.ts +7 -0
  42. package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js +10 -0
  43. package/es/dashboard-workbench/components/module-content/calendar-module/locales/en.js.map +1 -0
  44. package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.d.ts +22 -0
  45. package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js +29 -0
  46. package/es/dashboard-workbench/components/module-content/calendar-module/locales/zh.js.map +1 -0
  47. package/es/dashboard-workbench/components/module-content/chart-module/Empty.d.ts +5 -0
  48. package/es/dashboard-workbench/components/module-content/chart-module/Empty.js +30 -0
  49. package/es/dashboard-workbench/components/module-content/chart-module/Empty.js.map +1 -0
  50. package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.d.ts +8 -0
  51. package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js +62 -0
  52. package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js.map +1 -0
  53. package/es/dashboard-workbench/components/module-content/chart-module/index.d.ts +14 -0
  54. package/es/dashboard-workbench/components/module-content/chart-module/index.js +406 -0
  55. package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -0
  56. package/es/dashboard-workbench/components/module-content/chart-module/utils.d.ts +9 -0
  57. package/es/dashboard-workbench/components/module-content/chart-module/utils.js +200 -0
  58. package/es/dashboard-workbench/components/module-content/chart-module/utils.js.map +1 -0
  59. package/es/dashboard-workbench/components/module-content/index.d.ts +31 -0
  60. package/es/dashboard-workbench/components/module-content/index.js +81 -0
  61. package/es/dashboard-workbench/components/module-content/index.js.map +1 -0
  62. package/es/dashboard-workbench/components/module-content/statistics-module/index.d.ts +15 -0
  63. package/es/dashboard-workbench/components/module-content/statistics-module/index.js +305 -0
  64. package/es/dashboard-workbench/components/module-content/statistics-module/index.js.map +1 -0
  65. package/es/dashboard-workbench/components/module-content/statistics-module/utils.d.ts +4 -0
  66. package/es/dashboard-workbench/components/module-content/statistics-module/utils.js +41 -0
  67. package/es/dashboard-workbench/components/module-content/statistics-module/utils.js.map +1 -0
  68. package/es/dashboard-workbench/components/module-content/text-module/editor/index.d.ts +7 -0
  69. package/es/dashboard-workbench/components/module-content/text-module/editor/index.js +224 -0
  70. package/es/dashboard-workbench/components/module-content/text-module/editor/index.js.map +1 -0
  71. package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.d.ts +2 -0
  72. package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.js +24 -0
  73. package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.js.map +1 -0
  74. package/es/dashboard-workbench/components/module-content/text-module/index.d.ts +7 -0
  75. package/es/dashboard-workbench/components/module-content/text-module/index.js +11 -0
  76. package/es/dashboard-workbench/components/module-content/text-module/index.js.map +1 -0
  77. package/es/dashboard-workbench/components/module-content/utils.d.ts +15 -0
  78. package/es/dashboard-workbench/components/module-content/utils.js +113 -0
  79. package/es/dashboard-workbench/components/module-content/utils.js.map +1 -0
  80. package/es/dashboard-workbench/components/module-header/index.d.ts +12 -0
  81. package/es/dashboard-workbench/components/module-header/index.js +115 -0
  82. package/es/dashboard-workbench/components/module-header/index.js.map +1 -0
  83. package/es/dashboard-workbench/components/ui/modal/editor-header.d.ts +12 -0
  84. package/es/dashboard-workbench/components/ui/modal/editor-header.js +59 -0
  85. package/es/dashboard-workbench/components/ui/modal/editor-header.js.map +1 -0
  86. package/es/dashboard-workbench/components/ui/modal/index.module.less.js +9 -0
  87. package/es/dashboard-workbench/components/ui/modal/index.module.less.js.map +1 -0
  88. package/es/dashboard-workbench/context.d.ts +16 -0
  89. package/es/dashboard-workbench/context.js +21 -0
  90. package/es/dashboard-workbench/context.js.map +1 -0
  91. package/es/dashboard-workbench/icon/icon-bar-percentage.d.ts +2 -0
  92. package/es/dashboard-workbench/icon/icon-bar-percentage.js +17 -0
  93. package/es/dashboard-workbench/icon/icon-bar-percentage.js.map +1 -0
  94. package/es/dashboard-workbench/icon/icon-bar-pile.d.ts +2 -0
  95. package/es/dashboard-workbench/icon/icon-bar-pile.js +17 -0
  96. package/es/dashboard-workbench/icon/icon-bar-pile.js.map +1 -0
  97. package/es/dashboard-workbench/icon/icon-bar.d.ts +2 -0
  98. package/es/dashboard-workbench/icon/icon-bar.js +13 -0
  99. package/es/dashboard-workbench/icon/icon-bar.js.map +1 -0
  100. package/es/dashboard-workbench/icon/icon-calendar.d.ts +2 -0
  101. package/es/dashboard-workbench/icon/icon-calendar.js +40 -0
  102. package/es/dashboard-workbench/icon/icon-calendar.js.map +1 -0
  103. package/es/dashboard-workbench/icon/icon-drag.d.ts +2 -0
  104. package/es/dashboard-workbench/icon/icon-drag.js +25 -0
  105. package/es/dashboard-workbench/icon/icon-drag.js.map +1 -0
  106. package/es/dashboard-workbench/icon/icon-editor.d.ts +2 -0
  107. package/es/dashboard-workbench/icon/icon-editor.js +40 -0
  108. package/es/dashboard-workbench/icon/icon-editor.js.map +1 -0
  109. package/es/dashboard-workbench/icon/icon-empty.d.ts +2 -0
  110. package/es/dashboard-workbench/icon/icon-empty.js +139 -0
  111. package/es/dashboard-workbench/icon/icon-empty.js.map +1 -0
  112. package/es/dashboard-workbench/icon/icon-line-smooth.d.ts +2 -0
  113. package/es/dashboard-workbench/icon/icon-line-smooth.js +28 -0
  114. package/es/dashboard-workbench/icon/icon-line-smooth.js.map +1 -0
  115. package/es/dashboard-workbench/icon/icon-line.d.ts +2 -0
  116. package/es/dashboard-workbench/icon/icon-line.js +28 -0
  117. package/es/dashboard-workbench/icon/icon-line.js.map +1 -0
  118. package/es/dashboard-workbench/icon/icon-move.d.ts +2 -0
  119. package/es/dashboard-workbench/icon/icon-move.js +25 -0
  120. package/es/dashboard-workbench/icon/icon-move.js.map +1 -0
  121. package/es/dashboard-workbench/icon/icon-pie-circular.d.ts +2 -0
  122. package/es/dashboard-workbench/icon/icon-pie-circular.js +30 -0
  123. package/es/dashboard-workbench/icon/icon-pie-circular.js.map +1 -0
  124. package/es/dashboard-workbench/icon/icon-pie.d.ts +2 -0
  125. package/es/dashboard-workbench/icon/icon-pie.js +24 -0
  126. package/es/dashboard-workbench/icon/icon-pie.js.map +1 -0
  127. package/es/dashboard-workbench/icon/icon-statistics.d.ts +2 -0
  128. package/es/dashboard-workbench/icon/icon-statistics.js +37 -0
  129. package/es/dashboard-workbench/icon/icon-statistics.js.map +1 -0
  130. package/es/dashboard-workbench/icon/icon-strip-bar-percentage.d.ts +2 -0
  131. package/es/dashboard-workbench/icon/icon-strip-bar-percentage.js +105 -0
  132. package/es/dashboard-workbench/icon/icon-strip-bar-percentage.js.map +1 -0
  133. package/es/dashboard-workbench/icon/icon-strip-bar-pile.d.ts +2 -0
  134. package/es/dashboard-workbench/icon/icon-strip-bar-pile.js +105 -0
  135. package/es/dashboard-workbench/icon/icon-strip-bar-pile.js.map +1 -0
  136. package/es/dashboard-workbench/icon/icon-strip-bar.d.ts +2 -0
  137. package/es/dashboard-workbench/icon/icon-strip-bar.js +57 -0
  138. package/es/dashboard-workbench/icon/icon-strip-bar.js.map +1 -0
  139. package/es/dashboard-workbench/index.d.ts +33 -0
  140. package/es/dashboard-workbench/index.js +414 -0
  141. package/es/dashboard-workbench/index.js.map +1 -0
  142. package/es/dashboard-workbench/lang/en-US.d.ts +147 -0
  143. package/es/dashboard-workbench/lang/en-US.js +158 -0
  144. package/es/dashboard-workbench/lang/en-US.js.map +1 -0
  145. package/es/dashboard-workbench/lang/index.d.ts +2 -0
  146. package/es/dashboard-workbench/lang/index.js +25 -0
  147. package/es/dashboard-workbench/lang/index.js.map +1 -0
  148. package/es/dashboard-workbench/lang/zh-CN.d.ts +147 -0
  149. package/es/dashboard-workbench/lang/zh-CN.js +158 -0
  150. package/es/dashboard-workbench/lang/zh-CN.js.map +1 -0
  151. package/es/dashboard-workbench/types.d.ts +22 -0
  152. package/es/dashboard-workbench/utils/index.d.ts +9 -0
  153. package/es/dashboard-workbench/utils/index.js +30 -0
  154. package/es/dashboard-workbench/utils/index.js.map +1 -0
  155. package/es/index.d.ts +1 -0
  156. package/es/index.js +5 -0
  157. package/es/index.js.map +1 -0
  158. package/es/style.css +1 -0
  159. package/package.json +25 -24
  160. package/umd/pivot-table.umd.cjs +178 -0
  161. package/umd/style.css +1 -0
  162. package/index.d.ts +0 -98
  163. package/lib/index.js +0 -52222
  164. package/lib/index.umd.cjs +0 -178
  165. package/lib/style.css +0 -1
@@ -0,0 +1,406 @@
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";
5
+ import { message, Spin } from "antd";
6
+ import { mapConditionsToPostgrest } from "../utils.js";
7
+ import { t } from "i18next";
8
+ import { getChartConfig, getSerie, getGrid } from "./utils.js";
9
+ import { getTransformValue } from "../../../utils/index.js";
10
+ import { useMemoizedFn, useSize } from "ahooks";
11
+ import { Empty } from "./Empty.js";
12
+ const ChartModule = ({
13
+ moduleDataApi,
14
+ customData,
15
+ customeStyle,
16
+ width = 2,
17
+ height = 2
18
+ }) => {
19
+ const { globalData } = useAppContext();
20
+ const [chartData, setChartData] = useState();
21
+ const [loading, setloading] = useState();
22
+ const fetchChartData = useMemoizedFn(async () => {
23
+ var _a, _b;
24
+ setChartData([]);
25
+ if (customData) {
26
+ setloading(true);
27
+ let queryString = "";
28
+ const newXAxisField = (customData == null ? void 0 : customData.xAxis) === "tags" ? "tag" : customData == null ? void 0 : customData.xAxis;
29
+ const newGroupField = (customData == null ? void 0 : customData.groupField) === "tags" ? "tag" : customData == null ? void 0 : customData.groupField;
30
+ if (!customData.isGroup) {
31
+ if (customData.yAxis === "recordTotal") {
32
+ queryString += `select=${newXAxisField},id.count()`;
33
+ }
34
+ if (customData.yAxis === "fieldValue" && (customData == null ? void 0 : customData.yAxisField)) {
35
+ queryString += `select=${newXAxisField},${customData == null ? void 0 : customData.yAxisField}.${customData == null ? void 0 : customData.yAxisFieldType}()`;
36
+ }
37
+ } else {
38
+ if (customData.yAxis === "recordTotal") {
39
+ queryString += `select=${newXAxisField},${newGroupField},id.count()`;
40
+ }
41
+ if (customData.yAxis === "fieldValue" && (customData == null ? void 0 : customData.yAxisField)) {
42
+ queryString += `select=${newXAxisField},${newGroupField},${customData == null ? void 0 : customData.yAxisField}.${customData == null ? void 0 : customData.yAxisFieldType}()`;
43
+ }
44
+ }
45
+ 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
+ queryString += `&${mapConditionsToPostgrest(customData == null ? void 0 : customData.conditionData)}`;
47
+ }
48
+ if (customData == null ? void 0 : customData.dataSourceId) {
49
+ moduleDataApi == null ? void 0 : moduleDataApi({
50
+ id: customData == null ? void 0 : customData.dataSourceId,
51
+ query: queryString
52
+ }).then((res) => {
53
+ if (!res.success) {
54
+ message.error(res.message);
55
+ return;
56
+ }
57
+ setChartData(res.data);
58
+ }).finally(() => {
59
+ setloading(false);
60
+ });
61
+ }
62
+ } else {
63
+ setChartData([]);
64
+ }
65
+ });
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
+ ]);
80
+ const fieldOptions = useMemo(() => {
81
+ var _a, _b;
82
+ 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
+ return ret;
84
+ }, [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;
88
+ 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 }) => {
110
+ return getTransformValue({
111
+ fieldOptions,
112
+ val: item[field],
113
+ field,
114
+ fieldMap: globalData == null ? void 0 : globalData.fieldMap
115
+ });
116
+ };
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
+ });
146
+ };
147
+ const valueCounts = {};
148
+ const valuePercentages = {};
149
+ const valueGroups = {};
150
+ const valueGroupPercentages = {};
151
+ const categories = /* @__PURE__ */ new Set();
152
+ const stackCategories = /* @__PURE__ */ new Set();
153
+ chartData.forEach((item) => {
154
+ const category = getFieldVal({
155
+ item,
156
+ field: newXAxisField
157
+ });
158
+ categories.add(category);
159
+ const val = customData.yAxis === "recordTotal" ? item == null ? void 0 : item.count : item[customData == null ? void 0 : customData.yAxisFieldType] || 0;
160
+ if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
161
+ const stackCategory = getFieldVal({
162
+ item,
163
+ field: newGroupField
164
+ });
165
+ const key = category ?? t("unknown");
166
+ stackCategories.add(stackCategory);
167
+ if (!valueGroups[stackCategory]) {
168
+ valueGroups[stackCategory] = {};
169
+ }
170
+ valueGroups[stackCategory][key] = val;
171
+ } else {
172
+ const key = category ?? t("unknown");
173
+ valueCounts[key] = val;
174
+ }
175
+ });
176
+ if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
177
+ const totalPerCategory = {};
178
+ Object.keys(valueGroups).forEach((stackCategory) => {
179
+ Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {
180
+ totalPerCategory[key] = (totalPerCategory[key] || 0) + val;
181
+ });
182
+ });
183
+ Object.keys(valueGroups).forEach((stackCategory) => {
184
+ valueGroupPercentages[stackCategory] = {};
185
+ Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {
186
+ const total = totalPerCategory[key] || 1;
187
+ valueGroupPercentages[stackCategory][key] = val / total * 100;
188
+ });
189
+ });
190
+ } else {
191
+ Object.entries(valueCounts).forEach(([key, val]) => {
192
+ const total = val || 1;
193
+ valuePercentages[key] = val / total * 100;
194
+ });
195
+ }
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));
206
+ }
207
+ const labels = Array.from(categories);
208
+ const stackLabels = Array.from(stackCategories);
209
+ const chartConfig = getChartConfig(customData.type, labels);
210
+ const series = [];
211
+ if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
212
+ 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;
216
+ }) : 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,
237
+ data,
238
+ label,
239
+ name: customData.yAxis === "recordTotal" ? t("pb.statisticsText") : getFieldLabel(customData == null ? void 0 : customData.yAxisField),
240
+ isGroup: customData == null ? void 0 : customData.isGroup,
241
+ groupField: customData == null ? void 0 : customData.groupField,
242
+ labels
243
+ })
244
+ );
245
+ }
246
+ const grids = getGrid({ series, chartConfig, width });
247
+ const options = {
248
+ legend: {
249
+ type: "scroll",
250
+ left: "center",
251
+ right: "center",
252
+ top: "0",
253
+ show: isShowLegend,
254
+ itemWidth: 12,
255
+ itemHeight: 12,
256
+ data: (series == null ? void 0 : series.map((item) => (item == null ? void 0 : item.name) || "")) || []
257
+ },
258
+ grid: {
259
+ top: grids.top,
260
+ left: grids.left,
261
+ right: grids.right,
262
+ bottom: grids.bottom
263
+ },
264
+ graphic: {
265
+ elements: [
266
+ {
267
+ type: "text",
268
+ left: "center",
269
+ bottom: "10px",
270
+ style: {
271
+ text: (customeStyle == null ? void 0 : customeStyle.xtitle) || "",
272
+ fill: "#333",
273
+ // 文本颜色
274
+ fontSize: 12,
275
+ fontWeight: "bold"
276
+ }
277
+ },
278
+ {
279
+ type: "text",
280
+ left: "10px",
281
+ top: "center",
282
+ style: {
283
+ text: (customeStyle == null ? void 0 : customeStyle.ytitle) || "",
284
+ fill: "#333",
285
+ // 文本颜色
286
+ fontSize: 12,
287
+ fontWeight: "bold"
288
+ },
289
+ rotation: Math.PI / 2
290
+ }
291
+ ]
292
+ },
293
+ xAxis: {
294
+ ...chartConfig.xAxis,
295
+ axisTick: {
296
+ show: (_d = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _d.includes("axis")
297
+ },
298
+ 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"))
300
+ },
301
+ 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")),
303
+ rotate: grids.axisLabelRotate,
304
+ // 使标签倾斜,调整为合适的角度
305
+ interval: "auto",
306
+ // 自动隐藏
307
+ formatter: (value) => {
308
+ return value.length > 15 ? `${value.slice(0, 15)}...` : value;
309
+ },
310
+ ...(_i = chartConfig.xAxis) == null ? void 0 : _i.axisLabel
311
+ },
312
+ splitLine: {
313
+ show: (_j = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _j.includes("splitLine")
314
+ // 不显示x轴网格线
315
+ }
316
+ },
317
+ yAxis: {
318
+ ...chartConfig.yAxis,
319
+ axisTick: {
320
+ show: (_k = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _k.includes("axis")
321
+ },
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轴网格线
336
+ }
337
+ },
338
+ series,
339
+ tooltip: {
340
+ trigger: "item",
341
+ // 触发方式:鼠标悬浮在坐标轴上
342
+ axisPointer: {
343
+ type: "shadow"
344
+ // 阴影指示器,鼠标悬停时显示柱状图的阴影
345
+ },
346
+ appendTo: "body"
347
+ }
348
+ };
349
+ setChartOptions(options);
350
+ } else {
351
+ setChartOptions(void 0);
352
+ }
353
+ });
354
+ useEffect(() => {
355
+ initChartOptions();
356
+ }, [
357
+ customData == null ? void 0 : customData.sortField,
358
+ customData == null ? void 0 : customData.sortOrder,
359
+ customData == null ? void 0 : customData.type,
360
+ customData == null ? void 0 : customData.chartOptions,
361
+ customeStyle,
362
+ chartData,
363
+ width,
364
+ height,
365
+ fieldOptions
366
+ ]);
367
+ const echartRef = useRef();
368
+ const containerRef = useRef(null);
369
+ const size = useSize(containerRef);
370
+ useEffect(() => {
371
+ var _a;
372
+ if (!!size) {
373
+ (_a = echartRef == null ? void 0 : echartRef.current) == null ? void 0 : _a.resize();
374
+ }
375
+ }, [size]);
376
+ const isLoading = loading && !chartOptions;
377
+ const isEmpyt = !loading && !chartOptions;
378
+ const isOk = !isLoading && !isEmpyt;
379
+ console.log("asd", {
380
+ isLoading,
381
+ isEmpyt,
382
+ isOk
383
+ });
384
+ return /* @__PURE__ */ jsxs("div", { style: { width: "100%", height: "100%" }, ref: containerRef, children: [
385
+ isLoading && /* @__PURE__ */ jsx(
386
+ Spin,
387
+ {
388
+ style: {
389
+ width: "100%",
390
+ height: "100%",
391
+ display: "flex",
392
+ justifyContent: "center",
393
+ alignItems: "center"
394
+ },
395
+ spinning: loading
396
+ }
397
+ ),
398
+ isEmpyt && /* @__PURE__ */ jsx(Empty, {}),
399
+ isOk && /* @__PURE__ */ jsx(Chart, { echartRef, options: chartOptions })
400
+ ] });
401
+ };
402
+ const ChartModule$1 = React.memo(ChartModule);
403
+ export {
404
+ ChartModule$1 as default
405
+ };
406
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/chart-module/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { ModuleDataApi, SourceDataFieldsTypes } from '../../../types'\nimport { ChartCustomeDataTypes } from '../../add-module-modal/add-chart-modal/custome-data'\nimport { ChartCustomeStylesTypes } from '../../add-module-modal/add-chart-modal/custome-styles'\nimport BaseChart from './base-chart'\nimport { useAppContext } from '../../../context'\nimport { message, Spin } from 'antd'\nimport { mapConditionsToPostgrest } from '../utils'\nimport { t } from 'i18next'\nimport { getChartConfig, getGrid, getSerie } from './utils'\nimport { getTransformValue } from '../../../utils'\nimport React from 'react'\nimport { useMemoizedFn, useSize } from 'ahooks'\nimport { EChartsOption, LabelFormatterCallback } from 'echarts'\nimport IconEmpty from '@platox/pivot-table/dashboard-workbench/icon/icon-empty'\nimport Empty from './Empty'\n\ninterface ChartModuleProps {\n customData?: ChartCustomeDataTypes\n customeStyle?: ChartCustomeStylesTypes\n onChange?: (val: unknown) => void\n moduleDataApi?: ModuleDataApi\n width?: number\n height?: number\n}\n\nconst ChartModule: React.FC<ChartModuleProps> = ({\n moduleDataApi,\n customData,\n customeStyle,\n width = 2,\n height = 2,\n}) => {\n const { globalData } = useAppContext()\n /* ============================== split =============================== */\n const [chartData, setChartData] = useState<any>()\n const [loading, setloading] = useState<any>()\n const fetchChartData = useMemoizedFn(async () => {\n setChartData([])\n if (customData) {\n // 调用方法\n setloading(true)\n let queryString = ''\n const newXAxisField = customData?.xAxis === 'tags' ? 'tag' : customData?.xAxis\n const newGroupField = customData?.groupField === 'tags' ? 'tag' : customData?.groupField\n\n if (!customData.isGroup) {\n if (customData.yAxis === 'recordTotal') {\n queryString += `select=${newXAxisField},id.count()`\n }\n\n if (customData.yAxis === 'fieldValue' && customData?.yAxisField) {\n queryString += `select=${newXAxisField},${customData?.yAxisField}.${customData?.yAxisFieldType}()`\n }\n } else {\n if (customData.yAxis === 'recordTotal') {\n queryString += `select=${newXAxisField},${newGroupField},id.count()`\n }\n if (customData.yAxis === 'fieldValue' && customData?.yAxisField) {\n queryString += `select=${newXAxisField},${newGroupField},${customData?.yAxisField}.${customData?.yAxisFieldType}()`\n }\n }\n\n if (customData?.conditionData && customData?.conditionData?.conditionList?.length > 0) {\n queryString += `&${mapConditionsToPostgrest(customData?.conditionData)}`\n }\n\n if (customData?.dataSourceId) {\n moduleDataApi?.({\n id: customData?.dataSourceId,\n query: queryString,\n })\n .then((res: any) => {\n if (!res.success) {\n message.error(res.message)\n return\n }\n setChartData(res.data)\n })\n .finally(() => {\n setloading(false)\n })\n }\n } else {\n setChartData([])\n }\n })\n\n useEffect(() => {\n if (customData) {\n fetchChartData()\n }\n }, [\n customData?.dataSourceId,\n customData?.conditionData,\n customData?.xAxis,\n customData?.yAxis,\n customData?.yAxisField,\n customData?.yAxisFieldType,\n customData?.isGroup,\n customData?.groupField,\n ])\n\n /* ============================== split =============================== */\n const fieldOptions = useMemo(() => {\n let ret = globalData?.sourceData?.find(item => item.value === customData?.dataSourceId)?.fields\n return ret\n }, [globalData, customData?.dataSourceId])\n\n const [chartOptions, setChartOptions] = useState<any>()\n\n const initChartOptions = useMemoizedFn(() => {\n if (customData && chartData && customData.type && chartData.length > 0) {\n const formatter: LabelFormatterCallback = data => {\n if (customData?.isGroup && customData?.groupField) {\n return data?.value == 0 ? '' : `${data?.value}`\n } else {\n return `${data?.value}`\n }\n }\n const label = {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.xchartOptions?.includes('label'),\n position: 'top',\n // formatter: '{c}',\n formatter,\n }\n const newXAxisField = customData?.xAxis === 'tags' ? 'tag' : customData?.xAxis\n const newGroupField = customData?.groupField === 'tags' ? 'tag' : customData?.groupField\n const isShowLegend = customData?.chartOptions?.includes('legend')\n\n const getFieldLabel = (field: any) => {\n const fieldData = fieldOptions?.find(item => item.value === field)\n return fieldData?.label\n }\n\n const getFieldVal = ({ item, field }: { item: any; field: any }) => {\n return getTransformValue({\n fieldOptions,\n val: item[field],\n field: field,\n fieldMap: globalData?.fieldMap,\n })\n }\n\n const sortChartData = (\n data: any[],\n sortField: 'xAxis' | 'yAxisField' | 'recordValue',\n sortOrder: 'asc' | 'desc'\n ) => {\n const orderMultiplier = sortOrder === 'asc' ? 1 : -1\n\n return [...data].sort((a, b) => {\n let valA, valB\n\n switch (sortField) {\n case 'xAxis':\n valA = getFieldVal({\n item: a,\n field: newXAxisField,\n })\n valB = getFieldVal({\n item: b,\n field: newXAxisField,\n })\n break\n\n case 'yAxisField':\n valA = a[customData?.yAxisFieldType] || 0\n valB = b[customData?.yAxisFieldType] || 0\n break\n\n case 'recordValue':\n default:\n valA =\n customData.yAxis === 'recordTotal' ? a?.count : a[customData?.yAxisFieldType] || 0\n valB =\n customData.yAxis === 'recordTotal' ? b?.count : b[customData?.yAxisFieldType] || 0\n break\n }\n\n if (valA > valB) return 1 * orderMultiplier\n if (valA < valB) return -1 * orderMultiplier\n return 0\n })\n }\n\n const valueCounts: Record<string, any> = {}\n const valuePercentages: Record<string, any> = {}\n const valueGroups: Record<string, Record<string, number>> = {}\n const valueGroupPercentages: Record<string, Record<string, number>> = {}\n const categories = new Set<string>()\n const stackCategories = new Set<string>()\n\n // 数据分组处理\n chartData.forEach((item: any) => {\n const category = getFieldVal({\n item: item,\n field: newXAxisField,\n })\n\n categories.add(category)\n\n const val =\n customData.yAxis === 'recordTotal' ? item?.count : item[customData?.yAxisFieldType] || 0\n\n if (customData?.isGroup && customData?.groupField) {\n const stackCategory = getFieldVal({\n item: item,\n field: newGroupField,\n })\n\n const key = category ?? t('unknown')\n\n stackCategories.add(stackCategory)\n\n if (!valueGroups[stackCategory]) {\n valueGroups[stackCategory] = {}\n }\n valueGroups[stackCategory][key] = val\n } else {\n const key = category ?? t('unknown')\n valueCounts[key] = val\n }\n })\n\n if (customData?.isGroup && customData?.groupField) {\n const totalPerCategory: Record<string, number> = {}\n\n Object.keys(valueGroups).forEach(stackCategory => {\n Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {\n totalPerCategory[key] = (totalPerCategory[key] || 0) + val\n })\n })\n\n Object.keys(valueGroups).forEach(stackCategory => {\n valueGroupPercentages[stackCategory] = {}\n Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {\n const total = totalPerCategory[key] || 1 // 防止除以 0\n valueGroupPercentages[stackCategory][key] = (val / total) * 100\n })\n })\n } else {\n Object.entries(valueCounts).forEach(([key, val]) => {\n const total = val || 1 // 防止除以 0\n valuePercentages[key] = (val / total) * 100\n })\n }\n\n if (customData?.sortField && customData?.sortOrder) {\n const sortedChartData = sortChartData(chartData, customData.sortField, customData.sortOrder)\n\n const sortedCategories = sortedChartData.map(item =>\n getFieldVal({\n item,\n field: newXAxisField,\n })\n )\n categories.clear()\n sortedCategories.forEach(cat => categories.add(cat))\n }\n\n const labels = Array.from(categories)\n const stackLabels = Array.from(stackCategories)\n\n const chartConfig: any = getChartConfig(customData.type, labels)\n\n const series = []\n if (customData?.isGroup && customData?.groupField) {\n stackLabels.forEach(stackCategory => {\n const data =\n customData.type === 'chart-bar-percentage' ||\n customData.type === 'chart-strip-bar-percentage'\n ? labels.map(label => valueGroupPercentages[stackCategory][label]?.toFixed(2) || 0)\n : labels.map(label => valueGroups[stackCategory][label] || 0)\n series.push(\n getSerie({\n type: customData.type,\n data,\n label,\n name: stackCategory,\n isGroup: customData?.isGroup,\n groupField: customData?.groupField,\n labels,\n })\n )\n })\n } else {\n const data =\n customData.type === 'chart-bar-percentage' ||\n customData.type === 'chart-strip-bar-percentage'\n ? labels.map(label => valuePercentages[label]?.toFixed(2) || 0) // 使用百分比数据\n : labels.map(label => valueCounts[label] || 0)\n series.push(\n getSerie({\n type: customData.type,\n data,\n label,\n name:\n customData.yAxis === 'recordTotal'\n ? t('pb.statisticsText')\n : getFieldLabel(customData?.yAxisField),\n isGroup: customData?.isGroup,\n groupField: customData?.groupField,\n labels,\n })\n )\n }\n\n const grids = getGrid({ series, chartConfig, width })\n\n const options: EChartsOption = {\n legend: {\n type: 'scroll',\n\n left: 'center',\n right: 'center',\n top: '0',\n show: isShowLegend,\n itemWidth: 12,\n itemHeight: 12,\n data: series?.map((item: any) => item?.name || '') || [],\n },\n grid: {\n top: grids.top,\n left: grids.left,\n right: grids.right,\n bottom: grids.bottom,\n },\n graphic: {\n elements: [\n {\n type: 'text',\n left: 'center',\n bottom: '10px',\n style: {\n text: customeStyle?.xtitle || '',\n fill: '#333', // 文本颜色\n fontSize: 12,\n fontWeight: 'bold',\n },\n },\n {\n type: 'text',\n left: '10px',\n top: 'center',\n style: {\n text: customeStyle?.ytitle || '',\n fill: '#333', // 文本颜色\n fontSize: 12,\n fontWeight: 'bold',\n },\n rotation: Math.PI / 2,\n },\n ],\n },\n xAxis: {\n ...chartConfig.xAxis,\n axisTick: {\n show: customData?.chartOptions?.includes('axis'),\n },\n axisLine: {\n show:\n customData?.chartOptions?.includes('axis') ||\n customeStyle?.xchartOptions?.includes('axisLine'),\n },\n axisLabel: {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.xchartOptions?.includes('label'),\n rotate: grids.axisLabelRotate, // 使标签倾斜,调整为合适的角度\n interval: 'auto', // 自动隐藏\n formatter: (value: string) => {\n return value.length > 15 ? `${value.slice(0, 15)}...` : value // 截断并添加 \"...\"\n },\n ...chartConfig.xAxis?.axisLabel,\n },\n splitLine: {\n show: customData?.chartOptions?.includes('splitLine'), // 不显示x轴网格线\n },\n },\n yAxis: {\n ...chartConfig.yAxis,\n axisTick: {\n show: customData?.chartOptions?.includes('axis'),\n },\n axisLine: {\n show:\n customData?.chartOptions?.includes('axis') ||\n customeStyle?.ychartOptions?.includes('axisLine'),\n },\n axisLabel: {\n show:\n customData?.chartOptions?.includes('label') ||\n customeStyle?.ychartOptions?.includes('label'),\n formatter: (value: string) => {\n return value.length > 15 ? `${value.slice(0, 15)}...` : value // 截断并添加 \"...\"\n },\n hideOverlap: true,\n ...chartConfig.yAxis?.axisLabel,\n },\n splitLine: {\n show: customData?.chartOptions?.includes('splitLine'), // 不显示x轴网格线\n },\n },\n series: series,\n tooltip: {\n trigger: 'item', // 触发方式:鼠标悬浮在坐标轴上\n axisPointer: {\n type: 'shadow', // 阴影指示器,鼠标悬停时显示柱状图的阴影\n },\n appendTo: 'body',\n },\n }\n setChartOptions(options)\n } else {\n setChartOptions(undefined)\n }\n })\n\n useEffect(() => {\n initChartOptions()\n }, [\n customData?.sortField,\n customData?.sortOrder,\n customData?.type,\n customData?.chartOptions,\n customeStyle,\n chartData,\n width,\n height,\n fieldOptions,\n ])\n\n /* ============================== split =============================== */\n const echartRef = useRef<any>()\n const containerRef = useRef<HTMLDivElement>(null)\n const size = useSize(containerRef)\n\n useEffect(() => {\n if (!!size) {\n echartRef?.current?.resize()\n }\n }, [size])\n\n const isLoading = loading && !chartOptions\n const isEmpyt = !loading && !chartOptions\n const isOk = !isLoading && !isEmpyt\n\n console.log('asd', {\n isLoading,\n isEmpyt,\n isOk,\n })\n\n return (\n <div style={{ width: '100%', height: '100%' }} ref={containerRef}>\n {isLoading && (\n <Spin\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n }}\n spinning={loading}\n />\n )}\n {isEmpyt && <Empty />}\n {isOk && <BaseChart echartRef={echartRef} options={chartOptions} />}\n </div>\n )\n}\n\nexport default React.memo(ChartModule)\n"],"names":["label","_a","BaseChart"],"mappings":";;;;;;;;;;;AA2BA,MAAM,cAA0C,CAAC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,SAAS;AACX,MAAM;AACE,QAAA,EAAE,WAAW,IAAI,cAAc;AAErC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAc;AAChD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAc;AACtC,QAAA,iBAAiB,cAAc,YAAY;;AAC/C,iBAAa,CAAA,CAAE;AACf,QAAI,YAAY;AAEd,iBAAW,IAAI;AACf,UAAI,cAAc;AAClB,YAAM,iBAAgB,yCAAY,WAAU,SAAS,QAAQ,yCAAY;AACzE,YAAM,iBAAgB,yCAAY,gBAAe,SAAS,QAAQ,yCAAY;AAE1E,UAAA,CAAC,WAAW,SAAS;AACnB,YAAA,WAAW,UAAU,eAAe;AACtC,yBAAe,UAAU,aAAa;AAAA,QAAA;AAGxC,YAAI,WAAW,UAAU,iBAAgB,yCAAY,aAAY;AAC/D,yBAAe,UAAU,aAAa,IAAI,yCAAY,UAAU,IAAI,yCAAY,cAAc;AAAA,QAAA;AAAA,MAChG,OACK;AACD,YAAA,WAAW,UAAU,eAAe;AACvB,yBAAA,UAAU,aAA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W,CAAC;AACvB,QAAA,OAAO,CAAC,aAAa,CAAC;AAE5B,UAAQ,IAAI,OAAO;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAGC,SAAA,qBAAC,OAAI,EAAA,OAAO,EAAE,OAAO,QAAQ,QAAQ,OAAU,GAAA,KAAK,cACjD,UAAA;AAAA,IACC,aAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO;AAAA,UACL,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,SAAS;AAAA,UACT,gBAAgB;AAAA,UAChB,YAAY;AAAA,QACd;AAAA,QACA,UAAU;AAAA,MAAA;AAAA,IACZ;AAAA,IAED,+BAAY,OAAM,EAAA;AAAA,IAClB,QAAQ,oBAACE,OAAU,EAAA,WAAsB,SAAS,aAAc,CAAA;AAAA,EAAA,GACnE;AAEJ;AAEA,MAAA,gBAAe,MAAM,KAAK,WAAW;"}
@@ -0,0 +1,9 @@
1
+ export declare const getChartConfig: (type: any, categories: any) => any;
2
+ export declare const getSerie: ({ type, data, label, name, isGroup, groupField, labels }: any) => any;
3
+ export declare const getGrid: ({ series, chartConfig, width }: any) => {
4
+ top: string;
5
+ left: string;
6
+ right: string;
7
+ bottom: string;
8
+ axisLabelRotate: number;
9
+ };
@@ -0,0 +1,200 @@
1
+ const getChartConfig = (type, categories) => {
2
+ const optionsConfig = {
3
+ "chart-bar": {
4
+ xAxis: {
5
+ type: "category",
6
+ data: categories
7
+ },
8
+ yAxis: {
9
+ type: "value"
10
+ }
11
+ },
12
+ "chart-bar-pile": {
13
+ xAxis: { type: "category", data: categories },
14
+ yAxis: { type: "value" }
15
+ },
16
+ "chart-bar-percentage": {
17
+ xAxis: { type: "category", data: categories },
18
+ yAxis: {
19
+ type: "value",
20
+ max: 100,
21
+ axisLabel: {
22
+ formatter: "{value} %"
23
+ // 在值后面添加 'kg'
24
+ }
25
+ }
26
+ },
27
+ "chart-line": {
28
+ xAxis: { type: "category", data: categories },
29
+ yAxis: { type: "value" }
30
+ },
31
+ "chart-line-smooth": {
32
+ xAxis: { type: "category", data: categories },
33
+ yAxis: { type: "value" }
34
+ },
35
+ "chart-pie": {
36
+ xAxis: { show: false },
37
+ yAxis: { show: false }
38
+ },
39
+ "chart-pie-circular": {
40
+ xAxis: { show: false },
41
+ yAxis: { show: false }
42
+ },
43
+ "chart-strip-bar": {
44
+ xAxis: { type: "value" },
45
+ yAxis: { type: "category", data: categories }
46
+ },
47
+ "chart-strip-bar-pile": {
48
+ xAxis: { type: "value" },
49
+ yAxis: { type: "category", data: categories }
50
+ },
51
+ "chart-strip-bar-percentage": {
52
+ xAxis: {
53
+ type: "value",
54
+ max: 100,
55
+ axisLabel: {
56
+ formatter: "{value} %"
57
+ // 在值后面添加 'kg'
58
+ }
59
+ },
60
+ yAxis: {
61
+ type: "category",
62
+ data: categories
63
+ }
64
+ }
65
+ };
66
+ return optionsConfig[type];
67
+ };
68
+ const getSerie = ({ type, data, label, name, isGroup, groupField, labels }) => {
69
+ let serie;
70
+ if (type === "chart-pie") {
71
+ serie = {
72
+ data: data.map((item, idx) => ({
73
+ value: item,
74
+ name: labels[idx]
75
+ })),
76
+ name,
77
+ type: "pie",
78
+ radius: "50%",
79
+ label: {
80
+ ...label,
81
+ position: "outside"
82
+ },
83
+ labelLine: {
84
+ normal: {
85
+ show: true
86
+ }
87
+ }
88
+ };
89
+ } else if (type === "chart-pie-circular") {
90
+ serie = {
91
+ data: data.map((item, idx) => ({
92
+ value: item,
93
+ name: labels[idx]
94
+ })),
95
+ type: "pie",
96
+ name,
97
+ radius: ["40%", "70%"],
98
+ label: {
99
+ ...label,
100
+ position: "outside"
101
+ },
102
+ labelLine: {
103
+ normal: {
104
+ show: true
105
+ }
106
+ }
107
+ };
108
+ } else if (type === "chart-line") {
109
+ serie = {
110
+ data,
111
+ name,
112
+ type: "line",
113
+ label
114
+ };
115
+ } else if (type === "chart-line-smooth") {
116
+ serie = {
117
+ data,
118
+ name,
119
+ type: "line",
120
+ smooth: true,
121
+ // 这里设置平滑曲线
122
+ label
123
+ };
124
+ } else {
125
+ serie = {
126
+ data,
127
+ name,
128
+ type: "bar",
129
+ label
130
+ };
131
+ }
132
+ if (type === "chart-bar-percentage" || type === "chart-bar-pile" || type === "chart-strip-bar-pile" || type === "chart-strip-bar-percentage") {
133
+ if (isGroup && groupField) {
134
+ serie.stack = groupField;
135
+ }
136
+ }
137
+ return serie;
138
+ };
139
+ const getGrid = ({ series, chartConfig, width }) => {
140
+ var _a, _b, _c, _d;
141
+ const maxSeriesDataStrLen = Math.max(
142
+ ...(series ?? []).flatMap(
143
+ (item) => item.data.map((value) => String(value).length)
144
+ ) || []
145
+ );
146
+ const maxSeriesDataLen = Math.max(
147
+ ...(series == null ? void 0 : series.flatMap((item) => item.data.length)) || []
148
+ );
149
+ let labelAxis = ((_a = chartConfig == null ? void 0 : chartConfig.xAxis) == null ? void 0 : _a.type) === "category" ? "xAxis" : "yAxis";
150
+ let labelData = labelAxis === "xAxis" ? (_b = chartConfig == null ? void 0 : chartConfig.xAxis) == null ? void 0 : _b.data : (_c = chartConfig == null ? void 0 : chartConfig.yAxis) == null ? void 0 : _c.data;
151
+ const maxLabelLength = (_d = labelData ?? []) == null ? void 0 : _d.reduce((maxLength, value) => {
152
+ const length = String(value).length;
153
+ return Math.max(maxLength, length);
154
+ }, 0);
155
+ const fontSize = 9;
156
+ const gap = 12;
157
+ let top = 45;
158
+ let left = 0;
159
+ let right = gap;
160
+ let bottom = 0;
161
+ let axisRtateX = 0;
162
+ if (labelAxis == "xAxis") {
163
+ const labelUnitMapping = {
164
+ ["45"]: fontSize * 0.8,
165
+ // 根号2
166
+ ["90"]: fontSize,
167
+ ["0"]: fontSize
168
+ };
169
+ if (maxSeriesDataLen > 3) {
170
+ if (maxLabelLength >= 15) {
171
+ axisRtateX = 90;
172
+ }
173
+ if (maxLabelLength > 5) {
174
+ axisRtateX = 45;
175
+ }
176
+ if (width < 3) {
177
+ axisRtateX = 90;
178
+ }
179
+ }
180
+ const labelUnit = labelUnitMapping[`${axisRtateX}`];
181
+ bottom = labelUnit * (axisRtateX == 0 ? 1 : Math.min(maxLabelLength, 18)) + gap;
182
+ left = Math.min(maxSeriesDataStrLen, 18) * fontSize + gap;
183
+ } else {
184
+ bottom = Math.min(maxSeriesDataStrLen, 18) * fontSize + gap;
185
+ left = Math.min(maxLabelLength, 18) * fontSize + gap;
186
+ }
187
+ return {
188
+ top: top + "px",
189
+ left: Math.max(left, 40) + "px",
190
+ right: right + "px",
191
+ bottom: Math.max(bottom, 40) + "px",
192
+ axisLabelRotate: axisRtateX
193
+ };
194
+ };
195
+ export {
196
+ getChartConfig,
197
+ getGrid,
198
+ getSerie
199
+ };
200
+ //# sourceMappingURL=utils.js.map