@platox/pivot-table 0.0.42 → 0.0.43
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.
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js +156 -160
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +2 -1
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -1
- package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js +2 -1
- package/es/dashboard-workbench/components/global-filter-condition/ConditionSymbolAndValuePicker.js.map +1 -1
- package/es/dashboard-workbench/components/global-filter-condition/index.module.less.js +3 -3
- package/es/dashboard-workbench/components/module-content/chart-module/index.js +307 -278
- package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -1
- package/es/style.css +1 -1
- package/package.json +1 -1
- package/umd/pivot-table.umd.cjs +46 -46
- package/umd/style.css +1 -1
|
@@ -3,6 +3,7 @@ import React, { useMemo, useState, useRef, useEffect } from "react";
|
|
|
3
3
|
import { message, Spin } from "antd";
|
|
4
4
|
import { useMemoizedFn, useDebounceEffect, useSize } from "ahooks";
|
|
5
5
|
import { t } from "i18next";
|
|
6
|
+
import { groupBy, isNumber } from "lodash-es";
|
|
6
7
|
import { useAppContext } from "../../../context.js";
|
|
7
8
|
import { getTransformValue } from "../../../utils/index.js";
|
|
8
9
|
import { ChartType } from "../../add-module-modal/add-chart-modal/interface.js";
|
|
@@ -87,6 +88,8 @@ const ChartModule = ({
|
|
|
87
88
|
[
|
|
88
89
|
customData == null ? void 0 : customData.dataSourceId,
|
|
89
90
|
customData == null ? void 0 : customData.conditionData,
|
|
91
|
+
customData == null ? void 0 : customData.sortField,
|
|
92
|
+
customData == null ? void 0 : customData.sortOrder,
|
|
90
93
|
customData == null ? void 0 : customData.xAxis,
|
|
91
94
|
customData == null ? void 0 : customData.yAxis,
|
|
92
95
|
customData == null ? void 0 : customData.yAxisField,
|
|
@@ -103,334 +106,360 @@ const ChartModule = ({
|
|
|
103
106
|
return ret;
|
|
104
107
|
}, [globalData, customData == null ? void 0 : customData.dataSourceId]);
|
|
105
108
|
const chartOptions = useMemo(() => {
|
|
106
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
107
109
|
if (customData && chartData && customData.type && chartData.length > 0) {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}) => {
|
|
113
|
-
return getTransformValue({
|
|
114
|
-
fieldOptions,
|
|
115
|
-
val: item[field],
|
|
110
|
+
const getChartOptions = (_chartData) => {
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
112
|
+
const getFieldVal = ({
|
|
113
|
+
item,
|
|
116
114
|
field,
|
|
117
|
-
fieldMap: globalData == null ? void 0 : globalData.fieldMap,
|
|
118
115
|
timeGroupInterval
|
|
116
|
+
}) => {
|
|
117
|
+
return getTransformValue({
|
|
118
|
+
fieldOptions,
|
|
119
|
+
val: item[field],
|
|
120
|
+
field,
|
|
121
|
+
fieldMap: globalData == null ? void 0 : globalData.fieldMap,
|
|
122
|
+
timeGroupInterval
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
const getFieldLabel = (field) => {
|
|
126
|
+
const fieldData = fieldOptions == null ? void 0 : fieldOptions.find((item) => item.value === field);
|
|
127
|
+
return fieldData == null ? void 0 : fieldData.label;
|
|
128
|
+
};
|
|
129
|
+
const isTimeField = (fieldName) => {
|
|
130
|
+
var _a2;
|
|
131
|
+
return ((_a2 = fieldOptions == null ? void 0 : fieldOptions.find((item) => item.value === fieldName)) == null ? void 0 : _a2.type) === "timestamp";
|
|
132
|
+
};
|
|
133
|
+
const mapping = {
|
|
134
|
+
tags: "tag"
|
|
135
|
+
//后端数据名不一致
|
|
136
|
+
};
|
|
137
|
+
const newXAxisField = mapping[customData == null ? void 0 : customData.xAxis] ?? (customData == null ? void 0 : customData.xAxis);
|
|
138
|
+
const newGroupField = mapping[customData == null ? void 0 : customData.groupField] ?? (customData == null ? void 0 : customData.groupField);
|
|
139
|
+
let groupData = groupBy(_chartData, (item) => {
|
|
140
|
+
const category = getFieldVal({
|
|
141
|
+
item,
|
|
142
|
+
field: newXAxisField,
|
|
143
|
+
timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
|
|
144
|
+
});
|
|
145
|
+
return category;
|
|
119
146
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const newGroupField = mapping[customData == null ? void 0 : customData.groupField] ?? (customData == null ? void 0 : customData.groupField);
|
|
135
|
-
const categories = /* @__PURE__ */ new Set();
|
|
136
|
-
const stackCategories = /* @__PURE__ */ new Set();
|
|
137
|
-
const valueGroups = {};
|
|
138
|
-
const valueCounts = {};
|
|
139
|
-
chartData.forEach((item) => {
|
|
140
|
-
const category = getFieldVal({
|
|
141
|
-
item,
|
|
142
|
-
field: newXAxisField,
|
|
143
|
-
timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
|
|
147
|
+
let chartData2 = Object.keys(groupData).map((key) => {
|
|
148
|
+
let groupList = groupData[key];
|
|
149
|
+
let mergeObj = groupList.reduce((acc, item) => {
|
|
150
|
+
Object.keys(item).forEach((k) => {
|
|
151
|
+
let value = item[k];
|
|
152
|
+
if (isNumber(value)) {
|
|
153
|
+
acc[k] = (acc == null ? void 0 : acc[k]) ? acc[k] + value : value;
|
|
154
|
+
} else {
|
|
155
|
+
acc[k] = value;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return acc;
|
|
159
|
+
}, {});
|
|
160
|
+
return mergeObj;
|
|
144
161
|
});
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
const categories = /* @__PURE__ */ new Set();
|
|
163
|
+
const stackCategories = /* @__PURE__ */ new Set();
|
|
164
|
+
const valueGroups = {};
|
|
165
|
+
const valueCounts = {};
|
|
166
|
+
chartData2.forEach((item) => {
|
|
167
|
+
const category = getFieldVal({
|
|
150
168
|
item,
|
|
151
|
-
field:
|
|
169
|
+
field: newXAxisField,
|
|
170
|
+
timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
|
|
152
171
|
});
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
172
|
+
const val = customData.yAxis === "recordTotal" ? item == null ? void 0 : item.count : item[customData == null ? void 0 : customData.yAxisFieldType] || 0;
|
|
173
|
+
const key = category ?? t("unknown");
|
|
174
|
+
valueCounts[key] = val;
|
|
175
|
+
if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
|
|
176
|
+
const stackCategory = getFieldVal({
|
|
177
|
+
item,
|
|
178
|
+
field: newGroupField
|
|
179
|
+
});
|
|
180
|
+
const key2 = category ?? t("unknown");
|
|
181
|
+
stackCategories.add(stackCategory);
|
|
182
|
+
if (!valueGroups[stackCategory]) {
|
|
183
|
+
valueGroups[stackCategory] = {};
|
|
184
|
+
}
|
|
185
|
+
valueGroups[stackCategory][key2] = val;
|
|
157
186
|
}
|
|
158
|
-
valueGroups[stackCategory][key2] = val;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
const valuePercentages = {};
|
|
162
|
-
const valueGroupPercentages = {};
|
|
163
|
-
if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
|
|
164
|
-
const totalPerCategory = {};
|
|
165
|
-
Object.keys(valueGroups).forEach((stackCategory) => {
|
|
166
|
-
Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {
|
|
167
|
-
totalPerCategory[key] = (totalPerCategory[key] || 0) + val;
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
Object.keys(valueGroups).forEach((stackCategory) => {
|
|
171
|
-
valueGroupPercentages[stackCategory] = {};
|
|
172
|
-
Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {
|
|
173
|
-
const total = totalPerCategory[key] || 1;
|
|
174
|
-
valueGroupPercentages[stackCategory][key] = val / total * 100;
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
} else {
|
|
178
|
-
Object.entries(valueCounts).forEach(([key, val]) => {
|
|
179
|
-
const total = val || 1;
|
|
180
|
-
valuePercentages[key] = val / total * 100;
|
|
181
187
|
});
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
valA = getFieldVal({
|
|
190
|
-
item: a,
|
|
191
|
-
field: newXAxisField,
|
|
192
|
-
timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
|
|
188
|
+
const valuePercentages = {};
|
|
189
|
+
const valueGroupPercentages = {};
|
|
190
|
+
if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
|
|
191
|
+
const totalPerCategory = {};
|
|
192
|
+
Object.keys(valueGroups).forEach((stackCategory) => {
|
|
193
|
+
Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {
|
|
194
|
+
totalPerCategory[key] = (totalPerCategory[key] || 0) + val;
|
|
193
195
|
});
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
});
|
|
197
|
+
Object.keys(valueGroups).forEach((stackCategory) => {
|
|
198
|
+
valueGroupPercentages[stackCategory] = {};
|
|
199
|
+
Object.entries(valueGroups[stackCategory]).forEach(([key, val]) => {
|
|
200
|
+
const total = totalPerCategory[key] || 1;
|
|
201
|
+
valueGroupPercentages[stackCategory][key] = val / total * 100;
|
|
198
202
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
Object.entries(valueCounts).forEach(([key, val]) => {
|
|
206
|
+
const total = val || 1;
|
|
207
|
+
valuePercentages[key] = val / total * 100;
|
|
208
|
+
});
|
|
204
209
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
210
|
+
let sortField = (customData == null ? void 0 : customData.sortField) ?? "xAxis";
|
|
211
|
+
let sortOrder = (customData == null ? void 0 : customData.sortOrder) ?? "asc";
|
|
212
|
+
const sortedChartData = [...chartData2].sort((a, b) => {
|
|
213
|
+
let valA, valB;
|
|
214
|
+
switch (sortField) {
|
|
215
|
+
case "xAxis":
|
|
216
|
+
valA = getFieldVal({
|
|
217
|
+
item: a,
|
|
218
|
+
field: newXAxisField,
|
|
219
|
+
timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
|
|
220
|
+
});
|
|
221
|
+
valB = getFieldVal({
|
|
222
|
+
item: b,
|
|
223
|
+
field: newXAxisField,
|
|
224
|
+
timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
|
|
225
|
+
});
|
|
226
|
+
break;
|
|
227
|
+
case "yAxisField":
|
|
228
|
+
valA = customData.yAxis === "recordTotal" ? a == null ? void 0 : a.count : a[customData == null ? void 0 : customData.yAxisFieldType] || 0;
|
|
229
|
+
valB = customData.yAxis === "recordTotal" ? b == null ? void 0 : b.count : b[customData == null ? void 0 : customData.yAxisFieldType] || 0;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
const orderMultiplier = sortOrder === "asc" ? 1 : -1;
|
|
233
|
+
if (valA > valB) return 1 * orderMultiplier;
|
|
234
|
+
if (valA < valB) return -1 * orderMultiplier;
|
|
235
|
+
return 0;
|
|
222
236
|
});
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
237
|
+
const sortedCategories = sortedChartData.map(
|
|
238
|
+
(item) => getFieldVal({
|
|
239
|
+
item,
|
|
240
|
+
field: newXAxisField,
|
|
241
|
+
timeGroupInterval: customData == null ? void 0 : customData.timeGroupInterval
|
|
242
|
+
})
|
|
243
|
+
);
|
|
244
|
+
categories.clear();
|
|
245
|
+
sortedCategories.forEach((cat) => categories.add(cat));
|
|
246
|
+
if (!isTimeField(customData == null ? void 0 : customData.xAxis) && customData.displayRange !== "ALL" && !!customData.displayRange) {
|
|
247
|
+
let sortedByCountCategories = Array.from(categories).sort((a, b) => {
|
|
248
|
+
return valueCounts[b] - valueCounts[a];
|
|
249
|
+
});
|
|
250
|
+
let ableCategories = [];
|
|
251
|
+
let [pos, count] = customData.displayRange.split("_");
|
|
252
|
+
if (pos === "TOP") {
|
|
253
|
+
ableCategories = sortedByCountCategories.slice(0, Number(count));
|
|
254
|
+
} else {
|
|
255
|
+
ableCategories = sortedByCountCategories.slice(-Number(count));
|
|
256
|
+
}
|
|
257
|
+
Array.from(categories).forEach((item) => {
|
|
258
|
+
if (!ableCategories.includes(item)) {
|
|
259
|
+
categories.delete(item);
|
|
260
|
+
}
|
|
261
|
+
return item;
|
|
262
|
+
});
|
|
229
263
|
}
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
|
|
264
|
+
const formatter = (data) => {
|
|
265
|
+
if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
|
|
266
|
+
return (data == null ? void 0 : data.value) == 0 ? "" : `${data == null ? void 0 : data.value}`;
|
|
267
|
+
} else {
|
|
268
|
+
return `${data == null ? void 0 : data.value}`;
|
|
233
269
|
}
|
|
234
|
-
|
|
270
|
+
};
|
|
271
|
+
const label = {
|
|
272
|
+
show: (_a = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _a.includes("label"),
|
|
273
|
+
position: "top",
|
|
274
|
+
formatter
|
|
275
|
+
};
|
|
276
|
+
const labels = Array.from(categories);
|
|
277
|
+
const stackLabels = Array.from(stackCategories);
|
|
278
|
+
const series = [];
|
|
279
|
+
const chartConfig = getChartConfig({
|
|
280
|
+
type: customData == null ? void 0 : customData.type,
|
|
281
|
+
categories: labels
|
|
235
282
|
});
|
|
236
|
-
}
|
|
237
|
-
const formatter = (data) => {
|
|
238
283
|
if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
|
|
239
|
-
|
|
284
|
+
stackLabels.forEach((stackCategory) => {
|
|
285
|
+
var _a2, _b2;
|
|
286
|
+
const data = ["chart-bar-percentage", "chart-strip-bar-percentage"].includes(
|
|
287
|
+
customData.type
|
|
288
|
+
) ? labels.map((label2) => {
|
|
289
|
+
var _a3;
|
|
290
|
+
return ((_a3 = valueGroupPercentages[stackCategory][label2]) == null ? void 0 : _a3.toFixed(2)) || 0;
|
|
291
|
+
}) : labels.map((label2) => valueGroups[stackCategory][label2] || 0);
|
|
292
|
+
let type = customData.type;
|
|
293
|
+
let yAxisPos = "left";
|
|
294
|
+
if (type == ChartType["chartCombination"]) {
|
|
295
|
+
let matchCombinationChartConfig = ((customData == null ? void 0 : customData.groupFieldConfig) ?? []).find(
|
|
296
|
+
(item) => getFieldVal({
|
|
297
|
+
item: {
|
|
298
|
+
[newGroupField]: item == null ? void 0 : item.value
|
|
299
|
+
},
|
|
300
|
+
field: newGroupField
|
|
301
|
+
}) == stackCategory
|
|
302
|
+
);
|
|
303
|
+
type = ((_a2 = matchCombinationChartConfig == null ? void 0 : matchCombinationChartConfig.config) == null ? void 0 : _a2.chartType) ?? ChartType["ChartBar"];
|
|
304
|
+
yAxisPos = ((_b2 = matchCombinationChartConfig == null ? void 0 : matchCombinationChartConfig.config) == null ? void 0 : _b2.yAxisPos) ?? "left";
|
|
305
|
+
}
|
|
306
|
+
let seriesItem = getSerie({
|
|
307
|
+
type,
|
|
308
|
+
data,
|
|
309
|
+
label,
|
|
310
|
+
name: stackCategory,
|
|
311
|
+
isGroup: customData == null ? void 0 : customData.isGroup,
|
|
312
|
+
groupField: customData == null ? void 0 : customData.groupField,
|
|
313
|
+
labels
|
|
314
|
+
});
|
|
315
|
+
seriesItem.yAxisIndex = yAxisPos == "left" ? 0 : 1;
|
|
316
|
+
series.push(seriesItem);
|
|
317
|
+
});
|
|
240
318
|
} 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
|
-
};
|
|
249
|
-
const labels = Array.from(categories);
|
|
250
|
-
const stackLabels = Array.from(stackCategories);
|
|
251
|
-
const series = [];
|
|
252
|
-
const chartConfig = getChartConfig({
|
|
253
|
-
type: customData == null ? void 0 : customData.type,
|
|
254
|
-
categories: labels
|
|
255
|
-
});
|
|
256
|
-
if ((customData == null ? void 0 : customData.isGroup) && (customData == null ? void 0 : customData.groupField)) {
|
|
257
|
-
stackLabels.forEach((stackCategory) => {
|
|
258
|
-
var _a2, _b2;
|
|
259
319
|
const data = ["chart-bar-percentage", "chart-strip-bar-percentage"].includes(
|
|
260
320
|
customData.type
|
|
261
321
|
) ? labels.map((label2) => {
|
|
262
|
-
var
|
|
263
|
-
return ((
|
|
264
|
-
}) : labels.map((label2) =>
|
|
322
|
+
var _a2;
|
|
323
|
+
return ((_a2 = valuePercentages[label2]) == null ? void 0 : _a2.toFixed(2)) || 0;
|
|
324
|
+
}) : labels.map((label2) => valueCounts[label2] || 0);
|
|
265
325
|
let type = customData.type;
|
|
266
326
|
let yAxisPos = "left";
|
|
267
327
|
if (type == ChartType["chartCombination"]) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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";
|
|
328
|
+
type = ((_b = customData == null ? void 0 : customData.yAxisFieldConfig) == null ? void 0 : _b.chartType) ?? ChartType["ChartBar"];
|
|
329
|
+
} else {
|
|
330
|
+
yAxisPos = ((_c = customData == null ? void 0 : customData.yAxisFieldConfig) == null ? void 0 : _c.yAxisPos) ?? "left";
|
|
278
331
|
}
|
|
279
332
|
let seriesItem = getSerie({
|
|
280
|
-
type,
|
|
333
|
+
type: customData.type,
|
|
281
334
|
data,
|
|
282
335
|
label,
|
|
283
|
-
name:
|
|
336
|
+
name: customData.yAxis === "recordTotal" ? t("pb.statisticsText") : getFieldLabel(customData == null ? void 0 : customData.yAxisField),
|
|
284
337
|
isGroup: customData == null ? void 0 : customData.isGroup,
|
|
285
338
|
groupField: customData == null ? void 0 : customData.groupField,
|
|
286
339
|
labels
|
|
287
340
|
});
|
|
288
341
|
seriesItem.yAxisIndex = yAxisPos == "left" ? 0 : 1;
|
|
289
342
|
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
343
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
groupField: customData == null ? void 0 : customData.groupField,
|
|
312
|
-
labels
|
|
313
|
-
});
|
|
314
|
-
seriesItem.yAxisIndex = yAxisPos == "left" ? 0 : 1;
|
|
315
|
-
series.push(seriesItem);
|
|
316
|
-
}
|
|
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
|
-
};
|
|
342
|
-
const options = {
|
|
343
|
-
legend: {
|
|
344
|
-
type: "scroll",
|
|
345
|
-
left: "center",
|
|
346
|
-
right: "center",
|
|
347
|
-
top: "0",
|
|
348
|
-
show: isShowLegend,
|
|
349
|
-
itemWidth: 12,
|
|
350
|
-
itemHeight: 12,
|
|
351
|
-
data: (series == null ? void 0 : series.map((item) => (item == null ? void 0 : item.name) || "")) || []
|
|
352
|
-
},
|
|
353
|
-
grid: {
|
|
354
|
-
top: grids.top,
|
|
355
|
-
left: grids.left,
|
|
356
|
-
right: grids.right,
|
|
357
|
-
bottom: grids.bottom
|
|
358
|
-
},
|
|
359
|
-
graphic: {
|
|
360
|
-
elements: [
|
|
361
|
-
{
|
|
362
|
-
type: "text",
|
|
363
|
-
left: "center",
|
|
364
|
-
bottom: "10px",
|
|
365
|
-
style: {
|
|
366
|
-
text: (customeStyle == null ? void 0 : customeStyle.xtitle) || "",
|
|
367
|
-
fill: "#333",
|
|
368
|
-
// 文本颜色
|
|
369
|
-
fontSize: 12,
|
|
370
|
-
fontWeight: "bold"
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
type: "text",
|
|
375
|
-
left: "10px",
|
|
376
|
-
top: "center",
|
|
377
|
-
style: {
|
|
378
|
-
text: (customeStyle == null ? void 0 : customeStyle.ytitle) || "",
|
|
379
|
-
fill: "#333",
|
|
380
|
-
// 文本颜色
|
|
381
|
-
fontSize: 12,
|
|
382
|
-
fontWeight: "bold"
|
|
383
|
-
},
|
|
384
|
-
rotation: Math.PI / 2
|
|
385
|
-
}
|
|
386
|
-
]
|
|
387
|
-
},
|
|
388
|
-
xAxis: {
|
|
389
|
-
...chartConfig.xAxis,
|
|
344
|
+
const grids = getGrid({ series, chartConfig, width, customeStyle });
|
|
345
|
+
const isShowLegend = (_d = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _d.includes("legend");
|
|
346
|
+
let isLeftYAxisShow = series.some((item) => (item == null ? void 0 : item.yAxisIndex) == 0);
|
|
347
|
+
let isRightYAxisShow = series.some((item) => (item == null ? void 0 : item.yAxisIndex) == 1);
|
|
348
|
+
let yAxisConfig = {
|
|
349
|
+
...chartConfig.yAxis,
|
|
390
350
|
axisTick: {
|
|
391
|
-
show: (
|
|
351
|
+
show: (_e = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _e.includes("axis")
|
|
392
352
|
},
|
|
393
353
|
axisLine: {
|
|
394
|
-
show: (
|
|
354
|
+
show: (_f = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _f.includes("axis")
|
|
395
355
|
},
|
|
396
356
|
axisLabel: {
|
|
397
|
-
show: (
|
|
398
|
-
rotate: grids.axisLabelRotate,
|
|
399
|
-
// 使标签倾斜,调整为合适的角度
|
|
400
|
-
interval: "auto",
|
|
401
|
-
// 自动隐藏
|
|
357
|
+
show: (_g = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _g.includes("label"),
|
|
402
358
|
formatter: (value) => {
|
|
403
359
|
return value.length > 15 ? `${value.slice(0, 15)}...` : value;
|
|
404
360
|
},
|
|
405
|
-
|
|
361
|
+
hideOverlap: true,
|
|
362
|
+
...(_h = chartConfig.yAxis) == null ? void 0 : _h.axisLabel
|
|
406
363
|
},
|
|
407
364
|
splitLine: {
|
|
408
|
-
show: (
|
|
365
|
+
show: (_i = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _i.includes("splitLine")
|
|
409
366
|
// 不显示x轴网格线
|
|
410
367
|
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
{
|
|
414
|
-
|
|
415
|
-
|
|
368
|
+
};
|
|
369
|
+
const options = {
|
|
370
|
+
legend: {
|
|
371
|
+
type: "scroll",
|
|
372
|
+
left: "center",
|
|
373
|
+
right: "center",
|
|
374
|
+
top: "0",
|
|
375
|
+
show: isShowLegend,
|
|
376
|
+
itemWidth: 12,
|
|
377
|
+
itemHeight: 12,
|
|
378
|
+
data: (series == null ? void 0 : series.map((item) => (item == null ? void 0 : item.name) || "")) || []
|
|
416
379
|
},
|
|
417
|
-
{
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
series,
|
|
423
|
-
tooltip: {
|
|
424
|
-
trigger: "item",
|
|
425
|
-
// 触发方式:鼠标悬浮在坐标轴上
|
|
426
|
-
axisPointer: {
|
|
427
|
-
type: "shadow"
|
|
428
|
-
// 阴影指示器,鼠标悬停时显示柱状图的阴影
|
|
380
|
+
grid: {
|
|
381
|
+
top: grids.top,
|
|
382
|
+
left: grids.left,
|
|
383
|
+
right: grids.right,
|
|
384
|
+
bottom: grids.bottom
|
|
429
385
|
},
|
|
430
|
-
|
|
431
|
-
|
|
386
|
+
graphic: {
|
|
387
|
+
elements: [
|
|
388
|
+
{
|
|
389
|
+
type: "text",
|
|
390
|
+
left: "center",
|
|
391
|
+
bottom: "10px",
|
|
392
|
+
style: {
|
|
393
|
+
text: (customeStyle == null ? void 0 : customeStyle.xtitle) || "",
|
|
394
|
+
fill: "#333",
|
|
395
|
+
// 文本颜色
|
|
396
|
+
fontSize: 12,
|
|
397
|
+
fontWeight: "bold"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
type: "text",
|
|
402
|
+
left: "10px",
|
|
403
|
+
top: "center",
|
|
404
|
+
style: {
|
|
405
|
+
text: (customeStyle == null ? void 0 : customeStyle.ytitle) || "",
|
|
406
|
+
fill: "#333",
|
|
407
|
+
// 文本颜色
|
|
408
|
+
fontSize: 12,
|
|
409
|
+
fontWeight: "bold"
|
|
410
|
+
},
|
|
411
|
+
rotation: Math.PI / 2
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
},
|
|
415
|
+
xAxis: {
|
|
416
|
+
...chartConfig.xAxis,
|
|
417
|
+
axisTick: {
|
|
418
|
+
show: (_j = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _j.includes("axis")
|
|
419
|
+
},
|
|
420
|
+
axisLine: {
|
|
421
|
+
show: (_k = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _k.includes("axis")
|
|
422
|
+
},
|
|
423
|
+
axisLabel: {
|
|
424
|
+
show: (_l = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _l.includes("label"),
|
|
425
|
+
rotate: grids.axisLabelRotate,
|
|
426
|
+
// 使标签倾斜,调整为合适的角度
|
|
427
|
+
interval: "auto",
|
|
428
|
+
// 自动隐藏
|
|
429
|
+
formatter: (value) => {
|
|
430
|
+
return value.length > 15 ? `${value.slice(0, 15)}...` : value;
|
|
431
|
+
},
|
|
432
|
+
...((_m = chartConfig.xAxis) == null ? void 0 : _m.axisLabel) ?? {}
|
|
433
|
+
},
|
|
434
|
+
splitLine: {
|
|
435
|
+
show: (_n = customData == null ? void 0 : customData.chartOptions) == null ? void 0 : _n.includes("splitLine")
|
|
436
|
+
// 不显示x轴网格线
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
yAxis: [
|
|
440
|
+
{
|
|
441
|
+
show: isLeftYAxisShow,
|
|
442
|
+
...yAxisConfig
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
show: isRightYAxisShow,
|
|
446
|
+
...yAxisConfig
|
|
447
|
+
}
|
|
448
|
+
],
|
|
449
|
+
series,
|
|
450
|
+
tooltip: {
|
|
451
|
+
trigger: "item",
|
|
452
|
+
// 触发方式:鼠标悬浮在坐标轴上
|
|
453
|
+
axisPointer: {
|
|
454
|
+
type: "shadow"
|
|
455
|
+
// 阴影指示器,鼠标悬停时显示柱状图的阴影
|
|
456
|
+
},
|
|
457
|
+
appendTo: "body"
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
return options;
|
|
432
461
|
};
|
|
433
|
-
return
|
|
462
|
+
return getChartOptions(chartData);
|
|
434
463
|
} else {
|
|
435
464
|
return null;
|
|
436
465
|
}
|