首页 > 其他分享 >环状图,三种渐变

环状图,三种渐变

时间:2023-02-02 09:33:18浏览次数:45  
标签:false name color data 渐变 default 三种 环状 type

<template>
<div :style="{width: width, height: height}" ref="donutChart"></div>
</template>

<script>
const echarts = require('echarts');
export default {
name: "donutChart",
data(){
return{
chart:null,//图表实例
}
},
props:{
width:{
type:String,
default:'100%'
},
height:{
type:String,
default:'100%'
},

seriesColor:{
type:Array,
default(){
return ['#1B243C','#0D92F7']
}
},
optionType:{
type:Number,
default:1
},
seriesData:{
type:Array,
default(){
return []
}
},
legendData:{
type:Array,
default(){
return []
}
},
arr:{
type:Array,
default(){
return []
}
},
txt:{
type:String,
default:'普通教室'
}

},
watch: {
/* 如果图表数据是后台获取的,监听父组件中的数据变化,重新触发Echarts */
chartData: {
deep: true,
handler(val) {
val && this.chart.setOption(val)
}
}
},
mounted() {

/* 图表初始化 */
this.$nextTick(() => {
this.init()
})
},

methods: {
init() {
//2.初始化
this.chart = echarts.init(this.$refs.donutChart);
//3.配置数据
//配置1
let that=this
let a = {
title: {
// text: "80%",
left: "center",
top: "45%",
textStyle: {
color: "#fff",
fontSize: 22,
align: "center",
fontWeight: '400'
}
},
series: [
{
name: 'Access From',
type: 'pie',
// minAngle: 10, // 最小的扇区角度(0 ~ 360),用于防止某个值过小导致扇区太小影响交互
radius: ['60%', '70%'],
// roseType: 'area', //所有圆心角相同,仅通过半径展示数据大小
// data: this.seriesData,
// color: this.seriesColor,
label:{
position:'center',
show:true,
formatter:() => {
let str=that.arr[0]+'\n'+that.txt
return str
},
color:'#fff',
lineHeight:20,
fontSize:14
},
labelLine: { //删除指示线
show: false
},
itemStyle:{
show:false,
// borderColor:'#ffffff',
// borderWidth:1,
},

data:[
{
value:that.arr[0],
name:'完成',
itemStyle:{
normal:{
color:new echarts.graphic.LinearGradient(
1,1,1,0,[
{offset:0,color:'rgba(24, 144, 255, 1)'},
{offset:0.5,color:'rgba(27, 189, 243, 1)'},
{offset:1,color:'rgba(30, 231, 231, 1)'}
]
)
}
}
},
{
value:that.arr[1],
name:'wei完成',
itemStyle: {
normal: {
color:'#1B243C'
}
}

}
]
},
// {
// name: '外边框',
// type: 'pie',
// hoverAnimation: false,
// center: ['50%', '50%'], //外圈位置
// radius: ['52%', '52%'], //内边距
// data: [{
// value: 9,
// name: '',
// itemStyle: {
// normal: {
// borderWidth: 60,
// borderColor: 'rgba(255,255,255,0.1)'
// }
// }
// }],
// labelLine: { //删除指示线
// show: false
// }
// }
]
};
//配置2
let b = {
tooltip: { //鼠标悬浮标题
trigger: 'item',
backgroundColor: '#fff',
textStyle: {
color: 'rgba(51,51,51,0.95)',
}
},
legend: {
orient: 'vertical',
bottom: 'bottom', //文字位置
textStyle: {
color: '#fff'
},
itemGap: 40, //下方文字间距
itemHeight: 6,
itemWidth: 6,
// data: [
// {
// name: '讲授',
// icon: 'circle',
// },
// {
// name: '互动',
// icon: 'circle',
// },
// {
// name: '其他',
// icon: 'circle',
// }
// ]
data:this.legendData
},
series: [
{
name: 'Access From',
type: 'pie',
radius: ['30%', '65%'],
// roseType: 'area', //所有圆心角相同,仅通过半径展示数据大小
label: {
show: false,
},
// data: [
// {value: 300, name: '讲授', icon: 'circle'},
// {value: 748, name: '互动', icon: 'circle'},
// {value: 596, name: '其他', icon: 'circle'},
// ],
data:this.seriesData,
color: ['#4AC2FC', '#6967E4', '#63D64C'],
labelLine: { //删除指示线
show: false
}
},
{
name: '外边框',
type: 'pie',
hoverAnimation: false,
center: ['50%', '50%'], //外圈位置
radius: ['74%', '74%'], //内边距
data: [{
value: 9,
name: '',
itemStyle: {
normal: {
borderType: 'dashed',
borderWidth: 1,
borderColor: 'rgba(24,144,255,0.51)'
}
}
}],
labelLine: { //删除指示线
show: false
}
}
]
};
let option= this.optionType==1 ? a:b;
// 4.传入数据
this.chart.setOption(option);
}
}
}
</script>

<style scoped>

</style>

标签:false,name,color,data,渐变,default,三种,环状,type
From: https://www.cnblogs.com/connie256/p/17084872.html

相关文章

  • css渐变动画
    鼠标放上去渐变div{width:100px;transition:width2s;-moz-transition:width2s;/*Firefox4*/-webkit-transition:width2s;/*Safari和Chrome*/-o-tran......
  • m基于matlab的光通信的信道估计,均衡,抑制papr误码率仿真,对比ZF,RLS,MMSE三种算法
    1.算法描述可见光通信的信道估计,均衡,抑制papr。不考虑光信道,用传统的无线通信的OFDM的信道估计,均衡,抑制papr信道估计,均衡最好有两个以上的方法比较%本次仿真载频为2GHz......
  • 三种微服务治理方式
    1、应用程序中包含微服务治理逻辑在微服务架构中,服务间不再是在朴素的进程内通信,取而代之的是通过轻量级的网络协议进行通信。那么,如何找到服务提供方?如何超时重试?当存在多......
  • java 开启子线程的三种方式
    1.实现多线程的方式继承Thread类实现Runnable接口一般使用匿名的方式2.示例packagecomi.example.liy.mytestdemo;importorg.junit.Test;importstaticorg.ju......
  • 虚拟机有三种网络模式,分别是桥接、NAT、Host-Only
    桥接定义:桥接(Bridging),是指依据OSI网络模型的链路层的地址,对网络数据包进行转发的过程,工作在OSI的第二层。一般的交换机,网桥就有桥接作用。俗的说就是通过一台设备(可能不止......
  • redis之三种特殊数据类型
    redis之三种特殊数据类型一、Geospatial(地理位置)朋友的定位,附近的人,打车距离计算?Redis的Geo在Redis3.2版本就推出了!这个功能可以推算地理位置的信息,两地之间的距离,方......
  • CSS边框渐变发光动画特效
    动画演示CSS代码 @property--rotate{syntax:"<angle>";initial-value:132deg;inherits:false;}:root{--card-height:65vh;--card-width:calc(var(--c......
  • 父子组件通讯三种方式
         ......
  • 网页数据实时更新的三种简单方法
    一、页面自动刷新<metahttp-equiv="refresh"content="20">其中20指每隔20秒刷新一次页面.二、页面自动跳转:<metahttp-equiv="refresh"content="20;url=http://www.hackh......
  • Linux 常用替换命令三种方法(perl、shell、sed)
    举例在文件服务器上有一文件,文件名字:aaa.txt文件内容为:name=guodongsex=nanage=1001、perl:find-name'文件名'|xargsperl-pi-e's|被替换的字符串|替换后的字......