lowcoder-comps 0.0.6 → 0.0.7
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/package.json +13 -2
- package/icons/icon-chart.svg +0 -15
- package/icons/icon-comp-calendar.svg +0 -22
- package/index.html +0 -26
- package/index.tsx +0 -19
- package/jest.config.js +0 -5
- package/src/__test__/allComp.test.tsx +0 -61
- package/src/app-env.d.ts +0 -3
- package/src/comps/calendarComp/calendarComp.tsx +0 -442
- package/src/comps/calendarComp/calendarConstants.tsx +0 -897
- package/src/comps/chartComp/chartComp.tsx +0 -249
- package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +0 -51
- package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +0 -307
- package/src/comps/chartComp/chartConfigs/chartUrls.tsx +0 -6
- package/src/comps/chartComp/chartConfigs/legendConfig.tsx +0 -55
- package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +0 -96
- package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +0 -83
- package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +0 -62
- package/src/comps/chartComp/chartConstants.tsx +0 -243
- package/src/comps/chartComp/chartPropertyView.tsx +0 -161
- package/src/comps/chartComp/chartUtils.ts +0 -240
- package/src/comps/chartComp/reactEcharts/core.tsx +0 -187
- package/src/comps/chartComp/reactEcharts/index.ts +0 -20
- package/src/comps/chartComp/reactEcharts/types.ts +0 -70
- package/src/comps/chartComp/seriesComp.tsx +0 -119
- package/src/comps/imageEditorComp/imageEditorClass.tsx +0 -52
- package/src/comps/imageEditorComp/imageEditorConstants.tsx +0 -109
- package/src/comps/imageEditorComp/index.tsx +0 -184
- package/src/comps/mermaidComp/index.tsx +0 -44
- package/src/comps/mermaidComp/mermaid.tsx +0 -29
- package/src/global.ts +0 -1
- package/src/i18n/comps/index.tsx +0 -29
- package/src/i18n/comps/locales/en.ts +0 -142
- package/src/i18n/comps/locales/enObj.tsx +0 -120
- package/src/i18n/comps/locales/index.ts +0 -7
- package/src/i18n/comps/locales/types.tsx +0 -9
- package/src/i18n/comps/locales/zh.ts +0 -4
- package/src/i18n/comps/locales/zhObj.tsx +0 -4
- package/src/index.ts +0 -9
- package/vite.config.js +0 -10
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { LineSeriesOption } from "echarts";
|
|
2
|
-
import {
|
|
3
|
-
MultiCompBuilder,
|
|
4
|
-
BoolControl,
|
|
5
|
-
dropdownControl,
|
|
6
|
-
showLabelPropertyView,
|
|
7
|
-
withContext,
|
|
8
|
-
StringControl,
|
|
9
|
-
ColorOrBoolCodeControl,
|
|
10
|
-
} from "lowcoder-sdk";
|
|
11
|
-
import { trans } from "i18n/comps";
|
|
12
|
-
|
|
13
|
-
const BarTypeOptions = [
|
|
14
|
-
{
|
|
15
|
-
label: trans("chart.basicLine"),
|
|
16
|
-
value: "basicLine",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
label: trans("chart.stackedLine"),
|
|
20
|
-
value: "stackedLine",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
label: trans("chart.areaLine"),
|
|
24
|
-
value: "areaLine",
|
|
25
|
-
},
|
|
26
|
-
] as const;
|
|
27
|
-
|
|
28
|
-
export const ItemColorComp = withContext(
|
|
29
|
-
new MultiCompBuilder({ value: ColorOrBoolCodeControl }, (props) => props.value)
|
|
30
|
-
.setPropertyViewFn((children) =>
|
|
31
|
-
children.value.propertyView({
|
|
32
|
-
label: trans("chart.pointColorLabel"),
|
|
33
|
-
placeholder: "{{value < 25000}}",
|
|
34
|
-
tooltip: trans("chart.pointColorTooltip"),
|
|
35
|
-
})
|
|
36
|
-
)
|
|
37
|
-
.build(),
|
|
38
|
-
["seriesName", "value"] as const
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
export const LineChartConfig = (function () {
|
|
42
|
-
return new MultiCompBuilder(
|
|
43
|
-
{
|
|
44
|
-
showLabel: BoolControl,
|
|
45
|
-
type: dropdownControl(BarTypeOptions, "basicLine"),
|
|
46
|
-
smooth: BoolControl,
|
|
47
|
-
itemColor: ItemColorComp,
|
|
48
|
-
},
|
|
49
|
-
(props): LineSeriesOption => {
|
|
50
|
-
const config: LineSeriesOption = {
|
|
51
|
-
type: "line",
|
|
52
|
-
label: {
|
|
53
|
-
show: props.showLabel,
|
|
54
|
-
},
|
|
55
|
-
itemStyle: {
|
|
56
|
-
color: (params) => {
|
|
57
|
-
if (!params.encode || !params.dimensionNames) {
|
|
58
|
-
return params.color;
|
|
59
|
-
}
|
|
60
|
-
const dataKey = params.dimensionNames[params.encode["y"][0]];
|
|
61
|
-
const color = (props.itemColor as any)({
|
|
62
|
-
seriesName: params.seriesName,
|
|
63
|
-
value: (params.data as any)[dataKey],
|
|
64
|
-
});
|
|
65
|
-
if (color === "true") {
|
|
66
|
-
return "red";
|
|
67
|
-
} else if (color === "false" || !color) {
|
|
68
|
-
return params.color;
|
|
69
|
-
}
|
|
70
|
-
return color;
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
if (props.type === "stackedLine") {
|
|
75
|
-
config.stack = "stackValue";
|
|
76
|
-
} else if (props.type === "areaLine") {
|
|
77
|
-
config.areaStyle = {};
|
|
78
|
-
}
|
|
79
|
-
if (props.smooth) {
|
|
80
|
-
config.smooth = true;
|
|
81
|
-
}
|
|
82
|
-
return config;
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
.setPropertyViewFn((children) => (
|
|
86
|
-
<>
|
|
87
|
-
{children.type.propertyView({
|
|
88
|
-
label: trans("chart.lineType"),
|
|
89
|
-
})}
|
|
90
|
-
{showLabelPropertyView(children)}
|
|
91
|
-
{children.smooth.propertyView({ label: trans("chart.smooth") })}
|
|
92
|
-
{children.itemColor.getPropertyView()}
|
|
93
|
-
</>
|
|
94
|
-
))
|
|
95
|
-
.build();
|
|
96
|
-
})();
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { MultiCompBuilder } from "lowcoder-sdk";
|
|
2
|
-
import { PieSeriesOption } from "echarts";
|
|
3
|
-
import { dropdownControl } from "lowcoder-sdk";
|
|
4
|
-
import { ConstructorToView } from "lowcoder-core";
|
|
5
|
-
import { trans } from "i18n/comps";
|
|
6
|
-
|
|
7
|
-
const BarTypeOptions = [
|
|
8
|
-
{
|
|
9
|
-
label: trans("chart.basicPie"),
|
|
10
|
-
value: "basicPie",
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
label: trans("chart.doughnutPie"),
|
|
14
|
-
value: "doughnutPie",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
label: trans("chart.rosePie"),
|
|
18
|
-
value: "rosePie",
|
|
19
|
-
},
|
|
20
|
-
] as const;
|
|
21
|
-
|
|
22
|
-
// radius percent for each pie chart when one line has [1, 2, 3] pie charts
|
|
23
|
-
const pieRadiusConfig = [65, 35, 20];
|
|
24
|
-
|
|
25
|
-
type PieConfigViewType = ConstructorToView<typeof PieChartConfig>;
|
|
26
|
-
|
|
27
|
-
export const PieChartConfig = (function () {
|
|
28
|
-
return new MultiCompBuilder(
|
|
29
|
-
{
|
|
30
|
-
type: dropdownControl(BarTypeOptions, "basicPie"),
|
|
31
|
-
},
|
|
32
|
-
(props): PieSeriesOption => {
|
|
33
|
-
const config: PieSeriesOption = {
|
|
34
|
-
type: "pie",
|
|
35
|
-
label: {
|
|
36
|
-
show: true,
|
|
37
|
-
formatter: "{d}%",
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
if (props.type === "rosePie") {
|
|
41
|
-
config.roseType = "area";
|
|
42
|
-
} else if (props.type === "doughnutPie") {
|
|
43
|
-
config.radius = ["40%", "60%"];
|
|
44
|
-
}
|
|
45
|
-
return config;
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
.setPropertyViewFn((children) => (
|
|
49
|
-
<>
|
|
50
|
-
{children.type.propertyView({
|
|
51
|
-
label: trans("chart.pieType"),
|
|
52
|
-
})}
|
|
53
|
-
</>
|
|
54
|
-
))
|
|
55
|
-
.build();
|
|
56
|
-
})();
|
|
57
|
-
|
|
58
|
-
export function getPieRadiusAndCenter(
|
|
59
|
-
seriesLength: number,
|
|
60
|
-
pieIndex: number,
|
|
61
|
-
pieConfig: PieConfigViewType
|
|
62
|
-
) {
|
|
63
|
-
const columnPieNum = Math.min(seriesLength, pieRadiusConfig.length);
|
|
64
|
-
const radiusNumber = pieRadiusConfig[columnPieNum - 1];
|
|
65
|
-
const isDoughnutPie = Array.isArray(pieConfig.radius);
|
|
66
|
-
const radius = isDoughnutPie
|
|
67
|
-
? [(radiusNumber / 1.6).toFixed(2) + "%", radiusNumber + "%"]
|
|
68
|
-
: radiusNumber + "%";
|
|
69
|
-
|
|
70
|
-
/*** calculate center coordinates ***/
|
|
71
|
-
const pieDiameter = 100 / columnPieNum;
|
|
72
|
-
const xPosition = (pieDiameter * (pieIndex % columnPieNum) + pieDiameter / 2).toFixed(2) + "%";
|
|
73
|
-
const rowIndex = Math.floor(pieIndex / columnPieNum) + 1;
|
|
74
|
-
const yPosition =
|
|
75
|
-
((100 / Math.floor((columnPieNum * 2 + seriesLength - 1) / columnPieNum)) * rowIndex).toFixed(
|
|
76
|
-
2
|
|
77
|
-
) + "%";
|
|
78
|
-
// log.log("Echarts height: index:", pieConfig, radius, pieIndex, xPosition, yPosition);
|
|
79
|
-
return {
|
|
80
|
-
radius: radius,
|
|
81
|
-
center: [xPosition, yPosition],
|
|
82
|
-
} as const;
|
|
83
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MultiCompBuilder,
|
|
3
|
-
dropdownControl,
|
|
4
|
-
BoolControl,
|
|
5
|
-
showLabelPropertyView,
|
|
6
|
-
} from "lowcoder-sdk";
|
|
7
|
-
import { ScatterSeriesOption } from "echarts";
|
|
8
|
-
import { trans } from "i18n/comps";
|
|
9
|
-
|
|
10
|
-
const ScatterShapeOptions = [
|
|
11
|
-
{
|
|
12
|
-
label: trans("chart.circle"),
|
|
13
|
-
value: "circle",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
label: trans("chart.rect"),
|
|
17
|
-
value: "rect",
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
label: trans("chart.triangle"),
|
|
21
|
-
value: "triangle",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
label: trans("chart.diamond"),
|
|
25
|
-
value: "diamond",
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
label: trans("chart.pin"),
|
|
29
|
-
value: "pin",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
label: trans("chart.arrow"),
|
|
33
|
-
value: "arrow",
|
|
34
|
-
},
|
|
35
|
-
] as const;
|
|
36
|
-
|
|
37
|
-
export const ScatterChartConfig = (function () {
|
|
38
|
-
return new MultiCompBuilder(
|
|
39
|
-
{
|
|
40
|
-
showLabel: BoolControl,
|
|
41
|
-
shape: dropdownControl(ScatterShapeOptions, "circle"),
|
|
42
|
-
},
|
|
43
|
-
(props): ScatterSeriesOption => {
|
|
44
|
-
return {
|
|
45
|
-
type: "scatter",
|
|
46
|
-
symbol: props.shape,
|
|
47
|
-
label: {
|
|
48
|
-
show: props.showLabel,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
.setPropertyViewFn((children) => (
|
|
54
|
-
<>
|
|
55
|
-
{showLabelPropertyView(children)}
|
|
56
|
-
{children.shape.propertyView({
|
|
57
|
-
label: trans("chart.scatterShape"),
|
|
58
|
-
})}
|
|
59
|
-
</>
|
|
60
|
-
))
|
|
61
|
-
.build();
|
|
62
|
-
})();
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { jsonControl, JSONObject, stateComp, toJSONObjectArray, toObject } from "lowcoder-sdk";
|
|
2
|
-
import { StringControl } from "lowcoder-sdk";
|
|
3
|
-
import { dropdownControl } from "lowcoder-sdk";
|
|
4
|
-
import { eventHandlerControl } from "lowcoder-sdk";
|
|
5
|
-
import { valueComp, withType } from "lowcoder-sdk";
|
|
6
|
-
import { ValueFromOption } from "lowcoder-sdk";
|
|
7
|
-
import { uiChildren } from "lowcoder-sdk";
|
|
8
|
-
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
|
|
9
|
-
import { BarChartConfig } from "./chartConfigs/barChartConfig";
|
|
10
|
-
import { XAxisConfig, YAxisConfig } from "./chartConfigs/cartesianAxisConfig";
|
|
11
|
-
import { LegendConfig } from "./chartConfigs/legendConfig";
|
|
12
|
-
import { LineChartConfig } from "./chartConfigs/lineChartConfig";
|
|
13
|
-
import { PieChartConfig } from "./chartConfigs/pieChartConfig";
|
|
14
|
-
import { ScatterChartConfig } from "./chartConfigs/scatterChartConfig";
|
|
15
|
-
import { SeriesListComp } from "./seriesComp";
|
|
16
|
-
import { EChartsOption } from "echarts";
|
|
17
|
-
import { i18nObjs, trans } from "i18n/comps";
|
|
18
|
-
import { JSONValue } from "lowcoder";
|
|
19
|
-
|
|
20
|
-
export const ChartTypeOptions = [
|
|
21
|
-
{
|
|
22
|
-
label: trans("chart.bar"),
|
|
23
|
-
value: "bar",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
label: trans("chart.line"),
|
|
27
|
-
value: "line",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
label: trans("chart.scatter"),
|
|
31
|
-
value: "scatter",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
label: trans("chart.pie"),
|
|
35
|
-
value: "pie",
|
|
36
|
-
},
|
|
37
|
-
] as const;
|
|
38
|
-
|
|
39
|
-
const chartModeOptions = [
|
|
40
|
-
{
|
|
41
|
-
label: trans("chart.UIMode"),
|
|
42
|
-
value: "ui",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
label: "ECharts JSON",
|
|
46
|
-
value: "json",
|
|
47
|
-
},
|
|
48
|
-
] as const;
|
|
49
|
-
|
|
50
|
-
export const EventOptions = [
|
|
51
|
-
{
|
|
52
|
-
label: trans("chart.select"),
|
|
53
|
-
value: "select",
|
|
54
|
-
description: trans("chart.selectDesc"),
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
label: trans("chart.unSelect"),
|
|
59
|
-
value: "unselect",
|
|
60
|
-
description: trans("chart.unselectDesc"),
|
|
61
|
-
},
|
|
62
|
-
] as const;
|
|
63
|
-
|
|
64
|
-
export const XAxisDirectionOptions = [
|
|
65
|
-
{
|
|
66
|
-
label: trans("chart.horizontal"),
|
|
67
|
-
value: "horizontal",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: trans("chart.vertical"),
|
|
71
|
-
value: "vertical",
|
|
72
|
-
},
|
|
73
|
-
] as const;
|
|
74
|
-
|
|
75
|
-
export type XAxisDirectionType = ValueFromOption<typeof XAxisDirectionOptions>;
|
|
76
|
-
|
|
77
|
-
export const noDataAxisConfig = {
|
|
78
|
-
animation: false,
|
|
79
|
-
xAxis: {
|
|
80
|
-
type: "category",
|
|
81
|
-
name: trans("chart.noData"),
|
|
82
|
-
nameLocation: "middle",
|
|
83
|
-
data: [],
|
|
84
|
-
axisLine: {
|
|
85
|
-
lineStyle: {
|
|
86
|
-
color: "#8B8FA3",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
yAxis: {
|
|
91
|
-
type: "value",
|
|
92
|
-
axisLabel: {
|
|
93
|
-
color: "#8B8FA3",
|
|
94
|
-
},
|
|
95
|
-
splitLine: {
|
|
96
|
-
lineStyle: {
|
|
97
|
-
color: "#F0F0F0",
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
tooltip: {
|
|
102
|
-
show: false,
|
|
103
|
-
},
|
|
104
|
-
series: [
|
|
105
|
-
{
|
|
106
|
-
data: [700],
|
|
107
|
-
type: "line",
|
|
108
|
-
itemStyle: {
|
|
109
|
-
opacity: 0,
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
} as EChartsOption;
|
|
114
|
-
|
|
115
|
-
export const noDataPieChartConfig = {
|
|
116
|
-
animation: false,
|
|
117
|
-
tooltip: {
|
|
118
|
-
show: false,
|
|
119
|
-
},
|
|
120
|
-
legend: {
|
|
121
|
-
formatter: trans("chart.unknown"),
|
|
122
|
-
top: "bottom",
|
|
123
|
-
selectedMode: false,
|
|
124
|
-
},
|
|
125
|
-
color: ["#B8BBCC", "#CED0D9", "#DCDEE6", "#E6E6EB"],
|
|
126
|
-
series: [
|
|
127
|
-
{
|
|
128
|
-
type: "pie",
|
|
129
|
-
radius: "35%",
|
|
130
|
-
center: ["25%", "50%"],
|
|
131
|
-
silent: true,
|
|
132
|
-
label: {
|
|
133
|
-
show: false,
|
|
134
|
-
},
|
|
135
|
-
data: [
|
|
136
|
-
{
|
|
137
|
-
name: "1",
|
|
138
|
-
value: 70,
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
name: "2",
|
|
142
|
-
value: 68,
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: "3",
|
|
146
|
-
value: 48,
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: "4",
|
|
150
|
-
value: 40,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
type: "pie",
|
|
156
|
-
radius: "35%",
|
|
157
|
-
center: ["75%", "50%"],
|
|
158
|
-
silent: true,
|
|
159
|
-
label: {
|
|
160
|
-
show: false,
|
|
161
|
-
},
|
|
162
|
-
data: [
|
|
163
|
-
{
|
|
164
|
-
name: "1",
|
|
165
|
-
value: 70,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: "2",
|
|
169
|
-
value: 68,
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: "3",
|
|
173
|
-
value: 48,
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
name: "4",
|
|
177
|
-
value: 40,
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
} as EChartsOption;
|
|
183
|
-
|
|
184
|
-
export type ChartSize = { w: number; h: number };
|
|
185
|
-
|
|
186
|
-
export const getDataKeys = (data: Array<JSONObject>) => {
|
|
187
|
-
if (!data) {
|
|
188
|
-
return [];
|
|
189
|
-
}
|
|
190
|
-
const dataKeys: Array<string> = [];
|
|
191
|
-
data.slice(0, 50).forEach((d) => {
|
|
192
|
-
Object.keys(d).forEach((key) => {
|
|
193
|
-
if (!dataKeys.includes(key)) {
|
|
194
|
-
dataKeys.push(key);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
return dataKeys;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
const ChartOptionMap = {
|
|
202
|
-
bar: BarChartConfig,
|
|
203
|
-
line: LineChartConfig,
|
|
204
|
-
pie: PieChartConfig,
|
|
205
|
-
scatter: ScatterChartConfig,
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const ChartOptionComp = withType(ChartOptionMap, "bar");
|
|
209
|
-
export type CharOptionCompType = keyof typeof ChartOptionMap;
|
|
210
|
-
|
|
211
|
-
export const chartUiModeChildren = {
|
|
212
|
-
title: StringControl,
|
|
213
|
-
data: jsonControl(toJSONObjectArray, i18nObjs.defaultDataSource),
|
|
214
|
-
xAxisKey: valueComp<string>(""), // x-axis, key from data
|
|
215
|
-
xAxisDirection: dropdownControl(XAxisDirectionOptions, "horizontal"),
|
|
216
|
-
series: SeriesListComp,
|
|
217
|
-
xConfig: XAxisConfig,
|
|
218
|
-
yConfig: YAxisConfig,
|
|
219
|
-
legendConfig: LegendConfig,
|
|
220
|
-
onEvent: eventHandlerControl(EventOptions),
|
|
221
|
-
chartConfig: ChartOptionComp,
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export const chartChildrenMap = {
|
|
225
|
-
mode: dropdownControl(chartModeOptions, "ui"),
|
|
226
|
-
echartsOption: jsonControl(toObject, i18nObjs.defaultEchartsJsonOption),
|
|
227
|
-
selectedPoints: stateComp<
|
|
228
|
-
Array<{
|
|
229
|
-
seriesName: string;
|
|
230
|
-
// coordinate chart
|
|
231
|
-
x?: any;
|
|
232
|
-
y?: any;
|
|
233
|
-
// pie or funnel
|
|
234
|
-
itemName?: any;
|
|
235
|
-
value?: any;
|
|
236
|
-
}>
|
|
237
|
-
>([]),
|
|
238
|
-
...chartUiModeChildren,
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const chartUiChildrenMap = uiChildren(chartChildrenMap);
|
|
242
|
-
export type ChartCompPropsType = RecordConstructorToView<typeof chartUiChildrenMap>;
|
|
243
|
-
export type ChartCompChildrenType = RecordConstructorToComp<typeof chartUiChildrenMap>;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { changeChildAction, CompAction } from "lowcoder-core";
|
|
2
|
-
import { ChartCompChildrenType, ChartTypeOptions, getDataKeys } from "./chartConstants";
|
|
3
|
-
import { newSeries } from "./seriesComp";
|
|
4
|
-
import {
|
|
5
|
-
CustomModal,
|
|
6
|
-
Dropdown,
|
|
7
|
-
hiddenPropertyView,
|
|
8
|
-
Option,
|
|
9
|
-
RedButton,
|
|
10
|
-
Section,
|
|
11
|
-
sectionNames,
|
|
12
|
-
} from "lowcoder-sdk";
|
|
13
|
-
import { trans } from "i18n/comps";
|
|
14
|
-
import { examplesUrl, optionUrl } from "./chartConfigs/chartUrls";
|
|
15
|
-
|
|
16
|
-
export function chartPropertyView(
|
|
17
|
-
children: ChartCompChildrenType,
|
|
18
|
-
dispatch: (action: CompAction) => void
|
|
19
|
-
) {
|
|
20
|
-
const series = children.series.getView();
|
|
21
|
-
const columnOptions = getDataKeys(children.data.getView()).map((key) => ({
|
|
22
|
-
label: key,
|
|
23
|
-
value: key,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const uiModePropertyView = (
|
|
27
|
-
<>
|
|
28
|
-
<Section name={trans("chart.data")}>
|
|
29
|
-
{children.data.propertyView({
|
|
30
|
-
label: trans("chart.data"),
|
|
31
|
-
})}
|
|
32
|
-
<Dropdown
|
|
33
|
-
value={children.chartConfig.children.compType.getView()}
|
|
34
|
-
options={ChartTypeOptions}
|
|
35
|
-
label={trans("chart.chartType")}
|
|
36
|
-
onChange={(value) => {
|
|
37
|
-
// keep the previous value
|
|
38
|
-
if (children.chartConfig.children.comp.children.hasOwnProperty("showLabel")) {
|
|
39
|
-
children.chartConfig.dispatchChangeValueAction({
|
|
40
|
-
compType: value as any,
|
|
41
|
-
comp: {
|
|
42
|
-
showLabel: (
|
|
43
|
-
children.chartConfig.children.comp.children as any
|
|
44
|
-
).showLabel.toJsonValue(),
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
} else {
|
|
48
|
-
children.chartConfig.dispatchChangeValueAction({
|
|
49
|
-
compType: value,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}}
|
|
53
|
-
/>
|
|
54
|
-
<Dropdown
|
|
55
|
-
value={children.xAxisKey.getView()}
|
|
56
|
-
options={columnOptions}
|
|
57
|
-
label={trans("chart.xAxis")}
|
|
58
|
-
onChange={(value) => {
|
|
59
|
-
dispatch(changeChildAction("xAxisKey", value));
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
<Option
|
|
63
|
-
items={series}
|
|
64
|
-
title={trans("chart.chartSeries")}
|
|
65
|
-
itemTitle={(s) => s.getView().seriesName}
|
|
66
|
-
popoverTitle={(s) => s.getView().columnName}
|
|
67
|
-
content={(s, index) => (
|
|
68
|
-
<>
|
|
69
|
-
{s.getPropertyViewWithData(columnOptions)}
|
|
70
|
-
{
|
|
71
|
-
<RedButton
|
|
72
|
-
onClick={() => {
|
|
73
|
-
CustomModal.confirm({
|
|
74
|
-
title: trans("chart.delete"),
|
|
75
|
-
content: trans("chart.confirmDelete") + `${s.getView().seriesName}?`,
|
|
76
|
-
onConfirm: () =>
|
|
77
|
-
children.series.dispatch(children.series.deleteAction(index)),
|
|
78
|
-
confirmBtnType: "delete",
|
|
79
|
-
okText: trans("chart.delete"),
|
|
80
|
-
});
|
|
81
|
-
}}
|
|
82
|
-
>
|
|
83
|
-
{trans("chart.delete")}
|
|
84
|
-
</RedButton>
|
|
85
|
-
}
|
|
86
|
-
</>
|
|
87
|
-
)}
|
|
88
|
-
onAdd={() => {
|
|
89
|
-
if (columnOptions.length <= 0) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
children.series.dispatch(
|
|
93
|
-
children.series.pushAction(
|
|
94
|
-
newSeries(trans("chart.customSeries"), columnOptions[0].value)
|
|
95
|
-
)
|
|
96
|
-
);
|
|
97
|
-
}}
|
|
98
|
-
onMove={(fromIndex, toIndex) => {
|
|
99
|
-
const action = children.series.arrayMoveAction(fromIndex, toIndex);
|
|
100
|
-
children.series.dispatch(action);
|
|
101
|
-
}}
|
|
102
|
-
hide={(s) => s.getView().hide}
|
|
103
|
-
onHide={(s, hide) => s.children.hide.dispatchChangeValueAction(hide)}
|
|
104
|
-
dataIndex={(s) => s.getView().dataIndex}
|
|
105
|
-
/>
|
|
106
|
-
</Section>
|
|
107
|
-
<Section name={sectionNames.interaction}>{children.onEvent.getPropertyView()}</Section>
|
|
108
|
-
<Section name={sectionNames.layout}>
|
|
109
|
-
{children.title.propertyView({ label: trans("chart.title") })}
|
|
110
|
-
{children.chartConfig.children.compType.getView() !== "pie" && (
|
|
111
|
-
<>
|
|
112
|
-
{children.xAxisDirection.propertyView({
|
|
113
|
-
label: trans("chart.xAxisDirection"),
|
|
114
|
-
radioButton: true,
|
|
115
|
-
})}
|
|
116
|
-
{children.xConfig.getPropertyView()}
|
|
117
|
-
{children.yConfig.getPropertyView()}
|
|
118
|
-
</>
|
|
119
|
-
)}
|
|
120
|
-
{children.legendConfig.getPropertyView()}
|
|
121
|
-
{hiddenPropertyView(children)}
|
|
122
|
-
</Section>
|
|
123
|
-
<Section name={sectionNames.style}>{children.chartConfig.getPropertyView()}</Section>
|
|
124
|
-
</>
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const jsonModePropertyView = (
|
|
128
|
-
<>
|
|
129
|
-
<Section name={trans("chart.config")}>
|
|
130
|
-
{children.echartsOption.propertyView({
|
|
131
|
-
label: trans("chart.echartsOptionLabel"),
|
|
132
|
-
styleName: "higher",
|
|
133
|
-
tooltip: (
|
|
134
|
-
<div>
|
|
135
|
-
<a href={optionUrl} target="_blank" rel="noopener noreferrer">
|
|
136
|
-
{trans("chart.echartsOptionTooltip")}
|
|
137
|
-
</a>
|
|
138
|
-
<br />
|
|
139
|
-
<a href={examplesUrl} target="_blank" rel="noopener noreferrer">
|
|
140
|
-
{trans("chart.echartsOptionExamples")}
|
|
141
|
-
</a>
|
|
142
|
-
</div>
|
|
143
|
-
),
|
|
144
|
-
})}
|
|
145
|
-
</Section>
|
|
146
|
-
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
|
|
147
|
-
</>
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<>
|
|
152
|
-
<Section name={trans("chart.mode")}>
|
|
153
|
-
{children.mode.propertyView({
|
|
154
|
-
label: "",
|
|
155
|
-
radioButton: true,
|
|
156
|
-
})}
|
|
157
|
-
</Section>
|
|
158
|
-
{children.mode.getView() === "ui" ? uiModePropertyView : jsonModePropertyView}
|
|
159
|
-
</>
|
|
160
|
-
);
|
|
161
|
-
}
|