Skip to content

Commit 4098b68

Browse files
committed
Added an ability that legend of funnel can be on the left or right.
1 parent 6384363 commit 4098b68

File tree

8 files changed

+106
-3
lines changed

8 files changed

+106
-3
lines changed

client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartPropertyView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export function candleStickChartPropertyView(
3232
),
3333
})}
3434
{children.echartsTitleConfig.getPropertyView()}
35+
{children.legendVisibility.getView() && children.echartsLegendConfig.getPropertyView()}
3536
{children.left.propertyView({ label: trans("candleStickChart.left") })}
3637
{children.right.propertyView({ label: trans("candleStickChart.right") })}
3738
{children.top.propertyView({ label: trans("candleStickChart.top") })}
3839
{children.bottom.propertyView({ label: trans("candleStickChart.bottom") })}
39-
{children.legendVisibility.getView() && children.echartsLegendConfig.getPropertyView()}
4040
{children.echartsTitle.propertyView({ label: trans("candleStickChart.title") })}
4141
{children.dataZoomVisibility.getView() && children.dataZoomHeight.propertyView({ label: trans("candleStickChart.dataZoomHeight") })}
4242
{children.dataZoomVisibility.getView() && children.dataZoomBottom.propertyView({ label: trans("candleStickChart.dataZoomBottom") })}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {
2+
AlignClose,
3+
AlignRight,
4+
AlignLeft,
5+
dropdownControl,
6+
MultiCompBuilder,
7+
} from "lowcoder-sdk";
8+
import {FunnelSeriesOption, LegendComponentOption} from "echarts";
9+
import { trans } from "i18n/comps";
10+
11+
const FunnelLegnedAlignOptions = [
12+
{
13+
label: <AlignClose />,
14+
value: "center",
15+
},
16+
{
17+
label: <AlignRight />,
18+
value: "right",
19+
},
20+
{
21+
label: <AlignLeft />,
22+
value: "left",
23+
},
24+
] as const;
25+
26+
export const EchartsLegendAlignConfig = (function () {
27+
return new MultiCompBuilder(
28+
{
29+
legendAlign: dropdownControl(FunnelLegnedAlignOptions, "center"),
30+
},
31+
(props): FunnelSeriesOption => {
32+
const config: FunnelSeriesOption = {
33+
left: "center",
34+
};
35+
config.left = props.legendAlign
36+
return config;
37+
}
38+
)
39+
.setPropertyViewFn((children) => (
40+
<>
41+
{children.legendAlign.propertyView({
42+
label: trans("echarts.legendAlign"),
43+
radioButton: true,
44+
})}
45+
</>
46+
))
47+
.build();
48+
})();
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
HorizontoalIcon,
3+
VerticalIcon,
4+
dropdownControl,
5+
MultiCompBuilder,
6+
} from "lowcoder-sdk";
7+
import { LegendComponentOption } from "echarts";
8+
import { trans } from "i18n/comps";
9+
10+
const LegendLayoutOptions = [
11+
{
12+
label: <HorizontoalIcon />,
13+
value: "horizontal",
14+
},
15+
{
16+
label: <VerticalIcon />,
17+
value: "vertical",
18+
},
19+
] as const;
20+
21+
export const EchartsLegendLayoutConfig = (function () {
22+
return new MultiCompBuilder(
23+
{
24+
legendLayout: dropdownControl(LegendLayoutOptions, "bottom"),
25+
},
26+
(props): LegendComponentOption => {
27+
const config: LegendComponentOption = {
28+
orient: "horizontal",
29+
};
30+
config.orient = props.legendLayout
31+
return config;
32+
}
33+
)
34+
.setPropertyViewFn((children) => (
35+
<>
36+
{children.legendLayout.propertyView({
37+
label: trans("echarts.legendLayout"),
38+
radioButton: true,
39+
})}
40+
</>
41+
))
42+
.build();
43+
})();

