Skip to content

Commit 763d979

Browse files
committed
Added control fields and style fields to tree charts.
1 parent 09f2c33 commit 763d979

File tree

6 files changed

+107
-41
lines changed

6 files changed

+107
-41
lines changed

client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartConstants.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
uiChildren,
1717
clickEvent,
1818
styleControl,
19-
EchartsStyle
19+
EchartsStyle, RadarLabelStyle, EchartDefaultChartStyle, EchartDefaultTextStyle
2020
} from "lowcoder-sdk";
2121
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
2222
import { BarChartConfig } from "../chartComp/chartConfigs/barChartConfig";
@@ -31,6 +31,8 @@ import { SeriesListComp } from "../chartComp/seriesComp";
3131
import { EChartsOption } from "echarts";
3232
import { i18nObjs, trans } from "i18n/comps";
3333
import { TreeChartConfig } from "comps/chartComp/chartConfigs/treeChartConfig";
34+
import {EchartsTitleVerticalConfig} from "../chartComp/chartConfigs/echartsTitleVerticalConfig";
35+
import {EchartsTitleConfig} from "../chartComp/chartConfigs/echartsTitleConfig";
3436

3537
export const ChartTypeOptions = [
3638
{
@@ -253,14 +255,27 @@ let chartJsonModeChildren: any = {
253255
echartsLegendConfig: EchartsLegendConfig,
254256
echartsLabelConfig: EchartsLabelConfig,
255257
echartsConfig: EchartsOptionComp,
256-
// style: styleControl(EchartsStyle, 'style'),
258+
echartsTitleVerticalConfig: EchartsTitleVerticalConfig,
259+
echartsTitleConfig:EchartsTitleConfig,
260+
261+
left:withDefault(NumberControl,trans('treeChart.defaultLeft')),
262+
right:withDefault(NumberControl,trans('treeChart.defaultRight')),
263+
top:withDefault(NumberControl,trans('treeChart.defaultTop')),
264+
bottom:withDefault(NumberControl,trans('treeChart.defaultBottom')),
265+
pointSize:withDefault(NumberControl,trans('treeChart.defaultPointSize')),
266+
lineWidth:withDefault(NumberControl,trans('treeChart.defaultlineWidth')),
267+
268+
edgeShape: withDefault(BoolControl, true),
257269
tooltip: withDefault(BoolControl, true),
258270
legendVisibility: withDefault(BoolControl, true),
259271
}
260-
if (EchartsStyle) {
272+
273+
if (RadarLabelStyle && EchartDefaultChartStyle && EchartDefaultTextStyle) {
261274
chartJsonModeChildren = {
262275
...chartJsonModeChildren,
263-
style: styleControl(EchartsStyle, 'style'),
276+
chartStyle: styleControl(EchartDefaultChartStyle, 'chartStyle'),
277+
titleStyle: styleControl(EchartDefaultTextStyle, 'titleStyle'),
278+
detailStyle: styleControl(RadarLabelStyle, 'detailStyle'),
264279
}
265280
}
266281

client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartPropertyView.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,34 @@ export function treeChartPropertyView(
3131
</div>
3232
),
3333
})}
34+
{children.echartsTitleConfig.getPropertyView()}
35+
{children.echartsTitleVerticalConfig.getPropertyView()}
3436
{children.echartsTitle.propertyView({ label: trans("treeChart.title") })}
37+
38+
{children.left.propertyView({ label: trans("treeChart.left"), tooltip: trans("echarts.leftTooltip") })}
39+
{children.right.propertyView({ label: trans("treeChart.right"), tooltip: trans("echarts.rightTooltip") })}
40+
{children.top.propertyView({ label: trans("treeChart.top"), tooltip: trans("echarts.topTooltip") })}
41+
{children.bottom.propertyView({ label: trans("treeChart.bottom"), tooltip: trans("echarts.bottomTooltip") })}
42+
{children.pointSize.propertyView({ label: trans("treeChart.pointSize"), tooltip: trans("treeChart.pointSizeTooltip") })}
43+
{children.lineWidth.propertyView({ label: trans("treeChart.lineWidth"), tooltip: trans("treeChart.lineWidthTooltip") })}
44+
3545
{children.tooltip.propertyView({label: trans("treeChart.tooltip")})}
46+
3647
</Section>
3748
<Section name={sectionNames.interaction}>
3849
{children.onEvent.propertyView()}
3950
</Section>
40-
<Section name={sectionNames.style}>
41-
{children.style?.getPropertyView()}
51+
52+
<Section name={sectionNames.chartStyle}>
53+
{children.chartStyle?.getPropertyView()}
4254
</Section>
55+
<Section name={sectionNames.titleStyle}>
56+
{children.titleStyle?.getPropertyView()}
57+
</Section>
58+
<Section name={sectionNames.detailStyle}>
59+
{children.detailStyle?.getPropertyView()}
60+
</Section>
61+
4362
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
4463
</>
4564
);

