Skip to content

Commit 31ddc52

Browse files
committed
Added control fields and style fields on Graph charts.
1 parent 5fb1fc0 commit 31ddc52

File tree

8 files changed

+127
-34
lines changed

8 files changed

+127
-34
lines changed

client/packages/lowcoder-comps/src/comps/candleStickChartComp/candleStickChartUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ export function getEchartsConfig(
144144
text: props.echartsTitle,
145145
top: props.echartsTitleVerticalConfig.top,
146146
left:props.echartsTitleConfig.top,
147+
textStyle: {
148+
...styleWrapper(props?.titleStyle, theme?.titleStyle)
149+
}
147150
},
148151
backgroundColor: parseBackground( props?.chartStyle?.background || theme?.chartStyle?.backgroundColor || "#FFFFFF"),
149152
color: props?.echartsOption.data?.map(data => data.color),

client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartComp.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ GraphChartTmpComp = withViewFn(GraphChartTmpComp, (comp) => {
146146
return getEchartsConfig(
147147
childrenToProps(echartsConfigChildren) as ToViewReturn<typeof echartsConfigChildren>,
148148
chartSize,
149-
theme?.theme?.components?.candleStickChart || {},
149+
themeConfig
150150
);
151151
}, [chartSize, ...Object.values(echartsConfigChildren)]);
152152

@@ -176,7 +176,6 @@ GraphChartTmpComp = withViewFn(GraphChartTmpComp, (comp) => {
176176
lazyUpdate
177177
opts={{ locale: getEchartsLocale() }}
178178
option={option}
179-
theme={mode !== 'map' ? themeConfig : undefined}
180179
mode={mode}
181180
/>
182181
</ReactResizeDetector>

client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartConstants.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ import {
1616
uiChildren,
1717
clickEvent,
1818
styleControl,
19-
EchartsStyle
19+
EchartsStyle,
20+
EchartDefaultChartStyle,
21+
EchartDefaultTextStyle,
2022
} from "lowcoder-sdk";
23+
2124
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
2225
import { BarChartConfig } from "../chartComp/chartConfigs/barChartConfig";
2326
import { XAxisConfig, YAxisConfig } from "../chartComp/chartConfigs/cartesianAxisConfig";
@@ -27,6 +30,8 @@ import { EchartsLabelConfig } from "../chartComp/chartConfigs/echartsLabelConfig
2730
import { LineChartConfig } from "../chartComp/chartConfigs/lineChartConfig";
2831
import { PieChartConfig } from "../chartComp/chartConfigs/pieChartConfig";
2932
import { ScatterChartConfig } from "../chartComp/chartConfigs/scatterChartConfig";
33+
import { EchartsTitleVerticalConfig } from "../chartComp/chartConfigs/echartsTitleVerticalConfig";
34+
import { EchartsTitleConfig } from "comps/chartComp/chartConfigs/echartsTitleConfig";
3035
import { SeriesListComp } from "../chartComp/seriesComp";
3136
import { EChartsOption } from "echarts";
3237
import { i18nObjs, trans } from "i18n/comps";
@@ -252,15 +257,25 @@ let chartJsonModeChildren: any = {
252257
echartsTitle: withDefault(StringControl, trans("graphChart.defaultTitle")),
253258
echartsLegendConfig: EchartsLegendConfig,
254259
echartsLabelConfig: EchartsLabelConfig,
260+
echartsTitleVerticalConfig: EchartsTitleVerticalConfig,
261+
echartsTitleConfig:EchartsTitleConfig,
255262
echartsConfig: EchartsOptionComp,
256-
// style: styleControl(EchartsStyle, 'style'),
263+
arrowSize:withDefault(NumberControl,trans('graphChart.defaultArrowSize')),
264+
pointSize:withDefault(NumberControl,trans('graphChart.defaultPointSize')),
265+
repulsion:withDefault(NumberControl,trans('graphChart.defaultRepulsion')),
266+
gravity:withDefault(NumberControl,trans('graphChart.defaultGravity')),
267+
lineLength:withDefault(NumberControl,trans('graphChart.defaultLineLength')),
268+
lineWidth:withDefault(NumberControl,trans('graphChart.defaultLineWidth')),
269+
curveness:withDefault(NumberControl,trans('graphChart.defaultCurveness')),
257270
tooltip: withDefault(BoolControl, true),
271+
arrowFlag: withDefault(BoolControl, true),
258272
legendVisibility: withDefault(BoolControl, true),
259273
}
260274
if (EchartsStyle) {
261275
chartJsonModeChildren = {
262276
...chartJsonModeChildren,
263-
style: styleControl(EchartsStyle, 'style'),
277+
chartStyle: styleControl(EchartDefaultChartStyle, 'chartStyle'),
278+
titleStyle: styleControl(EchartDefaultTextStyle, 'titleStyle'),
264279
}
265280
}
266281

client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartPropertyView.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,29 @@ export function graphChartPropertyView(
3131
</div>
3232
),
3333
})}
34-
{children.echartsTitle.propertyView({ label: trans("graphChart.title") })}
35-
{children.tooltip.propertyView({label: trans("graphChart.tooltip")})}
34+
{children.echartsTitle.propertyView({ label: trans("graphChart.title"), tooltip: trans("echarts.titleTooltip") })}
35+
{children.echartsTitleConfig.getPropertyView()}
36+
{children.echartsTitleVerticalConfig.getPropertyView()}
37+
38+
{children.arrowFlag.getView() && children.arrowSize.propertyView({ label: trans("graphChart.arrowSize"), tooltip: trans("graphChart.arrowSizeTooltip") })}
39+
{children.pointSize.propertyView({ label: trans("graphChart.pointSize"), tooltip: trans("graphChart.pointSizeTooltip") })}
40+
{children.repulsion.propertyView({ label: trans("graphChart.repulsion"), tooltip: trans("graphChart.repulsionTooltip") })}
41+
{children.gravity.propertyView({ label: trans("graphChart.gravity"), tooltip: trans("graphChart.gravityTooltip") })}
42+
{children.lineLength.propertyView({ label: trans("graphChart.lineLength"), tooltip: trans("graphChart.lineLengthTooltip") })}
43+
{children.lineWidth.propertyView({ label: trans("graphChart.lineWidth"), tooltip: trans("graphChart.lineWidthTooltip") })}
44+
{children.curveness.propertyView({ label: trans("graphChart.curveness"), tooltip: trans("graphChart.curvenessTooltip") })}
45+
46+
{children.arrowFlag.propertyView({label: trans("graphChart.arrowFlag"), tooltip: trans("graphChart.arrowFlagTooltip") })}
47+
{children.tooltip.propertyView({label: trans("graphChart.tooltip"), tooltip: trans("graphChart.tooltipTooltip") })}
3648
</Section>
3749
<Section name={sectionNames.interaction}>
3850
{children.onEvent.propertyView()}
3951
</Section>
40-
<Section name={sectionNames.style}>
41-
{children.style?.getPropertyView()}
52+
<Section name={sectionNames.chartStyle}>
53+
{children.chartStyle?.getPropertyView()}
54+
</Section>
55+
<Section name={sectionNames.titleStyle}>
56+
{children.titleStyle?.getPropertyView()}
4257
</Section>
4358
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
4459
</>

