Skip to content

Commit 8fae70f

Browse files
committed
Added control fields and style fields to treemap charts.
1 parent 763d979 commit 8fae70f

File tree

6 files changed

+124
-65
lines changed

6 files changed

+124
-65
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ TreemapChartTmpComp = withViewFn(TreemapChartTmpComp, (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/comps/treemapChartComp/treemapChartConstants.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import {
1616
uiChildren,
1717
clickEvent,
1818
styleControl,
19-
EchartsStyle
19+
RadarLabelStyle,
20+
EchartDefaultChartStyle,
21+
EchartDefaultTextStyle
2022
} from "lowcoder-sdk";
2123
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
2224
import { BarChartConfig } from "../chartComp/chartConfigs/barChartConfig";
@@ -31,6 +33,8 @@ import { SeriesListComp } from "../chartComp/seriesComp";
3133
import { EChartsOption } from "echarts";
3234
import { i18nObjs, trans } from "i18n/comps";
3335
import { TreemapChartConfig } from "comps/chartComp/chartConfigs/treemapChartConfig";
36+
import {EchartsTitleVerticalConfig} from "../chartComp/chartConfigs/echartsTitleVerticalConfig";
37+
import {EchartsTitleConfig} from "../chartComp/chartConfigs/echartsTitleConfig";
3438

3539
export const ChartTypeOptions = [
3640
{
@@ -253,14 +257,25 @@ let chartJsonModeChildren: any = {
253257
echartsLegendConfig: EchartsLegendConfig,
254258
echartsLabelConfig: EchartsLabelConfig,
255259
echartsConfig: EchartsOptionComp,
256-
// style: styleControl(EchartsStyle, 'style'),
260+
261+
echartsTitleVerticalConfig: EchartsTitleVerticalConfig,
262+
echartsTitleConfig:EchartsTitleConfig,
263+
264+
left:withDefault(NumberControl,trans('treemapChart.defaultLeft')),
265+
right:withDefault(NumberControl,trans('treemapChart.defaultRight')),
266+
top:withDefault(NumberControl,trans('treemapChart.defaultTop')),
267+
bottom:withDefault(NumberControl,trans('treemapChart.defaultBottom')),
268+
257269
tooltip: withDefault(BoolControl, true),
258-
legendVisibility: withDefault(BoolControl, true),
270+
labelVisibility: 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/treemapChartComp/treemapChartPropertyView.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,31 @@ export function treeChartPropertyView(
3131
</div>
3232
),
3333
})}
34-
{children.echartsTitle.propertyView({ label: trans("treemapChart.title") })}
35-
{children.tooltip.propertyView({label: trans("treemapChart.tooltip")})}
34+
35+
{children.echartsTitleConfig.getPropertyView()}
36+
{children.echartsTitleVerticalConfig.getPropertyView()}
37+
{children.echartsTitle.propertyView({ label: trans("treeChart.title"), tooltip: trans("echarts.titleTooltip") })}
38+
39+
{children.left.propertyView({ label: trans("treemapChart.left"), tooltip: trans("echarts.leftTooltip") })}
40+
{children.right.propertyView({ label: trans("treemapChart.right"), tooltip: trans("echarts.rightTooltip") })}
41+
{children.top.propertyView({ label: trans("treemapChart.top"), tooltip: trans("echarts.topTooltip") })}
42+
{children.bottom.propertyView({ label: trans("treemapChart.bottom"), tooltip: trans("echarts.bottomTooltip") })}
43+
44+
{children.tooltip.propertyView({label: trans("treemapChart.tooltip"), tooltip: trans("echarts.tooltipTooltip") })}
45+
{children.labelVisibility.propertyView({label: trans("echarts.labelVisibility"), tooltip: trans("echarts.labelVisibilityTooltip") })}
3646
</Section>
3747
<Section name={sectionNames.interaction}>
3848
{children.onEvent.propertyView()}
3949
</Section>
40-
<Section name={sectionNames.style}>
41-
{children.style?.getPropertyView()}
50+
51+
<Section name={sectionNames.chartStyle}>
52+
{children.chartStyle?.getPropertyView()}
53+
</Section>
54+
<Section name={sectionNames.titleStyle}>
55+
{children.titleStyle?.getPropertyView()}
56+
</Section>
57+
<Section name={sectionNames.detailStyle}>
58+
{children.detailStyle?.getPropertyView()}
4259
</Section>
4360
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
4461
</>

client/packages/lowcoder-comps/src/comps/treemapChartComp/treemapChartUtils.ts

Lines changed: 40 additions & 24 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,30 +137,44 @@ 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": [],
145-
"tooltip": props.tooltip&&{
146-
"trigger": "item",
147-
"formatter": "{b}: {c}",
148-
"axisPointer": {
149-
"type": "shadow"
150-
},
151-
},
152-
"series": [
153-
{
154-
"name": props.echartsConfig.type,
155-
"type": props.echartsConfig.type,
156-
'data': props.echartsOption.data,
157-
"breadcrumb": {
158-
"show": true
159-
}
160-
}
161-
]
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: [],
150+
tooltip: props.tooltip&&{
151+
trigger: "item",
152+
formatter: "{b}: {c}",
153+
axisPointer: {
154+
type: "shadow"
155+
},
156+
},
157+
series: [
158+
{
159+
name: props.echartsConfig.type,
160+
type: props.echartsConfig.type,
161+
left: `${props?.left}%`,
162+
right: `${props?.right}%`,
163+
bottom: `${props?.bottom}%`,
164+
top: `${props?.top}%`,
165+
data: props.echartsOption.data,
166+
breadcrumb: {
167+
show: true
168+
},
169+
color: props.echartsOption.color,
170+
itemStyle: {
171+
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle)
172+
},
173+
label: {
174+
...styleWrapper(props?.detailStyle, theme?.detailStyle, 12),
175+
}
176+
}
177+
]
162178
}
163179
return props.echartsOption ? opt : {};
164180

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ export const en = {
4343
title: 'Title',
4444
defaultTitle: 'Treemap Chart',
4545
tooltip: 'Tooltip',
46+
defaultLeft: "10",
47+
left: "Left",
48+
defaultRight: "10",
49+
right: "Right",
50+
defaultTop: "20",
51+
top: "Top",
52+
defaultBottom: "20",
53+
bottom: "Bottom",
4654
},
4755
treeChart: {
4856
treeType: 'Tree Chart Type',
@@ -347,6 +355,7 @@ export const en = {
347355
axisTickColorTooltip: "Select the Color of Axis Tick",
348356
axisLabelDistanceTooltip: "Select the Distance between the Axis labels and the Split line",
349357
tooltipTooltip: "Show or hide the Tooltip of the Chart.",
358+
labelVisibility: "Label",
350359
},
351360
chart: {
352361
delete: "Delete",

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

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -423,37 +423,39 @@ export const enObj: I18nObjects = {
423423
},
424424
defaultTreemapChartOption: {
425425
data: [
426-
{
427-
name: 'nodeA',
428-
value: 10,
429-
children: [
430-
{
431-
name: 'nodeAa',
432-
value: 4,
433-
},
434-
{
435-
name: 'nodeAb',
436-
value: 6
437-
}
438-
]
439-
},
440-
{
441-
name: 'nodeB',
442-
value: 20,
443-
children: [
444-
{
445-
name: 'nodeBa',
446-
value: 20,
447-
children: [
448-
{
449-
name: 'nodeBa1',
450-
value: 20
451-
}
452-
]
453-
}
454-
]
455-
}
456-
]
426+
{
427+
name: 'Category A',
428+
value: 100,
429+
children: [
430+
{
431+
name: 'Subcategory A1',
432+
value: 70,
433+
children: [
434+
{ name: 'Item A1-1', value: 10 },
435+
{ name: 'Item A1-2', value: 20 },
436+
{ name: 'Item A1-3', value: 10 },
437+
{ name: 'Item A1-4', value: 30 }
438+
]
439+
}
440+
]
441+
},
442+
{
443+
name: 'Category B',
444+
value: 80,
445+
children: [
446+
{
447+
name: 'Subcategory B1',
448+
value: 50,
449+
children: [
450+
{ name: 'Item B1-1', value: 20 },
451+
{ name: 'Item B1-2', value: 15 },
452+
{ name: 'Item B1-3', value: 15 }
453+
]
454+
},
455+
]
456+
}
457+
],
458+
color: ['#5470C6', '#91CC75', '#FAC858', '#6b51a1']
457459
},
458460
defaultSunburstChartOption: {
459461
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