Skip to content

Commit f1f500c

Browse files
committed
Added control fields and style fields to themeriver charts
1 parent d2f4f77 commit f1f500c

File tree

8 files changed

+116
-44
lines changed

8 files changed

+116
-44
lines changed

client/packages/lowcoder-comps/src/comps/radarChartComp/radarChartUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ export function getEchartsConfig(
136136
theme?: any,
137137
): EChartsOptionWithMap {
138138
if (props.mode === "json") {
139-
console.log(props?.detailStyle?.detailSize?.split('px')[0] || theme?.detailStyle?.detailSize.split('px')[0] || 3,
140-
props?.detailStyle?.detailSize?.split('px')[1] || theme?.detailStyle?.detailSize.split('px')[1] || 3)
141139
let opt={
142140
title: {
143141
text: props?.echartsTitle,

client/packages/lowcoder-comps/src/comps/sankeyChartComp/sankeyChartUtils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ export function getEchartsConfig(
136136
chartSize?: ChartSize,
137137
theme?: any,
138138
): EChartsOptionWithMap {
139-
console.log(props.echartsOption && props?.echartsOption?.data?.map(item => ({
140-
name: item.name,
141-
itemStyle: item.color && {color: item.color}
142-
})))
143139
if (props.mode === "json") {
144140
let opt={
145141
title: {

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

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
uiChildren,
1717
clickEvent,
1818
styleControl,
19-
EchartsStyle
19+
EchartDefaultChartStyle,
20+
EchartDefaultTextStyle,
2021
} from "lowcoder-sdk";
2122
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
2223
import { BarChartConfig } from "../chartComp/chartConfigs/barChartConfig";
@@ -31,6 +32,10 @@ import { SeriesListComp } from "../chartComp/seriesComp";
3132
import { EChartsOption } from "echarts";
3233
import { i18nObjs, trans } from "i18n/comps";
3334
import { ThemeriverChartConfig } from "comps/chartComp/chartConfigs/themeriverChartConfig";
35+
import {EchartsTitleVerticalConfig} from "../chartComp/chartConfigs/echartsTitleVerticalConfig";
36+
import {EchartsTitleConfig} from "../chartComp/chartConfigs/echartsTitleConfig";
37+
import {EchartsLegendOrientConfig} from "../chartComp/chartConfigs/echartsLegendOrientConfig";
38+
import {EchartsLegendAlignConfig} from "../chartComp/chartConfigs/echartsLegendAlignConfig";
3439

3540
export const ChartTypeOptions = [
3641
{
@@ -253,14 +258,27 @@ let chartJsonModeChildren: any = {
253258
echartsLegendConfig: EchartsLegendConfig,
254259
echartsLabelConfig: EchartsLabelConfig,
255260
echartsConfig: EchartsOptionComp,
256-
// style: styleControl(EchartsStyle, 'style'),
261+
echartsTitleVerticalConfig: EchartsTitleVerticalConfig,
262+
echartsTitleConfig:EchartsTitleConfig,
263+
echartsLegendOrientConfig: EchartsLegendOrientConfig,
264+
echartsLegendAlignConfig: EchartsLegendAlignConfig,
265+
266+
splitNumber:withDefault(NumberControl,trans('themeriverChart.defaultSplitNumber')),
267+
left:withDefault(NumberControl,trans('themeriverChart.defaultLeft')),
268+
right:withDefault(NumberControl,trans('themeriverChart.defaultRight')),
269+
top:withDefault(NumberControl,trans('themeriverChart.defaultTop')),
270+
bottom:withDefault(NumberControl,trans('themeriverChart.defaultBottom')),
271+
257272
tooltip: withDefault(BoolControl, true),
258273
legendVisibility: withDefault(BoolControl, true),
259274
}
260-
if (EchartsStyle) {
275+
if (EchartDefaultChartStyle && EchartDefaultTextStyle) {
261276
chartJsonModeChildren = {
262277
...chartJsonModeChildren,
263-
style: styleControl(EchartsStyle, 'style'),
278+
chartStyle: styleControl(EchartDefaultChartStyle, 'chartStyle'),
279+
titleStyle: styleControl(EchartDefaultTextStyle, 'titleStyle'),
280+
axisStyle: styleControl(EchartDefaultTextStyle, 'axisStyle'),
281+
legendStyle: styleControl(EchartDefaultTextStyle, 'legendStyle'),
264282
}
265283
}
266284
const chartMapModeChildren = {

client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartPropertyView.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,43 @@ export function themeriverChartPropertyView(
3131
</div>
3232
),
3333
})}
34-
{children.echartsTitle.propertyView({ label: trans("themeriverChart.title") })}
34+
35+
{children.echartsTitleConfig.getPropertyView()}
36+
{children.echartsTitleVerticalConfig.getPropertyView()}
37+
{children.legendVisibility.getView() && children.echartsLegendAlignConfig.getPropertyView()}
38+
{children.legendVisibility.getView() && children.echartsLegendConfig.getPropertyView()}
39+
{children.legendVisibility.getView() && children.echartsLegendOrientConfig.getPropertyView()}
40+
41+
{children.echartsTitle.propertyView({ label: trans("themeriverChart.title"), tooltip: trans("echarts.titleTooltip") })}
42+
{children.splitNumber.propertyView({ label: trans("themeriverChart.splitNumber"), tooltip: trans("echarts.splitNumberTooltip") })}
43+
{children.left.propertyView({ label: trans("themeriverChart.left"), tooltip: trans("echarts.leftTooltip") })}
44+
{children.right.propertyView({ label: trans("themeriverChart.right"), tooltip: trans("echarts.rightTooltip") })}
45+
{children.top.propertyView({ label: trans("themeriverChart.top"), tooltip: trans("echarts.topTooltip") })}
46+
{children.bottom.propertyView({ label: trans("themeriverChart.bottom"), tooltip: trans("echarts.bottomTooltip") })}
47+
48+
{children.legendVisibility.propertyView({label: trans("echarts.legendVisibility")})}
3549
{children.tooltip.propertyView({label: trans("themeriverChart.tooltip")})}
3650
</Section>
3751
<Section name={sectionNames.interaction}>
3852
{children.onEvent.propertyView()}
3953
</Section>
40-
<Section name={sectionNames.style}>
41-
{children.style?.getPropertyView()}
54+
55+
<Section name={sectionNames.chartStyle}>
56+
{children.chartStyle?.getPropertyView()}
4257
</Section>
58+
<Section name={sectionNames.titleStyle}>
59+
{children.titleStyle?.getPropertyView()}
60+
</Section>
61+
<Section name={sectionNames.xAxisStyle}>
62+
{children.axisStyle?.getPropertyView()}
63+
</Section>
64+
{
65+
children.legendVisibility.getView() &&
66+
<Section name={sectionNames.legendStyle}>
67+
{children.legendStyle?.getPropertyView()}
68+
</Section>
69+
}
70+
4371
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
4472
</>
4573
);

client/packages/lowcoder-comps/src/comps/themeriverChartComp/themeriverChartUtils.ts

Lines changed: 31 additions & 9 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,12 +137,15 @@ 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,
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"),
144149
"tooltip": props.tooltip&&{
145150
"trigger": "axis",
146151
"axisPointer": {
@@ -152,11 +157,25 @@ export function getEchartsConfig(
152157
}
153158
}
154159
},
160+
legend: props.legendVisibility && {
161+
"top": props.echartsLegendConfig.top,
162+
"left": props.echartsLegendAlignConfig.left,
163+
"orient": props.echartsLegendOrientConfig.orient,
164+
data: Array.from(new Set(props.echartsOption.data.map(item => item[2]))),
165+
textStyle: {
166+
...styleWrapper(props?.legendStyle, theme?.legendStyle, 13)
167+
}
168+
},
155169
"singleAxis": {
170+
left: `${props?.left}%`,
171+
right: `${props?.right}%`,
172+
bottom: `${props?.bottom}%`,
173+
top: `${props?.top}%`,
156174
"type": "time",
157-
"bottom": 50,
158175
"axisTick": {},
159-
"axisLabel": {},
176+
"axisLabel": {
177+
...styleWrapper(props?.axisStyle, theme?.axisStyle, 13)
178+
},
160179
"splitLine": {},
161180
"axisPointer": {
162181
"animation": true,
@@ -165,7 +184,7 @@ export function getEchartsConfig(
165184
"color": "#fff"
166185
}
167186
},
168-
"splitNumber": 30
187+
"splitNumber": props?.splitNumber
169188
},
170189
"series": [
171190
{
@@ -176,6 +195,9 @@ export function getEchartsConfig(
176195
"position": "top",
177196
"fontSize": 12
178197
},
198+
itemStyle: {
199+
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle),
200+
},
179201
"emphasis": {
180202
"itemStyle": {
181203
"shadowBlur": 20,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ export const en = {
1010
title: 'Title',
1111
defaultTitle: 'Themeriver Chart',
1212
tooltip: 'Tooltip',
13+
left: 'Left',
14+
defaultLeft:'15',
15+
right: 'Right',
16+
defaultRight:'10',
17+
top: 'Top',
18+
defaultTop:'15',
19+
bottom: 'Bottom',
20+
defaultBottom:'20',
21+
splitNumber: 'Split Number',
22+
defaultSplitNumber: '3'
1323
},
1424
sunburstChart: {
1525
sunburstType: 'Sunburst Chart Type',

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -493,27 +493,27 @@ export const enObj: I18nObjects = {
493493
},
494494
defaultThemeriverChartOption: {
495495
data: [
496-
["2024-01-01", 10, "Category A"],
497-
["2024-01-02", 15, "Category A"],
498-
["2024-01-03", 20, "Category A"],
499-
["2024-01-04", 25, "Category A"],
500-
["2024-01-05", 30, "Category A"],
501-
["2024-01-06", 35, "Category A"],
502-
["2024-01-07", 40, "Category A"],
503-
["2024-01-08", 45, "Category A"],
504-
["2024-01-09", 50, "Category A"],
505-
["2024-01-10", 55, "Category A"],
506-
["2024-01-01", 15, "Category B"],
507-
["2024-01-02", 20, "Category B"],
508-
["2024-01-03", 25, "Category B"],
509-
["2024-01-04", 30, "Category B"],
510-
["2024-01-05", 35, "Category B"],
511-
["2024-01-06", 40, "Category B"],
512-
["2024-01-07", 45, "Category B"],
513-
["2024-01-08", 50, "Category B"],
514-
["2024-01-09", 55, "Category B"],
515-
["2024-01-10", 60, "Category B"]
516-
]
496+
['2025-01-01', 12, 'Product A'],
497+
['2025-01-01', 10, 'Product B'],
498+
['2025-01-01', 15, 'Product C'],
499+
['2025-01-01', 8, 'Product D'],
500+
['2025-01-02', 14, 'Product A'],
501+
['2025-01-02', 9, 'Product B'],
502+
['2025-01-02', 16, 'Product C'],
503+
['2025-01-02', 7, 'Product D'],
504+
['2025-01-03', 16, 'Product A'],
505+
['2025-01-03', 12, 'Product B'],
506+
['2025-01-03', 18, 'Product C'],
507+
['2025-01-03', 10, 'Product D'],
508+
['2025-01-04', 20, 'Product A'],
509+
['2025-01-04', 15, 'Product B'],
510+
['2025-01-04', 22, 'Product C'],
511+
['2025-01-04', 12, 'Product D'],
512+
['2025-01-05', 18, 'Product A'],
513+
['2025-01-05', 13, 'Product B'],
514+
['2025-01-05', 20, 'Product C'],
515+
['2025-01-05', 11, 'Product D']
516+
]
517517
},
518518

519519
defaultMapJsonOption: defaultMapData,

0 commit comments

Comments
 (0)