Skip to content

Commit 6056207

Browse files
committed
Fixed some issues and added border and detailSize to Detail Style.
1 parent d7e5a2d commit 6056207

File tree

8 files changed

+146
-72
lines changed

8 files changed

+146
-72
lines changed

client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartConstants.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
styleControl,
1919
EchartDefaultChartStyle,
2020
EchartDefaultTextStyle,
21-
ColorControl
21+
ColorControl,
22+
EchartDefaultDetailStyle
2223
} from "lowcoder-sdk";
2324
import { RecordConstructorToComp, RecordConstructorToView } from "lowcoder-core";
2425
import { BarChartConfig } from "../chartComp/chartConfigs/barChartConfig";
@@ -303,8 +304,11 @@ let chartJsonModeChildren: any = {
303304
endAngle:withDefault(NumberControl,trans('gaugeChart.defaultEndAngle')),
304305
splitNumber:withDefault(NumberControl,trans('gaugeChart.defaultSplitNumber')),
305306
pointerLength:withDefault(NumberControl,trans('gaugeChart.defaultPointerLength')),
307+
barometerPointerLength:withDefault(NumberControl,trans('gaugeChart.defaultBarometerPointerLength')),
306308
pointerWidth:withDefault(NumberControl,trans('gaugeChart.defaultPointerWidth')),
309+
barometerPointerWidth:withDefault(NumberControl,trans('gaugeChart.defaultBarometerPointerWidth')),
307310
pointer_Y:withDefault(NumberControl,trans('gaugeChart.defaultPointer_Y')),
311+
barometerPointer_Y:withDefault(NumberControl,trans('gaugeChart.defaultBarometerPointer_Y')),
308312
pointerIcon:withDefault(StringControl),
309313
gradePointerIcon:withDefault(StringControl, trans('gaugeChart.gradeDefaultPointerIcon')),
310314
clockPointerIcon:withDefault(StringControl, trans('gaugeChart.clockDefaultPointerIcon')),
@@ -326,13 +330,13 @@ let chartJsonModeChildren: any = {
326330

327331
}
328332

329-
if (EchartDefaultChartStyle && EchartDefaultTextStyle) {
333+
if (EchartDefaultChartStyle && EchartDefaultTextStyle && EchartDefaultDetailStyle) {
330334
chartJsonModeChildren = {
331335
...chartJsonModeChildren,
332336
chartStyle: styleControl(EchartDefaultChartStyle, 'chartStyle'),
333337
titleStyle: styleControl(EchartDefaultTextStyle, 'titleStyle'),
334338
labelStyle: styleControl(EchartDefaultTextStyle, 'labelStyle'),
335-
legendStyle: styleControl(EchartDefaultTextStyle, 'legendStyle'),
339+
legendStyle: styleControl(EchartDefaultDetailStyle, 'legendStyle'),
336340
axisLabelStyle: styleControl(EchartDefaultTextStyle, 'axisLabelStyle'),
337341
axisLabelStyleOutline: styleControl(EchartDefaultTextStyle, 'axisLabelStyleOutline'),
338342
}

client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartPropertyView.tsx

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@ export function gaugeChartPropertyView(
290290
{children.chartType.propertyView({label: trans("gaugeChart.chartType"), tooltip: trans("gaugeChart.chartTypeTooltip") })}
291291
{children.echartsTitleConfig.getPropertyView()}
292292
{children.echartsTitle.propertyView({ label: trans("gaugeChart.title"), tooltip: trans("echarts.titleTooltip") })}
293-
{/* {children.left.propertyView({ label: trans("gaugeChart.left") })}
294-
{children.top.propertyView({ label: trans("gaugeChart.top") })}
295-
{children.bottom.propertyView({ label: trans("gaugeChart.bottom") })}
296-
{children.width.propertyView({ label: trans("gaugeChart.width") })} */}
297293
{children.radius.propertyView({ label: trans("gaugeChart.radius"), tooltip: trans("echarts.radiusTooltip") })}
298294
{children.min.propertyView({ label: trans("gaugeChart.min"), tooltip: trans("echarts.minTooltip") })}
299295
{children.max.propertyView({ label: trans("gaugeChart.max"), tooltip: trans("echarts.maxTooltip") })}
@@ -302,14 +298,15 @@ export function gaugeChartPropertyView(
302298
{children.startAngle.propertyView({ label: trans("gaugeChart.startAngle"), tooltip: trans("echarts.startAngleTooltip") })}
303299
{children.endAngle.propertyView({ label: trans("gaugeChart.endAngle"), tooltip: trans("echarts.endAngleTooltip") })}
304300
{children.splitNumber.propertyView({ label: trans("gaugeChart.splitNumber"), tooltip: trans("echarts.splitNumberTooltip") })}
301+
{children.axisTickLength.propertyView({ label: trans("gaugeChart.axisTickLength"), tooltip: trans("echarts.axisTickLengthTooltip") })}
302+
{children.axisTickWidth.propertyView({ label: trans("gaugeChart.axisTickWidth"), tooltip: trans("echarts.axisTickWidthTooltip") })}
303+
{children.axisTickColor.propertyView({ label: trans("gaugeChart.axisTickColor"), tooltip: trans("echarts.axisTickColorTooltip") })}
305304
{children.pointerLength.propertyView({ label: trans("gaugeChart.pointerLength"), tooltip: trans("echarts.pointerLengthTooltip") })}
306305
{children.pointerWidth.propertyView({ label: trans("gaugeChart.pointerWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
307306
{children.pointer_Y.propertyView({ label: trans("gaugeChart.pointer_Y"), tooltip: trans("gaugeChart.pointer_Y_Tooltip") })}
308307
{children.pointerIcon.propertyView({ label: trans("gaugeChart.pointerIcon"), tooltip: trans("gaugeChart.pointerIconTooltip") })}
309-
{children.progressBar.getView() && children.progressBarWidth.propertyView({ label: trans("gaugeChart.progressBarWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
310-
{/* {children.gap.propertyView({ label: trans("gaugeChart.gap") })} */}
308+
{children.progressBarWidth.propertyView({ label: trans("gaugeChart.progressBarWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
311309
{children.tooltip.propertyView({ label: trans("gaugeChart.tooltip"), tooltip: trans("echarts.tooltipVisibilityTooltip") })}
312-
{children.progressBar.propertyView({ label: trans("gaugeChart.progressBar"), tooltip: trans("echarts.progressBarVisibilityTooltip") })}
313310
{children.roundCap.propertyView({ label: trans("gaugeChart.roundCap"), tooltip: trans("echarts.roundCapVisibilityTooltip") })}
314311
</Section>
315312
<Section name={sectionNames.interaction}>
@@ -355,24 +352,13 @@ export function gaugeChartPropertyView(
355352
{children.chartType.propertyView({label: trans("gaugeChart.chartType"), tooltip: trans("gaugeChart.chartTypeTooltip") })}
356353
{children.echartsTitleConfig.getPropertyView()}
357354
{children.echartsTitle.propertyView({ label: trans("gaugeChart.title"), tooltip: trans("echarts.titleTooltip") })}
358-
{/* {children.left.propertyView({ label: trans("gaugeChart.left") })}
359-
{children.top.propertyView({ label: trans("gaugeChart.top") })}
360-
{children.bottom.propertyView({ label: trans("gaugeChart.bottom") })}
361-
{children.width.propertyView({ label: trans("gaugeChart.width") })} */}
362355
{children.radius.propertyView({ label: trans("gaugeChart.radius"), tooltip: trans("echarts.radiusTooltip") })}
363356
{children.min.propertyView({ label: trans("gaugeChart.min"), tooltip: trans("echarts.minTooltip") })}
364357
{children.max.propertyView({ label: trans("gaugeChart.max"), tooltip: trans("echarts.maxTooltip") })}
365358
{children.position_x.propertyView({ label: trans("gaugeChart.position_x"), tooltip: trans("echarts.positionChart_x_Tooltip") })}
366359
{children.position_y.propertyView({ label: trans("gaugeChart.position_y"), tooltip: trans("echarts.positionChart_x_Tooltip") })}
367-
{children.startAngle.propertyView({ label: trans("gaugeChart.startAngle"), tooltip: trans("echarts.startAngleTooltip") })}
368-
{children.endAngle.propertyView({ label: trans("gaugeChart.endAngle"), tooltip: trans("echarts.endAngleTooltip") })}
369-
{children.splitNumber.propertyView({ label: trans("gaugeChart.splitNumber"), tooltip: trans("echarts.splitNumberTooltip") })}
370-
{children.pointerLength.propertyView({ label: trans("gaugeChart.pointerLength"), tooltip: trans("echarts.pointerLengthTooltip") })}
371-
{children.pointerWidth.propertyView({ label: trans("gaugeChart.pointerWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
372-
{children.progressBar.getView() && children.progressBarWidth.propertyView({ label: trans("gaugeChart.progressBarWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
373-
{/* {children.gap.propertyView({ label: trans("gaugeChart.gap") })} */}
360+
{children.progressBarWidth.propertyView({ label: trans("gaugeChart.progressBarWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
374361
{children.tooltip.propertyView({ label: trans("gaugeChart.tooltip"), tooltip: trans("echarts.tooltipVisibilityTooltip") })}
375-
{children.progressBar.propertyView({ label: trans("gaugeChart.progressBar"), tooltip: trans("echarts.progressBarVisibilityTooltip") })}
376362
{children.roundCap.propertyView({ label: trans("gaugeChart.roundCap"), tooltip: trans("echarts.roundCapVisibilityTooltip") })}
377363
</Section>
378364
<Section name={sectionNames.interaction}>
@@ -422,9 +408,9 @@ export function gaugeChartPropertyView(
422408
{children.position_y.propertyView({ label: trans("gaugeChart.position_y"), tooltip: trans("echarts.positionChart_x_Tooltip") })}
423409
{children.startAngle.propertyView({ label: trans("gaugeChart.startAngle"), tooltip: trans("echarts.startAngleTooltip") })}
424410
{children.endAngle.propertyView({ label: trans("gaugeChart.endAngle"), tooltip: trans("echarts.endAngleTooltip") })}
425-
{children.pointerLength.propertyView({ label: trans("gaugeChart.pointerLength"), tooltip: trans("echarts.pointerLengthTooltip") })}
426-
{children.pointerWidth.propertyView({ label: trans("gaugeChart.pointerWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
427-
{children.pointer_Y.propertyView({ label: trans("gaugeChart.pointer_Y"), tooltip: trans("gaugeChart.pointer_Y_Tooltip") })}
411+
{children.barometerPointerLength.propertyView({ label: trans("gaugeChart.pointerLength"), tooltip: trans("echarts.pointerLengthTooltip") })}
412+
{children.barometerPointerWidth.propertyView({ label: trans("gaugeChart.pointerWidth"), tooltip: trans("echarts.pointerWidthTooltip") })}
413+
{children.barometerPointer_Y.propertyView({ label: trans("gaugeChart.pointer_Y"), tooltip: trans("gaugeChart.pointer_Y_Tooltip") })}
428414
{children.barometerPointerIcon.propertyView({ label: trans("gaugeChart.pointerIcon"), tooltip: trans("gaugeChart.pointerIconTooltip") })}
429415
{children.tooltip.propertyView({ label: trans("gaugeChart.tooltip"), tooltip: trans("echarts.tooltipVisibilityTooltip") })}
430416
</Section>

client/packages/lowcoder-comps/src/comps/gaugeChartComp/gaugeChartUtils.ts

Lines changed: 62 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function getEchartsConfig(
137137
theme?: any,
138138
): EChartsOptionWithMap {
139139

140-
const styleWrapper = (styleContainer: any, themeContainer: any, defaultFontSize=18, defaultFontColor='#000000') => {
140+
const styleWrapper = (styleContainer: any, themeContainer: any, defaultFontSize=18, defaultFontColor='#000000', detailBorderWidth = 0, defaultBackgroundColor = "" ) => {
141141

142142
return {
143143
"fontFamily": styleContainer?.chartFontFamily || themeContainer?.fontFamily || 'Arial, sans-serif',
@@ -148,7 +148,14 @@ export function getEchartsConfig(
148148
"textShadowColor": styleContainer?.chartShadowColor || themeContainer?.shadowColor,
149149
"textShadowBlur": styleContainer?.chartBoxShadow?.split('px')[0] || themeContainer?.boxShadow?.split('px')[0],
150150
"textShadowOffsetX": styleContainer?.chartBoxShadow?.split('px')[1] || themeContainer?.boxShadow?.split('px')[1],
151-
"textShadowOffsetY": styleContainer?.chartBoxShadow?.split('px')[2] || themeContainer?.boxShadow?.split('px')[2]
151+
"textShadowOffsetY": styleContainer?.chartBoxShadow?.split('px')[2] || themeContainer?.boxShadow?.split('px')[2],
152+
"borderColor": styleContainer?.chartBorderColor || themeContainer?.borderColor || 'inherit',
153+
"borderWidth": styleContainer?.chartBorderWidth || themeContainer?.borderWidth || detailBorderWidth,
154+
"borderType": styleContainer?.chartBorderStyle || themeContainer?.borderType,
155+
"borderRadius": styleContainer?.chartBorderRadius || themeContainer?.borderRadius,
156+
"backgroundColor": styleContainer?.chartBackgroundColor || themeContainer?.backgroundColor || defaultBackgroundColor,
157+
"width": styleContainer?.detailSize?.split('px')[0] || themeContainer?.detailSize.split('px')[0] || 24,
158+
"height": styleContainer?.detailSize?.split('px')[1] || themeContainer?.detailSize.split('px')[1] || 12,
152159
}
153160

154161
}
@@ -304,6 +311,7 @@ export function getEchartsConfig(
304311
]
305312
}
306313

314+
console.log(props?.legendStyle)
307315
let gradeGaugeOpt = {
308316
...basicStyle,
309317
series: [
@@ -367,34 +375,36 @@ export function getEchartsConfig(
367375
]
368376
}
369377

378+
console.log(props?.barometerGaugeOption?.data)
379+
370380
let multiGaugeOpt = {
371381
...basicStyle,
372382
series: [
373383
{
374384
...basicSeries,
375385
type: 'gauge',
376-
pointer: {
377-
...basicSeries.pointer,
378-
icon: props.pointerIcon || 'path://M2.9,0.7L2.9,0.7c1.4,0,2.6,1.2,2.6,2.6v115c0,1.4-1.2,2.6-2.6,2.6l0,0c-1.4,0-2.6-1.2-2.6-2.6V3.3C0.3,1.9,1.4,0.7,2.9,0.7z',
379-
offsetCenter: [0, '8%']
386+
anchor: {
387+
show: true,
388+
showAbove: true,
389+
size: 10,
390+
itemStyle: {
391+
color: props?.multiTitleGaugeOption?.data[0]["value"].slice(-1)[0]
392+
}
380393
},
381394
progress: {
382-
show: true,
383395
overlap: true,
384-
roundCap: true
385-
},
386-
axisLine: {
387-
roundCap: true
396+
...progress
388397
},
389398

390-
data: props.multiTitleGaugeOption.data[0].value.map(item => ({
399+
data: props?.multiTitleGaugeOption?.data && props?.multiTitleGaugeOption?.data[0]?.value?.map(item => ({
391400
value: item.value,
392401
name: item.title,
393402
title: {
394403
offsetCenter: item.titlePosition
395404
},
396405
detail: {
397-
offsetCenter: item.valuePosition
406+
offsetCenter: item.valuePosition,
407+
398408
},
399409
itemStyle: {
400410
color: item.color
@@ -410,10 +420,7 @@ export function getEchartsConfig(
410420
...styleWrapper(props?.labelStyle, theme?.labelStyle, 16),
411421
},
412422
detail: {
413-
width: 30,
414-
height: 12,
415-
...styleWrapper(props?.legendStyle, theme?.legendStyle, 16, '#ffffff'),
416-
backgroundColor: 'inherit',
423+
...styleWrapper(props?.legendStyle, theme?.legendStyle, 16, '#ffffff', 0, 'inherit'),
417424
formatter: props?.multiTitleGaugeOption?.data?.map(data => data.formatter)[0],
418425
}
419426
}
@@ -458,7 +465,7 @@ export function getEchartsConfig(
458465
}
459466
},
460467
axisLabel: {
461-
distance: Number(props?.temperatureProgressBarWidth) - Number(props.temperatureAxisLabelDistance) + Number(props.axisTickLength) * 2,
468+
distance: Number(props?.temperatureProgressBarWidth) - Number(props.temperatureAxisLabelDistance),
462469
...styleWrapper(props?.axisLabelStyle, theme?.axisLabelStyle, 20, "#999"),
463470
},
464471
detail: {
@@ -528,20 +535,17 @@ export function getEchartsConfig(
528535
show: false
529536
},
530537
progress: {
538+
"roundCap": props.roundCap,
531539
show: true,
540+
width: props?.progressBarWidth,
532541
overlap: false,
533-
roundCap: true,
534542
clip: false,
535-
itemStyle: {
536-
borderWidth: 1,
537-
borderColor: 'inherit'
538-
}
539-
},
540-
axisLine: {
541-
lineStyle: {
542-
width: 20 // Reduced from 40
543-
}
544543
},
544+
// axisLine: {
545+
// lineStyle: {
546+
// width: 20 // Reduced from 40
547+
// }
548+
// },
545549
splitLine: {
546550
show: false
547551
},
@@ -551,7 +555,7 @@ export function getEchartsConfig(
551555
axisLabel: {
552556
show: false
553557
},
554-
data: props.ringGaugeOption.data[0].value.map(item => ({
558+
data: props?.ringGaugeOption?.data && props?.ringGaugeOption?.data[0]?.value.map(item => ({
555559
value: item.value,
556560
name: item.title,
557561
title: {
@@ -573,12 +577,7 @@ export function getEchartsConfig(
573577
...styleWrapper(props?.labelStyle, theme?.labelStyle, 16),
574578
},
575579
detail: {
576-
width: 40,
577-
height: 12,
578-
borderRadius: 20,
579-
borderWidth: 1,
580-
...styleWrapper(props?.legendStyle, theme?.legendStyle, 16, 'inherit'),
581-
borderColor: 'inherit',
580+
...styleWrapper(props?.legendStyle, theme?.legendStyle, 16, 'inherit', 1, ''),
582581
formatter: props?.multiTitleGaugeOption?.data?.map(data => data.formatter)[0],
583582
}
584583
}
@@ -587,7 +586,7 @@ export function getEchartsConfig(
587586

588587
let barometerGaugeOpt = {
589588
...basic,
590-
series: [
589+
series: props?.barometerGaugeOption?.data && [
591590
{
592591
...basicSeries,
593592
type: 'gauge',
@@ -603,32 +602,43 @@ export function getEchartsConfig(
603602
}
604603
},
605604
splitLine: {
606-
distance: -12, // Reduced from -18
607-
length: Number(props?.barometerGaugeOption?.data[0]?.outline?.axisTickLength) * 2,
605+
distance: -Number(props?.barometerGaugeOption?.data[0]?.outline?.progressBarWidth),
606+
length: -Number(props?.barometerGaugeOption?.data[0]?.outline?.axisTickLength) * 2,
608607
lineStyle: {
609608
color: props?.barometerGaugeOption?.data[0]?.outline?.color,
610609
width: Number(props?.barometerGaugeOption?.data[0]?.outline?.axisTickWidth) * 1.5
611610
}
612611
},
613612
axisTick: {
614-
distance: -8, // Reduced from -12
615-
length: props?.barometerGaugeOption?.data[0]?.outline?.axisTickLength,
613+
distance: -Number(props?.barometerGaugeOption?.data[0]?.outline?.progressBarWidth),
614+
length: -Number(props?.barometerGaugeOption?.data[0]?.outline?.axisTickLength),
616615
lineStyle: {
617616
color: props?.barometerGaugeOption?.data[0]?.outline?.color,
618617
width: props?.barometerGaugeOption?.data[0]?.outline?.axisTickWidth
619618
}
620619
},
621620
axisLabel: {
622-
distance: -30, // Reduced from -50 to bring labels closer
623-
...styleWrapper(props?.axisLabelStyle, theme?.axisLabelStyle, 14, '#f00')
621+
distance: Number(props?.barometerGaugeOption?.data[0]?.outline?.progressBarWidth) - 20,
622+
...styleWrapper(props?.axisLabelStyle, theme?.axisLabelStyle, 13, '#c80707')
624623
},
625624
pointer: {
626625
...basicSeries.pointer,
627626
icon: props?.barometerPointerIcon,
627+
length: `${props?.barometerPointerLength}%`,
628+
width: props?.barometerPointerWidth,
629+
offsetCenter: [0, `${-Number(props.barometerPointer_Y)}%`],
628630
itemStyle: {
629631
color: props?.barometerGaugeOption?.data[0]?.inline?.color
630632
}
631633
},
634+
anchor: {
635+
show: true,
636+
size: 10,
637+
itemStyle: {
638+
borderColor: '#000',
639+
borderWidth: 1
640+
}
641+
},
632642
detail: {
633643
valueAnimation: true,
634644
precision: 2, // Increase precision or keep as is
@@ -637,7 +647,7 @@ export function getEchartsConfig(
637647
},
638648
title: {
639649
offsetCenter: [0, '-40%'], // Adjust title placement for smaller chart
640-
...styleWrapper(props?.labelStyle, theme?.labelStyle, 14)
650+
...styleWrapper(props?.labelStyle, theme?.labelStyle, 13)
641651
},
642652
data: [
643653
{
@@ -654,6 +664,13 @@ export function getEchartsConfig(
654664
center: [`${props?.position_x}%`, `${props?.position_y}%`],
655665
splitNumber: props?.barometerGaugeOption?.data[0]?.inline?.splitNumber,
656666
radius: props?.barometerGaugeOption?.data[0]?.inline?.radius,
667+
anchor: {
668+
show: true,
669+
size: 6,
670+
itemStyle: {
671+
color: '#000'
672+
}
673+
},
657674
axisLine: {
658675
lineStyle: {
659676
color: [[1, props?.barometerGaugeOption?.data[0]?.inline?.color]],
@@ -677,8 +694,8 @@ export function getEchartsConfig(
677694
}
678695
},
679696
axisLabel: {
680-
distance: 6,
681-
...styleWrapper(props?.axisLabelStyleOutline, theme?.axisLabelStyleOutline, 14, '#000'),
697+
distance: Number(props?.barometerGaugeOption?.data[0]?.inline?.progressBarWidth) + 6,
698+
...styleWrapper(props?.axisLabelStyleOutline, theme?.axisLabelStyleOutline, 13, '#000'),
682699
},
683700
pointer: {
684701
show: false

0 commit comments

Comments
 (0)