|
|
<template>
|
|
|
<div :style="styleObj" class="fillContainer">
|
|
|
<div class="fill-item" :style="fillItemStyle" v-for="item in fillData">
|
|
|
<div class="circle" :style="circleStyle">
|
|
|
<div class="wave">
|
|
|
<div class="wave1" :style="[wave1Style,topStyle(item.num)]"></div>
|
|
|
<div class="wave-val">
|
|
|
<span :style="numStyle">{{ item.num }}</span><span :style="pieStyle">%</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="wave-title" :style="titleStyle">当前使用率</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- <v-chart :options="options" autoresize/>-->
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
var per = 60;
|
|
|
export default {
|
|
|
name: "customLiquidFillChart",//百分比图参考:https://www.makeapie.com/editor.html?c=xFkzKG-bpl
|
|
|
components: {},
|
|
|
props: {
|
|
|
value: Object,
|
|
|
ispreview: Boolean
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
// topStyle:'',//水波纹的大小
|
|
|
fillData:[],//数据
|
|
|
topNum:0,//水波纹的大小
|
|
|
nums:0,
|
|
|
options: {
|
|
|
title: {
|
|
|
text: '{nums|' + per + '}{percent|%}',
|
|
|
x: 'center',
|
|
|
y: 'center',
|
|
|
textStyle: {
|
|
|
rich: {
|
|
|
nums: {
|
|
|
fontSize: 60,
|
|
|
color: '#29EEF3',
|
|
|
},
|
|
|
percent: {
|
|
|
fontSize: 30,
|
|
|
color: '#29EEF3',
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
legend: {
|
|
|
type: 'plain',
|
|
|
orient: 'vertical',
|
|
|
right: 0,
|
|
|
top: '10%',
|
|
|
align: 'auto',
|
|
|
data: [{
|
|
|
name: '1',
|
|
|
icon: "circle"
|
|
|
}, {
|
|
|
name: '2',
|
|
|
icon: "circle"
|
|
|
}, {
|
|
|
name: '3',
|
|
|
icon: "circle"
|
|
|
}, {
|
|
|
name: '4',
|
|
|
icon: "circle"
|
|
|
}],
|
|
|
textStyle: {
|
|
|
color: 'white',
|
|
|
fontSize: 16,
|
|
|
padding: [10, 1, 10, 0],
|
|
|
},
|
|
|
selectedMode: false,
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
|
type: "liquidFill",
|
|
|
data: [0.47],
|
|
|
direction: "right", //波浪方向或者静止
|
|
|
radius: "80%",
|
|
|
// 水球颜色
|
|
|
color: ["#00c2ff"],
|
|
|
center: ["50%", "50%"], //水球位置
|
|
|
// outline 外边
|
|
|
outline: {
|
|
|
// show: false
|
|
|
borderDistance: 3, //内环padding值
|
|
|
itemStyle: {
|
|
|
borderWidth: 8, //圆边线宽度
|
|
|
borderColor: "#00c2ff",
|
|
|
shadowBlur: 10,
|
|
|
shadowColor: 'rgba(63, 218, 255, 0.5)'
|
|
|
}
|
|
|
},
|
|
|
backgroundStyle: {
|
|
|
// borderWidth: 5,
|
|
|
// borderColor: 'rgb(255,0,255,0.9)',
|
|
|
color: 'rgb(255,0,255,0.01)'
|
|
|
},
|
|
|
label: {
|
|
|
show: false
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
},
|
|
|
optionsStyle: {}, // 样式
|
|
|
optionsData: {}, // 数据
|
|
|
optionsCollapse: {}, // 图标属性
|
|
|
optionsSetup: {}
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
styleObj() {
|
|
|
return {
|
|
|
position: this.ispreview ? "absolute" : "static",
|
|
|
width: this.optionsStyle.width + "px",
|
|
|
height: this.optionsStyle.height + "px",
|
|
|
left: this.optionsStyle.left + "px",
|
|
|
top: this.optionsStyle.top + "px",
|
|
|
background: this.optionsSetup.background,
|
|
|
'flex-flow':this.optionsSetup.flexFlow
|
|
|
};
|
|
|
},
|
|
|
//圆环边框设置
|
|
|
circleStyle(){
|
|
|
return{
|
|
|
'background-image': 'linear-gradient(20deg, '+this.optionsSetup.lineColorDark+','+this.optionsSetup.lineColor+')',
|
|
|
'padding':this.optionsSetup.lineWidth+'px'
|
|
|
}
|
|
|
},
|
|
|
//多个水球样式
|
|
|
fillItemStyle(){
|
|
|
let length=this.fillData.length;
|
|
|
let widthCirle=this.optionsSetup.flexFlow=='column'?this.optionsStyle.height:this.optionsStyle.width;
|
|
|
let num=this.optionsSetup.flexFlow=='column'?60:20;
|
|
|
let width=widthCirle/length-num;
|
|
|
return {
|
|
|
width: width + "px",
|
|
|
height: width + "px",
|
|
|
}
|
|
|
},
|
|
|
//波纹样式
|
|
|
wave1Style(){
|
|
|
let optionsSetup=this.optionsSetup;
|
|
|
return{
|
|
|
'background-color':this.optionsSetup.color0Start,
|
|
|
// 'top':this.topNum+'%',
|
|
|
'background-image':'radial-gradient( '+optionsSetup.color0Start+' , '+optionsSetup.colorsurplus+', '+optionsSetup.color100End+')',
|
|
|
}
|
|
|
},
|
|
|
//百分比样式
|
|
|
pieStyle(){
|
|
|
return{
|
|
|
'font-size':this.optionsSetup.textPerFontSize+'px',
|
|
|
color: this.optionsSetup.textPerColor,
|
|
|
'font-weight': this.optionsSetup.textPerFontWeight
|
|
|
|
|
|
}
|
|
|
},
|
|
|
//数值样式
|
|
|
numStyle(){
|
|
|
let optionsSetup=this.optionsSetup;
|
|
|
return{
|
|
|
'font-size': optionsSetup.textNumFontSize+'px',
|
|
|
color: optionsSetup.textNumColor,
|
|
|
'font-weight': optionsSetup.textNumFontWeight
|
|
|
}
|
|
|
},
|
|
|
//下方标题样式
|
|
|
titleStyle(){
|
|
|
let optionsSetup=this.optionsSetup;
|
|
|
return{
|
|
|
'display':optionsSetup.isTitle?'block':'none',
|
|
|
'font-size':optionsSetup.titleFontSize+'px',
|
|
|
color: optionsSetup.titleColor,
|
|
|
'font-weight': optionsSetup.titleFontWeight
|
|
|
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
value: {
|
|
|
handler(val) {
|
|
|
this.optionsStyle = val.position;
|
|
|
this.optionsData = val.data;
|
|
|
this.optionsCollapse = val.collapse;
|
|
|
this.optionsSetup = val.setup;
|
|
|
this.editorOptions();
|
|
|
},
|
|
|
deep: true
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.optionsStyle = this.value.position;
|
|
|
this.optionsData = this.value.data;
|
|
|
this.optionsCollapse = this.value.collapse;
|
|
|
this.optionsSetup = this.value.setup;
|
|
|
this.editorOptions();
|
|
|
},
|
|
|
mounted() {
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
|
editorOptions() {
|
|
|
this.setOptionsData();
|
|
|
},
|
|
|
// 数据解析
|
|
|
setOptionsData() {
|
|
|
const optionsData = this.optionsData; // 数据类型 静态 or 动态
|
|
|
optionsData.dataType == "staticData"
|
|
|
? this.staticDataFn(optionsData.staticData)
|
|
|
: this.dynamicDataFn(
|
|
|
optionsData.dynamicData,
|
|
|
optionsData.refreshTime
|
|
|
);
|
|
|
},
|
|
|
staticDataFn(val) {
|
|
|
const title = this.options.title;
|
|
|
const num = val[0]['num'];
|
|
|
if(val && val.length>0) {
|
|
|
this.fillData=val;
|
|
|
}
|
|
|
this.nums = num ;
|
|
|
this.topNum=100-num;
|
|
|
|
|
|
},
|
|
|
topStyle(val){
|
|
|
let num=100-val;
|
|
|
return {
|
|
|
'top':num+'%'
|
|
|
};
|
|
|
},
|
|
|
dynamicDataFn(val, refreshTime) {
|
|
|
if (!val) return;
|
|
|
if (this.ispreview) {
|
|
|
this.getEchartData(val);
|
|
|
this.flagInter = setInterval(() => {
|
|
|
this.getEchartData(val);
|
|
|
}, refreshTime);
|
|
|
} else {
|
|
|
this.getEchartData(val);
|
|
|
}
|
|
|
},
|
|
|
getEchartData(val) {
|
|
|
const data = this.queryEchartsData(val);
|
|
|
data.then(res => {
|
|
|
|
|
|
this.nums = res[0].value ;
|
|
|
if(res && res.length>0){
|
|
|
this.fillData=res;
|
|
|
}
|
|
|
this.topNum=100-this.nums;
|
|
|
});
|
|
|
},
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
.echarts {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
.fillContainer{
|
|
|
box-sizing: content-box;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: space-around;
|
|
|
}
|
|
|
.fill-item{
|
|
|
width:100%;height:100%;
|
|
|
//flex: 1;
|
|
|
margin:10px;
|
|
|
}
|
|
|
.circle{
|
|
|
background-image: linear-gradient(20deg, #5a8ef5 , #aeedf1);
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
border-radius: 50%;
|
|
|
padding:4px;
|
|
|
box-sizing: content-box;
|
|
|
}
|
|
|
.wave{
|
|
|
background: #FFFFFF;
|
|
|
position: relative;
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
border-radius: 50%;
|
|
|
line-height: 50px;
|
|
|
margin: 0 auto;
|
|
|
font-size: 14px;
|
|
|
text-align: center;
|
|
|
overflow: hidden;
|
|
|
animation: water-wave linear infinite;
|
|
|
}
|
|
|
.wave1{
|
|
|
position: absolute;
|
|
|
top: 40%;
|
|
|
left: -70%;
|
|
|
background: #5a8ef5;
|
|
|
background-image: radial-gradient( #5a8ef5 , #aeedf1, #aeedf1, #5a8ef5);
|
|
|
opacity: .7;
|
|
|
width: 200%;
|
|
|
height: 200%;
|
|
|
border-radius: 40%;
|
|
|
animation: inherit;
|
|
|
animation-duration: 5s;
|
|
|
}
|
|
|
@keyframes water-wave{
|
|
|
0% {transform: rotate(0deg);}
|
|
|
100% {transform: rotate(360deg);}
|
|
|
}
|
|
|
.wave-val{
|
|
|
height: 100%;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
position: relative;
|
|
|
font-size: 20px;
|
|
|
}
|
|
|
.wave-title{
|
|
|
padding:10px;
|
|
|
}
|
|
|
</style> |
...
|
...
|
|