### **2、数据处理** 这个参数用于处理图表中的数据,比如:你有以下数据我想取“data”数值,渲染到饼图中,怎么处理? ```  {     tooltip: {         trigger: 'item',         formatter: '{a} {b}: {c} ({d}%)'     },      color:['#fbcd5a','#71d02b','#7EB0F3'\],     legend: {         data: \['视频设备', '门禁设备', '防盗报警'\]     },     series: [         {             name: '设备',             type: 'pie',             selectedMode: 'single',             radius: [0, '30%'],             label: {                 position: 'inner',                 fontSize: 50,             },             labelLine: {                 show: false             }         },         {             name: '设备',             type: 'pie',                       radius: ['45%', '60%'],             labelLine: {                 length: 39,             },             label: {                 formatter: '{a|{b}}{abg|}\\n{hr|}\\n  {fc|{c}}  {per|{d}%}  ',                 backgroundColor: '#F6F8FC',                 borderColor: '#8C8D8E',                 borderWidth: 1,                 borderRadius: 4,                 fontSize:30,                                  rich: {                     a: {                         color: '#6E7079',                         lineHeight: 52,                          fontSize: 25,                         align: 'center'                     },                                 hr: {                         borderColor: '#8C8D8E',                         width: '100%',                         borderWidth: 1,                         height: 0                     },                     b: {                         color: '#4C5058',                         fontSize: 5,                         fontWeight: 'bold',                         lineHeight: 80                     },                                                    fc: {                         color: '#4C5058',                         fontSize: 35,                         fontWeight: 'bold',                         lineHeight: 80                     },                                          per: {                         color: '#fff',                         backgroundColor: '#4C5058',                         padding: [3, 4],                          fontSize: 30,                         borderRadius: 4                     }                 }             },             data: [                 {value: 1048, name: '视频设备'},                 {value: 335, name: '门禁设备'},                 {value: 310, name: '防盗报警'}             ]         }     ] }; ``` ![](https://img.kancloud.cn/12/c6/12c6dac5500868a03818bd406d2a7763_800x612.png) ![](https://img.kancloud.cn/4f/e9/4fe900c6cf38ec6551bf8702d601a615_804x23.png) **处理方法:** * (1)查看数据格式: 点击数据“数据处理”的编辑按钮,代码编辑器中输入“console.log("op",op)”,如图2.101操作;打开调试模式,查看数据内容,如图2.102; ![](https://img.kancloud.cn/fd/df/fddfe5a9de573651441b44c37cfb715b_1155x432.png) :-: 图2.101 ![](https://img.kancloud.cn/9c/4a/9c4ab1226e65bfec944c141a8c096f60_769x303.png) :-: 图2.102 * (2)取数据: 在代码编辑器中输入如下代码,可取到数值,效果如图2.103; ``` op=>{ return op.series[1].data } ``` ![](https://img.kancloud.cn/17/3f/173f7b0c0e3eab11d901b1f8c999ed53_924x515.png) :-: 图2.103