|
|
export default {
|
|
|
name: 'Availability',
|
|
|
name: 'availability',
|
|
|
template: '',
|
|
|
components: {},
|
|
|
data () {
|
|
|
components: {
|
|
|
'LineChart': Vue.defineAsyncComponent(
|
|
|
() => myImport('views/zjdaping/components/lineChart/index')
|
|
|
)
|
|
|
},
|
|
|
data(){
|
|
|
return {
|
|
|
chartInstance: null,
|
|
|
allData: {
|
|
|
polyline: {
|
|
|
title: "业务可用性",
|
|
|
unit: "%",
|
|
|
data: {
|
|
|
name: "占比",
|
|
|
data: ["67","70","80","71","90","92","72","70","56","45","89","100"]
|
|
|
}
|
|
|
},
|
|
|
xAxis: {
|
|
|
time: ["01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00"]
|
|
|
}
|
|
|
},
|
|
|
titleFontSize: 20,
|
|
|
startValue: 0, // 区域缩放的起点值
|
|
|
endValue: 6, // 区域缩放的终点值
|
|
|
timerId: null // 定时器的标识
|
|
|
domainName:sessionStorage.getItem('domainName'),
|
|
|
apiUrl:'/api-web/sxview/getBusinessAvailability',
|
|
|
resourceStatisticsData:'',
|
|
|
optionData:'',
|
|
|
ySeriesCommon:[],
|
|
|
titleFontSize: 30,
|
|
|
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
this.initChart()
|
|
|
this.getData()
|
|
|
window.addEventListener('resize', this.screenAdapter)
|
|
|
this.screenAdapter()
|
|
|
},
|
|
|
unmounted () {
|
|
|
window.removeEventListener('resize', this.screenAdapter)
|
|
|
clearInterval(this.timerId)
|
|
|
},
|
|
|
computed: {
|
|
|
comtitleTextStyle () {
|
|
|
return {
|
...
|
...
|
@@ -42,159 +25,290 @@ export default { |
|
|
},
|
|
|
comtitleImgStyle () {
|
|
|
return {
|
|
|
// height: this.titleFontSize + 'px',
|
|
|
width: this.titleFontSize * 8 + 'px'
|
|
|
height: this.titleFontSize * 2.1 + 'px'
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
initChart () {
|
|
|
this.chartInstance = echarts.init(document.getElementById('availability_ref'))
|
|
|
const initOption = {
|
|
|
grid: {
|
|
|
top: '25%',
|
|
|
left: '3%',
|
|
|
right: '6%',
|
|
|
bottom: '3%',
|
|
|
containLabel: true
|
|
|
},
|
|
|
legend: {
|
|
|
right: '2%',
|
|
|
top: '5%'
|
|
|
setup(props, {attrs, slots, emit}) {
|
|
|
const {proxy} = Vue.getCurrentInstance();
|
|
|
|
|
|
|
|
|
// 挂载完
|
|
|
|
|
|
Vue.onMounted(() => {
|
|
|
proxy.screenAdapter();
|
|
|
proxy.getData();
|
|
|
|
|
|
})
|
|
|
const getData=()=> {
|
|
|
$.get(proxy.domainName + proxy.apiUrl, function (res) {
|
|
|
const data = res;
|
|
|
if (data && data.data) {
|
|
|
let resData = data.data;
|
|
|
|
|
|
}
|
|
|
// proxy.optionInit();
|
|
|
|
|
|
})
|
|
|
|
|
|
proxy.optionInit();
|
|
|
}
|
|
|
|
|
|
const optionInit=()=>{
|
|
|
|
|
|
let data3=[350, 350, 350, 350, 350, 350, 350];
|
|
|
let data4=[220, 182, 191, 234, 290, 330, 310];
|
|
|
let data2=[100, 100, 100, 100, 100, 100, 100];
|
|
|
let data1=[12.3, 7.56, 66.6, 5.44, 66.6, 5.44,6.52];
|
|
|
|
|
|
let min1=proxy.calMin([data1,data2]);
|
|
|
let max1=proxy.calMax([data1,data2]);
|
|
|
let min2=proxy.calMin([data3,data4]);
|
|
|
let max2=proxy.calMax([data3,data4]);
|
|
|
//业务双y轴数据
|
|
|
proxy.ySeriesCommon=[
|
|
|
{
|
|
|
name:'可用性',
|
|
|
type: 'line',
|
|
|
smooth:true,
|
|
|
// stack: 'Total',
|
|
|
show:false,
|
|
|
data:data3,
|
|
|
yAxisIndex:1,
|
|
|
showSymbol:false,
|
|
|
itemStyle : {
|
|
|
normal : {
|
|
|
color:"#97d5f4",//tooltip里的小圆点颜色
|
|
|
lineStyle:{
|
|
|
color:'#97d5f4',
|
|
|
width:1
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
areaStyle: {
|
|
|
// color:'rgba(151,213,244,0.4)',
|
|
|
normal:{
|
|
|
color:new echarts.graphic.LinearGradient(0, 0, 0, .6, [{ //关键在这里, 设置面积渐变
|
|
|
offset: 0,
|
|
|
color: '#97d5f4' //这里是我设置的渐变的颜色从线条颜色变为透明
|
|
|
}, {
|
|
|
offset: 1,
|
|
|
color: 'rgba(151,213,244,0.1)'
|
|
|
}])
|
|
|
}
|
|
|
|
|
|
},
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: 'category',
|
|
|
boundaryGap: false,
|
|
|
axisLabel: {
|
|
|
textStyle: {
|
|
|
color: '#E6E8EB'
|
|
|
{
|
|
|
name:'成功率',
|
|
|
type: 'line',
|
|
|
smooth:true,
|
|
|
// stack: 'Total',
|
|
|
show:false,
|
|
|
data:data1,
|
|
|
yAxisIndex:0,
|
|
|
showSymbol:false,
|
|
|
itemStyle : {
|
|
|
normal : {
|
|
|
color:"#efe0a7",//tooltip里的小圆点颜色
|
|
|
lineStyle:{
|
|
|
color:'#efe0a7',
|
|
|
width:1
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
areaStyle: {
|
|
|
color:'rgba(239,224,167,0)'
|
|
|
},
|
|
|
},
|
|
|
yAxis: {
|
|
|
type: 'value',
|
|
|
splitLine: {
|
|
|
show: false
|
|
|
{
|
|
|
name:'响应率',
|
|
|
type: 'line',
|
|
|
smooth:true,
|
|
|
// stack: 'Total',
|
|
|
show:false,
|
|
|
data:data2,
|
|
|
yAxisIndex:0,
|
|
|
showSymbol:false,
|
|
|
itemStyle : {
|
|
|
normal : {
|
|
|
color:"#e5abd1",//tooltip里的小圆点颜色
|
|
|
lineStyle:{
|
|
|
color:'#e5abd1',
|
|
|
width:1
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
axisLabel: {
|
|
|
textStyle: {
|
|
|
color: '#E6E8EB'
|
|
|
areaStyle: {
|
|
|
color:'rgba(229,171,209,0)'
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
name:'交易量',
|
|
|
type: 'line',
|
|
|
smooth:true,
|
|
|
// stack: 'Total',
|
|
|
show:false,
|
|
|
data:data4,
|
|
|
yAxisIndex:1,
|
|
|
showSymbol:false,
|
|
|
itemStyle : {
|
|
|
normal : {
|
|
|
color:"#97aaff",//tooltip里的小圆点颜色
|
|
|
lineStyle:{
|
|
|
color:'#97aaff',
|
|
|
width:1,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
areaStyle: {
|
|
|
color:'rgba(151,170,255,0)'
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
this.chartInstance.setOption(initOption)
|
|
|
},
|
|
|
getData () {
|
|
|
// await this.$http.get()
|
|
|
// const { data: ret } = await this.$http.get('responsemonitor')
|
|
|
// this.allData = ret
|
|
|
// console.log(ret)
|
|
|
this.updateChart()
|
|
|
this.startInterval()
|
|
|
},
|
|
|
updateChart () {
|
|
|
// 半透明的颜色值
|
|
|
const colorArr1 = [
|
|
|
'rgba(11, 168, 44, 0.5)',
|
|
|
'rgba(44, 110, 255, 0.5)',
|
|
|
'rgba(22, 242, 217, 0.5)',
|
|
|
'rgba(254, 33, 30, 0.5)',
|
|
|
'rgba(250, 105, 0, 0.5)'
|
|
|
]
|
|
|
// 全透明的颜色值
|
|
|
const colorArr2 = [
|
|
|
'rgba(11, 168, 44, 0)',
|
|
|
'rgba(44, 110, 255, 0)',
|
|
|
'rgba(22, 242, 217, 0)',
|
|
|
'rgba(254, 33, 30, 0)',
|
|
|
'rgba(250, 105, 0, 0)'
|
|
|
]
|
|
|
const timeArr = this.allData.xAxis.today
|
|
|
const seriesData = this.allData.polyline.data.data
|
|
|
const seriesName = this.allData.polyline.data.name
|
|
|
// 图例的数据
|
|
|
const legendArr = this.allData.polyline.data.data.map(item => {
|
|
|
return item.name
|
|
|
// let xAxisDataLength=proxy.ySeriesCommon[0].length;
|
|
|
let xAxisData=[];
|
|
|
for(let i=0;i<=24;i++){
|
|
|
if(i%4==0){
|
|
|
xAxisData.push(i+':00')
|
|
|
|
|
|
}
|
|
|
}
|
|
|
let legendData=[];
|
|
|
$.each(proxy.ySeriesCommon,function (i,v){
|
|
|
legendData.push(v.name)
|
|
|
})
|
|
|
console.log(legendArr)
|
|
|
const title = this.allData.polyline.title
|
|
|
const unit = this.allData.polyline.unit
|
|
|
const dataOption = {
|
|
|
// title: {
|
|
|
// text: '{Sunny| 业务可用性 }',
|
|
|
// show: true
|
|
|
// },
|
|
|
xAxis: {
|
|
|
data: timeArr
|
|
|
proxy.legendData=legendData;
|
|
|
proxy.optionData = {
|
|
|
title: {
|
|
|
text: ''
|
|
|
},
|
|
|
tooltip: {
|
|
|
trigger: 'axis',
|
|
|
backgroundColor:'rgba(50,50,50,0.7)',
|
|
|
borderColor:"#333",
|
|
|
textStyle:{
|
|
|
color:"#fff",
|
|
|
align:'left'
|
|
|
}
|
|
|
|
|
|
},
|
|
|
legend: {
|
|
|
data: legendArr
|
|
|
data: proxy.legendData,
|
|
|
itemHeight:0,//图例圆圈大小设置
|
|
|
y:'0px',
|
|
|
textStyle: {
|
|
|
color: '#ffffff',
|
|
|
fontsize:"12px"
|
|
|
}
|
|
|
|
|
|
},
|
|
|
dataZoom: {
|
|
|
show: false,
|
|
|
startValue: this.startValue,
|
|
|
endValue: this.endValue
|
|
|
grid: {
|
|
|
top:'15%',
|
|
|
left: '3%',
|
|
|
right: '4%',
|
|
|
// bottom: '3%',
|
|
|
containLabel: true,
|
|
|
},
|
|
|
series: [
|
|
|
xAxis: {
|
|
|
type: 'category',
|
|
|
boundaryGap: false,
|
|
|
data: xAxisData,
|
|
|
|
|
|
axisLine:{
|
|
|
show:false,//是否显示坐标线
|
|
|
},
|
|
|
axisTick: {
|
|
|
show: false //是否显示坐标刻度
|
|
|
},
|
|
|
axisLabel:{
|
|
|
color:'#ffffff',
|
|
|
},
|
|
|
|
|
|
},
|
|
|
yAxis:[
|
|
|
{
|
|
|
name: seriesName,
|
|
|
type: 'line',
|
|
|
data: seriesData,
|
|
|
smooth: true,
|
|
|
areaStyle: {
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
{
|
|
|
offset: 0,
|
|
|
color: colorArr1[2]
|
|
|
}, // %0的颜色值
|
|
|
{
|
|
|
offset: 1,
|
|
|
color: colorArr2[2]
|
|
|
} // 100%的颜色值
|
|
|
])
|
|
|
|
|
|
type: 'value',
|
|
|
axisLabel: {
|
|
|
formatter: '{value} %'//以百分比显示
|
|
|
},
|
|
|
splitLine:{
|
|
|
lineStyle: {
|
|
|
color:'#0a1b31'
|
|
|
}
|
|
|
},
|
|
|
min:0,
|
|
|
max:100,
|
|
|
splitNumber:5,
|
|
|
interval:(100-0)/5
|
|
|
}, {
|
|
|
name: '单位:万',
|
|
|
type: 'value',
|
|
|
axisLabel: {
|
|
|
show: true,
|
|
|
interval: 'right',//居中显示
|
|
|
},
|
|
|
splitLine:{
|
|
|
lineStyle: {
|
|
|
color:'#0a1b31'
|
|
|
}
|
|
|
},
|
|
|
min:min2,
|
|
|
max:max2,
|
|
|
splitNumber:5,
|
|
|
interval:(max2-min2)/5
|
|
|
},
|
|
|
],
|
|
|
series: proxy.ySeriesCommon,
|
|
|
itemStyle:{
|
|
|
showSymbol:false
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
//计算最大值
|
|
|
const calMax=(arr)=>{
|
|
|
let max=0;
|
|
|
arr.forEach((el)=>{
|
|
|
el.forEach((el1)=>{
|
|
|
if(!(el1 === undefined || el1 === '')){
|
|
|
if(max<el1){
|
|
|
max=el1;
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
this.chartInstance.setOption(dataOption)
|
|
|
},
|
|
|
screenAdapter () {
|
|
|
this.titleFontSize = document.getElementById('availability_ref').offsetWidth / 100 * 3.6
|
|
|
const adapterOption = {
|
|
|
legend: {
|
|
|
itemWidth: this.titleFontSize,
|
|
|
itemHeight: this.titleFontSize,
|
|
|
itemGap: this.titleFontSize,
|
|
|
textStyle: {
|
|
|
fontSize: this.titleFontSize / 2
|
|
|
})
|
|
|
})
|
|
|
let maxint=Math.ceil(max/9.5);
|
|
|
let maxval=maxint * 10;//让显示的刻度是整数
|
|
|
return maxval;
|
|
|
}
|
|
|
//计算最小值
|
|
|
const calMin=(arr)=>{
|
|
|
let min=0;
|
|
|
arr.forEach((el)=>{
|
|
|
el.forEach((el1)=>{
|
|
|
if(!(el1 === undefined || el1 === '')){
|
|
|
if(min>el1){
|
|
|
min=el1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
this.chartInstance.setOption(adapterOption)
|
|
|
this.chartInstance.resize()
|
|
|
},
|
|
|
startInterval () {
|
|
|
if (this.timerId) {
|
|
|
clearInterval(this.timerId)
|
|
|
}
|
|
|
let index = 12
|
|
|
/*this.timerId = setInterval(() => {
|
|
|
this.startValue++
|
|
|
this.endValue++
|
|
|
// this.allData.polyline.data
|
|
|
// console.log((this.allData.polyline.data)[0].data.length)
|
|
|
if ((this.allData.polyline.data).length > 0) {
|
|
|
index = (this.allData.polyline.data)[0].data.length
|
|
|
}
|
|
|
if (this.endValue > index - 1) {
|
|
|
this.startValue = 0
|
|
|
this.endValue = 6
|
|
|
}
|
|
|
console.log(this.startValue)
|
|
|
console.log(this.endValue)
|
|
|
this.updateChart()
|
|
|
}, 5000)*/
|
|
|
})
|
|
|
})
|
|
|
let minint=Math.floor(min/10);
|
|
|
let minval=minint * 10;//让显示的刻度是整数
|
|
|
return minval;
|
|
|
}
|
|
|
|
|
|
const screenAdapter=()=>{
|
|
|
proxy.titleFontSize = document.getElementById('availability_ref').offsetWidth / 100 * 3.6
|
|
|
}
|
|
|
|
|
|
return{
|
|
|
calMax,
|
|
|
calMin,
|
|
|
optionInit,
|
|
|
getData,
|
|
|
screenAdapter
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|