@@ -33,36 +33,6 @@ const setChildDefaultMax = (data) => {
3333 return sum ;
3434} ;
3535
36- // 配置玉闋图外围坐标系百分比展示文本
37- const setAxisLabel = ( sum , iChartOption , baseOpt ) => {
38- if ( iChartOption . max ) {
39- baseOpt . angleAxis . sum = iChartOption . max ;
40- const formatter = params => {
41- if ( params === iChartOption . max ) {
42- return '100%' ;
43- }
44- if ( ( params / iChartOption . max ) * 100 > 100 ) {
45- return '' ;
46- }
47- const x = Math . ceil ( ( params / iChartOption . max ) * 100 ) ;
48- return `${ Math . ceil ( x / 10 ) * 10 } %` ;
49- } ;
50- return formatter ;
51- } else {
52- const formatter = params => {
53- if ( params === sum ) {
54- return '100%' ;
55- }
56- if ( ( params / sum ) * 100 > 100 ) {
57- return '' ;
58- }
59- const x = Math . ceil ( ( params / sum ) * 100 ) ;
60- return `${ Math . ceil ( x / 10 ) * 10 } %` ;
61- } ;
62- return formatter ;
63- }
64- } ;
65-
6636/**
6737 * 此函数两部分作用:(1)根据data和max,将数据分为四种数据类型,分类处理angleAxis的sum和max值
6838 * (2)根据用户传入的formatter,配置极坐标系文本
@@ -109,15 +79,16 @@ const handleLabelFormatter = (iChartOption, baseOpt, chartType) => {
10979 * 传入函数,用户自定义展示内容
11080 */
11181 let formatter = angleAxis . axisLabel . formatter ;
82+ const defaultFormatter = ( params ) => `${ ( params / angleAxis . sum * 100 ) . toFixed ( 0 ) } %` ;
11283 switch ( formatter ) {
11384 case 'percent' :
114- formatter = setAxisLabel ( angleAxis . sum , iChartOption , baseOpt ) ;
85+ formatter = defaultFormatter ;
11586 break ;
11687 case 'number' :
11788 formatter = undefined ;
11889 break ;
11990 case undefined :
120- formatter = setAxisLabel ( angleAxis . sum , iChartOption , baseOpt ) ;
91+ formatter = defaultFormatter ;
12192 break ;
12293 }
12394 if ( chartType === CHARTTYPE . PROCESS ) {
@@ -126,6 +97,15 @@ const handleLabelFormatter = (iChartOption, baseOpt, chartType) => {
12697 return ;
12798 }
12899 angleAxis . axisLabel . formatter = formatter ;
100+ // 使用customValues属性(echarts5.5.1以上版本才支持)将刻度均分为5份。
101+ const customValues = [ 0 ] ;
102+ const interval = angleAxis . splitNumber || 5 ;
103+ const averageVal = angleAxis . sum / interval ;
104+ for ( let i = 0 ; i < interval ; i ++ ) {
105+ customValues . push ( customValues [ customValues . length - 1 ] + averageVal ) ;
106+ }
107+ angleAxis . axisTick . customValues = customValues ;
108+ angleAxis . axisLabel . customValues = customValues ;
129109} ;
130110
131111export { handleLabelFormatter } ;
0 commit comments