client/packages/lowcoder-comps/src/comps/graphChartComp/graphChartUtils.ts

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { chartColorPalette, isNumeric, JSONObject, loadScript } from "lowcoder-s
1212
import { calcXYConfig } from "comps/chartComp/chartConfigs/cartesianAxisConfig";
1313
import Big from "big.js";
1414
import { googleMapsApiUrl } from "../chartComp/chartConfigs/chartUrls";
15+
import parseBackground from "../../util/gradientBackgroundColor";
16+
import {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";
1517

1618
export function transformData(
1719
originData: JSONObject[],
@@ -134,32 +136,48 @@ export function getEchartsConfig(
134136
theme?: any,
135137
): EChartsOptionWithMap {
136138
if (props.mode === "json") {
137-
let opt={
138-
"title": {
139-
"text": props.echartsTitle,
140-
'top': props.echartsLegendConfig.top === 'bottom' ?'top':'bottom',
141-
"left":"center"
142-
},
143-
"backgroundColor": props?.style?.background || theme?.style?.background,
144-
"color": props.echartsOption.data?.map(data => data.color),
145-
"tooltip": props.tooltip&& {
146-
"trigger": "item"
147-
},
148-
'series': [
149-
{
150-
"type": "graph",
151-
"layout": "force",
152-
"force": {
153-
"repulsion": 100,
154-
"gravity": 0.1,
155-
"edgeLength": 100
156-
},
157-
'categories': props.echartsOption.categories,
158-
'links': props.echartsOption.links,
159-
'nodes': props.echartsOption.nodes,
139+
let opt= props?.echartsOption && {
140+
title: {
141+
text: props.echartsTitle,
142+
top: props.echartsTitleVerticalConfig.top,
143+
left:props.echartsTitleConfig.top,
144+
textStyle: {
145+
...styleWrapper(props?.titleStyle, theme?.titleStyle)
160146
}
161-
]
162-
}
147+
},
148+
backgroundColor: parseBackground( props?.chartStyle?.background || theme?.chartStyle?.backgroundColor || "#FFFFFF"),
149+
"tooltip": props.tooltip&& {
150+
"trigger": "item"
151+
},
152+
'series': [
153+
{
154+
155+
"type": "graph",
156+
"layout": "force",
157+
'categories': props.echartsOption.categories,
158+
'links': props.echartsOption.links,
159+
"force": {
160+
"repulsion": props.repulsion,
161+
"gravity": props?.gravity,
162+
"edgeLength": props?.lineLength
163+
},
164+
edgeSymbol: ['', props?.arrowFlag ? 'arrow' : ''],
165+
edgeSymbolSize: [0, props?.arrowSize],
166+
symbolSize: props?.pointSize,
167+
lineStyle: {
168+
color: props.echartsOption?.color?.lineColor || "#00000033",
169+
...chartStyleWrapper(props?.chartStyle,theme?.chartStyle),
170+
width: props?.lineWidth || 1,
171+
curveness: props?.curveness
172+
},
173+
'nodes': props.echartsOption.nodes,
174+
itemStyle: {
175+
"color": props.echartsOption?.color?.pointColor || "#0000ff",
176+
...chartStyleWrapper(props?.chartStyle,theme?.chartStyle),
177+
},
178+
}
179+
],
180+
}
163181
return props.echartsOption ? opt : {};
164182

165183
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,31 @@ export const en = {
3434
title: 'Title',
3535
defaultTitle: 'Graph Chart',
3636
tooltip: 'Tooltip',
37+
arrowSize: "Arrow Size",
38+
pointSize: "Point Size",
39+
repulsion: "Repulsion",
40+
gravity: "Gravity",
41+
lineLength: "Line Length",
42+
curveness: "Curveness",
43+
lineWidth: "Line Width",
44+
arrowFlag: "Arrow Flag",
45+
arrowSizeTooltip: "Select the Arrow Size of the Chart.",
46+
pointSizeTooltip: "Select the Point Size of the Chart.",
47+
repulsionTooltip: "Select the Repulsion of the Chart.",
48+
gravityTooltip: "Select the Gravity of the Chart.",
49+
lineLengthTooltip: "Select the Line length of the Chart.",
50+
lineWidthTooltip: "Select the Line width of the Chart.",
51+
arrowFlagTooltip: "Show or hide the Arrow of the Chart.",
52+
tooltipTooltip: "Show or hide the Tooltip of the Chart.",
53+
curvenessTooltip: "defaultCurveness",
54+
defaultArrowSize: "10",
55+
defaultPointSize: "15",
56+
defaultRepulsion: "100",
57+
defaultGravity: "0.1",
58+
defaultLineLength: "100",
59+
defaultLineWidth: "2",
60+
defaultCurveness: "0",
61+
3762
},
3863
heatmapChart: {
3964
heatmapType: 'Heatmap Chart Type',

client/packages/lowcoder-comps/src/i18n/comps/locales/enObj.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ export const enObj: I18nObjects = {
385385
]
386386
},
387387
defaultGraphChartOption: {
388+
color:{
389+
pointColor: "#0000ff",
390+
lineColor: "#00000033"
391+
},
388392
categories: [
389393
{name: "Nodes"},
390394
{name: "Edges"}

client/packages/lowcoder-comps/src/util/styleWrapper.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,18 @@ export const styleWrapper = (styleContainer: any, themeContainer: any, defaultFo
1818
"width": styleContainer?.detailSize?.split('px')[0] || themeContainer?.detailSize.split('px')[0] || 24,
1919
"height": styleContainer?.detailSize?.split('px')[1] || themeContainer?.detailSize.split('px')[1] || 12,
2020
}
21+
}
22+
23+
export const chartStyleWrapper = (styleContainer: any, themeContainer: any, detailBorderWidth = 0) => {
24+
25+
return {
26+
"shadowColor": styleContainer?.chartShadowColor || themeContainer?.shadowColor,
27+
"shadowBlur": styleContainer?.chartBoxShadow?.split('px')[0] || themeContainer?.boxShadow?.split('px')[0],
28+
"shadowOffsetX": styleContainer?.chartBoxShadow?.split('px')[1] || themeContainer?.boxShadow?.split('px')[1],
29+
"shadowOffsetY": styleContainer?.chartBoxShadow?.split('px')[2] || themeContainer?.boxShadow?.split('px')[2],
30+
"borderColor": styleContainer?.chartBorderColor || themeContainer?.borderColor || 'inherit',
31+
"borderWidth": styleContainer?.chartBorderWidth || themeContainer?.borderWidth || detailBorderWidth,
32+
"borderType": styleContainer?.chartBorderStyle || themeContainer?.borderType,
33+
"borderRadius": Number(styleContainer?.chartBorderRadius || themeContainer?.borderRadius),
34+
}
2135
}

0 commit comments

Comments
 (0)