@@ -21,6 +21,8 @@ export type BarChartInfo = {
2121 traffic2xxTotal ?: string
2222 traffic4xxTotal ?: string
2323 traffic5xxTotal ?: string
24+ max ?: string | number
25+ min ?: string | number
2426}
2527
2628type ServiceBarCharProps = {
@@ -29,9 +31,17 @@ type ServiceBarCharProps = {
2931 height ?: number
3032 showAvgLine ?: boolean
3133 showLegendIndicator ?: boolean
34+ hideIndicatorValue ?: boolean
3235}
3336
34- const ServiceBarChar = ( { customClassNames, dataInfo, height, showAvgLine, showLegendIndicator } : ServiceBarCharProps ) => {
37+ const ServiceBarChar = ( {
38+ customClassNames,
39+ dataInfo,
40+ height,
41+ showAvgLine,
42+ showLegendIndicator,
43+ hideIndicatorValue
44+ } : ServiceBarCharProps ) => {
3545 const chartRef = useRef < ECharts > ( null )
3646 const [ option , setOption ] = useState < EChartsOption | undefined > ( { } )
3747 // 使用从主题配置中导入的默认颜色,而不是硬编码的颜色值
@@ -78,7 +88,10 @@ const ServiceBarChar = ({ customClassNames, dataInfo, height, showAvgLine, showL
7888 const option : EChartsOption = {
7989 title : [
8090 {
81- text : '{titleStyle|' + $t ( dataInfo . title ) + '}\n\n{valueStyle|' + dataInfo . value + '}' ,
91+ text :
92+ '{titleStyle|' +
93+ $t ( dataInfo . title ) +
94+ `}${ hideIndicatorValue ? '' : '\n\n{valueStyle|' + dataInfo . value + '}' } ` ,
8295 left : '2%' ,
8396 top : '0' ,
8497 textStyle : {
@@ -125,23 +138,23 @@ const ServiceBarChar = ({ customClassNames, dataInfo, height, showAvgLine, showL
125138 show : ! isNumberArray ,
126139 data : legendData ,
127140 right : '10px' ,
128- top : '60px' ,
141+ top : hideIndicatorValue ? '10px' : '60px' ,
129142 itemWidth : 10 ,
130143 itemHeight : 10 ,
131144 textStyle : {
132145 color : '#333'
133146 } ,
134147 icon : 'rect' ,
135- formatter : function ( name : string ) : string {
148+ formatter : function ( name : string ) : string {
136149 // 这里可以映射或自定义图例文本
137150 const customNames : Record < string , string > = {
138- ' inputToken' : `${ $t ( '输入 Token' ) } ${ showLegendIndicator ? `(${ dataInfo . inputTokenTotal } )` : '' } ` ,
139- ' outputToken' : `${ $t ( '输出 Token' ) } ${ showLegendIndicator ? `(${ dataInfo . outputTokenTotal } )` : '' } ` ,
151+ inputToken : `${ $t ( '输入 Token' ) } ${ showLegendIndicator ? `(${ dataInfo . inputTokenTotal } )` : '' } ` ,
152+ outputToken : `${ $t ( '输出 Token' ) } ${ showLegendIndicator ? `(${ dataInfo . outputTokenTotal } )` : '' } ` ,
140153 '2xx' : `${ '2xx' } ${ showLegendIndicator ? `(${ dataInfo . request2xxTotal || dataInfo . traffic2xxTotal } )` : '' } ` ,
141154 '4xx' : `${ '4xx' } ${ showLegendIndicator ? `(${ dataInfo . request4xxTotal || dataInfo . traffic4xxTotal } )` : '' } ` ,
142155 '5xx' : `${ '5xx' } ${ showLegendIndicator ? `(${ dataInfo . request5xxTotal || dataInfo . traffic5xxTotal } )` : '' } `
143- } ;
144- return customNames [ name ] || name ;
156+ }
157+ return customNames [ name ] || name
145158 }
146159 } ,
147160 xAxis : {
@@ -161,7 +174,7 @@ const ServiceBarChar = ({ customClassNames, dataInfo, height, showAvgLine, showL
161174 type : 'value' ,
162175 name : '' ,
163176 min : 0 ,
164- minInterval : 1 ,
177+ ... ( showAvgLine ? { } : { minInterval : 1 } ) ,
165178 show : dataExists , // 没有数据时不显示Y轴
166179 splitLine : {
167180 show : dataExists , // 没有数据时不显示网格线
@@ -252,10 +265,10 @@ const ServiceBarChar = ({ customClassNames, dataInfo, height, showAvgLine, showL
252265 } ,
253266 emphasis : {
254267 lineStyle : {
255- width : 1 // 保持线条宽度不变,禁用默认的悬停加粗
268+ width : 1 // 保持线条宽度不变,禁用默认的悬停加粗
256269 } ,
257270 label : {
258- show : false // 悬停时不显示标签
271+ show : false // 悬停时不显示标签
259272 }
260273 } ,
261274 data : [ { type : 'average' , name : 'Avg' } ]
@@ -289,10 +302,10 @@ const ServiceBarChar = ({ customClassNames, dataInfo, height, showAvgLine, showL
289302 } ,
290303 emphasis : {
291304 lineStyle : {
292- width : 1 // 保持线条宽度不变,禁用默认的悬停加粗
305+ width : 1 // 保持线条宽度不变,禁用默认的悬停加粗
293306 } ,
294307 label : {
295- show : false // 悬停时不显示标签
308+ show : false // 悬停时不显示标签
296309 }
297310 } ,
298311 data : [ { type : 'average' , name : 'Avg' } ]
@@ -348,6 +361,24 @@ const ServiceBarChar = ({ customClassNames, dataInfo, height, showAvgLine, showL
348361 } , [ ] )
349362 return (
350363 < div className = { `w-full ${ customClassNames } ` } >
364+ {
365+ hideIndicatorValue && (
366+ < div className = "absolute top-[26px] left-[10px] w-full" >
367+ < div className = "relative top-[5px]" >
368+ < div className = "absolute top-[23px] right-[5%] grid grid-cols-[auto_auto] justify-items-end" >
369+ < div className = "flex justify-center items-center" >
370+ < span className = "text-[#FE564D] text-[9px]" > ▲</ span >
371+ </ div >
372+ < span className = "ml-1 text-right" > { dataInfo ?. max } </ span >
373+ < div className = "flex justify-center items-center" >
374+ < span className = "text-[#27B148] text-[9px]" > ▼</ span >
375+ </ div >
376+ < span className = "ml-1 text-right" > { dataInfo ?. min } </ span >
377+ </ div >
378+ </ div >
379+ </ div >
380+ )
381+ }
351382 < div style = { ! hasData ? { cursor : 'default' , pointerEvents : 'none' } : { } } >
352383 < ECharts
353384 ref = { chartRef }
0 commit comments