client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartConstants.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import { i18nObjs, trans } from "i18n/comps";
3636
import { FunnelChartConfig} from "../chartComp/chartConfigs/funnelChartConfig";
3737
import { EchartsTitleConfig } from "comps/chartComp/chartConfigs/echartsTitleConfig";
3838
import { EchartsSortingConfig } from "../chartComp/chartConfigs/echartsSortingConfig";
39+
import { EchartsLegendAlignConfig } from "../chartComp/chartConfigs/echartsLegendAlignConfig";
40+
import { EchartsLegendLayoutConfig } from "../chartComp/chartConfigs/echartsLegendLayoutConfig";
3941

4042
export const ChartTypeOptions = [
4143
{
@@ -259,6 +261,8 @@ let chartJsonModeChildren: any = {
259261
echartsSortingConfig: EchartsSortingConfig,
260262
echartsLabelConfig: EchartsLabelConfig,
261263
echartsFunnelAlignConfig: EchartsFunnelAlignConfig,
264+
echartsLegendLayoutConfig: EchartsLegendLayoutConfig,
265+
echartsLegendAlignConfig: EchartsLegendAlignConfig,
262266
echartsConfig: EchartsOptionComp,
263267
echartsTitleConfig:EchartsTitleConfig,
264268
// style: styleControl(EchartsStyle, 'style'),

client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartPropertyView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export function funnelChartPropertyView(
3434
{children.legendVisibility.getView()&& children.echartsLegendConfig.getPropertyView()}
3535
{children.echartsSortingConfig.getPropertyView()}
3636
{children.label.getView()&& children.echartsLabelConfig.getPropertyView()}
37-
{children.echartsFunnelAlignConfig.getPropertyView()}
37+
{children.echartsLegendLayoutConfig.getPropertyView()}
38+
{children.echartsLegendAlignConfig.getPropertyView()}
39+
{children.echartsConfig.getPropertyView()}
3840
{children.echartsTitleConfig.getPropertyView()}
3941
{children.left.propertyView({ label: trans("funnelChart.left") })}
4042
{children.top.propertyView({ label: trans("funnelChart.top") })}

client/packages/lowcoder-comps/src/comps/funnelChartComp/funnelChartUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ export function getEchartsConfig(
174174
"legend":props.legendVisibility&& {
175175
"data": props.echartsOption.data?.map(data=>data.name),
176176
"top": props.echartsLegendConfig.top,
177+
"left": props.echartsLegendAlignConfig.left,
178+
"orient": props.echartsLegendAlignConfig.orient,
177179
"textStyle": {
178180
"fontFamily": props?.legendStyle?.chartFontFamily || theme?.legendStyle?.fontFamily,
179181
"fontSize": props?.legendStyle?.chartTextSize || theme?.legendStyle?.fontSize,

client/packages/lowcoder-comps/src/i18n/comps/locales/en.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ export const en = {
145145
labelPosition: "Label Position",
146146
titlePosition: "Title Position",
147147
funnelAlign: "Funnel Align",
148-
sort: "Sort"
148+
sort: "Sort",
149+
legendLayout: "Chart Legend Layout",
150+
legendAlign: "Chart Legend Align"
149151
},
150152
chart: {
151153
delete: "Delete",

client/packages/lowcoder-design/src/icons/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ export { ReactComponent as MarketplaceIcon } from "./v1/icon-application-marketp
250250
export { ReactComponent as FavoritesIcon } from "./v1/icon-application-favorites.svg";
251251
export { ReactComponent as HomeSettingIcon } from "./remix/settings-4-line.svg";
252252
export { ReactComponent as EnterpriseIcon } from "./remix/earth-line.svg";
253+
export { ReactComponent as VerticalIcon } from "./remix/vertical.svg";
254+
export { ReactComponent as HorizontalIcon } from "./remix/horizontal.svg";
253255

254256

255257
// components

0 commit comments

Comments
 (0)