client/packages/lowcoder-comps/src/comps/treeChartComp/treeChartUtils.ts

Lines changed: 49 additions & 33 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 {chartStyleWrapper, styleWrapper} from "../../util/styleWrapper";
16+
import parseBackground from "../../util/gradientBackgroundColor";
1517

1618
export function transformData(
1719
originData: JSONObject[],
@@ -135,42 +137,56 @@ export function getEchartsConfig(
135137
): EChartsOptionWithMap {
136138
if (props.mode === "json") {
137139
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-
"triggerOn": "mousemove"
148-
},
149-
"series": [
150-
{
151-
"name": props.echartsConfig.type,
152-
"type": props.echartsConfig.type,
153-
"top": "10%",
154-
"left": "10%",
155-
"bottom": "10%",
156-
"right": "10%",
157-
"symbolSize": 7,
158-
'data': props.echartsOption.data,
159-
"label": {
160-
"position": "top",
161-
"verticalAlign": "middle",
162-
"align": "right"
140+
title: {
141+
text: props?.echartsTitle,
142+
top: props?.echartsTitleVerticalConfig.top,
143+
left: props?.echartsTitleConfig.top,
144+
textStyle: {
145+
...styleWrapper(props?.titleStyle, theme?.titleStyle)
146+
}
147+
},
148+
backgroundColor: parseBackground(props?.chartStyle?.background || theme?.chartStyle?.backgroundColor || "#FFFFFF"),
149+
color: props.echartsOption.data?.map(data => data.color), // Node colors from data
150+
tooltip: props.tooltip && {
151+
trigger: "item",
152+
triggerOn: "mousemove"
153+
},
154+
series: [
155+
{
156+
name: props.echartsConfig.type,
157+
type: props.echartsConfig.type,
158+
left: `${props?.left}%`,
159+
right: `${props?.right}%`,
160+
bottom: `${props?.bottom}%`,
161+
top: `${props?.top}%`,
162+
symbol: "circle", // Define the shape of the nodes (e.g., 'circle', 'rect', etc.)
163+
symbolSize: props?.pointSize || 20, // Control the size of the nodes
164+
data: props.echartsOption.data,
165+
label: {
166+
position: "top",
167+
verticalAlign: "middle",
168+
align: "right",
169+
...styleWrapper(props?.detailStyle, theme?.detailStyle, 11),
170+
},
171+
leaves: {
172+
label: {
173+
position: "bottom",
174+
verticalAlign: "middle",
175+
align: "left"
176+
}
163177
},
164-
"leaves": {
165-
"label": {
166-
"position": "bottom",
167-
"verticalAlign": "middle",
168-
"align": "left"
178+
itemStyle: {
179+
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle),
180+
color: props.echartsOption.pointColor,
181+
},
182+
lineStyle: {
183+
width: props?.lineWidth || 2, // Control the line thickness
184+
color: props.echartsOption.lineColor,
185+
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle)
186+
}
169187
}
170-
}
188+
]
171189
}
172-
]
173-
}
174190
return props.echartsOption ? opt : {};
175191

176192
}

client/packages/lowcoder-comps/src/comps/treeChartComp/treechartComp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ TreeChartTmpComp = withViewFn(TreeChartTmpComp, (comp) => {
145145
return getEchartsConfig(
146146
childrenToProps(echartsConfigChildren) as ToViewReturn<typeof echartsConfigChildren>,
147147
chartSize,
148-
theme?.theme?.components?.candleStickChart || {},
148+
themeConfig
149149
);
150150
}, [chartSize, ...Object.values(echartsConfigChildren)]);
151151

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ export const en = {
4949
title: 'Title',
5050
defaultTitle: 'Tree Chart',
5151
tooltip: 'Tooltip',
52+
defaultLeft: "10",
53+
left: "Left",
54+
defaultRight: "10",
55+
right: "Right",
56+
defaultTop: "20",
57+
top: "Top",
58+
defaultBottom: "20",
59+
bottom: "Bottom",
60+
defaultPointSize: "10",
61+
pointSize: "Point Size",
62+
pointSizeTooltip: "Set the Point Size of the Chart.",
63+
defaultlineWidth: '2',
64+
lineWidth: "Line Width",
65+
lineWidthTooltip: "Set the Line Width of the Chart."
5266
},
5367
graphChart: {
5468
graphType: 'Graph Chart Type',

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ export const enObj: I18nObjects = {
417417
]
418418
}
419419
]
420-
}]
420+
}],
421+
pointColor: "#380e81",
422+
lineColor: "#1a93b8",
421423
},
422424
defaultTreemapChartOption: {
423425
data: [

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy