当前位置: 首页 > Web前端 > vue.js

echarts百分比图表

时间:2023-03-31 22:29:22 vue.js

.ringChart{width:100%;高度:100%;}二次开发打包百度echarts图表百分比图公司需求样式如下:代码上就不多说了:script>importechartsfrom'echarts'exportdefault{name:"Ring",props:{//color颜色:{type:String,default(){return'red'}},//data数据:{type:Object,default(){return{}}}},data(){return{}},mounted(){constoption={legend:{orient:'vertical',left:'center',top:'10%',selectedMode:false,icon:'none',formatter:[`{a|${this.data.text}}{b|/${this.data.subtext}}`,].join('\n'),textStyle:{rich:{a:{color:this.color,textShadowColor:this.color,textShadowBlur:2,fontSize:14},b:{color:'#DCDCDC',fontSize:12,},}}},title:{text:`${parseFloat(this.data.value)}%`,textStyle:{颜色:this.color,textShadowColor:this.color,textShadowBlur:2,fontSize:22},left:'center',top:'80%'},angleAxis:{max:100,show:false,},radiusAxis:{type:'category',show:true,axisLabel:{show:false,},axisLine:{show:false,},axisTick:{show:false},},polar:{radius:'75%',center:['50%','50%'],},series:[{type:'bar',//圆角//roundCap:true,barWidth:40,showBackground:true,backgroundStyle:{color:"rgba(219,219,219,0.3)"},数据:[parseFloat(this.data.value)],坐标系统:'polar',名称:`${parseFloat(this.data.value)}`,标签:{show:true,},itemStyle:{normal:{opacity:1,color:this.color,}},}],}constchartObj=echarts.init(this.$refs.ringChart);chartObj.setOption(选项)}}}/script>.ringChart{width:100%;高度:100%;}调用方法(我不会注册代码)一共有两个参数:color颜色数据值值百分比值数字类型文本主标题字符串类型子文本副标题字符串类型