|
|
<template>
|
|
|
<div :style="styleObj" class="flex-div" @click="goJump">
|
|
|
<div class="percent-title" :style="titleStyle">
|
|
|
<img :src="imgStyle.imageAdress" alt="" class="icon-title">
|
|
|
{{ optionsSetup.titleName }}
|
|
|
</div>
|
|
|
<div class="percentContainer" :style="flexStyle">
|
|
|
<v-chart :options="options" autoresize/>
|
|
|
<div class="percent-label-item">
|
|
|
<div class="chart-title" v-for="(item,index) in percentData" :key="index">
|
|
|
<span :style="numStyle(item)">{{ item.num }}</span>
|
|
|
<span :style="pieStyle(item)">%</span>
|
|
|
</div>
|
|
|
<div :style="styleObj" class="flex-div-content" >
|
|
|
<div :style="styleObjItem" class="flex-div" @click="goJump(item)" v-for="(item,index) in percentData" :key="index">
|
|
|
<div class="percent-title" :style="titleStyle">
|
|
|
<img :src="imgStyle.imageAdress" alt="" class="icon-title">
|
|
|
<!-- {{ optionsSetup.titleName }}-->
|
|
|
{{item.resName}}
|
|
|
</div>
|
|
|
<div class="percent-item" >
|
|
|
<div class="chart-title" :style="subTitleStyle" v-for="(item,index) in percentData" :key="index">{{ item.name }}</div>
|
|
|
<div class="percentContainer" :style="flexStyle">
|
|
|
<v-chart :options="options[index]" autoresize/>
|
|
|
<div class="percent-label-item">
|
|
|
<div class="chart-title" v-for="(itemChild,index) in item.percentData" :key="index">
|
|
|
<span :style="numStyle(itemChild)">{{ itemChild.num }}</span>
|
|
|
<span :style="pieStyle(itemChild)">%</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="percent-item" >
|
|
|
<div class="chart-title" :style="subTitleStyle" v-for="(itemChild,index) in item.percentData" :key="index">{{ itemChild.name }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div :style="styleObjItemSup" class="flex-div" v-for="(item,index) in 3"></div>
|
|
|
|
|
|
|
|
|
</div>
|
|
|
</template>
|
...
|
...
|
@@ -33,100 +38,25 @@ export default { |
|
|
return {
|
|
|
percentData:'',//数据
|
|
|
angle: 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',
|
|
|
textStyle: {
|
|
|
color: 'white',
|
|
|
fontSize: 16,
|
|
|
padding: [10, 1, 10, 0],
|
|
|
},
|
|
|
selectedMode: false,
|
|
|
},
|
|
|
bottom:10,
|
|
|
series:[],
|
|
|
/*series: [
|
|
|
{
|
|
|
//name: '圆环',
|
|
|
type: 'pie',
|
|
|
radius: ['58%', '45%'],
|
|
|
silent: true,
|
|
|
clockwise: false,//圆环旋转方向,逆时针/顺时针
|
|
|
startAngle: 90,
|
|
|
z: 0,
|
|
|
zlevel: 0,
|
|
|
label: {
|
|
|
normal: {
|
|
|
position: 'center',
|
|
|
},
|
|
|
},
|
|
|
itemStyle:{
|
|
|
borderColor:'#00ff00',
|
|
|
borderWidth:[0,0,0,3],
|
|
|
borderType :'solid',
|
|
|
},
|
|
|
data: [
|
|
|
{
|
|
|
value: per,
|
|
|
name: '',
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
|
color: {
|
|
|
// 完成的圆环的颜色
|
|
|
colorStops: [
|
|
|
{
|
|
|
offset: 0,
|
|
|
color: '#4FADFD', // 0% 处的颜色
|
|
|
},
|
|
|
{
|
|
|
offset: 1,
|
|
|
color: '#28E8FA', // 100% 处的颜色
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
value: 100 - per,
|
|
|
name: '',
|
|
|
label: {
|
|
|
normal: {
|
|
|
show: false,
|
|
|
},
|
|
|
},
|
|
|
//剩余圆环颜色
|
|
|
itemStyle: {
|
|
|
normal: {
|
|
|
color: '#173164',
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
],*/
|
|
|
},
|
|
|
options: [
|
|
|
{
|
|
|
legend: {
|
|
|
type: 'plain',
|
|
|
orient: 'vertical',
|
|
|
right: 0,
|
|
|
top: '10%',
|
|
|
align: 'auto',
|
|
|
textStyle: {
|
|
|
color: 'white',
|
|
|
fontSize: 16,
|
|
|
padding: [10, 1, 10, 0],
|
|
|
},
|
|
|
selectedMode: false,
|
|
|
},
|
|
|
bottom:10,
|
|
|
series:[],
|
|
|
},
|
|
|
],
|
|
|
optionsStyle: {}, // 样式
|
|
|
optionsData: {}, // 数据
|
|
|
optionsCollapse: {}, // 图标属性
|
...
|
...
|
@@ -142,12 +72,28 @@ export default { |
|
|
left: this.optionsStyle.left + "px",
|
|
|
top: this.optionsStyle.top + "px",
|
|
|
background: this.optionsSetup.background,
|
|
|
cursor:this.optionsSetup.isNextPage?'pointer':''
|
|
|
};
|
|
|
},
|
|
|
styleObjItem(){
|
|
|
return{
|
|
|
width: this.optionsSetup.widthCard + "px",
|
|
|
height: this.optionsSetup.heightCard + "px",
|
|
|
cursor:this.optionsSetup.isNextPage?'pointer':'',
|
|
|
background: this.optionsSetup.backgroundItem,
|
|
|
'border-radius':this.optionsSetup.radiusCard+'px'
|
|
|
|
|
|
}
|
|
|
},
|
|
|
//补充空div
|
|
|
styleObjItemSup(){
|
|
|
return{
|
|
|
width: this.optionsSetup.widthCard + "px",
|
|
|
height: this.optionsSetup.heightCard + "px",
|
|
|
}
|
|
|
},
|
|
|
flexStyle(){
|
|
|
return{
|
|
|
'flex-flow':this.optionsSetup.flexFlow
|
|
|
// 'flex-flow':this.optionsSetup.flexFlow
|
|
|
}
|
|
|
},
|
|
|
//标题样式设置
|
...
|
...
|
@@ -236,11 +182,11 @@ export default { |
|
|
this.setOptionSurplusColor();
|
|
|
this.setOptionsData();
|
|
|
},
|
|
|
//设置环形图中心点
|
|
|
/*//设置环形图中心点
|
|
|
setSeriesCenter(){
|
|
|
if(this.percentData.series){
|
|
|
let width=this.optionsStyle.width;
|
|
|
let height=this.optionsStyle.height;
|
|
|
let width=this.optionsSetup.widthCard;
|
|
|
let height=this.optionsSetup.heightCard;
|
|
|
let width1=width/this.percentData.length;
|
|
|
let height1=height/2;
|
|
|
this.percentData.series.map((item,index)=> {
|
...
|
...
|
@@ -248,66 +194,72 @@ export default { |
|
|
item.center=center;
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
setOptionsTitle() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
if(this.percentData && this.percentData.length>0){
|
|
|
this.percentData.map(item=>{
|
|
|
const title = item.options.title;
|
|
|
title.x = "center";
|
|
|
title.y = "center";
|
|
|
const rich = {
|
|
|
nums: {
|
|
|
fontSize: optionsSetup.textNumFontSize,
|
|
|
color: optionsSetup.isCircleColor?item.num<60?optionsSetup.color0Start:item.num<90?optionsSetup.color0Start90:optionsSetup.color0Start100: optionsSetup.textNumColor,
|
|
|
fontWeight: optionsSetup.textNumFontWeight
|
|
|
},
|
|
|
percent: {
|
|
|
fontSize: optionsSetup.textPerFontSize,
|
|
|
color: optionsSetup.isCircleColor?item.num<60?optionsSetup.color0Start:item.num<90?optionsSetup.color0Start90:optionsSetup.color0Start100:optionsSetup.textPerColor,
|
|
|
fontWeight: optionsSetup.textPerFontWeight
|
|
|
}
|
|
|
};
|
|
|
title.textStyle['rich'] = rich;
|
|
|
item.options.title = title;
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
},*/
|
|
|
/* setOptionsTitle() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
if(this.percentData && this.percentData.length>0){
|
|
|
this.percentData.map(item=>{
|
|
|
const title = item.options.title;
|
|
|
title.x = "center";
|
|
|
title.y = "center";
|
|
|
const rich = {
|
|
|
nums: {
|
|
|
fontSize: optionsSetup.textNumFontSize,
|
|
|
color: optionsSetup.isCircleColor?item.num<60?optionsSetup.color0Start:item.num<90?optionsSetup.color0Start90:optionsSetup.color0Start100: optionsSetup.textNumColor,
|
|
|
fontWeight: optionsSetup.textNumFontWeight
|
|
|
},
|
|
|
percent: {
|
|
|
fontSize: optionsSetup.textPerFontSize,
|
|
|
color: optionsSetup.isCircleColor?item.num<60?optionsSetup.color0Start:item.num<90?optionsSetup.color0Start90:optionsSetup.color0Start100:optionsSetup.textPerColor,
|
|
|
fontWeight: optionsSetup.textPerFontWeight
|
|
|
}
|
|
|
};
|
|
|
title.textStyle['rich'] = rich;
|
|
|
item.options.title = title;
|
|
|
})
|
|
|
}
|
|
|
},*/
|
|
|
//圆环0-100%颜色
|
|
|
setOptionsColor() {
|
|
|
const optionsSetup = this.optionsSetup;
|
|
|
if(this.options.series && this.options.series.length>0){
|
|
|
this.options.series.map(item=>{
|
|
|
const itemStyle = item['data'][0]['itemStyle']
|
|
|
const normal = {
|
|
|
color: {
|
|
|
// 完成的圆环的颜色
|
|
|
colorStops: [
|
|
|
{
|
|
|
offset: 0,
|
|
|
color: item['data'][0].value<60?optionsSetup.color0Start:item['data'][0].value<90?optionsSetup.color0Start90:optionsSetup.color0Start100, // 0% 处的颜色
|
|
|
},
|
|
|
{
|
|
|
offset: 1,
|
|
|
color: item['data'][0].value<60?optionsSetup.color100End:item['data'][0].value<90?optionsSetup.color100End90:optionsSetup.color100End100, // 100% 处的颜色
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
};
|
|
|
itemStyle['normal'] = normal
|
|
|
})
|
|
|
}
|
|
|
this.options.map(itemAll=>{
|
|
|
if(itemAll.series && itemAll.series.length>0){
|
|
|
itemAll.series.map(item=>{
|
|
|
const itemStyle = item['data'][0]['itemStyle']
|
|
|
const normal = {
|
|
|
color: {
|
|
|
// 完成的圆环的颜色
|
|
|
colorStops: [
|
|
|
{
|
|
|
offset: 0,
|
|
|
color: item['data'][0].value<60?optionsSetup.color0Start:item['data'][0].value<90?optionsSetup.color0Start90:optionsSetup.color0Start100, // 0% 处的颜色
|
|
|
},
|
|
|
{
|
|
|
offset: 1,
|
|
|
color: item['data'][0].value<60?optionsSetup.color100End:item['data'][0].value<90?optionsSetup.color100End90:optionsSetup.color100End100, // 100% 处的颜色
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
};
|
|
|
itemStyle['normal'] = normal
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
|
|
|
},
|
|
|
setOptionSurplusColor() {
|
|
|
if(this.options.series && this.options.series.length>0){
|
|
|
this.options.series.map(item=>{
|
|
|
const itemStyle = item['data'][1]['itemStyle']
|
|
|
const normal = {
|
|
|
color: this.optionsSetup.colorsurplus,
|
|
|
};
|
|
|
itemStyle['normal'] = normal
|
|
|
})
|
|
|
}
|
|
|
this.options.map(itemAll=>{
|
|
|
if(itemAll.series && itemAll.series.length>0){
|
|
|
itemAll.series.map(item=>{
|
|
|
const itemStyle = item['data'][1]['itemStyle']
|
|
|
const normal = {
|
|
|
color: this.optionsSetup.colorsurplus,
|
|
|
};
|
|
|
itemStyle['normal'] = normal
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
|
|
|
},
|
|
|
// 数据解析
|
|
|
setOptionsData() {
|
...
|
...
|
@@ -320,22 +272,94 @@ export default { |
|
|
);
|
|
|
},
|
|
|
staticDataFn(val) {
|
|
|
this.percentData=val;
|
|
|
this.setPercentData();
|
|
|
this.setData(val)
|
|
|
},
|
|
|
//处理数据
|
|
|
setData(val){
|
|
|
let dataArr=val;
|
|
|
let arrCpu=[];
|
|
|
let arrmemory=[];
|
|
|
let arrstorage=[];
|
|
|
let optionArr=[]
|
|
|
dataArr.map(item=>{
|
|
|
if(item.cpuSetRate){
|
|
|
arrCpu=[{
|
|
|
num:item.cpuSetRate,
|
|
|
name:'cpu容量'
|
|
|
}]
|
|
|
}
|
|
|
if(item.storageSetRate){
|
|
|
arrmemory=[{
|
|
|
num:item.storageSetRate,
|
|
|
name:'存储容量'
|
|
|
}]
|
|
|
}
|
|
|
if(item.memorySetRate){
|
|
|
arrstorage=[{
|
|
|
num:item.memorySetRate,
|
|
|
name:'内存容量'
|
|
|
}]
|
|
|
}
|
|
|
if(arrCpu.length>0 && arrmemory.length>0 && arrstorage.length>0){
|
|
|
item.percentData=arrCpu.concat(arrmemory).concat(arrstorage);
|
|
|
|
|
|
}else if(arrCpu.length==0 && arrmemory.length>0 && arrstorage.length>0){
|
|
|
item.percentData=arrmemory.concat(arrstorage);
|
|
|
|
|
|
}else if(arrCpu.length>0 && arrmemory.length==0 && arrstorage.length>0){
|
|
|
item.percentData=arrCpu.concat(arrstorage);
|
|
|
|
|
|
}else if(arrCpu.length>0 && arrmemory.length>0 && arrstorage.length==0){
|
|
|
item.percentData=arrCpu.concat(arrmemory);
|
|
|
|
|
|
}else if(arrCpu.length==0 && arrmemory.length==0 && arrstorage.length>0){
|
|
|
item.percentData=arrstorage;
|
|
|
}else if(arrCpu.length==0 && arrmemory.length>0 && arrstorage.length==0){
|
|
|
item.percentData=arrmemory;
|
|
|
|
|
|
}else if(arrCpu.length>0 && arrmemory.length==0 && arrstorage.length==0){
|
|
|
item.percentData=arrCpu;
|
|
|
|
|
|
}
|
|
|
optionArr.push({
|
|
|
legend: {
|
|
|
type: 'plain',
|
|
|
orient: 'vertical',
|
|
|
right: 0,
|
|
|
top: '10%',
|
|
|
align: 'auto',
|
|
|
textStyle: {
|
|
|
color: 'white',
|
|
|
fontSize: 16,
|
|
|
padding: [10, 1, 10, 0],
|
|
|
},
|
|
|
selectedMode: false,
|
|
|
},
|
|
|
bottom:10,
|
|
|
series:[],
|
|
|
},)
|
|
|
})
|
|
|
this.options=optionArr;
|
|
|
this.percentData=dataArr;
|
|
|
this.percentData.map((item,index)=>{
|
|
|
this.setPercentData(index);
|
|
|
})
|
|
|
},
|
|
|
//设置数据
|
|
|
setPercentData(){
|
|
|
setPercentData(index){
|
|
|
let seriesArr=[];
|
|
|
let width=this.optionsStyle.width;
|
|
|
let height=this.optionsStyle.height;
|
|
|
let width1=width/this.percentData.length;
|
|
|
let height1=height/2;
|
|
|
this.percentData.map((item,index)=>{
|
|
|
let width=this.optionsSetup.widthCard;
|
|
|
let height=this.optionsSetup.heightCard;
|
|
|
let width1=width/this.percentData[0].percentData.length;
|
|
|
let height1=height/2-15;
|
|
|
let percentDataArr=this.percentData[index];
|
|
|
percentDataArr.percentData.map((item,index)=>{
|
|
|
let series={
|
|
|
//name: '圆环',
|
|
|
type: 'pie',
|
|
|
radius: ['70%', '60%'],
|
|
|
center:[(width1*index+width1/2),height1],
|
|
|
// center:[30,60],
|
|
|
silent: true,
|
|
|
clockwise: false,//圆环旋转方向,逆时针/顺时针
|
|
|
startAngle: 90,
|
...
|
...
|
@@ -394,7 +418,7 @@ export default { |
|
|
}
|
|
|
seriesArr.push(series)
|
|
|
})
|
|
|
this.options.series=seriesArr;
|
|
|
this.options[index].series=seriesArr;
|
|
|
},
|
|
|
dynamicDataFn(val, refreshTime) {
|
|
|
if (!val) return;
|
...
|
...
|
@@ -410,11 +434,10 @@ export default { |
|
|
getEchartData(val) {
|
|
|
const data = this.queryEchartsData(val);
|
|
|
data.then(res => {
|
|
|
this.percentData=res;
|
|
|
this.setPercentData()
|
|
|
this.setData(res)
|
|
|
});
|
|
|
},
|
|
|
goJump(){
|
|
|
goJump(item){
|
|
|
let locationUrl=this.$route.query;
|
|
|
if(this.optionsSetup.isNextPage){
|
|
|
let nextRouter=this.optionsSetup.nextRouter;
|
...
|
...
|
@@ -424,7 +447,7 @@ export default { |
|
|
if(nextRouter){
|
|
|
this.$router.push({
|
|
|
path: `/bigscreen/viewer`,
|
|
|
query: { reportCode: nextRouter },
|
|
|
query: { reportCode: nextRouter,titleName:item.resName ,resId:item.resId,resType: item.resType},
|
|
|
})
|
|
|
}
|
|
|
|
...
|
...
|
@@ -441,18 +464,24 @@ export default { |
|
|
height: 100%;
|
|
|
overflow: hidden;
|
|
|
}
|
|
|
.flex-div-content{
|
|
|
display: flex;
|
|
|
justify-content: space-between;
|
|
|
flex-wrap: wrap;
|
|
|
}
|
|
|
.flex-div{
|
|
|
display: flex;
|
|
|
flex-flow: column;
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
}
|
|
|
.percentContainer{
|
|
|
box-sizing: content-box;
|
|
|
/*display: flex;
|
|
|
align-items: center;
|
|
|
display: flex;
|
|
|
/*align-items: center;
|
|
|
justify-content: space-around;*/
|
|
|
flex:1;
|
|
|
position: relative;
|
|
|
flex-flow: column;
|
|
|
|
|
|
}
|
|
|
.percent-label-item{
|
...
|
...
|
@@ -472,6 +501,7 @@ export default { |
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: space-around;
|
|
|
padding:10px;
|
|
|
}
|
|
|
.chart-title{
|
|
|
/* position: absolute;
|
...
|
...
|
|