lowcoder-map-component 0.1.1
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/README.md +37 -0
- package/icons/demo-icon.svg +10 -0
- package/icons/hills.svg +17 -0
- package/index.css +27 -0
- package/index.html +35 -0
- package/index.tsx +20 -0
- package/loader.mjs +11 -0
- package/package.json +175 -0
- package/src/README.md +35 -0
- package/src/components/ChartPropertyView.tsx +961 -0
- package/src/components/SeriesComp.tsx +368 -0
- package/src/components/TabPropertyView.tsx +127 -0
- package/src/comps/Barcharts/comp.tsx +338 -0
- package/src/comps/Barcharts/constants.tsx +77 -0
- package/src/comps/Linecharts/comp.tsx +350 -0
- package/src/comps/Linecharts/constants.tsx +53 -0
- package/src/comps/Linechartsv2/comp.tsx +350 -0
- package/src/comps/Linechartsv2/constants.tsx +68 -0
- package/src/comps/Mapcharts/comp.tsx +381 -0
- package/src/comps/Mapcharts/constants.tsx +312 -0
- package/src/comps/Mapchartsv2/comp.tsx +393 -0
- package/src/comps/Mapchartsv2/constants.tsx +340 -0
- package/src/comps/MixedLineBarCharts/comp.tsx +353 -0
- package/src/comps/MixedLineBarCharts/constants.tsx +60 -0
- package/src/comps/MultiLineCharts/comp.tsx +362 -0
- package/src/comps/MultiLineCharts/constants.tsx +96 -0
- package/src/comps/PercentageCharts/comp.tsx +359 -0
- package/src/comps/PercentageCharts/constants.tsx +98 -0
- package/src/comps/Piecharts/comp.tsx +334 -0
- package/src/comps/Piecharts/constants.tsx +48 -0
- package/src/comps/Tablecharts/comp.tsx +429 -0
- package/src/comps/Tablecharts/constants.tsx +97 -0
- package/src/comps/Totalcharts/comp.tsx +463 -0
- package/src/comps/Totalcharts/constants.tsx +66 -0
- package/src/comps/TwoLineCharts/comp.tsx +350 -0
- package/src/comps/TwoLineCharts/constants.tsx +82 -0
- package/src/comps/mapComponent/comp.tsx +338 -0
- package/src/comps/mapComponent/constants.tsx +2149 -0
- package/src/comps/tab/comp.tsx +283 -0
- package/src/comps/tab/constants.tsx +79 -0
- package/src/configs/barChartConfig.tsx +153 -0
- package/src/configs/baseConfig.tsx +66 -0
- package/src/configs/candleStickChartConfig.tsx +35 -0
- package/src/configs/cartesianAxisConfig.tsx +314 -0
- package/src/configs/chartUrls.tsx +9 -0
- package/src/configs/echartConfig.tsx +260 -0
- package/src/configs/echartsLabelConfig.tsx +47 -0
- package/src/configs/echartsLegendConfig.tsx +29 -0
- package/src/configs/echartsTitleConfig.tsx +49 -0
- package/src/configs/echartsTitleVerticalConfig.tsx +50 -0
- package/src/configs/funnelChartConfig.tsx +35 -0
- package/src/configs/gaugeChartConfig.tsx +31 -0
- package/src/configs/graphChartConfig.tsx +31 -0
- package/src/configs/heatmapChartConfig.tsx +31 -0
- package/src/configs/legendConfig.tsx +55 -0
- package/src/configs/lineChartConfig.tsx +246 -0
- package/src/configs/lineChartConfigv2.tsx +246 -0
- package/src/configs/mapChartConfig.tsx +106 -0
- package/src/configs/mapChartConfigv2.tsx +106 -0
- package/src/configs/mixedChartConfig.tsx +21 -0
- package/src/configs/pieChartConfig.tsx +156 -0
- package/src/configs/radarChartConfig.tsx +31 -0
- package/src/configs/sankeyChartConfig.tsx +35 -0
- package/src/configs/scatterChartConfig.tsx +152 -0
- package/src/configs/sunburstChartConfig.tsx +31 -0
- package/src/configs/tabConfig.tsx +0 -0
- package/src/configs/tableChartConfig.tsx +81 -0
- package/src/configs/themeriverChartConfig.tsx +31 -0
- package/src/configs/totalChartConfig.tsx +670 -0
- package/src/configs/treeChartConfig.tsx +31 -0
- package/src/configs/treemapChartConfig.tsx +31 -0
- package/src/controls/AnimationsControls.tsx +3 -0
- package/src/controls/AutoHeightControl.tsx +2 -0
- package/src/controls/AxisControls.tsx +146 -0
- package/src/controls/AxisVisibilityControl.tsx +14 -0
- package/src/controls/ChartTypeControl.tsx +15 -0
- package/src/controls/ColorScaleControl.tsx +221 -0
- package/src/controls/ColumnControl.tsx +204 -0
- package/src/controls/ConfigControl.tsx +37 -0
- package/src/controls/DirectionControls.tsx +20 -0
- package/src/controls/IconControl.tsx +88 -0
- package/src/controls/LegendControl.tsx +8 -0
- package/src/controls/RowLimitControl.tsx +91 -0
- package/src/controls/StyleControls.tsx +22 -0
- package/src/controls/TimeControls.tsx +41 -0
- package/src/controls/TrendlineControl.tsx +89 -0
- package/src/controls/UIEventControl.tsx +21 -0
- package/src/controls/index.ts +16 -0
- package/src/controls/radioControl.tsx +88 -0
- package/src/exposing/index.ts +3 -0
- package/src/exposing/setPoint.ts +19 -0
- package/src/geo/vn.geo.json +369897 -0
- package/src/geo/world.geo.json +32127 -0
- package/src/i18n/comps/index.tsx +39 -0
- package/src/i18n/comps/locales/en.ts +558 -0
- package/src/i18n/comps/locales/enObj.tsx +7186 -0
- package/src/i18n/comps/locales/index.ts +7 -0
- package/src/i18n/comps/locales/pt.ts +37 -0
- package/src/i18n/comps/locales/ptObj.tsx +40 -0
- package/src/i18n/comps/locales/types.tsx +622 -0
- package/src/i18n/comps/locales/zh.ts +3 -0
- package/src/i18n/comps/locales/zhObj.tsx +4 -0
- package/src/index.ts +31 -0
- package/src/types/global.d.ts +9 -0
- package/src/types/lowcoder-sdk.d.ts +578 -0
- package/src/utils/chartStyle.util.ts +121 -0
- package/src/utils/columnExtractor.util.ts +41 -0
- package/src/utils/dataTransform.util.ts +37 -0
- package/src/utils/deepEqual.util.ts +29 -0
- package/src/utils/echarts.util.tsx +822 -0
- package/src/utils/getDataKey.util.ts +115 -0
- package/src/utils/getLinearRegression.util.ts +46 -0
- package/src/utils/googleMaps.util.ts +28 -0
- package/src/utils/isEmpty.util.ts +10 -0
- package/src/utils/move.util.ts +6 -0
- package/src/utils/selection.util.ts +73 -0
- package/src/utils/style.util.ts +315 -0
- package/src/utils/time.util.ts +221 -0
- package/src/utils/timeFormatter.util.ts +104 -0
- package/src/utils/timeProcessing.util.ts +38 -0
- package/src/utils/trendline.util.ts +342 -0
- package/tsconfig.json +25 -0
- package/vite.config.js +19 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { UICompBuilder, withExposingConfigs, withDefault } from "lowcoder-sdk";
|
|
2
|
+
import { TabPropertyView } from "@/components/TabPropertyView";
|
|
3
|
+
import { TabCompProps, tabData, TabUiPropsType } from "./constants";
|
|
4
|
+
import { useState, useEffect, useMemo, CSSProperties } from "react";
|
|
5
|
+
|
|
6
|
+
const TabTmpComp = (function () {
|
|
7
|
+
return new UICompBuilder(TabCompProps, (props: TabUiPropsType) => {
|
|
8
|
+
const [activeTab, setActiveTab] = useState(props.defaultValue);
|
|
9
|
+
|
|
10
|
+
const tabs = useMemo(() => {
|
|
11
|
+
console.log("DEBUG RENDER: Props items:", props.items);
|
|
12
|
+
return props.items.map((item: any) => {
|
|
13
|
+
const rawData = item.children.data.getView();
|
|
14
|
+
console.log(`DEBUG RENDER Tab ${item.children.label.getView()} Data:`, rawData);
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
id: String(item.children.id.getView()),
|
|
18
|
+
label: item.children.label.getView(),
|
|
19
|
+
data: rawData,
|
|
20
|
+
disabled: false,
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}, [props.items]);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const currentTabStillExists = tabs.some((t: any) => t.id === activeTab);
|
|
27
|
+
if (currentTabStillExists) return;
|
|
28
|
+
|
|
29
|
+
const hasDefault = tabs.some((t: any) => t.id === props.defaultValue);
|
|
30
|
+
if (hasDefault) setActiveTab(props.defaultValue);
|
|
31
|
+
else if (tabs.length > 0) setActiveTab(tabs[0].id);
|
|
32
|
+
}, [props.defaultValue, tabs, activeTab]);
|
|
33
|
+
|
|
34
|
+
const handleTabClick = (val: string) => {
|
|
35
|
+
setActiveTab(val);
|
|
36
|
+
props.onEvent("change");
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const cardTableCss = `
|
|
40
|
+
.lc-cardtable {
|
|
41
|
+
height: 100%;
|
|
42
|
+
width: 100%;
|
|
43
|
+
background: #24384f;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.lc-cardtable .lc-cardtable-wrap {
|
|
47
|
+
overflow-x: auto;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.lc-cardtable table {
|
|
51
|
+
width: 100%;
|
|
52
|
+
border-collapse: separate;
|
|
53
|
+
border-spacing: 0 12px; /* khoảng cách giữa các row như card */
|
|
54
|
+
background: transparent;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.lc-cardtable thead tr {
|
|
58
|
+
background: transparent;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.lc-cardtable thead th {
|
|
62
|
+
padding: 10px 12px;
|
|
63
|
+
border-bottom: none;
|
|
64
|
+
text-align: left;
|
|
65
|
+
font-size: 15px;
|
|
66
|
+
font-weight: 800;
|
|
67
|
+
color: rgba(255,255,255,0.9);
|
|
68
|
+
position: sticky;
|
|
69
|
+
top: 0;
|
|
70
|
+
background: #24384f;
|
|
71
|
+
z-index: 2;
|
|
72
|
+
white-space: nowrap;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.lc-cardtable tbody td {
|
|
76
|
+
padding: 14px 14px;
|
|
77
|
+
border-bottom: none;
|
|
78
|
+
font-size: 15px;
|
|
79
|
+
color: #0f172a;
|
|
80
|
+
vertical-align: middle;
|
|
81
|
+
background: #e9eef3;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.lc-cardtable tbody td:first-child {
|
|
85
|
+
border-top-left-radius: 12px;
|
|
86
|
+
border-bottom-left-radius: 12px;
|
|
87
|
+
|
|
88
|
+
box-shadow: inset 6px 0 0 #ef4444;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.lc-cardtable tbody td:last-child {
|
|
92
|
+
border-top-right-radius: 12px;
|
|
93
|
+
border-bottom-right-radius: 12px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.lc-cardtable tbody tr:hover td {
|
|
97
|
+
filter: brightness(0.985);
|
|
98
|
+
transform: translateY(-1px);
|
|
99
|
+
transition: transform .12s ease, filter .12s ease;
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<>
|
|
105
|
+
<style>{cardTableCss}</style>
|
|
106
|
+
|
|
107
|
+
<div style={styles.container} className="lc-cardtable">
|
|
108
|
+
{/* Tabs header */}
|
|
109
|
+
<div style={styles.header}>
|
|
110
|
+
{tabs.map((tab: any, idx: number) => {
|
|
111
|
+
const isActive = activeTab === tab.id;
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
key={tab.id || idx}
|
|
115
|
+
onClick={() => handleTabClick(tab.id)}
|
|
116
|
+
style={{
|
|
117
|
+
...styles.tab,
|
|
118
|
+
...(isActive ? styles.tabActive : null),
|
|
119
|
+
...(tab.disabled ? styles.tabDisabled : null),
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
{tab.label}
|
|
123
|
+
</div>
|
|
124
|
+
);
|
|
125
|
+
})}
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
{/* Content */}
|
|
129
|
+
<div style={styles.content}>
|
|
130
|
+
<div style={styles.contentDesc}>
|
|
131
|
+
{(() => {
|
|
132
|
+
const activeItem =
|
|
133
|
+
tabs.find((t: any) => t.id === activeTab) || tabs[0];
|
|
134
|
+
let data = activeItem?.data;
|
|
135
|
+
|
|
136
|
+
if (data && !Array.isArray(data)) data = [data];
|
|
137
|
+
|
|
138
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
139
|
+
const columns = Object.keys(data[0] || {});
|
|
140
|
+
return (
|
|
141
|
+
<div style={styles.tableWrap} className="lc-cardtable-wrap">
|
|
142
|
+
<table style={styles.table}>
|
|
143
|
+
<thead>
|
|
144
|
+
<tr style={styles.theadRow}>
|
|
145
|
+
{columns.map((col) => (
|
|
146
|
+
<th key={col} style={styles.th}>
|
|
147
|
+
{col}
|
|
148
|
+
</th>
|
|
149
|
+
))}
|
|
150
|
+
</tr>
|
|
151
|
+
</thead>
|
|
152
|
+
<tbody>
|
|
153
|
+
{data.map((row: any, rowIndex: number) => (
|
|
154
|
+
<tr key={rowIndex}>
|
|
155
|
+
{columns.map((col) => (
|
|
156
|
+
<td key={col} style={styles.td}>
|
|
157
|
+
{typeof row?.[col] === "object" &&
|
|
158
|
+
row?.[col] !== null
|
|
159
|
+
? JSON.stringify(row[col])
|
|
160
|
+
: row?.[col]}
|
|
161
|
+
</td>
|
|
162
|
+
))}
|
|
163
|
+
</tr>
|
|
164
|
+
))}
|
|
165
|
+
</tbody>
|
|
166
|
+
</table>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<div style={styles.empty}>No data for this tab</div>
|
|
173
|
+
);
|
|
174
|
+
})()}
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</>
|
|
179
|
+
);
|
|
180
|
+
})
|
|
181
|
+
.setPropertyViewFn(TabPropertyView)
|
|
182
|
+
.build();
|
|
183
|
+
})();
|
|
184
|
+
|
|
185
|
+
export const TabCompWithDefault = withDefault(
|
|
186
|
+
withExposingConfigs(TabTmpComp, []),
|
|
187
|
+
{
|
|
188
|
+
items: tabData,
|
|
189
|
+
defaultTabData: tabData,
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const styles: { [key: string]: CSSProperties } = {
|
|
194
|
+
container: {
|
|
195
|
+
display: "flex",
|
|
196
|
+
flexDirection: "column",
|
|
197
|
+
width: "100%",
|
|
198
|
+
height: "100%",
|
|
199
|
+
background: "#24384f",
|
|
200
|
+
overflow: "hidden",
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
header: {
|
|
204
|
+
display: "flex",
|
|
205
|
+
gap: 16,
|
|
206
|
+
padding: "12px 14px",
|
|
207
|
+
borderBottom: "1px solid rgba(255,255,255,0.18)",
|
|
208
|
+
background: "#24384f",
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
tab: {
|
|
212
|
+
padding: "10px 12px",
|
|
213
|
+
borderRadius: 10,
|
|
214
|
+
border: "1px solid transparent",
|
|
215
|
+
backgroundColor: "transparent",
|
|
216
|
+
fontWeight: 700,
|
|
217
|
+
fontSize: 16,
|
|
218
|
+
color: "rgba(255,255,255,0.70)",
|
|
219
|
+
cursor: "pointer",
|
|
220
|
+
userSelect: "none",
|
|
221
|
+
lineHeight: "20px",
|
|
222
|
+
whiteSpace: "nowrap",
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
tabActive: {
|
|
226
|
+
color: "#60a5fa",
|
|
227
|
+
borderBottom: "2px solid #60a5fa",
|
|
228
|
+
borderRadius: 0,
|
|
229
|
+
paddingBottom: 12,
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
tabDisabled: {
|
|
233
|
+
cursor: "not-allowed",
|
|
234
|
+
color: "rgba(255,255,255,0.35)",
|
|
235
|
+
opacity: 0.7,
|
|
236
|
+
pointerEvents: "none",
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
content: {
|
|
240
|
+
padding: 12,
|
|
241
|
+
flex: 1,
|
|
242
|
+
overflow: "auto",
|
|
243
|
+
background: "#24384f",
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
contentDesc: {
|
|
247
|
+
marginTop: 0,
|
|
248
|
+
color: "rgba(255,255,255,0.85)",
|
|
249
|
+
fontSize: 14,
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
empty: {
|
|
253
|
+
padding: 12,
|
|
254
|
+
borderRadius: 12,
|
|
255
|
+
background: "rgba(255,255,255,0.08)",
|
|
256
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
257
|
+
color: "rgba(255,255,255,0.85)",
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
tableWrap: {
|
|
261
|
+
overflowX: "auto",
|
|
262
|
+
border: "none",
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
table: {
|
|
266
|
+
width: "100%",
|
|
267
|
+
borderCollapse: "separate",
|
|
268
|
+
borderSpacing: "0 12px",
|
|
269
|
+
background: "transparent",
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
theadRow: {
|
|
273
|
+
backgroundColor: "transparent",
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
th: {
|
|
277
|
+
whiteSpace: "nowrap",
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
td: {
|
|
281
|
+
wordBreak: "break-word",
|
|
282
|
+
},
|
|
283
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RecordConstructorToView,
|
|
3
|
+
StringControl,
|
|
4
|
+
eventHandlerControl,
|
|
5
|
+
list,
|
|
6
|
+
uiChildren,
|
|
7
|
+
withDefault,
|
|
8
|
+
jsonControl,
|
|
9
|
+
toJSONObject,
|
|
10
|
+
toJSONObjectArray,
|
|
11
|
+
genRandomKey,
|
|
12
|
+
MultiCompBuilder,
|
|
13
|
+
} from "lowcoder-sdk";
|
|
14
|
+
|
|
15
|
+
export const tabData = [
|
|
16
|
+
{
|
|
17
|
+
id: "1",
|
|
18
|
+
label: "Tab 1",
|
|
19
|
+
data: [{ A: "A", B: "B", C: "C" }],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "2",
|
|
23
|
+
label: "Tab 2",
|
|
24
|
+
data: [{ A: "A", B: "B", C: "C" }],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "3",
|
|
28
|
+
label: "Tab 3",
|
|
29
|
+
data: [{ A: "A", B: "B", C: "C" }],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const tabEventOptions = [
|
|
34
|
+
{ label: "Change", description: "Triggered when tab is changed" },
|
|
35
|
+
] as const;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const TabItemTmpComp = new MultiCompBuilder(
|
|
40
|
+
{
|
|
41
|
+
id: withDefault(StringControl, "1"),
|
|
42
|
+
label: withDefault(StringControl, "Tab Label"),
|
|
43
|
+
data: withDefault(jsonControl((v) => v, []), []),
|
|
44
|
+
},
|
|
45
|
+
(props) => props
|
|
46
|
+
)
|
|
47
|
+
.setPropertyViewFn((children) => (
|
|
48
|
+
<>
|
|
49
|
+
{children.label.propertyView({ label: "Label" })}
|
|
50
|
+
{children.data.propertyView({ label: "Data" })}
|
|
51
|
+
</>
|
|
52
|
+
))
|
|
53
|
+
.build();
|
|
54
|
+
|
|
55
|
+
export const TabItemComp = TabItemTmpComp;
|
|
56
|
+
|
|
57
|
+
export function newTabItem(id: number | string) {
|
|
58
|
+
return {
|
|
59
|
+
id: String(genRandomKey()),
|
|
60
|
+
label: `Tab ${id}`,
|
|
61
|
+
data: [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const TabCompProps = {
|
|
66
|
+
items: withDefault(list(TabItemComp), tabData),
|
|
67
|
+
|
|
68
|
+
defaultTabData: withDefault(
|
|
69
|
+
jsonControl(toJSONObjectArray, tabData),
|
|
70
|
+
tabData
|
|
71
|
+
),
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
defaultValue: withDefault(StringControl, "1"),
|
|
75
|
+
onEvent: eventHandlerControl(tabEventOptions),
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const tabUiChildrenMap = uiChildren(TabCompProps);
|
|
79
|
+
export type TabUiPropsType = RecordConstructorToView<typeof tabUiChildrenMap>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { i18nObjs, trans } from "@/i18n/comps";
|
|
2
|
+
import { BarSeriesOption } from "echarts";
|
|
3
|
+
import {
|
|
4
|
+
BoolControl,
|
|
5
|
+
ColorControl,
|
|
6
|
+
CompAction,
|
|
7
|
+
dropdownControl,
|
|
8
|
+
jsonControl,
|
|
9
|
+
MultiCompBuilder,
|
|
10
|
+
NumberControl,
|
|
11
|
+
showLabelPropertyView,
|
|
12
|
+
StringControl,
|
|
13
|
+
toArray,
|
|
14
|
+
withDefault,
|
|
15
|
+
} from "lowcoder-sdk";
|
|
16
|
+
|
|
17
|
+
export const BarTypeOptions = [
|
|
18
|
+
{
|
|
19
|
+
label: trans("chart.bar"),
|
|
20
|
+
value: "bar",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: trans("chart.waterfallBar"),
|
|
24
|
+
value: "waterfall",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: trans("chart.polar"),
|
|
28
|
+
value: "polar",
|
|
29
|
+
},
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
export const BarChartConfig = (function () {
|
|
33
|
+
return new MultiCompBuilder(
|
|
34
|
+
{
|
|
35
|
+
showLabel: withDefault(BoolControl, true),
|
|
36
|
+
type: dropdownControl(BarTypeOptions, "bar"),
|
|
37
|
+
barWidth: withDefault(NumberControl, 40),
|
|
38
|
+
showBackground: withDefault(BoolControl, false),
|
|
39
|
+
backgroundColor: withDefault(
|
|
40
|
+
ColorControl,
|
|
41
|
+
i18nObjs.defaultBarChartOption.barBg
|
|
42
|
+
),
|
|
43
|
+
radiusAxisMax: NumberControl,
|
|
44
|
+
polarRadiusStart: withDefault(StringControl, "30"),
|
|
45
|
+
polarRadiusEnd: withDefault(StringControl, "80%"),
|
|
46
|
+
polarStartAngle: withDefault(NumberControl, 90),
|
|
47
|
+
polarEndAngle: withDefault(NumberControl, -180),
|
|
48
|
+
polarIsTangent: withDefault(BoolControl, false),
|
|
49
|
+
stack: withDefault(BoolControl, false),
|
|
50
|
+
race: withDefault(BoolControl, false),
|
|
51
|
+
labelData: jsonControl(toArray, []),
|
|
52
|
+
},
|
|
53
|
+
(props): BarSeriesOption => {
|
|
54
|
+
const config: BarSeriesOption & { polarData: any; race: any } = {
|
|
55
|
+
type: props.type,
|
|
56
|
+
realtimeSort: props.race,
|
|
57
|
+
seriesLayoutBy: props.race ? "column" : undefined,
|
|
58
|
+
label: {
|
|
59
|
+
show: props.showLabel,
|
|
60
|
+
position: "top",
|
|
61
|
+
valueAnimation: props.race,
|
|
62
|
+
},
|
|
63
|
+
barWidth: `${props.barWidth}%`,
|
|
64
|
+
showBackground: props.showBackground,
|
|
65
|
+
backgroundStyle: {
|
|
66
|
+
color: props.backgroundColor,
|
|
67
|
+
},
|
|
68
|
+
polarData: {
|
|
69
|
+
radiusAxisMax: props.radiusAxisMax,
|
|
70
|
+
polarRadiusStart: props.polarRadiusStart,
|
|
71
|
+
polarRadiusEnd: props.polarRadiusEnd,
|
|
72
|
+
polarStartAngle: props.polarStartAngle,
|
|
73
|
+
polarEndAngle: props.polarEndAngle,
|
|
74
|
+
labelData: props.labelData,
|
|
75
|
+
polarIsTangent: props.polarIsTangent,
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
race: props.race,
|
|
79
|
+
};
|
|
80
|
+
if (props.stack) {
|
|
81
|
+
config.stack = "stackValue";
|
|
82
|
+
}
|
|
83
|
+
if (props.type === "waterfall") {
|
|
84
|
+
config.label = undefined;
|
|
85
|
+
config.stack = "stackValue";
|
|
86
|
+
}
|
|
87
|
+
if (props.type === "polar") {
|
|
88
|
+
config.coordinateSystem = "polar";
|
|
89
|
+
}
|
|
90
|
+
return config;
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
.setPropertyViewFn((children, dispatch: (action: CompAction) => void) => (
|
|
94
|
+
<>
|
|
95
|
+
{/* <Dropdown
|
|
96
|
+
value={children.type.getView()}
|
|
97
|
+
options={BarTypeOptions}
|
|
98
|
+
label={trans("chart.barType")}
|
|
99
|
+
onChange={(value: string) => {
|
|
100
|
+
dispatch(changeChildAction("type", value));
|
|
101
|
+
}}
|
|
102
|
+
/> */}
|
|
103
|
+
{showLabelPropertyView(children)}
|
|
104
|
+
{children.barWidth.propertyView({
|
|
105
|
+
label: trans("barChart.barWidth"),
|
|
106
|
+
})}
|
|
107
|
+
{children.type.getView() !== "waterfall" &&
|
|
108
|
+
children.race.propertyView({
|
|
109
|
+
label: trans("barChart.race"),
|
|
110
|
+
})}
|
|
111
|
+
{children.type.getView() !== "waterfall" &&
|
|
112
|
+
children.stack.propertyView({
|
|
113
|
+
label: trans("barChart.stack"),
|
|
114
|
+
})}
|
|
115
|
+
{children.showBackground.propertyView({
|
|
116
|
+
label: trans("barChart.showBg"),
|
|
117
|
+
})}
|
|
118
|
+
{children.showBackground.getView() &&
|
|
119
|
+
children.backgroundColor.propertyView({
|
|
120
|
+
label: trans("barChart.bgColor"),
|
|
121
|
+
})}
|
|
122
|
+
{children.type.getView() === "polar" &&
|
|
123
|
+
children.polarIsTangent.propertyView({
|
|
124
|
+
label: trans("barChart.polarIsTangent"),
|
|
125
|
+
})}
|
|
126
|
+
{children.type.getView() === "polar" &&
|
|
127
|
+
children.polarStartAngle.propertyView({
|
|
128
|
+
label: trans("barChart.polarStartAngle"),
|
|
129
|
+
})}
|
|
130
|
+
{children.type.getView() === "polar" &&
|
|
131
|
+
children.polarEndAngle.propertyView({
|
|
132
|
+
label: trans("barChart.polarEndAngle"),
|
|
133
|
+
})}
|
|
134
|
+
{children.type.getView() === "polar" &&
|
|
135
|
+
children.radiusAxisMax.propertyView({
|
|
136
|
+
label: trans("barChart.radiusAxisMax"),
|
|
137
|
+
})}
|
|
138
|
+
{children.type.getView() === "polar" &&
|
|
139
|
+
children.polarRadiusStart.propertyView({
|
|
140
|
+
label: trans("barChart.polarRadiusStart"),
|
|
141
|
+
})}
|
|
142
|
+
{children.type.getView() === "polar" &&
|
|
143
|
+
children.polarRadiusEnd.propertyView({
|
|
144
|
+
label: trans("barChart.polarRadiusEnd"),
|
|
145
|
+
})}
|
|
146
|
+
{children.type.getView() === "polar" &&
|
|
147
|
+
children.labelData.propertyView({
|
|
148
|
+
label: trans("barChart.polarLabelData"),
|
|
149
|
+
})}
|
|
150
|
+
</>
|
|
151
|
+
))
|
|
152
|
+
.build();
|
|
153
|
+
})();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ChartType } from "@/controls";
|
|
2
|
+
import { EChartPropsType } from "../utils/echarts.util";
|
|
3
|
+
|
|
4
|
+
export function getBaseConfig(props: EChartPropsType, type?: ChartType) {
|
|
5
|
+
const gridPos = {
|
|
6
|
+
left: props?.left,
|
|
7
|
+
right: props?.right,
|
|
8
|
+
bottom: props?.bottom,
|
|
9
|
+
top: props?.top,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const baseConfig: any = {
|
|
13
|
+
title: {
|
|
14
|
+
text: props.title,
|
|
15
|
+
top: props.echartsTitleVerticalConfig.top,
|
|
16
|
+
left: props.echartsTitleConfig.top,
|
|
17
|
+
textStyle: props?.titleStyle, // Simplified for brevity
|
|
18
|
+
},
|
|
19
|
+
backgroundColor: "#FFFFFF", // Simplified for brevity
|
|
20
|
+
legend: {
|
|
21
|
+
...props.legendConfig,
|
|
22
|
+
textStyle: props?.legendStyle, // Simplified for brevity
|
|
23
|
+
},
|
|
24
|
+
tooltip: props.tooltip
|
|
25
|
+
? ["map"].includes(type as string)
|
|
26
|
+
? {}
|
|
27
|
+
: {
|
|
28
|
+
trigger: "axis",
|
|
29
|
+
axisPointer: {
|
|
30
|
+
type: "line",
|
|
31
|
+
lineStyle: {
|
|
32
|
+
color: "rgba(0,0,0,0.2)",
|
|
33
|
+
width: 2,
|
|
34
|
+
type: "solid",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
: undefined,
|
|
39
|
+
grid: { ...gridPos, containLabel: true },
|
|
40
|
+
animationDuration: props.animationDuration,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
if (props.areaPieces.length > 0) {
|
|
44
|
+
const pieces = props.areaPieces
|
|
45
|
+
.filter(
|
|
46
|
+
(p: any) => p.getView().from && p.getView().to && p.getView().color
|
|
47
|
+
)
|
|
48
|
+
.map((p: any) => ({
|
|
49
|
+
...(p.getView().from && { min: parseInt(p.getView().from) }),
|
|
50
|
+
...(p.getView().to && { max: parseInt(p.getView().to) }),
|
|
51
|
+
...(p.getView().color && { color: p.getView().color }),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
if (pieces.length > 0) {
|
|
55
|
+
baseConfig.visualMap = {
|
|
56
|
+
type: "piecewise",
|
|
57
|
+
show: false,
|
|
58
|
+
dimension: 0,
|
|
59
|
+
seriesIndex: 0,
|
|
60
|
+
pieces,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return baseConfig;
|
|
66
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { trans } from "@/i18n/comps";
|
|
2
|
+
import { CandlestickSeriesOption } from "echarts";
|
|
3
|
+
import {
|
|
4
|
+
BoolControl,
|
|
5
|
+
MultiCompBuilder,
|
|
6
|
+
showLabelPropertyView,
|
|
7
|
+
} from "lowcoder-sdk";
|
|
8
|
+
|
|
9
|
+
export const CandleStickChartConfig = (function () {
|
|
10
|
+
return new MultiCompBuilder(
|
|
11
|
+
{
|
|
12
|
+
showLabel: BoolControl,
|
|
13
|
+
},
|
|
14
|
+
(props): CandlestickSeriesOption => {
|
|
15
|
+
const config: CandlestickSeriesOption = {
|
|
16
|
+
type: "candlestick",
|
|
17
|
+
label: {
|
|
18
|
+
show: props.showLabel,
|
|
19
|
+
position: "top",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
.setPropertyViewFn((children) => (
|
|
26
|
+
<>
|
|
27
|
+
{showLabelPropertyView(children)}
|
|
28
|
+
{children.type.propertyView({
|
|
29
|
+
label: trans("candleStickChart.candleStickType"),
|
|
30
|
+
radioButton: true,
|
|
31
|
+
})}
|
|
32
|
+
</>
|
|
33
|
+
))
|
|
34
|
+
.build();
|
|
35
|
+
})();
|