@@ -7,7 +7,10 @@ import { useShapeProps } from '../../../shapes/use-shape-props.hook';
77
88import { BASIC_SHAPE } from '@/common/components/mock-components/front-components/shape.const' ;
99import { useGroupShapeProps } from '../../mock-components.utils' ;
10- import { getGaugePartsText } from './gauge.utils' ;
10+ import {
11+ endsWhithPercentageSymbol ,
12+ extractNumbersAsTwoDigitString ,
13+ } from './gauge.utils' ;
1114
1215const gaugeShapeSizeRestrictions : ShapeSizeRestrictions = {
1316 minWidth : 70 ,
@@ -42,7 +45,6 @@ export const Gauge = forwardRef<any, ShapeProps>((props, ref) => {
4245 ) ;
4346
4447 const { width : restrictedWidth , height : restrictedHeight } = restrictedSize ;
45- const { gaugeValue } = getGaugePartsText ( text ) ;
4648 const { fontSize } = useShapeProps ( otherProps , BASIC_SHAPE ) ;
4749 const commonGroupProps = useGroupShapeProps (
4850 props ,
@@ -52,19 +54,19 @@ export const Gauge = forwardRef<any, ShapeProps>((props, ref) => {
5254 ) ;
5355 const { stroke, fill, textColor } = useShapeProps ( otherProps , BASIC_SHAPE ) ;
5456
55- const parsedValue = gaugeValue ?. trim ( ) . endsWith ( '%' )
56- ? gaugeValue . slice ( 0 , - 1 )
57- : gaugeValue ;
58- const progress = Number ( parsedValue ) || 10 ;
59- const showPercentage = gaugeValue ?. trim ( ) . endsWith ( '%' ) ;
57+ const numericPart = extractNumbersAsTwoDigitString ( text ) ;
58+
59+ const progress = Number ( numericPart ) ;
60+ const displayValue = endsWhithPercentageSymbol ( text )
61+ ? `${ numericPart } %`
62+ : numericPart ;
6063
6164 const size = Math . min ( restrictedWidth , restrictedHeight ) ;
6265 const strokeWidth = Math . min ( restrictedWidth , restrictedHeight ) / 10 ;
6366 const radius = ( size - strokeWidth ) / 2 ;
6467 const center = size / 2 ;
6568 const angle = ( progress / 100.01 ) * 360 ;
6669 const fontSizeScaled = fontSize * ( size / 80 ) ;
67- console . log ( radius , center , angle , fontSizeScaled ) ;
6870 const arcPath = ( ) => {
6971 const startAngle = - 90 ;
7072 const endAngle = startAngle + angle ;
@@ -95,15 +97,12 @@ export const Gauge = forwardRef<any, ShapeProps>((props, ref) => {
9597 x = { center - 10 - radius / 2 }
9698 y = { center - fontSizeScaled / 2 }
9799 width = { center + 10 }
98- text = { ( parsedValue || '10%' ) + ( showPercentage ? '%' : '' ) }
100+ text = { displayValue }
99101 fontFamily = "Arial, sans-serif"
100102 fontSize = { fontSizeScaled }
101103 align = "center"
102104 fill = { textColor }
103105 fontStyle = "bold"
104- letterSpacing = { 1 }
105- wrap = "none"
106- ellipsis = { true }
107106 />
108107 </ Group >
109108 ) ;
0 commit comments