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,368 @@
|
|
|
1
|
+
import { MarkLineTypeOptions, StepOptions } from "@/configs/echartConfig";
|
|
2
|
+
import { ChartTypeOptions } from "@/controls";
|
|
3
|
+
import { trans } from "@/i18n/comps";
|
|
4
|
+
import {
|
|
5
|
+
BoolControl,
|
|
6
|
+
ColorControl,
|
|
7
|
+
CompAction,
|
|
8
|
+
ConstructorToComp,
|
|
9
|
+
ConstructorToDataType,
|
|
10
|
+
ConstructorToView,
|
|
11
|
+
CustomAction,
|
|
12
|
+
Dropdown,
|
|
13
|
+
JSONObject,
|
|
14
|
+
MultiCompBuilder,
|
|
15
|
+
Option,
|
|
16
|
+
OptionsType,
|
|
17
|
+
RedButton,
|
|
18
|
+
StringControl,
|
|
19
|
+
customAction,
|
|
20
|
+
dropdownControl,
|
|
21
|
+
genRandomKey,
|
|
22
|
+
isMyCustomAction,
|
|
23
|
+
isNumeric,
|
|
24
|
+
list,
|
|
25
|
+
valueComp,
|
|
26
|
+
withDefault,
|
|
27
|
+
} from "lowcoder-sdk";
|
|
28
|
+
|
|
29
|
+
export type SeriesCompType = ConstructorToComp<typeof SeriesComp>;
|
|
30
|
+
export type RawSeriesCompType = ConstructorToView<typeof SeriesComp>;
|
|
31
|
+
type SeriesDataType = ConstructorToDataType<typeof SeriesComp> | any;
|
|
32
|
+
type MarkLineDataType = ConstructorToDataType<typeof MarkLinesTmpComp>;
|
|
33
|
+
type MarkAreaDataType = ConstructorToDataType<typeof MarkAreasTmpComp>;
|
|
34
|
+
export type ChartType = "line" | "bar" | "pie" | "mixed" | string;
|
|
35
|
+
type ActionDataType = {
|
|
36
|
+
type: "chartDataChanged";
|
|
37
|
+
chartData: Array<JSONObject>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function newSeries(
|
|
41
|
+
name: string,
|
|
42
|
+
columnName: string,
|
|
43
|
+
chartType: string
|
|
44
|
+
): SeriesDataType {
|
|
45
|
+
return {
|
|
46
|
+
seriesName: name,
|
|
47
|
+
columnName,
|
|
48
|
+
chartType,
|
|
49
|
+
dataIndex: genRandomKey(),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function newMarkLine(type: string): MarkLineDataType {
|
|
54
|
+
return {
|
|
55
|
+
type,
|
|
56
|
+
dataIndex: genRandomKey(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function newMarkArea(): MarkAreaDataType {
|
|
61
|
+
return {
|
|
62
|
+
dataIndex: genRandomKey(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const valToLabel = (val: any) =>
|
|
67
|
+
MarkLineTypeOptions.find((o) => o.value === val)?.label || "";
|
|
68
|
+
|
|
69
|
+
const markLinesChildrenMap = {
|
|
70
|
+
type: dropdownControl(MarkLineTypeOptions, "max"),
|
|
71
|
+
dataIndex: valueComp<string>(""),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const MarkLinesTmpComp = new MultiCompBuilder(markLinesChildrenMap, (props) => {
|
|
75
|
+
return props;
|
|
76
|
+
})
|
|
77
|
+
.setPropertyViewFn((children: any) => {
|
|
78
|
+
return (
|
|
79
|
+
<>{children.type.propertyView({ label: trans("chart.markLineType") })}</>
|
|
80
|
+
);
|
|
81
|
+
})
|
|
82
|
+
.build();
|
|
83
|
+
|
|
84
|
+
const markAreasChildrenMap = {
|
|
85
|
+
name: StringControl,
|
|
86
|
+
from: StringControl,
|
|
87
|
+
to: StringControl,
|
|
88
|
+
dataIndex: valueComp<string>(""),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const MarkAreasTmpComp = new MultiCompBuilder(markAreasChildrenMap, (props) => {
|
|
92
|
+
return props;
|
|
93
|
+
})
|
|
94
|
+
.setPropertyViewFn((children: any) => (
|
|
95
|
+
<>
|
|
96
|
+
{children.name.propertyView({ label: trans("chart.markAreaName") })}
|
|
97
|
+
{children.from.propertyView({ label: trans("chart.markAreaFrom") })}
|
|
98
|
+
{children.to.propertyView({ label: trans("chart.markAreaTo") })}
|
|
99
|
+
</>
|
|
100
|
+
))
|
|
101
|
+
.build();
|
|
102
|
+
|
|
103
|
+
// Series Component
|
|
104
|
+
const seriesChildrenMap = {
|
|
105
|
+
columnName: StringControl,
|
|
106
|
+
seriesName: StringControl,
|
|
107
|
+
chartType: StringControl,
|
|
108
|
+
markLines: list(MarkLinesTmpComp),
|
|
109
|
+
markAreas: list(MarkAreasTmpComp),
|
|
110
|
+
hide: withDefault(BoolControl, false),
|
|
111
|
+
dataIndex: valueComp<string>(""),
|
|
112
|
+
step: dropdownControl(StepOptions, ""),
|
|
113
|
+
itemStyle: StringControl,
|
|
114
|
+
stack: StringControl,
|
|
115
|
+
barWidth: StringControl,
|
|
116
|
+
smooth: withDefault(BoolControl, false),
|
|
117
|
+
areaStyle: withDefault(BoolControl, false),
|
|
118
|
+
color: ColorControl,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const SeriesTmpComp = new MultiCompBuilder(seriesChildrenMap, (props) => {
|
|
122
|
+
return props;
|
|
123
|
+
}).build();
|
|
124
|
+
|
|
125
|
+
class SeriesComp extends SeriesTmpComp {
|
|
126
|
+
getPropertyViewWithData(columnOptions: OptionsType): React.ReactNode {
|
|
127
|
+
const chartType = this.children.chartType.getView();
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<>
|
|
131
|
+
{this.children.seriesName.propertyView({
|
|
132
|
+
label: trans("chart.seriesName"),
|
|
133
|
+
})}
|
|
134
|
+
|
|
135
|
+
<Dropdown
|
|
136
|
+
value={this.children.columnName.getView()}
|
|
137
|
+
options={columnOptions}
|
|
138
|
+
label={trans("chart.dataColumns")}
|
|
139
|
+
onChange={(value: any) => {
|
|
140
|
+
this.children.columnName.dispatchChangeValueAction(value);
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
{this.children.color.propertyView({
|
|
144
|
+
label: "Line Color",
|
|
145
|
+
})}
|
|
146
|
+
{!["pie"].includes(chartType) && (
|
|
147
|
+
<Dropdown
|
|
148
|
+
value={chartType}
|
|
149
|
+
options={ChartTypeOptions}
|
|
150
|
+
label={trans("chart.chartType")}
|
|
151
|
+
onChange={(value: any) => {
|
|
152
|
+
this.children.chartType.dispatchChangeValueAction(value);
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
{/* Regular chart type controls */}
|
|
158
|
+
{["line"].includes(chartType) && (
|
|
159
|
+
<>
|
|
160
|
+
{this.children.step.propertyView({
|
|
161
|
+
label: trans("chart.step"),
|
|
162
|
+
})}
|
|
163
|
+
{this.children.smooth.propertyView({
|
|
164
|
+
label: trans("chart.smooth"),
|
|
165
|
+
})}
|
|
166
|
+
{this.children.areaStyle.propertyView({
|
|
167
|
+
label: trans("chart.areaStyle"),
|
|
168
|
+
})}
|
|
169
|
+
</>
|
|
170
|
+
)}
|
|
171
|
+
|
|
172
|
+
{chartType === "bar" && (
|
|
173
|
+
<>
|
|
174
|
+
{this.children.barWidth.propertyView({
|
|
175
|
+
label: trans("barChart.barWidth"),
|
|
176
|
+
})}
|
|
177
|
+
{this.children.stack.propertyView({
|
|
178
|
+
label: trans("barChart.stack"),
|
|
179
|
+
})}
|
|
180
|
+
</>
|
|
181
|
+
)}
|
|
182
|
+
|
|
183
|
+
{!["pie"].includes(chartType) && (
|
|
184
|
+
<>
|
|
185
|
+
<Option
|
|
186
|
+
items={this.children.markLines.getView()}
|
|
187
|
+
title={trans("chart.markLines")}
|
|
188
|
+
itemTitle={(s) => valToLabel(s.getView().type)}
|
|
189
|
+
popoverTitle={(_) => trans("chart.markLineType")}
|
|
190
|
+
content={(s, index) => (
|
|
191
|
+
<>
|
|
192
|
+
{s.getPropertyView({ label: "Type" })}
|
|
193
|
+
{
|
|
194
|
+
<RedButton
|
|
195
|
+
onClick={() => {
|
|
196
|
+
this.children.markLines.dispatch(
|
|
197
|
+
this.children.markLines.deleteAction(index)
|
|
198
|
+
);
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
{trans("chart.delete")}
|
|
202
|
+
</RedButton>
|
|
203
|
+
}
|
|
204
|
+
</>
|
|
205
|
+
)}
|
|
206
|
+
onAdd={() => {
|
|
207
|
+
this.children.markLines.dispatch(
|
|
208
|
+
this.children.markLines.pushAction(newMarkLine("max"))
|
|
209
|
+
);
|
|
210
|
+
}}
|
|
211
|
+
onMove={(fromIndex, toIndex) => {
|
|
212
|
+
const action = this.children.markLines.arrayMoveAction(
|
|
213
|
+
fromIndex,
|
|
214
|
+
toIndex
|
|
215
|
+
);
|
|
216
|
+
this.children.markLines.dispatch(action);
|
|
217
|
+
}}
|
|
218
|
+
dataIndex={(s) => {
|
|
219
|
+
return s.getView().dataIndex;
|
|
220
|
+
}}
|
|
221
|
+
/>
|
|
222
|
+
|
|
223
|
+
<Option
|
|
224
|
+
items={this.children.markAreas.getView()}
|
|
225
|
+
title={trans("chart.markAreas")}
|
|
226
|
+
itemTitle={(s) => s.getView().name}
|
|
227
|
+
popoverTitle={(_) => trans("chart.markAreaConfig")}
|
|
228
|
+
content={(s, index) => (
|
|
229
|
+
<>
|
|
230
|
+
{s.getPropertyView({ label: "Config" })}
|
|
231
|
+
{
|
|
232
|
+
<RedButton
|
|
233
|
+
onClick={() => {
|
|
234
|
+
this.children.markAreas.dispatch(
|
|
235
|
+
this.children.markAreas.deleteAction(index)
|
|
236
|
+
);
|
|
237
|
+
}}
|
|
238
|
+
>
|
|
239
|
+
{trans("chart.delete")}
|
|
240
|
+
</RedButton>
|
|
241
|
+
}
|
|
242
|
+
</>
|
|
243
|
+
)}
|
|
244
|
+
onAdd={() => {
|
|
245
|
+
this.children.markAreas.dispatch(
|
|
246
|
+
this.children.markAreas.pushAction(newMarkArea())
|
|
247
|
+
);
|
|
248
|
+
}}
|
|
249
|
+
onMove={(fromIndex, toIndex) => {
|
|
250
|
+
const action = this.children.markAreas.arrayMoveAction(
|
|
251
|
+
fromIndex,
|
|
252
|
+
toIndex
|
|
253
|
+
);
|
|
254
|
+
this.children.markAreas.dispatch(action);
|
|
255
|
+
}}
|
|
256
|
+
dataIndex={(s) => {
|
|
257
|
+
return s.getView().dataIndex;
|
|
258
|
+
}}
|
|
259
|
+
/>
|
|
260
|
+
</>
|
|
261
|
+
)}
|
|
262
|
+
</>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const SeriesListTmpComp = list(SeriesComp);
|
|
268
|
+
export function createSeriesListComp(
|
|
269
|
+
defaultChartTypes: ChartType | ChartType[] = "line"
|
|
270
|
+
) {
|
|
271
|
+
// Chuyển đổi thành mảng nếu là string
|
|
272
|
+
const chartTypesArray = Array.isArray(defaultChartTypes)
|
|
273
|
+
? defaultChartTypes
|
|
274
|
+
: [defaultChartTypes];
|
|
275
|
+
|
|
276
|
+
class SeriesListComp extends SeriesListTmpComp {
|
|
277
|
+
reduce(action: CompAction): this {
|
|
278
|
+
if (isMyCustomAction<ActionDataType>(action, "chartDataChanged")) {
|
|
279
|
+
const actions = this.genExampleSeriesActions(action.value.chartData);
|
|
280
|
+
return this.reduce(this.multiAction(actions));
|
|
281
|
+
}
|
|
282
|
+
return super.reduce(action);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private genExampleSeriesActions(chartData: Array<JSONObject>) {
|
|
286
|
+
const actions: CustomAction[] = [];
|
|
287
|
+
|
|
288
|
+
if (!chartData || chartData.length <= 0 || !chartData[0]) {
|
|
289
|
+
return actions;
|
|
290
|
+
}
|
|
291
|
+
const chartView = this.getView();
|
|
292
|
+
const existColumns = chartView.map((s: any) => s.getView().columnName);
|
|
293
|
+
|
|
294
|
+
let delCnt = 0;
|
|
295
|
+
chartView.forEach((series: any, index: number) => {
|
|
296
|
+
const columnName = series.getView().columnName;
|
|
297
|
+
if (chartData[0]?.[columnName] === undefined) {
|
|
298
|
+
actions.push(this.deleteAction(index - delCnt));
|
|
299
|
+
delCnt++;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const numericKeys = Object.keys(chartData[0]).filter((key) => {
|
|
304
|
+
return !existColumns.includes(key) && isNumeric(chartData[0][key]);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
const categoryKeys = Object.keys(chartData[0]).filter((key) => {
|
|
308
|
+
return !existColumns.includes(key) && !isNumeric(chartData[0][key]);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const remainingSeriesCount = chartView.length - delCnt;
|
|
312
|
+
|
|
313
|
+
let seriesIndex = 0;
|
|
314
|
+
|
|
315
|
+
if (remainingSeriesCount === 0) {
|
|
316
|
+
if (numericKeys.length >= 2) {
|
|
317
|
+
numericKeys.slice(0, 3).forEach((key) => {
|
|
318
|
+
const chartType = this.getChartTypeByIndex(seriesIndex);
|
|
319
|
+
actions.push(this.pushAction(newSeries(key, key, chartType)));
|
|
320
|
+
seriesIndex++;
|
|
321
|
+
});
|
|
322
|
+
} else if (numericKeys.length === 1 && categoryKeys.length >= 1) {
|
|
323
|
+
const chartType = this.getChartTypeByIndex(seriesIndex);
|
|
324
|
+
actions.push(
|
|
325
|
+
this.pushAction(
|
|
326
|
+
newSeries(categoryKeys[0], numericKeys[0], chartType)
|
|
327
|
+
)
|
|
328
|
+
);
|
|
329
|
+
seriesIndex++;
|
|
330
|
+
} else if (numericKeys.length === 1) {
|
|
331
|
+
const chartType = this.getChartTypeByIndex(seriesIndex);
|
|
332
|
+
actions.push(
|
|
333
|
+
this.pushAction(
|
|
334
|
+
newSeries(numericKeys[0], numericKeys[0], chartType)
|
|
335
|
+
)
|
|
336
|
+
);
|
|
337
|
+
seriesIndex++;
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
if (numericKeys.length > 0) {
|
|
341
|
+
numericKeys.forEach((key) => {
|
|
342
|
+
const chartType = this.getChartTypeByIndex(seriesIndex);
|
|
343
|
+
actions.push(this.pushAction(newSeries(key, key, chartType)));
|
|
344
|
+
seriesIndex++;
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return actions;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private getChartTypeByIndex(index: number): string {
|
|
352
|
+
if (index < chartTypesArray.length) {
|
|
353
|
+
return chartTypesArray[index];
|
|
354
|
+
}
|
|
355
|
+
return chartTypesArray[chartTypesArray.length - 1] || "line";
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
dispatchDataChanged(chartData: Array<JSONObject>): void {
|
|
359
|
+
this.dispatch(
|
|
360
|
+
customAction<ActionDataType>({
|
|
361
|
+
type: "chartDataChanged",
|
|
362
|
+
chartData,
|
|
363
|
+
})
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return SeriesListComp;
|
|
368
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
childrenToProps,
|
|
3
|
+
changeValueAction,
|
|
4
|
+
CompAction,
|
|
5
|
+
Option,
|
|
6
|
+
RedButton,
|
|
7
|
+
Section,
|
|
8
|
+
toJSONObject,
|
|
9
|
+
} from "lowcoder-sdk";
|
|
10
|
+
import { TabUiPropsType, newTabItem } from "../comps/tab/constants";
|
|
11
|
+
|
|
12
|
+
export function TabPropertyView(
|
|
13
|
+
children: TabUiPropsType,
|
|
14
|
+
dispatch: (action: CompAction) => void
|
|
15
|
+
) {
|
|
16
|
+
const { onEvent } = childrenToProps(children);
|
|
17
|
+
|
|
18
|
+
const importJsonToItems = () => {
|
|
19
|
+
const rawProxy = children.defaultTabData.getView();
|
|
20
|
+
let raw: any;
|
|
21
|
+
try {
|
|
22
|
+
raw = JSON.parse(JSON.stringify(rawProxy));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
raw = rawProxy;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
console.log("DEBUG: Import raw (sanitized):", raw);
|
|
28
|
+
|
|
29
|
+
let arr: any[] = [];
|
|
30
|
+
if (Array.isArray(raw)) arr = raw;
|
|
31
|
+
else if (raw && typeof raw === "object") {
|
|
32
|
+
if ("data" in raw || "label" in raw) {
|
|
33
|
+
arr = [raw];
|
|
34
|
+
} else {
|
|
35
|
+
const values = Object.values(raw);
|
|
36
|
+
if (values.length > 0 && typeof values[0] === "object") arr = values as any[];
|
|
37
|
+
else arr = [raw];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
console.log("DEBUG: Intermediate arr:", arr);
|
|
41
|
+
|
|
42
|
+
const normalized = (arr ?? [])
|
|
43
|
+
.filter(Boolean)
|
|
44
|
+
.map((item: any, index: number) => {
|
|
45
|
+
let data = item?.data ?? [];
|
|
46
|
+
console.log("DEBUG: Data before clone:", data);
|
|
47
|
+
|
|
48
|
+
if (data && !Array.isArray(data)) data = [data];
|
|
49
|
+
console.log("DEBUG: Data after clone:", data);
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
id: String(item?.id ?? index + 1),
|
|
53
|
+
label: String(item?.label ?? item?.id ?? `Tab ${index + 1}`),
|
|
54
|
+
data,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
console.log("DEBUG: Normalized items:", normalized);
|
|
59
|
+
children.items.dispatch(changeValueAction(normalized));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const exportItemsToJson = () => {
|
|
63
|
+
const items = children.items.getView();
|
|
64
|
+
const exported = items.map((it: any) => {
|
|
65
|
+
const v = it.getView();
|
|
66
|
+
return {
|
|
67
|
+
id: String(v.id),
|
|
68
|
+
label: String(v.label),
|
|
69
|
+
data: v.data,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
dispatch(changeValueAction(children.defaultTabData, exported));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<Section name="Data (JSON)">
|
|
79
|
+
{children.defaultTabData.propertyView({
|
|
80
|
+
label: "Default Tab Data (JSON)",
|
|
81
|
+
})}
|
|
82
|
+
|
|
83
|
+
<div
|
|
84
|
+
style={{
|
|
85
|
+
marginTop: 8,
|
|
86
|
+
display: "flex",
|
|
87
|
+
gap: 8,
|
|
88
|
+
justifyContent: "flex-end",
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<RedButton onClick={importJsonToItems}>Import JSON to Tabs</RedButton>
|
|
92
|
+
{/* <RedButton onClick={exportItemsToJson}>Export Tabs to JSON</RedButton> */}
|
|
93
|
+
</div>
|
|
94
|
+
</Section>
|
|
95
|
+
|
|
96
|
+
<Section name="Tabs">
|
|
97
|
+
<Option
|
|
98
|
+
items={children.items.getView()}
|
|
99
|
+
title="Tab Items"
|
|
100
|
+
itemTitle={(item) => item.getView().label}
|
|
101
|
+
popoverTitle={(item) => item.getView().label}
|
|
102
|
+
content={(item, index) => (
|
|
103
|
+
<>
|
|
104
|
+
{item.getPropertyView()}
|
|
105
|
+
<RedButton
|
|
106
|
+
onClick={() => children.items.dispatch(children.items.deleteAction(index))}
|
|
107
|
+
>
|
|
108
|
+
Delete
|
|
109
|
+
</RedButton>
|
|
110
|
+
</>
|
|
111
|
+
)}
|
|
112
|
+
onAdd={() => {
|
|
113
|
+
children.items.dispatch(
|
|
114
|
+
children.items.pushAction(newTabItem(children.items.getView().length + 1))
|
|
115
|
+
);
|
|
116
|
+
}}
|
|
117
|
+
onMove={(fromIndex, toIndex) => {
|
|
118
|
+
children.items.dispatch(children.items.arrayMoveAction(fromIndex, toIndex));
|
|
119
|
+
}}
|
|
120
|
+
dataIndex={(item) => item.getView().id}
|
|
121
|
+
/>
|
|
122
|
+
</Section>
|
|
123
|
+
|
|
124
|
+
<Section name="Interaction">{onEvent.propertyView?.({ label: "Events" })}</Section>
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
}
|