formatter动态拼接指示器名称

 1 //雷达指示器参数配置
 2 indicator:[
 3     {"name":"车辆已售","value":380,"max":500},
 4     {"name":"商家冒充个人","value":290,"max":500},
 5     {"name":"商家服务态度差","value":450,"max":500},
 6     {"name":"电话无法接通","value":300,"max":500},
 7     {"name":"走私套牌抵押车","value":480,"max":500},
 8     {"name":"价格高于标价","value":200,"max":500},
 9     {"name":"卖新车","value":350,"max":500},
10     {"name":"图片与车款不符合","value":333,"max":500}
11 ]
12 name: {
13     textStyle: {
14         color: '#999',
15         backgroundColor: 'transparent'
16         // borderRadius: 3,
17         // padding: [3, 5]
18    },
19    formatter:function(value,indicator){
20            //指示器名称过长截取
21         value = value.replace(/\S{4}/g, function(match) {
22             return match + '\n'
23         })
24         // value = value + '\n' + indicator.value;
25         return '{a|'+value+'}'+ '\n' + '{b|'+indicator.value+'}'
26     },
27     //富文本编辑 修改文字展示样式
28     rich:{
29         a:{
30             color:"#999",
31             fontSize:12,
32             align: "center"
33 
34         },
35         b:{
36             color:"#333",
37             fontSize:17,
38             align: "center"
39         }
40     }
41 }
42 formatter回调参数:
43 value:返回indicator指示器的name值 如:车辆已售
44 indicator: 返回雷达指示器的所有参数 如:{"name":"车辆已售","value":380,"max":500}
45 rich定义富文本样式
46 可区分引用rich里面定义的样式 如上

 

posted @ 2021-11-24 17:11  一个动态类型的幽灵  阅读(55)  评论(0编辑  收藏  举报