this.define("load5", function () {\n o2.load(echartUrl, function () {\n // 基于准备好的dom,初始化echarts实例\n var myDue = echarts.init(document.getElementById('due'));\n\n // 指定图表的配置项和数据\n var data = [\n {\n name: '满意度',\n value: '60',\n },\n {\n name: '处理率',\n value: 25,\n },\n];\n\nvar titleArr = [],\n seriesArr = [];\ncolors = [\n ['#389af4', '#dfeaff'],\n ['#ff8c37', '#ffdcc3'],\n];\ndata.forEach(function (item, index) {\n titleArr.push({\n text: item.name,\n left: index * 40 + 30 + '%',\n top: '65%',\n textAlign: 'center',\n textStyle: {\n fontWeight: 'normal',\n fontSize: '16',\n color: colors[index][0],\n textAlign: 'center',\n },\n );\n seriesArr.push({\n name: item.name,\n type: 'pie',\n clockWise: false,\n radius: [60, 70],\n itemStyle: {\n normal: {\n color: colors[index][0],\n shadowColor: colors[index][0],\n shadowBlur: 0,\n label: {\n show: false,\n },\n labelLine: {\n show: false,\n },\n },\n },\n hoverAnimation: false,\n center: [index * 40 + 30 + '%', '50%'],\n data: [\n {\n value: item.value,\n label: {\n normal: {\n formatter: function (params) {\n return params.value + '%';\n },\n position: 'center',\n show: true,\n textStyle: {\n fontSize: '20',\n fontWeight: 'bold',\n color: colors[index][0],\n },\n },\n },\n },\n {\n value: 100 - item.value,\n name: 'invisible',\n itemStyle: {\n normal: {\n color: colors[index][1],\n },\n emphasis: {\n color: colors[index][1],\n },\n },\n },\n ],\n );\n);\n\noption = {\n title: [\n {\n text: '副标题',\n left: 'center',\n top: 20,\n textStyle: {\n fontWeight: 'normal',\n fontSize: '20',\n },\n },\n ...titleArr,\n ],\n series: seriesArr,\n};\n\n // 使用刚指定的配置项和数据显示图表。\n myDue.setOption(option);\n }.bind(this));\n);


原文地址: https://www.cveoy.top/t/topic/p357 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录