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,350 @@
|
|
|
1
|
+
import { ChartPropertyView } from "@/components/ChartPropertyView";
|
|
2
|
+
import { EchartsAxisType } from "@/configs/cartesianAxisConfig";
|
|
3
|
+
import { eChartConfigOmitChildren } from "@/configs/echartConfig";
|
|
4
|
+
import { ItemColorComp } from "@/configs/lineChartConfig";
|
|
5
|
+
import { AxisFormatterComp } from "@/controls";
|
|
6
|
+
import { getEchartsLocale, trans } from "@/i18n/comps";
|
|
7
|
+
import { formatAllStyles } from "@/utils/chartStyle.util";
|
|
8
|
+
import { deepEqual } from "@/utils/deepEqual.util";
|
|
9
|
+
import { ChartSize, echartProps, getEChartConfig } from "@/utils/echarts.util";
|
|
10
|
+
import { getDataKeys } from "@/utils/getDataKey.util";
|
|
11
|
+
import { getSelectedPoints } from "@/utils/selection.util";
|
|
12
|
+
import ReactECharts from "echarts-for-react";
|
|
13
|
+
import EChartsReactCore from "echarts-for-react/lib/core";
|
|
14
|
+
import {
|
|
15
|
+
changeChildAction,
|
|
16
|
+
changeValueAction,
|
|
17
|
+
chartColorPalette,
|
|
18
|
+
childrenToProps,
|
|
19
|
+
CompAction,
|
|
20
|
+
CompActionTypes,
|
|
21
|
+
depsConfig,
|
|
22
|
+
genRandomKey,
|
|
23
|
+
getPromiseAfterDispatch,
|
|
24
|
+
JSONObject,
|
|
25
|
+
NameConfig,
|
|
26
|
+
Theme,
|
|
27
|
+
ThemeContext,
|
|
28
|
+
UICompBuilder,
|
|
29
|
+
valueComp,
|
|
30
|
+
withDefault,
|
|
31
|
+
withExposingConfigs,
|
|
32
|
+
withViewFn,
|
|
33
|
+
wrapChildAction,
|
|
34
|
+
} from "lowcoder-sdk";
|
|
35
|
+
import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
36
|
+
import { useResizeDetector } from "react-resize-detector";
|
|
37
|
+
import { chartUiProps } from "./constants";
|
|
38
|
+
|
|
39
|
+
let clickEventCallback = () => {};
|
|
40
|
+
|
|
41
|
+
let TwoLineChartTmpComp = (function () {
|
|
42
|
+
return new UICompBuilder(
|
|
43
|
+
{
|
|
44
|
+
...echartProps,
|
|
45
|
+
...chartUiProps,
|
|
46
|
+
},
|
|
47
|
+
() => null
|
|
48
|
+
)
|
|
49
|
+
.setPropertyViewFn(ChartPropertyView)
|
|
50
|
+
.build();
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
TwoLineChartTmpComp = withViewFn(TwoLineChartTmpComp, (comp) => {
|
|
54
|
+
const onUIEvent = comp.children.onUIEvent.getView();
|
|
55
|
+
const onEvent = comp.children.onEvent.getView();
|
|
56
|
+
const eChartCompRef = useRef<EChartsReactCore | null>();
|
|
57
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
58
|
+
const [chartSize, setChartSize] = useState<ChartSize>();
|
|
59
|
+
const firstResize = useRef(true);
|
|
60
|
+
const theme: Theme = useContext(ThemeContext);
|
|
61
|
+
|
|
62
|
+
const defaultChartTheme = {
|
|
63
|
+
color: chartColorPalette,
|
|
64
|
+
backgroundColor: "#fff",
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
let themeConfig = defaultChartTheme;
|
|
68
|
+
try {
|
|
69
|
+
themeConfig = theme?.theme?.chart
|
|
70
|
+
? JSON.parse(theme.theme.chart)
|
|
71
|
+
: defaultChartTheme;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error("theme chart error: ", error);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const triggerClickEvent = async (dispatch: any, action: CompAction) => {
|
|
77
|
+
await getPromiseAfterDispatch(dispatch, action, {
|
|
78
|
+
autoHandleAfterReduce: true,
|
|
79
|
+
});
|
|
80
|
+
onEvent("click");
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const eChartCompInstance = eChartCompRef?.current?.getEchartsInstance();
|
|
85
|
+
if (!eChartCompInstance) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
eChartCompInstance?.on("click", (param: any) => {
|
|
89
|
+
document.dispatchEvent(
|
|
90
|
+
new CustomEvent("clickEvent", {
|
|
91
|
+
bubbles: true,
|
|
92
|
+
detail: {
|
|
93
|
+
action: "click",
|
|
94
|
+
data: param.data,
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
triggerClickEvent(
|
|
99
|
+
comp.dispatch,
|
|
100
|
+
changeChildAction("lastInteractionData", param.data, false)
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
return () => {
|
|
104
|
+
eChartCompInstance?.off("click");
|
|
105
|
+
document.removeEventListener("clickEvent", clickEventCallback);
|
|
106
|
+
};
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
// bind events
|
|
111
|
+
const eChartCompInstance = eChartCompRef?.current?.getEchartsInstance();
|
|
112
|
+
if (!eChartCompInstance) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
eChartCompInstance?.on("selectchanged", (param: any) => {
|
|
116
|
+
const option: any = eChartCompInstance?.getOption();
|
|
117
|
+
document.dispatchEvent(
|
|
118
|
+
new CustomEvent("clickEvent", {
|
|
119
|
+
bubbles: true,
|
|
120
|
+
detail: {
|
|
121
|
+
action: param.fromAction,
|
|
122
|
+
data: getSelectedPoints(param, option),
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
if (param.fromAction === "select") {
|
|
128
|
+
comp.dispatch(
|
|
129
|
+
changeChildAction(
|
|
130
|
+
"selectedPoints",
|
|
131
|
+
getSelectedPoints(param, option),
|
|
132
|
+
false
|
|
133
|
+
)
|
|
134
|
+
);
|
|
135
|
+
onUIEvent("select");
|
|
136
|
+
} else if (param.fromAction === "unselect") {
|
|
137
|
+
comp.dispatch(
|
|
138
|
+
changeChildAction(
|
|
139
|
+
"selectedPoints",
|
|
140
|
+
getSelectedPoints(param, option),
|
|
141
|
+
false
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
onUIEvent("unselect");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
triggerClickEvent(
|
|
148
|
+
comp.dispatch,
|
|
149
|
+
changeChildAction(
|
|
150
|
+
"lastInteractionData",
|
|
151
|
+
getSelectedPoints(param, option),
|
|
152
|
+
false
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
});
|
|
156
|
+
// unbind
|
|
157
|
+
return () => {
|
|
158
|
+
eChartCompInstance?.off("selectchanged");
|
|
159
|
+
document.removeEventListener("clickEvent", clickEventCallback);
|
|
160
|
+
};
|
|
161
|
+
}, [onUIEvent]);
|
|
162
|
+
|
|
163
|
+
const eChartConfigChildren: any = {};
|
|
164
|
+
for (const [key, value] of Object.entries(comp.children)) {
|
|
165
|
+
if (!eChartConfigOmitChildren.includes(key as any)) {
|
|
166
|
+
eChartConfigChildren[key] = value;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const childrenProps = formatAllStyles(childrenToProps(comp.children));
|
|
171
|
+
|
|
172
|
+
const option = useMemo(() => {
|
|
173
|
+
return getEChartConfig(childrenProps, chartSize, themeConfig);
|
|
174
|
+
}, [themeConfig, childrenProps, chartSize]);
|
|
175
|
+
|
|
176
|
+
useResizeDetector({
|
|
177
|
+
targetRef: containerRef,
|
|
178
|
+
onResize: ({ width, height }) => {
|
|
179
|
+
if (width && height) {
|
|
180
|
+
setChartSize({ w: width, h: height });
|
|
181
|
+
}
|
|
182
|
+
if (!firstResize.current) {
|
|
183
|
+
// ignore the first resize, which will impact the loading animation
|
|
184
|
+
eChartCompRef.current?.getEchartsInstance().resize();
|
|
185
|
+
} else {
|
|
186
|
+
firstResize.current = false;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<div ref={containerRef} style={{ height: "100%" }}>
|
|
193
|
+
<ReactECharts
|
|
194
|
+
ref={(e) => (eChartCompRef.current = e)}
|
|
195
|
+
style={{ height: "100%" }}
|
|
196
|
+
notMerge
|
|
197
|
+
lazyUpdate
|
|
198
|
+
opts={{ locale: getEchartsLocale() }}
|
|
199
|
+
option={option}
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
function getYAxisFormatContextValue(
|
|
206
|
+
data: Array<JSONObject>,
|
|
207
|
+
yAxisType: EchartsAxisType,
|
|
208
|
+
yAxisName?: string
|
|
209
|
+
) {
|
|
210
|
+
const dataSample = yAxisName && data.length > 0 && data[0][yAxisName];
|
|
211
|
+
let contextValue = dataSample;
|
|
212
|
+
|
|
213
|
+
if (yAxisType === "time") {
|
|
214
|
+
// to timestamp
|
|
215
|
+
const time =
|
|
216
|
+
typeof dataSample === "number" || typeof dataSample === "string"
|
|
217
|
+
? new Date(dataSample).getTime()
|
|
218
|
+
: null;
|
|
219
|
+
if (time) contextValue = time;
|
|
220
|
+
}
|
|
221
|
+
return contextValue;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
TwoLineChartTmpComp = class extends TwoLineChartTmpComp {
|
|
225
|
+
updateContext(comp: any) {
|
|
226
|
+
// the context value of axis format
|
|
227
|
+
let resultComp = comp;
|
|
228
|
+
const data = comp.children.data.getView();
|
|
229
|
+
const sampleSeries = comp.children.series
|
|
230
|
+
.getView()
|
|
231
|
+
.find((s: any) => !s.getView().hide);
|
|
232
|
+
const yAxisContextValue = getYAxisFormatContextValue(
|
|
233
|
+
data,
|
|
234
|
+
comp.children.yConfig.children.yAxisType.getView(),
|
|
235
|
+
sampleSeries?.children.columnName.getView()
|
|
236
|
+
);
|
|
237
|
+
if (yAxisContextValue !== comp.lastYAxisFormatContextVal) {
|
|
238
|
+
comp.lastYAxisFormatContextVal = yAxisContextValue;
|
|
239
|
+
resultComp = comp.setChild(
|
|
240
|
+
"yConfig",
|
|
241
|
+
comp.children.yConfig.reduce(
|
|
242
|
+
wrapChildAction(
|
|
243
|
+
"formatter",
|
|
244
|
+
AxisFormatterComp.changeContextDataAction({
|
|
245
|
+
value: yAxisContextValue,
|
|
246
|
+
})
|
|
247
|
+
)
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
// item color context
|
|
252
|
+
const colorContextVal = {
|
|
253
|
+
seriesName: sampleSeries?.children.seriesName.getView(),
|
|
254
|
+
value: yAxisContextValue,
|
|
255
|
+
};
|
|
256
|
+
if (
|
|
257
|
+
comp.children.chartConfig.children.comp.children.hasOwnProperty(
|
|
258
|
+
"itemColor"
|
|
259
|
+
) &&
|
|
260
|
+
!deepEqual(colorContextVal, comp.lastColorContext)
|
|
261
|
+
) {
|
|
262
|
+
comp.lastColorContext = colorContextVal;
|
|
263
|
+
resultComp = resultComp.setChild(
|
|
264
|
+
"chartConfig",
|
|
265
|
+
comp.children.chartConfig.reduce(
|
|
266
|
+
wrapChildAction(
|
|
267
|
+
"comp",
|
|
268
|
+
wrapChildAction(
|
|
269
|
+
"itemColor",
|
|
270
|
+
ItemColorComp.changeContextDataAction(colorContextVal)
|
|
271
|
+
)
|
|
272
|
+
)
|
|
273
|
+
)
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return resultComp;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
reduce(action: CompAction): this {
|
|
280
|
+
const comp = super.reduce(action);
|
|
281
|
+
if (action.type === CompActionTypes.UPDATE_NODES_V2) {
|
|
282
|
+
const newData = comp.children.data.getView();
|
|
283
|
+
// data changes
|
|
284
|
+
if (comp.children.data !== this.children.data) {
|
|
285
|
+
setTimeout(() => {
|
|
286
|
+
// update x-axis value
|
|
287
|
+
const keys = getDataKeys({ data: newData, dataType: "string" });
|
|
288
|
+
if (
|
|
289
|
+
keys.length > 0 &&
|
|
290
|
+
!keys.includes(comp.children.xAxisKey.getView())
|
|
291
|
+
) {
|
|
292
|
+
comp.children.xAxisKey.dispatch(changeValueAction(keys[0] || ""));
|
|
293
|
+
}
|
|
294
|
+
// pass to child series comp
|
|
295
|
+
comp.children.series.dispatchDataChanged(newData);
|
|
296
|
+
}, 0);
|
|
297
|
+
}
|
|
298
|
+
return this.updateContext(comp);
|
|
299
|
+
}
|
|
300
|
+
return comp;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
autoHeight(): boolean {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
let TwoLineChartComp = withExposingConfigs(TwoLineChartTmpComp, [
|
|
309
|
+
depsConfig({
|
|
310
|
+
name: "selectedPoints",
|
|
311
|
+
desc: trans("chart.selectedPointsDesc"),
|
|
312
|
+
depKeys: ["selectedPoints"],
|
|
313
|
+
func: (input) => {
|
|
314
|
+
return input.selectedPoints;
|
|
315
|
+
},
|
|
316
|
+
}),
|
|
317
|
+
depsConfig({
|
|
318
|
+
name: "lastInteractionData",
|
|
319
|
+
desc: trans("chart.lastInteractionDataDesc"),
|
|
320
|
+
depKeys: ["lastInteractionData"],
|
|
321
|
+
func: (input) => {
|
|
322
|
+
return input.lastInteractionData;
|
|
323
|
+
},
|
|
324
|
+
}),
|
|
325
|
+
depsConfig({
|
|
326
|
+
name: "data",
|
|
327
|
+
desc: trans("chart.dataDesc"),
|
|
328
|
+
depKeys: ["data", "mode"],
|
|
329
|
+
func: (input) => [],
|
|
330
|
+
}),
|
|
331
|
+
new NameConfig("title", trans("chart.titleDesc")),
|
|
332
|
+
]);
|
|
333
|
+
|
|
334
|
+
export const TwoLineChartCompWithDefault = withDefault(TwoLineChartComp, {
|
|
335
|
+
xAxisKey: valueComp<string>("date"),
|
|
336
|
+
series: [
|
|
337
|
+
{
|
|
338
|
+
dataIndex: genRandomKey(),
|
|
339
|
+
seriesName: "LineA",
|
|
340
|
+
columnName: "lineA",
|
|
341
|
+
chartType: "line",
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
dataIndex: genRandomKey(),
|
|
345
|
+
seriesName: "LineB",
|
|
346
|
+
columnName: "lineB",
|
|
347
|
+
chartType: "line",
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createSeriesListComp } from "@/components/SeriesComp";
|
|
2
|
+
import { ChartOptionMap } from "@/controls";
|
|
3
|
+
import { trans } from "@/i18n/comps";
|
|
4
|
+
import {
|
|
5
|
+
EchartDefaultTextStyle,
|
|
6
|
+
jsonControl,
|
|
7
|
+
RecordConstructorToView,
|
|
8
|
+
StringControl,
|
|
9
|
+
styleControl,
|
|
10
|
+
toJSONObjectArray,
|
|
11
|
+
uiChildren,
|
|
12
|
+
withDefault,
|
|
13
|
+
withType,
|
|
14
|
+
} from "lowcoder-sdk";
|
|
15
|
+
|
|
16
|
+
const defaultChartData = [
|
|
17
|
+
{
|
|
18
|
+
date: "2025-09-01",
|
|
19
|
+
lineA: 120,
|
|
20
|
+
lineB: 95,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
date: "2025-09-02",
|
|
24
|
+
lineA: 132,
|
|
25
|
+
lineB: 100,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
date: "2025-09-03",
|
|
29
|
+
lineA: 101,
|
|
30
|
+
lineB: 110,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
date: "2025-09-04",
|
|
34
|
+
lineA: 134,
|
|
35
|
+
lineB: 105,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
date: "2025-09-05",
|
|
39
|
+
lineA: 90,
|
|
40
|
+
lineB: 120,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
date: "2025-09-06",
|
|
44
|
+
lineA: 230,
|
|
45
|
+
lineB: 150,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
date: "2025-09-07",
|
|
49
|
+
lineA: 210,
|
|
50
|
+
lineB: 180,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
export const chartUiProps = {
|
|
55
|
+
chartConfig: withType(ChartOptionMap, "line"),
|
|
56
|
+
chartType: withDefault(StringControl, "line"),
|
|
57
|
+
title: withDefault(StringControl, trans("twoLineChart.defaultTitle")),
|
|
58
|
+
defaultData: jsonControl(toJSONObjectArray, defaultChartData),
|
|
59
|
+
series: createSeriesListComp("line"),
|
|
60
|
+
xAxisStyle: styleControl(EchartDefaultTextStyle, "xAxis"),
|
|
61
|
+
yAxisStyle: styleControl(EchartDefaultTextStyle, "yAxisStyle"),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const chartUiChildrenMap = uiChildren(chartUiProps);
|
|
65
|
+
export type ChartUiPropsType = RecordConstructorToView<
|
|
66
|
+
typeof chartUiChildrenMap
|
|
67
|
+
>;
|
|
68
|
+
|
|
69
|
+
export type UIChartDataType = {
|
|
70
|
+
seriesName: string;
|
|
71
|
+
// coordinate chart
|
|
72
|
+
x?: any;
|
|
73
|
+
y?: any;
|
|
74
|
+
// pie or funnel
|
|
75
|
+
itemName?: any;
|
|
76
|
+
value?: any;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type NonUIChartDataType = {
|
|
80
|
+
name: string;
|
|
81
|
+
value: any;
|
|
82
|
+
};
|