@platox/pivot-table 0.0.32 → 0.0.34
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-btn/index.d.ts +11 -0
- package/es/dashboard-workbench/components/add-module-btn/index.js +97 -0
- package/es/dashboard-workbench/components/add-module-btn/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.d.ts +20 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js +178 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/custome-data.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.d.ts +17 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js +91 -0
- package/es/dashboard-workbench/components/add-module-modal/add-calendar-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.d.ts +27 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js +328 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-data.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.d.ts +15 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js +58 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/custome-styles.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.d.ts +20 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js +123 -0
- package/es/dashboard-workbench/components/add-module-modal/add-chart-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.d.ts +20 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js +180 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-data.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.d.ts +13 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js +119 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/custome-styles.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.d.ts +19 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js +120 -0
- package/es/dashboard-workbench/components/add-module-modal/add-statistics-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.d.ts +12 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js +44 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/debounce-select.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.d.ts +21 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js +510 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/index.js.map +1 -0
- package/es/dashboard-workbench/components/add-module-modal/components/condition-modal/utils.d.ts +25 -0
- package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.d.ts +12 -0
- package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.js +45 -0
- package/es/dashboard-workbench/components/add-module-modal/components/select-color/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/index.d.ts +14 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js +231 -0
- package/es/dashboard-workbench/components/module-content/calendar-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.d.ts +8 -0
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js +62 -0
- package/es/dashboard-workbench/components/module-content/chart-module/base-chart/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/index.d.ts +14 -0
- package/es/dashboard-workbench/components/module-content/chart-module/index.js +384 -0
- package/es/dashboard-workbench/components/module-content/chart-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/chart-module/utils.d.ts +9 -0
- package/es/dashboard-workbench/components/module-content/chart-module/utils.js +200 -0
- package/es/dashboard-workbench/components/module-content/chart-module/utils.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/index.d.ts +31 -0
- package/es/dashboard-workbench/components/module-content/index.js +81 -0
- package/es/dashboard-workbench/components/module-content/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/index.d.ts +15 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/index.js +305 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/utils.d.ts +4 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/utils.js +41 -0
- package/es/dashboard-workbench/components/module-content/statistics-module/utils.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.d.ts +7 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.js +224 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.d.ts +2 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.js +24 -0
- package/es/dashboard-workbench/components/module-content/text-module/editor/useDebounce.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/text-module/index.d.ts +7 -0
- package/es/dashboard-workbench/components/module-content/text-module/index.js +11 -0
- package/es/dashboard-workbench/components/module-content/text-module/index.js.map +1 -0
- package/es/dashboard-workbench/components/module-content/utils.d.ts +15 -0
- package/es/dashboard-workbench/components/module-content/utils.js +113 -0
- package/es/dashboard-workbench/components/module-content/utils.js.map +1 -0
- package/es/dashboard-workbench/components/module-header/index.d.ts +12 -0
- package/es/dashboard-workbench/components/module-header/index.js +115 -0
- package/es/dashboard-workbench/components/module-header/index.js.map +1 -0
- package/es/dashboard-workbench/context.d.ts +16 -0
- package/es/dashboard-workbench/context.js +21 -0
- package/es/dashboard-workbench/context.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-bar-percentage.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-bar-percentage.js +17 -0
- package/es/dashboard-workbench/icon/icon-bar-percentage.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-bar-pile.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-bar-pile.js +17 -0
- package/es/dashboard-workbench/icon/icon-bar-pile.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-bar.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-bar.js +13 -0
- package/es/dashboard-workbench/icon/icon-bar.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-calendar.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-calendar.js +40 -0
- package/es/dashboard-workbench/icon/icon-calendar.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-drag.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-drag.js +25 -0
- package/es/dashboard-workbench/icon/icon-drag.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-editor.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-editor.js +40 -0
- package/es/dashboard-workbench/icon/icon-editor.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-line-smooth.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-line-smooth.js +28 -0
- package/es/dashboard-workbench/icon/icon-line-smooth.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-line.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-line.js +28 -0
- package/es/dashboard-workbench/icon/icon-line.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-move.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-move.js +25 -0
- package/es/dashboard-workbench/icon/icon-move.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-pie-circular.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-pie-circular.js +30 -0
- package/es/dashboard-workbench/icon/icon-pie-circular.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-pie.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-pie.js +24 -0
- package/es/dashboard-workbench/icon/icon-pie.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-statistics.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-statistics.js +37 -0
- package/es/dashboard-workbench/icon/icon-statistics.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-percentage.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-percentage.js +105 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-percentage.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-pile.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-pile.js +105 -0
- package/es/dashboard-workbench/icon/icon-strip-bar-pile.js.map +1 -0
- package/es/dashboard-workbench/icon/icon-strip-bar.d.ts +2 -0
- package/es/dashboard-workbench/icon/icon-strip-bar.js +57 -0
- package/es/dashboard-workbench/icon/icon-strip-bar.js.map +1 -0
- package/es/dashboard-workbench/index.d.ts +33 -0
- package/es/dashboard-workbench/index.js +435 -0
- package/es/dashboard-workbench/index.js.map +1 -0
- package/es/dashboard-workbench/lang/en-US.d.ts +146 -0
- package/es/dashboard-workbench/lang/en-US.js +157 -0
- package/es/dashboard-workbench/lang/en-US.js.map +1 -0
- package/es/dashboard-workbench/lang/index.d.ts +2 -0
- package/es/dashboard-workbench/lang/index.js +25 -0
- package/es/dashboard-workbench/lang/index.js.map +1 -0
- package/es/dashboard-workbench/lang/zh-CN.d.ts +146 -0
- package/es/dashboard-workbench/lang/zh-CN.js +157 -0
- package/es/dashboard-workbench/lang/zh-CN.js.map +1 -0
- package/es/dashboard-workbench/types.d.ts +22 -0
- package/es/dashboard-workbench/utils/index.d.ts +9 -0
- package/es/dashboard-workbench/utils/index.js +30 -0
- package/es/dashboard-workbench/utils/index.js.map +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +5 -0
- package/es/index.js.map +1 -0
- package/es/style.css +1 -0
- package/package.json +27 -24
- package/umd/pivot-table.umd.cjs +178 -0
- package/umd/style.css +1 -0
- package/index.d.ts +0 -98
- package/lib/index.js +0 -52233
- package/lib/index.umd.cjs +0 -178
- package/lib/style.css +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ModuleDataApi } from '../../types';
|
|
3
|
+
import { ModuleValueType } from '../add-module-btn';
|
|
4
|
+
export interface ModuleData {
|
|
5
|
+
id?: string;
|
|
6
|
+
i?: string;
|
|
7
|
+
w: number;
|
|
8
|
+
h: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
title: string;
|
|
12
|
+
type: ModuleValueType['type'];
|
|
13
|
+
customData?: ModuleValueType['customData'];
|
|
14
|
+
customeStyle?: ModuleValueType['customeStyle'];
|
|
15
|
+
}
|
|
16
|
+
interface ModuleProps {
|
|
17
|
+
module: ModuleData;
|
|
18
|
+
onUpdate: (id: ModuleData['id'], updatedProps: Partial<ModuleData>) => void;
|
|
19
|
+
activeId?: ModuleData['id'];
|
|
20
|
+
onClick?: () => void;
|
|
21
|
+
onEdit?: () => void;
|
|
22
|
+
onDelete?: () => void;
|
|
23
|
+
onCopy?: () => void;
|
|
24
|
+
moduleDataApi?: ModuleDataApi;
|
|
25
|
+
onStartDragOrResize?: () => void;
|
|
26
|
+
onStopDragOrResize?: () => void;
|
|
27
|
+
rowWidth?: number;
|
|
28
|
+
rowHeight?: number;
|
|
29
|
+
}
|
|
30
|
+
declare const ModuleContent: React.FC<ModuleProps>;
|
|
31
|
+
export default ModuleContent;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import TextModule from "./text-module/index.js";
|
|
4
|
+
import StatisticsModule from "./statistics-module/index.js";
|
|
5
|
+
import CalendarModule from "./calendar-module/index.js";
|
|
6
|
+
import ChartModule from "./chart-module/index.js";
|
|
7
|
+
import { isEqual } from "lodash-es";
|
|
8
|
+
function areEqual(prevProps, nextProps) {
|
|
9
|
+
return isEqual(prevProps.module, nextProps.module);
|
|
10
|
+
}
|
|
11
|
+
const ModuleContent = React.memo(
|
|
12
|
+
({ module, onUpdate, moduleDataApi, rowWidth, rowHeight }) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
className: "module-content isNoCanDrag",
|
|
18
|
+
style: {
|
|
19
|
+
overflow: ((_a = module.type) == null ? void 0 : _a.includes("chart")) ? "inherit" : "hidden"
|
|
20
|
+
},
|
|
21
|
+
children: /* @__PURE__ */ jsxs("div", { className: "dashboard-grid-container", children: [
|
|
22
|
+
module.type === "text" ? /* @__PURE__ */ jsx(
|
|
23
|
+
TextModule,
|
|
24
|
+
{
|
|
25
|
+
defaultValue: module.customData.editor,
|
|
26
|
+
onChange: (value) => {
|
|
27
|
+
if (module.id) {
|
|
28
|
+
onUpdate(module.id, {
|
|
29
|
+
type: "text",
|
|
30
|
+
customData: {
|
|
31
|
+
title: module.customData.title,
|
|
32
|
+
editor: value
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
) : null,
|
|
39
|
+
module.type === "statistics" ? /* @__PURE__ */ jsx(
|
|
40
|
+
StatisticsModule,
|
|
41
|
+
{
|
|
42
|
+
customData: module.customData,
|
|
43
|
+
customeStyle: module.customeStyle,
|
|
44
|
+
moduleDataApi,
|
|
45
|
+
width: module.w,
|
|
46
|
+
height: module.h,
|
|
47
|
+
rowWidth,
|
|
48
|
+
rowHeight
|
|
49
|
+
}
|
|
50
|
+
) : null,
|
|
51
|
+
module.type === "calendar" ? /* @__PURE__ */ jsx(
|
|
52
|
+
CalendarModule,
|
|
53
|
+
{
|
|
54
|
+
customData: module.customData,
|
|
55
|
+
moduleDataApi,
|
|
56
|
+
width: module.w,
|
|
57
|
+
height: module.h,
|
|
58
|
+
rowWidth,
|
|
59
|
+
rowHeight
|
|
60
|
+
}
|
|
61
|
+
) : null,
|
|
62
|
+
((_b = module.type) == null ? void 0 : _b.includes("chart")) ? /* @__PURE__ */ jsx(
|
|
63
|
+
ChartModule,
|
|
64
|
+
{
|
|
65
|
+
width: module.w,
|
|
66
|
+
height: module.h,
|
|
67
|
+
customData: module.customData,
|
|
68
|
+
customeStyle: module.customeStyle,
|
|
69
|
+
moduleDataApi
|
|
70
|
+
}
|
|
71
|
+
) : null
|
|
72
|
+
] })
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
areEqual
|
|
77
|
+
);
|
|
78
|
+
export {
|
|
79
|
+
ModuleContent as default
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/dashboard-workbench/components/module-content/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react'\nimport { ModuleDataApi } from '../../types'\nimport { ModuleValueType } from '../add-module-btn'\nimport TextModule from './text-module'\nimport StatisticsModule from './statistics-module'\nimport CalendarModule from './calendar-module'\nimport ChartModule from './chart-module'\nimport { isEqual } from 'lodash-es'\n\nexport interface ModuleData {\n id?: string\n i?: string\n w: number\n h: number\n x: number\n y: number\n title: string\n type: ModuleValueType['type']\n customData?: ModuleValueType['customData']\n customeStyle?: ModuleValueType['customeStyle']\n}\n\ninterface ModuleProps {\n module: ModuleData\n onUpdate: (id: ModuleData['id'], updatedProps: Partial<ModuleData>) => void\n activeId?: ModuleData['id']\n onClick?: () => void\n onEdit?: () => void\n onDelete?: () => void\n onCopy?: () => void\n moduleDataApi?: ModuleDataApi\n onStartDragOrResize?: () => void\n onStopDragOrResize?: () => void\n rowWidth?: number\n rowHeight?: number\n}\n\nfunction areEqual(prevProps: any, nextProps: any) {\n return isEqual(prevProps.module, nextProps.module)\n}\n\nconst ModuleContent: React.FC<ModuleProps> = React.memo(\n ({ module, onUpdate, moduleDataApi, rowWidth, rowHeight }) => {\n return (\n <div\n className=\"module-content isNoCanDrag\"\n style={{\n overflow: module.type?.includes('chart') ? 'inherit' : 'hidden',\n }}\n >\n <div className=\"dashboard-grid-container\">\n {module.type === 'text' ? (\n <TextModule\n defaultValue={module.customData.editor}\n onChange={value => {\n if (module.id) {\n onUpdate(module.id, {\n type: 'text',\n customData: {\n title: module.customData.title,\n editor: value,\n },\n })\n }\n }}\n />\n ) : null}\n {module.type === 'statistics' ? (\n <StatisticsModule\n customData={module.customData}\n customeStyle={module.customeStyle}\n moduleDataApi={moduleDataApi}\n width={module.w}\n height={module.h}\n rowWidth={rowWidth}\n rowHeight={rowHeight}\n />\n ) : null}\n {module.type === 'calendar' ? (\n <CalendarModule\n customData={module.customData}\n moduleDataApi={moduleDataApi}\n width={module.w}\n height={module.h}\n rowWidth={rowWidth}\n rowHeight={rowHeight}\n />\n ) : null}\n {module.type?.includes('chart') ? (\n <ChartModule\n width={module.w}\n height={module.h}\n customData={module.customData}\n customeStyle={module.customeStyle}\n moduleDataApi={moduleDataApi}\n />\n ) : null}\n </div>\n </div>\n )\n },\n areEqual\n)\n\nexport default ModuleContent\n"],"names":[],"mappings":";;;;;;;AAsCA,SAAS,SAAS,WAAgB,WAAgB;AAChD,SAAO,QAAQ,UAAU,QAAQ,UAAU,MAAM;AACnD;AAEA,MAAM,gBAAuC,MAAM;AAAA,EACjD,CAAC,EAAE,QAAQ,UAAU,eAAe,UAAU,gBAAgB;;AAE1D,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO;AAAA,UACL,YAAU,YAAO,SAAP,mBAAa,SAAS,YAAW,YAAY;AAAA,QACzD;AAAA,QAEA,UAAA,qBAAC,OAAI,EAAA,WAAU,4BACZ,UAAA;AAAA,UAAA,OAAO,SAAS,SACf;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,cAAc,OAAO,WAAW;AAAA,cAChC,UAAU,CAAS,UAAA;AACjB,oBAAI,OAAO,IAAI;AACb,2BAAS,OAAO,IAAI;AAAA,oBAClB,MAAM;AAAA,oBACN,YAAY;AAAA,sBACV,OAAO,OAAO,WAAW;AAAA,sBACzB,QAAQ;AAAA,oBAAA;AAAA,kBACV,CACD;AAAA,gBAAA;AAAA,cACH;AAAA,YACF;AAAA,UAAA,IAEA;AAAA,UACH,OAAO,SAAS,eACf;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,YAAY,OAAO;AAAA,cACnB,cAAc,OAAO;AAAA,cACrB;AAAA,cACA,OAAO,OAAO;AAAA,cACd,QAAQ,OAAO;AAAA,cACf;AAAA,cACA;AAAA,YAAA;AAAA,UAAA,IAEA;AAAA,UACH,OAAO,SAAS,aACf;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,YAAY,OAAO;AAAA,cACnB;AAAA,cACA,OAAO,OAAO;AAAA,cACd,QAAQ,OAAO;AAAA,cACf;AAAA,cACA;AAAA,YAAA;AAAA,UAAA,IAEA;AAAA,YACH,YAAO,SAAP,mBAAa,SAAS,YACrB;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,OAAO,OAAO;AAAA,cACd,QAAQ,OAAO;AAAA,cACf,YAAY,OAAO;AAAA,cACnB,cAAc,OAAO;AAAA,cACrB;AAAA,YAAA;AAAA,UAAA,IAEA;AAAA,QAAA,EACN,CAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAEJ;AAAA,EACA;AACF;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleDataApi } from '../../../types';
|
|
2
|
+
import { StatisticsCustomeDataTypes } from '../../add-module-modal/add-statistics-modal/custome-data';
|
|
3
|
+
import { StatisticsCustomeStylesTypes } from '../../add-module-modal/add-statistics-modal/custome-styles';
|
|
4
|
+
import { default as React } from 'react';
|
|
5
|
+
interface StatisticsModuleProps {
|
|
6
|
+
customData?: StatisticsCustomeDataTypes;
|
|
7
|
+
customeStyle?: StatisticsCustomeStylesTypes;
|
|
8
|
+
moduleDataApi?: ModuleDataApi;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
rowWidth?: number;
|
|
12
|
+
rowHeight?: number;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: React.NamedExoticComponent<StatisticsModuleProps>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { message, Spin } from "antd";
|
|
4
|
+
import { mapConditionsToPostgrest } from "../utils.js";
|
|
5
|
+
import { useMemoizedFn, useSize } from "ahooks";
|
|
6
|
+
import { calculatePxMultiRange } from "./utils.js";
|
|
7
|
+
function formatToPercentage(value, decimalPlaces = 0) {
|
|
8
|
+
if (!Number.isFinite(value)) {
|
|
9
|
+
throw new Error("Value must be a finite number.");
|
|
10
|
+
}
|
|
11
|
+
return new Intl.NumberFormat(void 0, {
|
|
12
|
+
style: "percent",
|
|
13
|
+
minimumFractionDigits: decimalPlaces,
|
|
14
|
+
maximumFractionDigits: decimalPlaces
|
|
15
|
+
}).format(value);
|
|
16
|
+
}
|
|
17
|
+
function formatToThousands(value, decimalPlaces = 0) {
|
|
18
|
+
if (!Number.isFinite(value)) {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
const formattedValue = new Intl.NumberFormat(void 0, {
|
|
22
|
+
minimumFractionDigits: 0,
|
|
23
|
+
maximumFractionDigits: decimalPlaces
|
|
24
|
+
}).format(value);
|
|
25
|
+
const [integerPart, decimalPart] = formattedValue.split(".");
|
|
26
|
+
const paddedDecimal = (decimalPart || "").padEnd(decimalPlaces, "0");
|
|
27
|
+
return `${integerPart}${decimalPlaces > 0 ? "." : ""}${paddedDecimal}`;
|
|
28
|
+
}
|
|
29
|
+
const StatisticsModule = ({
|
|
30
|
+
moduleDataApi,
|
|
31
|
+
customData,
|
|
32
|
+
customeStyle,
|
|
33
|
+
width,
|
|
34
|
+
height
|
|
35
|
+
}) => {
|
|
36
|
+
const [list, setList] = useState();
|
|
37
|
+
const [loading, setLoading] = useState(false);
|
|
38
|
+
const getData = useMemoizedFn(async () => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (customData) {
|
|
41
|
+
let queryString = "";
|
|
42
|
+
setLoading(true);
|
|
43
|
+
if (customData.statisticalMethod === "fieldValue" && customData.field) {
|
|
44
|
+
queryString += `select=${customData.field}.${customData == null ? void 0 : customData.statisticalType}()`;
|
|
45
|
+
} else if (customData.statisticalMethod === "recordTotal") {
|
|
46
|
+
queryString += `select=id.count()`;
|
|
47
|
+
}
|
|
48
|
+
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) {
|
|
49
|
+
queryString += `&${mapConditionsToPostgrest(customData == null ? void 0 : customData.conditionData)}`;
|
|
50
|
+
}
|
|
51
|
+
if (customData == null ? void 0 : customData.dataSourceId) {
|
|
52
|
+
moduleDataApi == null ? void 0 : moduleDataApi({
|
|
53
|
+
id: customData == null ? void 0 : customData.dataSourceId,
|
|
54
|
+
query: queryString
|
|
55
|
+
}).then((res) => {
|
|
56
|
+
if (!res.success) {
|
|
57
|
+
message.error(res.message);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setList(res.data);
|
|
61
|
+
}).finally(() => {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
setList([]);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (customData) {
|
|
71
|
+
getData();
|
|
72
|
+
}
|
|
73
|
+
}, [
|
|
74
|
+
customData == null ? void 0 : customData.conditionData,
|
|
75
|
+
customData == null ? void 0 : customData.statisticalMethod,
|
|
76
|
+
customData == null ? void 0 : customData.statisticalType,
|
|
77
|
+
customData == null ? void 0 : customData.field,
|
|
78
|
+
customData == null ? void 0 : customData.dataSourceId
|
|
79
|
+
]);
|
|
80
|
+
const statisticValue = useMemo(() => {
|
|
81
|
+
var _a, _b, _c, _d, _e;
|
|
82
|
+
if (!list) {
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
const newList = list;
|
|
86
|
+
const { statisticalMethod, statisticalType, field } = customData || {};
|
|
87
|
+
let val = 0;
|
|
88
|
+
if (newList.length && statisticalMethod === "fieldValue" && field) {
|
|
89
|
+
switch (statisticalType) {
|
|
90
|
+
case "sum":
|
|
91
|
+
val = ((_a = newList == null ? void 0 : newList[0]) == null ? void 0 : _a.sum) || 0;
|
|
92
|
+
break;
|
|
93
|
+
case "max":
|
|
94
|
+
val = ((_b = newList == null ? void 0 : newList[0]) == null ? void 0 : _b.max) || 0;
|
|
95
|
+
break;
|
|
96
|
+
case "min":
|
|
97
|
+
val = ((_c = newList == null ? void 0 : newList[0]) == null ? void 0 : _c.min) || 0;
|
|
98
|
+
break;
|
|
99
|
+
case "avg":
|
|
100
|
+
val = ((_d = newList == null ? void 0 : newList[0]) == null ? void 0 : _d.avg) || 0;
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
val = 0;
|
|
104
|
+
}
|
|
105
|
+
} else if (statisticalMethod === "recordTotal") {
|
|
106
|
+
val = ((_e = newList == null ? void 0 : newList[0]) == null ? void 0 : _e.count) || 0;
|
|
107
|
+
}
|
|
108
|
+
if (customeStyle == null ? void 0 : customeStyle.unit) {
|
|
109
|
+
const { unit, precision } = customeStyle;
|
|
110
|
+
switch (unit) {
|
|
111
|
+
case "8":
|
|
112
|
+
val = `฿${formatToThousands(val, precision)}`;
|
|
113
|
+
break;
|
|
114
|
+
case "7":
|
|
115
|
+
val = `£${formatToThousands(val, precision)}`;
|
|
116
|
+
break;
|
|
117
|
+
case "6":
|
|
118
|
+
val = `€${formatToThousands(val, precision)}`;
|
|
119
|
+
break;
|
|
120
|
+
case "4":
|
|
121
|
+
val = `¥${formatToThousands(val, precision)}`;
|
|
122
|
+
break;
|
|
123
|
+
case "5":
|
|
124
|
+
val = `$${formatToThousands(val, precision)}`;
|
|
125
|
+
break;
|
|
126
|
+
case "1":
|
|
127
|
+
val = formatToThousands(val, precision);
|
|
128
|
+
break;
|
|
129
|
+
case "3":
|
|
130
|
+
val = formatToPercentage(val, precision);
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
val = formatToThousands(val, precision);
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
val = formatToThousands(val, customeStyle == null ? void 0 : customeStyle.precision);
|
|
137
|
+
}
|
|
138
|
+
return val;
|
|
139
|
+
}, [list, customData, customeStyle]);
|
|
140
|
+
const boxRef = useRef();
|
|
141
|
+
const size = useSize(boxRef);
|
|
142
|
+
const caclSize = useMemo(() => {
|
|
143
|
+
if (!size) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
let PX = 0;
|
|
147
|
+
let PY = 32;
|
|
148
|
+
let fontSize = 0;
|
|
149
|
+
let subFontSize = 0;
|
|
150
|
+
{
|
|
151
|
+
const boxWidth1 = 116;
|
|
152
|
+
const px1 = 16;
|
|
153
|
+
const boxWidth2 = 760;
|
|
154
|
+
const px2 = 56;
|
|
155
|
+
PX = calculatePxMultiRange(size.width, {
|
|
156
|
+
ranges: [
|
|
157
|
+
[boxWidth1, px1],
|
|
158
|
+
[boxWidth2, px2]
|
|
159
|
+
],
|
|
160
|
+
step: 4
|
|
161
|
+
});
|
|
162
|
+
const min = 16;
|
|
163
|
+
const max = 72;
|
|
164
|
+
PX = Math.max(min, Math.min(max, PX));
|
|
165
|
+
}
|
|
166
|
+
let innerBoxW = size.width - PX * 2;
|
|
167
|
+
let innerBoxH = size.height - PY * 2;
|
|
168
|
+
{
|
|
169
|
+
fontSize = calculatePxMultiRange(innerBoxW, {
|
|
170
|
+
ranges: [
|
|
171
|
+
[400, 60],
|
|
172
|
+
[500, 64]
|
|
173
|
+
],
|
|
174
|
+
step: 0.1
|
|
175
|
+
});
|
|
176
|
+
const min = 16;
|
|
177
|
+
const max = Math.min(72, innerBoxH / 2);
|
|
178
|
+
fontSize = Math.max(min, Math.min(max, fontSize));
|
|
179
|
+
}
|
|
180
|
+
{
|
|
181
|
+
subFontSize = calculatePxMultiRange(innerBoxH, {
|
|
182
|
+
ranges: [
|
|
183
|
+
[140, 12],
|
|
184
|
+
[500, 24],
|
|
185
|
+
[860, 36]
|
|
186
|
+
],
|
|
187
|
+
step: 0.1
|
|
188
|
+
});
|
|
189
|
+
const min = 12;
|
|
190
|
+
const max = Math.min(36, innerBoxH / 2);
|
|
191
|
+
subFontSize = Math.max(min, Math.min(max, subFontSize));
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
PX,
|
|
195
|
+
PY,
|
|
196
|
+
fontSize,
|
|
197
|
+
subFontSize
|
|
198
|
+
};
|
|
199
|
+
}, [size]);
|
|
200
|
+
return /* @__PURE__ */ jsxs(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
ref: boxRef,
|
|
204
|
+
style: {
|
|
205
|
+
display: "flex",
|
|
206
|
+
height: "100%",
|
|
207
|
+
width: "100%"
|
|
208
|
+
},
|
|
209
|
+
children: [
|
|
210
|
+
loading ? /* @__PURE__ */ jsx(
|
|
211
|
+
Spin,
|
|
212
|
+
{
|
|
213
|
+
style: {
|
|
214
|
+
width: "100%",
|
|
215
|
+
height: "100%",
|
|
216
|
+
display: "flex",
|
|
217
|
+
justifyContent: "center",
|
|
218
|
+
alignItems: "center",
|
|
219
|
+
position: "absolute",
|
|
220
|
+
background: "rgba(255,255,255,0.6)",
|
|
221
|
+
top: 0,
|
|
222
|
+
left: 0,
|
|
223
|
+
right: 0,
|
|
224
|
+
bottom: 0,
|
|
225
|
+
zIndex: 1e3
|
|
226
|
+
},
|
|
227
|
+
spinning: loading
|
|
228
|
+
}
|
|
229
|
+
) : null,
|
|
230
|
+
/* @__PURE__ */ jsxs(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
style: {
|
|
234
|
+
overflow: "hidden",
|
|
235
|
+
position: "relative",
|
|
236
|
+
flex: 1,
|
|
237
|
+
display: "flex",
|
|
238
|
+
justifyContent: "center",
|
|
239
|
+
alignItems: "center",
|
|
240
|
+
flexDirection: "column",
|
|
241
|
+
padding: `${caclSize == null ? void 0 : caclSize.PY}px ${caclSize == null ? void 0 : caclSize.PX}px`
|
|
242
|
+
},
|
|
243
|
+
children: [
|
|
244
|
+
statisticValue !== "" && /* @__PURE__ */ jsx(
|
|
245
|
+
"div",
|
|
246
|
+
{
|
|
247
|
+
style: {
|
|
248
|
+
width: "100%",
|
|
249
|
+
position: "relative",
|
|
250
|
+
overflow: "hidden",
|
|
251
|
+
textOverflow: "ellipsis",
|
|
252
|
+
whiteSpace: "nowrap",
|
|
253
|
+
textAlign: "center"
|
|
254
|
+
},
|
|
255
|
+
children: /* @__PURE__ */ jsx(
|
|
256
|
+
"span",
|
|
257
|
+
{
|
|
258
|
+
style: {
|
|
259
|
+
fontWeight: "bold",
|
|
260
|
+
lineHeight: `${caclSize == null ? void 0 : caclSize.fontSize}px`,
|
|
261
|
+
fontSize: `${caclSize == null ? void 0 : caclSize.fontSize}px`,
|
|
262
|
+
color: customeStyle == null ? void 0 : customeStyle.color
|
|
263
|
+
},
|
|
264
|
+
children: statisticValue
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
),
|
|
269
|
+
(customeStyle == null ? void 0 : customeStyle.desc) !== "" && /* @__PURE__ */ jsx(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
style: {
|
|
273
|
+
width: "100%",
|
|
274
|
+
position: "relative",
|
|
275
|
+
overflow: "hidden",
|
|
276
|
+
textOverflow: "ellipsis",
|
|
277
|
+
whiteSpace: "nowrap",
|
|
278
|
+
textAlign: "center"
|
|
279
|
+
},
|
|
280
|
+
children: /* @__PURE__ */ jsx(
|
|
281
|
+
"span",
|
|
282
|
+
{
|
|
283
|
+
style: {
|
|
284
|
+
fontSize: `${caclSize == null ? void 0 : caclSize.subFontSize}px`,
|
|
285
|
+
lineHeight: `${caclSize == null ? void 0 : caclSize.subFontSize}px`,
|
|
286
|
+
color: customeStyle == null ? void 0 : customeStyle.color,
|
|
287
|
+
textAlign: "center"
|
|
288
|
+
},
|
|
289
|
+
children: customeStyle == null ? void 0 : customeStyle.desc
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
}
|
|
293
|
+
)
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
};
|
|
301
|
+
const StatisticsModule$1 = React.memo(StatisticsModule);
|
|
302
|
+
export {
|
|
303
|
+
StatisticsModule$1 as default
|
|
304
|
+
};
|
|
305
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/statistics-module/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { message, Spin } from 'antd'\nimport { ModuleDataApi } from '../../../types'\nimport { StatisticsCustomeDataTypes } from '../../add-module-modal/add-statistics-modal/custome-data'\nimport { StatisticsCustomeStylesTypes } from '../../add-module-modal/add-statistics-modal/custome-styles'\nimport { mapConditionsToPostgrest } from '../utils'\nimport React from 'react'\nimport { useMemoizedFn, useSize } from 'ahooks'\nimport { calculatePxMultiRange } from './utils'\ninterface StatisticsModuleProps {\n customData?: StatisticsCustomeDataTypes\n customeStyle?: StatisticsCustomeStylesTypes\n moduleDataApi?: ModuleDataApi\n width?: number\n height?: number\n rowWidth?: number\n rowHeight?: number\n}\n\nfunction formatToPercentage(value: number, decimalPlaces: number = 0): string {\n if (!Number.isFinite(value)) {\n throw new Error('Value must be a finite number.')\n }\n return new Intl.NumberFormat(undefined, {\n style: 'percent',\n minimumFractionDigits: decimalPlaces,\n maximumFractionDigits: decimalPlaces,\n }).format(value)\n}\n\nfunction formatToThousands(value: number, decimalPlaces: number = 0): string {\n if (!Number.isFinite(value)) {\n return ''\n }\n\n const formattedValue = new Intl.NumberFormat(undefined, {\n minimumFractionDigits: 0,\n maximumFractionDigits: decimalPlaces,\n }).format(value)\n\n const [integerPart, decimalPart] = formattedValue.split('.')\n const paddedDecimal = (decimalPart || '').padEnd(decimalPlaces, '0')\n\n return `${integerPart}${decimalPlaces > 0 ? '.' : ''}${paddedDecimal}`\n}\n\nconst StatisticsModule: React.FC<StatisticsModuleProps> = ({\n moduleDataApi,\n customData,\n customeStyle,\n width,\n height,\n}) => {\n /* ============================== split =============================== */\n const [list, setList] = useState<any>()\n const [loading, setLoading] = useState<boolean>(false)\n\n const getData = useMemoizedFn(async () => {\n if (customData) {\n // 调用方法\n let queryString = ''\n setLoading(true)\n if (customData.statisticalMethod === 'fieldValue' && customData.field) {\n queryString += `select=${customData.field}.${customData?.statisticalType}()`\n } else if (customData.statisticalMethod === 'recordTotal') {\n queryString += `select=id.count()`\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 setList(res.data)\n })\n .finally(() => {\n setLoading(false)\n })\n }\n } else {\n setList([])\n }\n })\n useEffect(() => {\n if (customData) {\n getData()\n }\n }, [\n customData?.conditionData,\n customData?.statisticalMethod,\n customData?.statisticalType,\n customData?.field,\n customData?.dataSourceId,\n ])\n\n /* ============================== split =============================== */\n\n const statisticValue = useMemo(() => {\n if (!list) {\n return ''\n }\n\n const newList: any[] = list\n const { statisticalMethod, statisticalType, field } = customData || {}\n\n let val: any = 0\n if (newList.length && statisticalMethod === 'fieldValue' && field) {\n switch (statisticalType) {\n case 'sum':\n val = newList?.[0]?.sum || 0\n break\n case 'max':\n val = newList?.[0]?.max || 0\n break\n case 'min':\n val = newList?.[0]?.min || 0\n break\n case 'avg':\n val = newList?.[0]?.avg || 0\n break\n default:\n val = 0\n }\n } else if (statisticalMethod === 'recordTotal') {\n val = newList?.[0]?.count || 0\n }\n\n // 格式化\n if (customeStyle?.unit) {\n const { unit, precision } = customeStyle\n switch (unit) {\n case '8':\n val = `฿${formatToThousands(val, precision)}`\n break\n case '7':\n val = `£${formatToThousands(val, precision)}`\n break\n case '6':\n val = `€${formatToThousands(val, precision)}`\n break\n case '4':\n val = `¥${formatToThousands(val, precision)}`\n break\n case '5':\n val = `$${formatToThousands(val, precision)}`\n break\n case '1':\n val = formatToThousands(val, precision)\n break\n case '3':\n val = formatToPercentage(val, precision)\n break\n default:\n val = formatToThousands(val, precision)\n }\n } else {\n val = formatToThousands(val, customeStyle?.precision)\n }\n\n return val\n }, [list, customData, customeStyle])\n\n /* ============================== split =============================== */\n\n const boxRef = useRef<any>()\n const size = useSize(boxRef)\n\n const caclSize = useMemo(() => {\n if (!size) {\n return null\n }\n let PX: number = 0\n let PY: number = 32 // 固定\n let fontSize: number = 0\n let subFontSize: number = 0\n // 计算padding x 的值\n {\n const boxWidth1 = 116\n const px1 = 16\n\n const boxWidth2 = 760\n const px2 = 56\n\n PX = calculatePxMultiRange(size.width, {\n ranges: [\n [boxWidth1, px1],\n [boxWidth2, px2],\n ],\n step: 4,\n })\n const min = 16\n const max = 72\n PX = Math.max(min, Math.min(max, PX))\n }\n\n // 计算字体大小\n let innerBoxW = size.width - PX * 2\n let innerBoxH = size.height - PY * 2\n {\n fontSize = calculatePxMultiRange(innerBoxW, {\n ranges: [\n [400, 60],\n [500, 64],\n ],\n step: 0.1,\n })\n const min = 16\n const max = Math.min(72, innerBoxH / 2)\n fontSize = Math.max(min, Math.min(max, fontSize))\n }\n {\n subFontSize = calculatePxMultiRange(innerBoxH, {\n ranges: [\n [140, 12],\n [500, 24],\n [860, 36],\n ],\n step: 0.1,\n })\n const min = 12\n const max = Math.min(36, innerBoxH / 2)\n subFontSize = Math.max(min, Math.min(max, subFontSize))\n }\n\n return {\n PX,\n PY,\n fontSize,\n subFontSize,\n }\n }, [size])\n\n return (\n <div\n ref={boxRef}\n style={{\n display: 'flex',\n height: '100%',\n width: '100%',\n }}\n >\n {loading ? (\n <Spin\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n position: 'absolute',\n background: 'rgba(255,255,255,0.6)',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n zIndex: 1000,\n }}\n spinning={loading}\n />\n ) : null}\n <div\n style={{\n overflow: 'hidden',\n position: 'relative',\n flex: 1,\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n flexDirection: 'column',\n padding: `${caclSize?.PY}px ${caclSize?.PX}px`,\n }}\n >\n {statisticValue !== '' && (\n <div\n style={{\n width: '100%',\n position: 'relative',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n textAlign: 'center',\n }}\n >\n <span\n style={{\n fontWeight: 'bold',\n lineHeight: `${caclSize?.fontSize}px`,\n fontSize: `${caclSize?.fontSize}px`,\n color: customeStyle?.color,\n }}\n >\n {statisticValue}\n </span>\n </div>\n )}\n\n {customeStyle?.desc !== '' && (\n <div\n style={{\n width: '100%',\n position: 'relative',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n textAlign: 'center',\n }}\n >\n <span\n style={{\n fontSize: `${caclSize?.subFontSize}px`,\n lineHeight: `${caclSize?.subFontSize}px`,\n color: customeStyle?.color,\n textAlign: 'center',\n }}\n >\n {customeStyle?.desc}\n </span>\n </div>\n )}\n </div>\n </div>\n )\n}\n\nexport default React.memo(StatisticsModule)\n"],"names":[],"mappings":";;;;;;AAoBA,SAAS,mBAAmB,OAAe,gBAAwB,GAAW;AAC5E,MAAI,CAAC,OAAO,SAAS,KAAK,GAA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EA,MAAA,qBAAe,MAAM,KAAK,gBAAgB;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function calculatePxMultiRange(width, options) {
|
|
2
|
+
const { ranges, step } = options;
|
|
3
|
+
let rang1 = null;
|
|
4
|
+
let rang2 = null;
|
|
5
|
+
for (let i = 0; i < ranges.length - 1; i++) {
|
|
6
|
+
const [width1, px1] = ranges[i];
|
|
7
|
+
const [width2, px2] = ranges[i + 1];
|
|
8
|
+
if (width >= width1 && width <= width2) {
|
|
9
|
+
rang1 = [width1, px1];
|
|
10
|
+
rang2 = [width2, px2];
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (width < ranges[0][0]) {
|
|
15
|
+
rang1 = ranges[0];
|
|
16
|
+
rang2 = ranges[1];
|
|
17
|
+
}
|
|
18
|
+
if (width > ranges[ranges.length - 1][0]) {
|
|
19
|
+
rang1 = ranges[ranges.length - 2];
|
|
20
|
+
rang2 = ranges[ranges.length - 1];
|
|
21
|
+
}
|
|
22
|
+
if (!!rang1 && !!rang2) {
|
|
23
|
+
let [width1, px1] = rang1;
|
|
24
|
+
let [width2, px2] = rang2;
|
|
25
|
+
const slope = (px2 - px1) / (width2 - width1);
|
|
26
|
+
const intercept = px1 - slope * width1;
|
|
27
|
+
const rawPx = slope * width + intercept;
|
|
28
|
+
return Math.round(rawPx / step) * step;
|
|
29
|
+
}
|
|
30
|
+
if (!!rang1 || !!rang2) {
|
|
31
|
+
let rang = !!rang1 ? rang1 : rang2;
|
|
32
|
+
let [width1, px1] = rang;
|
|
33
|
+
const rawPx = px1 * width / width1;
|
|
34
|
+
return Math.round(rawPx / step) * step;
|
|
35
|
+
}
|
|
36
|
+
throw new Error("Unexpected error in range calculation");
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
calculatePxMultiRange
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../../packages/dashboard-workbench/components/module-content/statistics-module/utils.tsx"],"sourcesContent":["export function calculatePxMultiRange(\n width: number,\n options: {\n ranges: [number, number][]\n step: number\n }\n): number {\n const { ranges, step } = options\n\n let rang1: [number, number] | null = null\n let rang2: [number, number] | null = null\n\n for (let i = 0; i < ranges.length - 1; i++) {\n const [width1, px1] = ranges[i]\n const [width2, px2] = ranges[i + 1]\n\n // 判断宽度是否在当前区间内\n if (width >= width1 && width <= width2) {\n rang1 = [width1, px1]\n rang2 = [width2, px2]\n break\n }\n }\n\n if (width < ranges[0][0]) {\n rang1 = ranges[0]\n rang2 = ranges[1]\n }\n\n if (width > ranges[ranges.length - 1][0]) {\n rang1 = ranges[ranges.length - 2]\n rang2 = ranges[ranges.length - 1]\n }\n\n if (!!rang1 && !!rang2) {\n let [width1, px1] = rang1\n let [width2, px2] = rang2\n const slope = (px2 - px1) / (width2 - width1)\n const intercept = px1 - slope * width1\n\n const rawPx = slope * width + intercept\n return Math.round(rawPx / step) * step\n }\n\n if (!!rang1 || !!rang2) {\n let rang = !!rang1 ? rang1 : rang2\n let [width1, px1] = rang!\n\n // px1 /width1 = ? / width\n const rawPx = (px1 * width) / width1\n return Math.round(rawPx / step) * step\n }\n // 不允许一个不传\n throw new Error('Unexpected error in range calculation')\n}\n"],"names":[],"mappings":"AAAgB,SAAA,sBACd,OACA,SAIQ;AACF,QAAA,EAAE,QAAQ,KAAA,IAAS;AAEzB,MAAI,QAAiC;AACrC,MAAI,QAAiC;AAErC,WAAS,IAAI,GAAG,IAAI,OAAO,SAAS,GAAG,KAAK;AAC1C,UAAM,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC;AAC9B,UAAM,CAAC,QAAQ,GAAG,IAAI,OAAO,IAAI,CAAC;AAG9B,QAAA,SAAS,UAAU,SAAS,QAAQ;AAC9B,cAAA,CAAC,QAAQ,GAAG;AACZ,cAAA,CAAC,QAAQ,GAAG;AACpB;AAAA,IAAA;AAAA,EACF;AA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