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,429 @@
|
|
|
1
|
+
import { ChartPropertyView } from "@/components/ChartPropertyView";
|
|
2
|
+
import { EchartsAxisType } from "@/configs/cartesianAxisConfig";
|
|
3
|
+
import { AxisFormatterComp } from "@/controls";
|
|
4
|
+
import { trans } from "@/i18n/comps";
|
|
5
|
+
import { formatAllStyles } from "@/utils/chartStyle.util";
|
|
6
|
+
import { deepEqual } from "@/utils/deepEqual.util";
|
|
7
|
+
import { echartProps } from "@/utils/echarts.util";
|
|
8
|
+
import { Flex, Table, Typography } from "antd";
|
|
9
|
+
import { ColumnsType } from "antd/es/table";
|
|
10
|
+
import ReactECharts from "echarts-for-react";
|
|
11
|
+
import EChartsReactCore from "echarts-for-react/lib/core";
|
|
12
|
+
import {
|
|
13
|
+
changeChildAction,
|
|
14
|
+
childrenToProps,
|
|
15
|
+
CompAction,
|
|
16
|
+
depsConfig,
|
|
17
|
+
getPromiseAfterDispatch,
|
|
18
|
+
JSONObject,
|
|
19
|
+
NameConfig,
|
|
20
|
+
UICompBuilder,
|
|
21
|
+
valueComp,
|
|
22
|
+
withDefault,
|
|
23
|
+
withExposingConfigs,
|
|
24
|
+
withViewFn,
|
|
25
|
+
wrapChildAction,
|
|
26
|
+
} from "lowcoder-sdk";
|
|
27
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
28
|
+
import { chartUiProps } from "./constants";
|
|
29
|
+
|
|
30
|
+
const { Text } = Typography;
|
|
31
|
+
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// SPARKLINE CHART COMPONENT
|
|
34
|
+
// ============================================================================
|
|
35
|
+
|
|
36
|
+
const SparklineChart = React.memo(
|
|
37
|
+
({ data, chartStyle }: { data: number[]; chartStyle: any }) => {
|
|
38
|
+
const { shadowColor, fontSize, fontWeight, color } = chartStyle;
|
|
39
|
+
|
|
40
|
+
const chartOption = useMemo(
|
|
41
|
+
() => ({
|
|
42
|
+
xAxis: { type: "category", show: false },
|
|
43
|
+
yAxis: {
|
|
44
|
+
type: "value",
|
|
45
|
+
position: "right",
|
|
46
|
+
interval: Number.MAX_SAFE_INTEGER,
|
|
47
|
+
splitLine: {
|
|
48
|
+
lineStyle: {
|
|
49
|
+
color: shadowColor || "#e0e0e0",
|
|
50
|
+
type: "dashed",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
axisLine: { show: false },
|
|
54
|
+
axisTick: { show: false },
|
|
55
|
+
min: 0,
|
|
56
|
+
axisLabel: {
|
|
57
|
+
showMaxLabel: true,
|
|
58
|
+
fontSize: fontSize || 9,
|
|
59
|
+
formatter: (v: number) =>
|
|
60
|
+
(v >= 1000000 && `${(v / 1000000)?.toFixed(2)}M`) ||
|
|
61
|
+
(v >= 1000 && `${(v / 1000)?.toFixed(0)}k`) ||
|
|
62
|
+
v,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
grid: { left: 0, right: 0, top: 0, bottom: 0 },
|
|
66
|
+
tooltip: { trigger: "axis" },
|
|
67
|
+
series: [
|
|
68
|
+
{
|
|
69
|
+
data,
|
|
70
|
+
type: "line",
|
|
71
|
+
smooth: true,
|
|
72
|
+
lineStyle: {
|
|
73
|
+
width: fontWeight || 2,
|
|
74
|
+
color,
|
|
75
|
+
},
|
|
76
|
+
showSymbol: false,
|
|
77
|
+
areaStyle: {
|
|
78
|
+
opacity: 0.1,
|
|
79
|
+
color,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
}),
|
|
84
|
+
[data, shadowColor, fontSize, fontWeight, color]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<ReactECharts
|
|
89
|
+
option={chartOption}
|
|
90
|
+
style={{ height: 50, width: "100%" }}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
SparklineChart.displayName = "SparklineChart";
|
|
97
|
+
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// TABLE COLUMNS GENERATOR
|
|
100
|
+
// ============================================================================
|
|
101
|
+
|
|
102
|
+
const getColumns = (
|
|
103
|
+
data: any[],
|
|
104
|
+
columnConfigs: any[],
|
|
105
|
+
chartStyle: any
|
|
106
|
+
): ColumnsType<any> => {
|
|
107
|
+
if (!data?.length || !columnConfigs?.length) return [];
|
|
108
|
+
|
|
109
|
+
return columnConfigs
|
|
110
|
+
.filter(({ visible }) => visible !== false)
|
|
111
|
+
.map((config) => {
|
|
112
|
+
const {
|
|
113
|
+
title,
|
|
114
|
+
dataIndex,
|
|
115
|
+
key,
|
|
116
|
+
width,
|
|
117
|
+
styles,
|
|
118
|
+
fixed,
|
|
119
|
+
align,
|
|
120
|
+
sortable,
|
|
121
|
+
defaultSortOrder,
|
|
122
|
+
} = config;
|
|
123
|
+
|
|
124
|
+
const sortComparator = sortable
|
|
125
|
+
? (a: any, b: any) => {
|
|
126
|
+
const aVal = a[dataIndex];
|
|
127
|
+
const bVal = b[dataIndex];
|
|
128
|
+
|
|
129
|
+
if (typeof aVal === "number" && typeof bVal === "number") {
|
|
130
|
+
return aVal - bVal;
|
|
131
|
+
}
|
|
132
|
+
if (aVal == null) return -1;
|
|
133
|
+
if (bVal == null) return 1;
|
|
134
|
+
|
|
135
|
+
return String(aVal).localeCompare(String(bVal));
|
|
136
|
+
}
|
|
137
|
+
: false;
|
|
138
|
+
|
|
139
|
+
const renderCell = (val: any) => {
|
|
140
|
+
if (typeof val === "number") {
|
|
141
|
+
return <Text style={styles}>{val.toLocaleString()}</Text>;
|
|
142
|
+
}
|
|
143
|
+
if (Array.isArray(val) && dataIndex === "sparkline") {
|
|
144
|
+
return <SparklineChart data={val} chartStyle={chartStyle} />;
|
|
145
|
+
}
|
|
146
|
+
return <Text style={styles}>{val}</Text>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const column: any = {
|
|
150
|
+
title: title || dataIndex,
|
|
151
|
+
dataIndex,
|
|
152
|
+
key,
|
|
153
|
+
width,
|
|
154
|
+
align,
|
|
155
|
+
fixed: fixed !== "none" ? fixed : false,
|
|
156
|
+
sorter: sortComparator,
|
|
157
|
+
defaultSortOrder:
|
|
158
|
+
defaultSortOrder !== "none" ? defaultSortOrder : undefined,
|
|
159
|
+
render: renderCell,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
if (styles) {
|
|
163
|
+
column.onCell = () => ({ style: styles });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return column;
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// ============================================================================
|
|
171
|
+
// HELPER FUNCTIONS
|
|
172
|
+
// ============================================================================
|
|
173
|
+
|
|
174
|
+
const getYAxisFormatContextValue = (
|
|
175
|
+
data: Array<JSONObject>,
|
|
176
|
+
yAxisType: EchartsAxisType,
|
|
177
|
+
yAxisName?: string
|
|
178
|
+
): any => {
|
|
179
|
+
const dataSample = yAxisName && data.length > 0 && data[0][yAxisName];
|
|
180
|
+
|
|
181
|
+
if (yAxisType === "time") {
|
|
182
|
+
const time =
|
|
183
|
+
typeof dataSample === "number" || typeof dataSample === "string"
|
|
184
|
+
? new Date(dataSample).getTime()
|
|
185
|
+
: null;
|
|
186
|
+
return time || dataSample;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return dataSample;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// TABLE CHART COMPONENT BUILDER
|
|
194
|
+
// ============================================================================
|
|
195
|
+
|
|
196
|
+
let TablechartsTmpComp = new UICompBuilder(
|
|
197
|
+
{
|
|
198
|
+
...echartProps,
|
|
199
|
+
...chartUiProps,
|
|
200
|
+
},
|
|
201
|
+
() => null
|
|
202
|
+
)
|
|
203
|
+
.setPropertyViewFn(ChartPropertyView)
|
|
204
|
+
.build();
|
|
205
|
+
|
|
206
|
+
// ============================================================================
|
|
207
|
+
// VIEW FUNCTION WITH EVENT HANDLERS
|
|
208
|
+
// ============================================================================
|
|
209
|
+
|
|
210
|
+
TablechartsTmpComp = withViewFn(TablechartsTmpComp, (comp) => {
|
|
211
|
+
const eChartCompRef = useRef<EChartsReactCore | null>();
|
|
212
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
213
|
+
|
|
214
|
+
// Extract props
|
|
215
|
+
const {
|
|
216
|
+
columns: defaultColumns,
|
|
217
|
+
chartConfig,
|
|
218
|
+
onEvent,
|
|
219
|
+
data,
|
|
220
|
+
} = childrenToProps(comp.children);
|
|
221
|
+
|
|
222
|
+
// Format styles
|
|
223
|
+
const chartConfigView = formatAllStyles(chartConfig);
|
|
224
|
+
const { headerStyle, rowStyle, chartStyle } = chartConfigView;
|
|
225
|
+
|
|
226
|
+
// Get column config
|
|
227
|
+
const columnConfig = useMemo(
|
|
228
|
+
() => defaultColumns.map((col: any) => col.getView()),
|
|
229
|
+
[defaultColumns]
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
// Memoized columns
|
|
233
|
+
const columns = useMemo(
|
|
234
|
+
() => getColumns(data, columnConfig, chartStyle),
|
|
235
|
+
[data, columnConfig, chartStyle]
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
// ========================================================================
|
|
239
|
+
// EVENT HANDLERS
|
|
240
|
+
// ========================================================================
|
|
241
|
+
|
|
242
|
+
const triggerClickEvent = useCallback(
|
|
243
|
+
async (dispatch: any, action: CompAction) => {
|
|
244
|
+
await getPromiseAfterDispatch(dispatch, action, {
|
|
245
|
+
autoHandleAfterReduce: true,
|
|
246
|
+
});
|
|
247
|
+
onEvent("click");
|
|
248
|
+
},
|
|
249
|
+
[onEvent]
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
// Handle chart click events
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
const eChartInstance = eChartCompRef.current?.getEchartsInstance();
|
|
255
|
+
if (!eChartInstance) return;
|
|
256
|
+
|
|
257
|
+
const handleClick = (param: any) => {
|
|
258
|
+
const clickData = param.data;
|
|
259
|
+
|
|
260
|
+
// Dispatch custom event
|
|
261
|
+
document.dispatchEvent(
|
|
262
|
+
new CustomEvent("clickEvent", {
|
|
263
|
+
bubbles: true,
|
|
264
|
+
detail: {
|
|
265
|
+
action: "click",
|
|
266
|
+
data: clickData,
|
|
267
|
+
},
|
|
268
|
+
})
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
// Trigger click event handler
|
|
272
|
+
triggerClickEvent(
|
|
273
|
+
comp.dispatch,
|
|
274
|
+
changeChildAction("lastInteractionData", clickData, false)
|
|
275
|
+
);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
eChartInstance.on("click", handleClick);
|
|
279
|
+
|
|
280
|
+
return () => {
|
|
281
|
+
eChartInstance.off("click", handleClick);
|
|
282
|
+
};
|
|
283
|
+
}, [comp.dispatch, triggerClickEvent]);
|
|
284
|
+
|
|
285
|
+
// ========================================================================
|
|
286
|
+
// RENDER
|
|
287
|
+
// ========================================================================
|
|
288
|
+
|
|
289
|
+
if (!columnConfig.length) {
|
|
290
|
+
return (
|
|
291
|
+
<Flex vertical align="center" justify="center" style={{ height: "100%" }}>
|
|
292
|
+
<h3>{trans("chart.loadingTable")}</h3>
|
|
293
|
+
</Flex>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<div ref={containerRef} style={{ height: "100%" }}>
|
|
299
|
+
<Table
|
|
300
|
+
size="small"
|
|
301
|
+
loading={!data}
|
|
302
|
+
columns={columns}
|
|
303
|
+
dataSource={data}
|
|
304
|
+
pagination={false}
|
|
305
|
+
rowKey="key"
|
|
306
|
+
bordered={false}
|
|
307
|
+
sticky={false}
|
|
308
|
+
scroll={{ x: "max-content" }}
|
|
309
|
+
style={{ background: "transparent" }}
|
|
310
|
+
components={{
|
|
311
|
+
header: {
|
|
312
|
+
cell: (props: any) => (
|
|
313
|
+
<th
|
|
314
|
+
{...props}
|
|
315
|
+
style={{
|
|
316
|
+
...props.style,
|
|
317
|
+
...headerStyle,
|
|
318
|
+
}}
|
|
319
|
+
/>
|
|
320
|
+
),
|
|
321
|
+
},
|
|
322
|
+
}}
|
|
323
|
+
onRow={() => ({
|
|
324
|
+
style: rowStyle,
|
|
325
|
+
})}
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// ============================================================================
|
|
332
|
+
// CONTEXT UPDATE LOGIC
|
|
333
|
+
// ============================================================================
|
|
334
|
+
|
|
335
|
+
TablechartsTmpComp = class extends TablechartsTmpComp {
|
|
336
|
+
private lastYAxisFormatContextVal: any = null;
|
|
337
|
+
private lastColorContext: any = null;
|
|
338
|
+
|
|
339
|
+
updateContext(comp: any): any {
|
|
340
|
+
let resultComp = comp;
|
|
341
|
+
|
|
342
|
+
// Get data and sample series
|
|
343
|
+
const data = comp.children.data.getView();
|
|
344
|
+
const sampleSeries = comp.children.series
|
|
345
|
+
.getView()
|
|
346
|
+
.find((s: any) => !s.getView().hide);
|
|
347
|
+
|
|
348
|
+
// Update Y-Axis context
|
|
349
|
+
const yAxisContextValue = getYAxisFormatContextValue(
|
|
350
|
+
data,
|
|
351
|
+
comp.children.yConfig.children.yAxisType.getView(),
|
|
352
|
+
sampleSeries?.children.columnName.getView()
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
if (yAxisContextValue !== this.lastYAxisFormatContextVal) {
|
|
356
|
+
this.lastYAxisFormatContextVal = yAxisContextValue;
|
|
357
|
+
resultComp = comp.setChild(
|
|
358
|
+
"yConfig",
|
|
359
|
+
comp.children.yConfig.reduce(
|
|
360
|
+
wrapChildAction(
|
|
361
|
+
"formatter",
|
|
362
|
+
AxisFormatterComp.changeContextDataAction({
|
|
363
|
+
value: yAxisContextValue,
|
|
364
|
+
})
|
|
365
|
+
)
|
|
366
|
+
)
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Update color context
|
|
371
|
+
const colorContextVal = {
|
|
372
|
+
seriesName: sampleSeries?.children.seriesName.getView(),
|
|
373
|
+
value: yAxisContextValue,
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
if (
|
|
377
|
+
comp.children.chartConfig.children.comp.children.hasOwnProperty(
|
|
378
|
+
"itemColor"
|
|
379
|
+
) &&
|
|
380
|
+
!deepEqual(colorContextVal, this.lastColorContext)
|
|
381
|
+
) {
|
|
382
|
+
this.lastColorContext = colorContextVal;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return resultComp;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
reduce(action: CompAction): this {
|
|
389
|
+
return super.reduce(action);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
autoHeight(): boolean {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
// ============================================================================
|
|
398
|
+
// EXPOSED CONFIGS
|
|
399
|
+
// ============================================================================
|
|
400
|
+
|
|
401
|
+
let TablechartComp = withExposingConfigs(TablechartsTmpComp, [
|
|
402
|
+
depsConfig({
|
|
403
|
+
name: "selectedPoints",
|
|
404
|
+
desc: trans("chart.selectedPointsDesc"),
|
|
405
|
+
depKeys: ["selectedPoints"],
|
|
406
|
+
func: (input) => input.selectedPoints,
|
|
407
|
+
}),
|
|
408
|
+
depsConfig({
|
|
409
|
+
name: "lastInteractionData",
|
|
410
|
+
desc: trans("chart.lastInteractionDataDesc"),
|
|
411
|
+
depKeys: ["lastInteractionData"],
|
|
412
|
+
func: (input) => input.lastInteractionData,
|
|
413
|
+
}),
|
|
414
|
+
depsConfig({
|
|
415
|
+
name: "data",
|
|
416
|
+
desc: trans("chart.dataDesc"),
|
|
417
|
+
depKeys: ["data", "mode"],
|
|
418
|
+
func: () => [],
|
|
419
|
+
}),
|
|
420
|
+
new NameConfig("title", trans("chart.titleDesc")),
|
|
421
|
+
]);
|
|
422
|
+
|
|
423
|
+
// ============================================================================
|
|
424
|
+
// EXPORT WITH DEFAULT CONFIG
|
|
425
|
+
// ============================================================================
|
|
426
|
+
|
|
427
|
+
export const TablechartCompWithDefault = withDefault(TablechartComp, {
|
|
428
|
+
xAxisKey: valueComp<string>("value"),
|
|
429
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createSeriesListComp } from "@/components/SeriesComp";
|
|
2
|
+
import { ChartOptionMap, ColumnConfigComp } from "@/controls";
|
|
3
|
+
import { trans } from "@/i18n/comps";
|
|
4
|
+
import {
|
|
5
|
+
jsonControl,
|
|
6
|
+
list,
|
|
7
|
+
RecordConstructorToView,
|
|
8
|
+
StringControl,
|
|
9
|
+
toJSONObjectArray,
|
|
10
|
+
uiChildren,
|
|
11
|
+
withDefault,
|
|
12
|
+
withType,
|
|
13
|
+
} from "lowcoder-sdk";
|
|
14
|
+
|
|
15
|
+
const defaultChartData = [
|
|
16
|
+
{
|
|
17
|
+
key: "fl",
|
|
18
|
+
metric: "Florida",
|
|
19
|
+
newCases: 12624,
|
|
20
|
+
wow: -18.04,
|
|
21
|
+
mom: 255.54,
|
|
22
|
+
contribution: 18.29,
|
|
23
|
+
sparkline: [
|
|
24
|
+
8500, 7900, 8200, 7600, 8100, 8800, 9200, 9700, 10300, 9500, 8700, 9100,
|
|
25
|
+
8900, 9400, 10000, 10500, 9800, 9200, 8600, 8300, 8800, 9100, 9400, 9900,
|
|
26
|
+
10200, 10800, 11300, 11800, 12300, 12900,
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: "ca",
|
|
31
|
+
metric: "California",
|
|
32
|
+
newCases: 8814,
|
|
33
|
+
wow: 24.39,
|
|
34
|
+
mom: 251.99,
|
|
35
|
+
contribution: 19.38,
|
|
36
|
+
sparkline: [
|
|
37
|
+
6000, 6400, 6700, 7000, 7200, 7500, 7800, 8000, 8500, 8700, 8900, 9100,
|
|
38
|
+
9400, 9700, 10000, 10300, 10600, 10900, 11200, 11500, 11800, 12100, 12400,
|
|
39
|
+
12700, 13000, 13400, 13700, 14000, 14400, 14800,
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: "tx",
|
|
44
|
+
metric: "Texas",
|
|
45
|
+
newCases: 7016,
|
|
46
|
+
wow: 21.52,
|
|
47
|
+
mom: 203.63,
|
|
48
|
+
contribution: 15.07,
|
|
49
|
+
sparkline: [
|
|
50
|
+
4900, 5200, 5400, 5700, 6000, 6300, 6600, 6900, 7100, 7400, 7700, 8000,
|
|
51
|
+
8200, 8500, 8700, 9000, 9300, 9600, 9900, 10200, 10500, 10900, 11200,
|
|
52
|
+
11500, 11800, 12200, 12600, 13000, 13400, 13800,
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: "ga",
|
|
57
|
+
metric: "Georgia",
|
|
58
|
+
newCases: 3637,
|
|
59
|
+
wow: -32.55,
|
|
60
|
+
mom: 136.28,
|
|
61
|
+
contribution: 4.34,
|
|
62
|
+
sparkline: [
|
|
63
|
+
2800, 3000, 3100, 2900, 3200, 3300, 3400, 3500, 3400, 3600, 3700, 3800,
|
|
64
|
+
3900, 4000, 4100, 3900, 3700, 3600, 3500, 3400, 3300, 3200, 3100, 3000,
|
|
65
|
+
2900, 2800, 2700, 2600, 2500, 2400,
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
export const chartUiProps = {
|
|
71
|
+
chartConfig: withType(ChartOptionMap, "table"),
|
|
72
|
+
chartType: withDefault(StringControl, "table"),
|
|
73
|
+
title: withDefault(StringControl, trans("tableChart.defaultTitle")),
|
|
74
|
+
defaultData: jsonControl(toJSONObjectArray, defaultChartData),
|
|
75
|
+
series: createSeriesListComp(),
|
|
76
|
+
columns: list(ColumnConfigComp),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const chartUiChildrenMap = uiChildren(chartUiProps);
|
|
80
|
+
export type ChartUiPropsType = RecordConstructorToView<
|
|
81
|
+
typeof chartUiChildrenMap
|
|
82
|
+
>;
|
|
83
|
+
|
|
84
|
+
export type UIChartDataType = {
|
|
85
|
+
seriesName: string;
|
|
86
|
+
// coordinate chart
|
|
87
|
+
x?: any;
|
|
88
|
+
y?: any;
|
|
89
|
+
// pie or funnel
|
|
90
|
+
itemName?: any;
|
|
91
|
+
value?: any;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type NonUIChartDataType = {
|
|
95
|
+
name: string;
|
|
96
|
+
value: any;
|
|
97
|
+
};
|