Skip to content

Commit cbbbd52

Browse files
committed
Fixed an issue thant chart break when JSON data is invalid.
1 parent f1f500c commit cbbbd52

File tree

4 files changed

+60
-56
lines changed

4 files changed

+60
-56
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export function themeriverChartPropertyView(
4545
{children.top.propertyView({ label: trans("themeriverChart.top"), tooltip: trans("echarts.topTooltip") })}
4646
{children.bottom.propertyView({ label: trans("themeriverChart.bottom"), tooltip: trans("echarts.bottomTooltip") })}
4747

48-
{children.legendVisibility.propertyView({label: trans("echarts.legendVisibility")})}
49-
{children.tooltip.propertyView({label: trans("themeriverChart.tooltip")})}
48+
{children.legendVisibility.propertyView({label: trans("echarts.legendVisibility"), tooltip: trans("echarts.legendVisibilityTooltip")})}
49+
{children.tooltip.propertyView({label: trans("themeriverChart.tooltip"), tooltip: trans("echarts.tooltipTooltip")})}
5050
</Section>
5151
<Section name={sectionNames.interaction}>
5252
{children.onEvent.propertyView()}

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

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ export function getEchartsConfig(
136136
theme?: any,
137137
): EChartsOptionWithMap {
138138
if (props.mode === "json") {
139-
let opt={
139+
140+
console.log(props.echartsOption)
141+
let opt= props.echartsOption && {
140142
title: {
141143
text: props?.echartsTitle,
142144
top: props?.echartsTitleVerticalConfig.top,
@@ -146,67 +148,68 @@ export function getEchartsConfig(
146148
}
147149
},
148150
backgroundColor: parseBackground(props?.chartStyle?.background || theme?.chartStyle?.backgroundColor || "#FFFFFF"),
149-
"tooltip": props.tooltip&&{
150-
"trigger": "axis",
151-
"axisPointer": {
152-
"type": "line",
153-
"lineStyle": {
154-
"color": "rgba(0,0,0,0.2)",
155-
"width": 2,
156-
"type": "solid"
157-
}
158-
}
159-
},
151+
"tooltip": props.tooltip&&{
152+
"trigger": "axis",
153+
"axisPointer": {
154+
"type": "line",
155+
"lineStyle": {
156+
"color": "rgba(0,0,0,0.2)",
157+
"width": 2,
158+
"type": "solid"
159+
}
160+
}
161+
},
160162
legend: props.legendVisibility && {
161163
"top": props.echartsLegendConfig.top,
162164
"left": props.echartsLegendAlignConfig.left,
163165
"orient": props.echartsLegendOrientConfig.orient,
164-
data: Array.from(new Set(props.echartsOption.data.map(item => item[2]))),
166+
data: props?.echartsOption?.data && Array.from(new Set((props.echartsOption.data).map(item => item[2]))),
165167
textStyle: {
166168
...styleWrapper(props?.legendStyle, theme?.legendStyle, 13)
167169
}
168170
},
169-
"singleAxis": {
170-
left: `${props?.left}%`,
171-
right: `${props?.right}%`,
172-
bottom: `${props?.bottom}%`,
173-
top: `${props?.top}%`,
174-
"type": "time",
175-
"axisTick": {},
176-
"axisLabel": {
177-
...styleWrapper(props?.axisStyle, theme?.axisStyle, 13)
178-
},
179-
"splitLine": {},
180-
"axisPointer": {
181-
"animation": true,
182-
"label": {
183-
"show": true,
184-
"color": "#fff"
185-
}
186-
},
187-
"splitNumber": props?.splitNumber
188-
},
189-
"series": [
190-
{
191-
"type": props.echartsConfig.type,
192-
"data": props.echartsOption.data,
193-
"label": {
194-
"show": true,
195-
"position": "top",
196-
"fontSize": 12
197-
},
198-
itemStyle: {
199-
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle),
171+
"singleAxis": {
172+
left: `${props?.left}%`,
173+
right: `${props?.right}%`,
174+
bottom: `${props?.bottom}%`,
175+
top: `${props?.top}%`,
176+
"type": "time",
177+
"axisTick": {},
178+
"axisLabel": {
179+
...styleWrapper(props?.axisStyle, theme?.axisStyle, 13)
180+
},
181+
"splitLine": {},
182+
"axisPointer": {
183+
"animation": true,
184+
"label": {
185+
"show": true,
186+
"color": "#fff"
187+
}
188+
},
189+
"splitNumber": props?.splitNumber
200190
},
201-
"emphasis": {
202-
"itemStyle": {
203-
"shadowBlur": 20,
204-
"shadowColor": "rgba(0, 0, 0, 0.8)"
205-
}
206-
}
191+
"series": [
192+
{
193+
"type": props.echartsConfig.type,
194+
"data": props.echartsOption.data,
195+
"label": {
196+
"show": true,
197+
"position": "top",
198+
"fontSize": 12
199+
},
200+
itemStyle: {
201+
...chartStyleWrapper(props?.chartStyle, theme?.chartStyle),
202+
},
203+
"emphasis": {
204+
"itemStyle": {
205+
"shadowBlur": 20,
206+
"shadowColor": "rgba(0, 0, 0, 0.8)"
207+
}
208+
},
209+
color: props.echartsOption?.color && props.echartsOption.color
210+
},
211+
]
207212
}
208-
]
209-
}
210213

211214
return props.echartsOption ? opt : {};
212215

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const en = {
1919
bottom: 'Bottom',
2020
defaultBottom:'20',
2121
splitNumber: 'Split Number',
22-
defaultSplitNumber: '3'
22+
defaultSplitNumber: '4'
2323
},
2424
sunburstChart: {
2525
sunburstType: 'Sunburst Chart Type',

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ export const enObj: I18nObjects = {
492492
]
493493
},
494494
defaultThemeriverChartOption: {
495+
color: ['#5470C6', '#91CC75', '#FAC858', '#6b51a1'],
495496
data: [
496497
['2025-01-01', 12, 'Product A'],
497498
['2025-01-01', 10, 'Product B'],
@@ -513,7 +514,7 @@ export const enObj: I18nObjects = {
513514
['2025-01-05', 13, 'Product B'],
514515
['2025-01-05', 20, 'Product C'],
515516
['2025-01-05', 11, 'Product D']
516-
]
517+
],
517518
},
518519

519520
defaultMapJsonOption: defaultMapData,

0 commit comments

Comments
 (0)