相关代码:
/*
* @Author: wxl
* @Date: 2022-11-04 08:22:23
* @Last Modified by: wxl
* @Last Modified time: 2022-12-12 17:32:58
*/
<template>
<!-- 饼图 -->
<div :id="histogramId" v-bind:style="{height:height,width:width}">
</div>
</template>
<script type="text/ecmascript-6">
// import propAPI from './echartProp'
export default {
// props:propAPI,
props:{
//id
histogramId:{
type:String,
default:''
},
//组件的高度
height: {
type: String,
default: '310px'
},
//组件的宽度
width: {
type: String,
default: '100%'
},
pieData:{
type:Array,
default:()=>[
{name: '待派单',value: 20},
{name: '待接单',value: 10},
{name: '处理中',value: 30},
{name: '已完成',value: 40},
{name: '已取消',value: 10},
{name: '已评价',value: 20}
]
},
//颜色数组
colorList:{
type:Array,
default:()=>['#8C56FB','#ECE22E','#3A7FFF','#FF3329','#0DFF85','#16F3FB']
},
//虚线的相关展示
xuLine:{
type:Object,
default:()=>{
return{
// lineColor:'rgba(255,255,255,0.15)', //颜色
// radius: ['49%', '50%'],
// center:['15%','50%'],
lineColor:'', //颜色
radius: [],
center:[],
}
}
},
//外圆之类控制
outCircle:{
type:Object,
default:()=>{
return{
color:'rgba(255, 255, 255, 0.22)',
radius:['80%', '80%'],
center:['12%','50%'],
}
}
},
//主园的大小
mainCircle:{
type:Object,
default:()=>{
return{
radius:['64%', '68%'],
center:['50%','24%'],
}
}
},
//内圆
inCircle:{
type:Object,
default:()=>{
return{
radius: ['55%', '55%'],
center:['12%','50%'],
}
}
},
//title的相关设置
title:{
type:Array,
default:()=>[
// {name:'总数',top:'47%',left:'29.5%',color:'#3E95E8',fontSize:'16',fontWeight:400},
// {name:'1289',top:'36%',left:'29.5%',color:'#ffffff',fontSize:'26',fontWeight:'bold'}
]
},
//graphic的设置
graphic:{
type:Array,
default:()=>[
{img:require('../../assets/cockpit/circleImg.png'),top:'1%',left:'3%',width:161,height:149,position:[100,100]},
// {img:require('../../../assets/indexBig/redTwo.png'),top:'30%',left:'-5%',width:155,height:128,position:[100,100]},
// {img:require('../../../assets/indexBig/danghui.png'),top:'23%',left:'27%',width:45,height:45,position:[100,100]},
]
},
//lend的设置
legend:{
type:Object,
default:()=>{
return{
itemWidth:10,
itemHeight:10,
top: '15%',
left: '27%',
icon:'rect',
// itemGap设置各个item之间的间隔,单位px,默认为10,横向布局时为水平间隔,纵向布局时为纵向间隔
itemGap: 15,
// width:'100%',
height:'20%'
}
}
},
legendShow:{
type:Boolean,
default:false
},
//间距
spaceNum1:{
type:Number,
default:5
},
spaceNum2:{
type:Number,
default:5
},
},
data(){
return{
warnNUm:'',
totalSum:0,
}
},
methods:{
initPie(){
var that = this
//虚线
function Pie() {
let dataArr = [];
for (var i = 0; i < 150; i++) {
if (i % 2 === 0) {
dataArr.push({
name: (i + 1).toString(),
value: 25,
itemStyle: {
normal: {
color: that.xuLine.lineColor,
borderWidth: 0,
borderColor: "rgba(0,0,0,0)"
}
}
})
} else {
dataArr.push({
name: (i + 1).toString(),
value: 10,
itemStyle: {
normal: {
color: "rgba(0,0,0,0)",
borderWidth: 0,
borderColor: "rgba(0,0,0,0)"
}
}
})
}
}
return dataArr
}
function PieTwo() {
let dataArr = [];
for (var i = 0; i < 150; i++) {
if (i % 2 === 0) {
dataArr.push({
name: (i + 1).toString(),
value: 25,
itemStyle: {
normal: {
color: that.xuLine.lineColor,
borderWidth: 0,
borderColor: "rgba(0,0,0,0)"
}
}
})
} else {
dataArr.push({
name: (i + 1).toString(),
value: 10,
itemStyle: {
normal: {
color: "rgba(0,0,0,0)",
borderWidth: 0,
borderColor: "rgba(0,0,0,0)"
}
}
})
}
}
return dataArr
}
var img = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMYAAADGCAYAAACJm/9dAAABS2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRv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yZ+BaXhpSSkZhJ7pn9EzHhp770lUFlOJavOKpNKFEfI6WqF5KO37H8OB69DCtBtQjCvTM76ADnxcjZ5pfLJ1CXr2x1OBzaYkqkUYIUuBMcAxRIsSQe3gK4E/oTmQ0dmbVrGMRs/sT+jciXj/bQVwLHrmS7M3LT2qTRghT6ORkcODdEhfNAeyFB0schmwY+bWlT9D0LN5DT2rSejZhTyNnu0hwILMrcuAahVGyGJUe3wdHWnbEntvX7SP+F3gMbTUZAC1ywAkgMfQGqZb0TMKaUHP8OvomS7O1rxsqWtdUlOLVoejGdnzgD0S3v8IreGZi4I0fJydabmwHWoKTUR9tKRBitXo0MefkVI4zDxpam5MfL3WhBFSj/Z/nI/W7DQkXNOCdpE9jbbhVsSMbTcYARwFHI2aQ4X+748jQTQDWzKzLmMKCaNv4qvVzxbg2eBve/SLeTowjmg3WQP6NT02yL+Lmg/Lgr9VRGGAypU+SAijg7/DgF0LXLsZiWA2Cp68PgP7ypZarTEKMQzVIOPRr+rWJgivRkPA5cxVaIi1EJ+i2vAJVEOU7WrXtHCN0T3WovU+96DO6OEoksk4FNqn0n9F2tC+iGZUWy4CNuZqUZliYRRmI5pND2fUd0JDwKPRMGVLgfvKiRa0EegF1PxbDnyQq0UVwv8BNYmwIpIWBvwAAAAASUVORK5CYII=';
var trafficWay = this.pieData;
var data = [],data1=[],titleList=[],graphicList=[];
var color=that.colorList,lendList=[]
for (var i = 0; i < trafficWay.length; i++) {
this.totalSum+=trafficWay[i].value
lendList.push(trafficWay[i].name)
data.push({
value: trafficWay[i].value,
name: trafficWay[i].name,
itemStyle: {
normal: {
borderWidth: 5,
shadowBlur: 0,
borderColor:color[i],
shadowColor: color[i]
}
},
// show:false
}, {
value: that.spaceNum1,
name: '',
itemStyle: {
normal: {
label: {
show: false
},
labelLine: {
show: false
},
color: 'rgba(0, 0, 0, 0)',
borderColor: 'rgba(0, 0, 0, 0)',
borderWidth: 0
}
},
// show:false
tooltip:{
show:false,
},
});
data1.push({
value: trafficWay[i].value,
name: trafficWay[i].name,
tooltip:{
show:false,
},
itemStyle: {
normal: {
borderWidth: 1,
borderColor: that.outCircle.outCircle,
opacity:0.3,
}
}
},{
value: that.spaceNum2,
name: '',
tooltip:{
show:false,
},
itemStyle: {
normal: {
label: {
show: false
},
labelLine: {
show: false
},
color: 'rgba(0, 0, 0, 0)',
borderColor: 'rgba(0, 0, 0, 0)',
borderWidth: 0
}
}
});
}
var seriesOption = [{
name: '',
type: 'pie',
clockWise: false,
radius: that.mainCircle.radius,
center:that.mainCircle.center,
hoverAnimation: true,
itemStyle: {
normal: {
label: {
show: false,
position: 'outside',
color: '#ddd',
},
labelLine: {
length:30,
length2:100,
show: false,
color:'#00ffff'
}
}
},
data: data
},{ //外圈
name: '',
type: 'pie',
clockWise: false,
radius: that.outCircle.radius,
center:that.outCircle.center,
hoverAnimation: false,
data: data1,
itemStyle: {
normal: {
label: {
show: false,
position: 'outside',
color: '#ddd',
},
labelLine: {
length:30,
length2:100,
show: false,
color:'#00ffff'
}
}
}
},{ //虚线
type: 'pie',
zlevel: 0,
silent: true,
radius: that.xuLine.radius,
center:that.xuLine.center,
z: 10,
itemStyle: {
normal: {
areaColor: 'rgba(255,255,255,0.1)',
borderColor: 'rgba(255,255,255,0.1)',
},
emphasis: {
label: {
show: false
},
areaColor: 'rgba(255,255,255,0.1)',
}
},
label: {
normal: {
show: false
},
},
labelLine: {
normal: {
show: false
}
},
data: Pie()
},{ //内圆
type: 'pie',
radius: that.inCircle.radius,
center:that.inCircle.center,
z: 0,
itemStyle: {
normal: {
color: 'rgba(255,255,255,0.1)',
label: {
show: false
},
labelLine: {
show: false
}
},
},
label: {
normal: {
position: "center",
}
},
tooltip:{
show:false,
},
data: [100],
}];
for(var t = 0;t<this.title.length;t++){
titleList.push({
text: this.title[t].name,
top: this.title[t].top,
textAlign: "center",
left: this.title[t].left,
textStyle: {
color: this.title[t].color,
fontSize: this.title[t].fontSize,
fontWeight: this.title[t].fontWeight
}
})
}
for(var g = 0;g<this.graphic.length;g++){
graphicList.push({
type: "image",
z: -1,
style: {
image: this.graphic[g].img,
width: this.graphic[g].width,
height: this.graphic[g].height
},
left: this.graphic[g].left,
top: this.graphic[g].top,
position: [100, 100]
})
}
this.warnNUm = this.$echarts.init(document.getElementById(this.histogramId));
this.warnNUm.setOption({
color : color,
title: titleList,
graphic: {
elements: graphicList
},
tooltip: {
show: true
},
legend: {
// orient 设置布局方式,默认水平布局,可选值:'horizontal'(水平) | 'vertical'(垂直)
height:that.width.height,
orient: 'vertical',
top: that.legend.top,
left: that.legend.left,
itemWidth: that.legend.itemWidth, // 设置图例图形的宽
itemHeight: that.legend.itemHeight, // 设置图例图形的高
icon:that.legend.icon,
// itemGap设置各个item之间的间隔,单位px,默认为10,横向布局时为水平间隔,纵向布局时为纵向间隔
itemGap: that.legend.itemGap,
data:lendList,
show:that.legendShow,
formatter: function (name) {
var num,rate,sum
for(var i=0;i<trafficWay.length;i++){
if(trafficWay[i].name == name){
num = trafficWay[i].value
rate = ((data[i].value/that.totalSum)*100).toFixed(0)
}
}
return `{title|${name}}{value|${num}} `
},
textStyle: {
rich: {
title:{
color: '#CCE4FF',
fontSize: 12,
padding: [0, 10, 0, 3]
},
value:{
color: '#ffffff',
fontSize: 12,
padding: [0, 0, 0, 2]
},
unit: {
color: '#ffffff',
fontSize: 12,
padding: [0, 0, 0, 0]
},
percent: {
color: '#ffffff',
fontSize: 12,
padding: [0, 0, 0, 0]
}
}
}
},
toolbox: {
show: false
},
series: seriesOption
});
//点击
that.warnNUm.on('click', function (params) {
//向父级传递index
that.$emit('pieAll',params.dataIndex)
});
let index = 0;
//每隔一分钟高亮一下
function fun() {
var timer = setInterval(function() {
// 取消高亮指定的数据图形
that.warnNUm.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: index == 0 ? 5 : index - 1
});
that.warnNUm.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: index
});
index++;
if (index > 9) {
index = 0;
}
}, 1000)
}
fun()
},
},
watch:{
pieData: {
handler(newVal, oldVal) {
this.initPie()
},
deep: true
},
width:function(){
this.warnNUm.resize()
},
},
mounted(){
// this.initSingleColorZhu()
// 新建一个promise对象
let newPromise = new Promise((resolve) => {
resolve()
})
//然后异步执行echarts的初始化函数
newPromise.then(() => {
// 此dom为echarts图标展示dom
this.initPie()
})
},
}
</script>
标签:false,name,show,color,之带,255,type,echarts,图片
From: https://www.cnblogs.com/xuelinomen/p/17993998