Commit 7e408ccf authored by yanzhongrong's avatar yanzhongrong

pic analysis

parent e0543186
<template> <template>
<el-dialog title="驻波比图形分析" :visible.sync="visible" width="60%" @close="cancel"> <el-dialog
<div ref="chartLine" class="chartLine"></div> title="驻波比图形分析"
:visible.sync="visible"
width="1060px"
@close="cancel"
>
<div v-show="listData.length" ref="chartLine" class="chartLine" :key="componentKeys"></div>
<div v-show="!listData.length" style="font-size:20px;text-align:center"><i class="el-icon-warning" style="color:orange;margin-right:10px" />暂无数据</div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="cancel">关 闭</el-button> <el-button @click="cancel">关 闭</el-button>
</span> </span>
...@@ -24,6 +30,8 @@ export default { ...@@ -24,6 +30,8 @@ export default {
data() { data() {
return { return {
visible: false, visible: false,
componentKeys: 0,
listData: []
} }
}, },
watch: { watch: {
...@@ -35,6 +43,7 @@ export default { ...@@ -35,6 +43,7 @@ export default {
}, },
curInfo(newV) { curInfo(newV) {
if (newV) { if (newV) {
this.componentKeys++
this.init() this.init()
} }
} }
...@@ -45,20 +54,7 @@ export default { ...@@ -45,20 +54,7 @@ export default {
let keyList = Object.keys(res.collect) let keyList = Object.keys(res.collect)
let valueList = Object.values(res.collect) let valueList = Object.values(res.collect)
let finallyList = [] let finallyList = []
let obj = {} for (var i = 0; i < keyList.length; i++) {
let source = []
if(keyList.length == 1) {
valueList[0].map(item => {
let arr = []
arr.push(parseInt(item.distance),parseInt(item.value))
source.push(arr)
})
obj.dimensions = ['float', `${keyList[0]}`]
obj.source = source
finallyList.push(obj)
finallyList.length ? this.getLine(finallyList) : ''
} else {
for(var i = 0; i < keyList.length; i++) {
let obj = {} let obj = {}
let source = [] let source = []
valueList[i].map(item => { valueList[i].map(item => {
...@@ -66,29 +62,46 @@ export default { ...@@ -66,29 +62,46 @@ export default {
arr.push(parseInt(item.distance), parseInt(item.value)) arr.push(parseInt(item.distance), parseInt(item.value))
source.push(arr) source.push(arr)
}) })
obj.dimensions = ['', `${keyList[i]}`] obj.dimensions = [`${keyList[i]}`]
obj.source = source obj.source = source
finallyList.push(obj) finallyList.push(obj)
} }
console.log(finallyList, 'finallyList'); this.listData = finallyList
finallyList.length ? this.getLine(finallyList) : '' finallyList.length ? this.getLine(finallyList) : ''
}
}) })
}, },
getLine(data) { getLine(data) {
if(data.length) {
this.myChartLine = echarts.init(this.$refs.chartLine) this.myChartLine = echarts.init(this.$refs.chartLine)
let option = { let option = {
legend: {}, legend: {},
tooltip: {}, tooltip: {
trigger: 'axis',
formatter: function (params) {
if (params.length > 1) {
let str = params[0].data[0] + "<br />"
params.forEach(item => {
str += '<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:' + item.color + '"></span>'
+ '<span style="display:inline-block;width:70px;margin-right:5px;">' + item.seriesName + '</span>'
+ " 驻波比"
+ '<span style="font-weight:700;">' + item.data[1] + "</span><br />";
})
return str;
} else {
let str = params[0].data[0] + "<br />"
str += '<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:' + params[0].color + '"></span>'
+ '<span style="display:inline-block;width:70px;margin-right:5px;">' + params[0].seriesName + '</span>'
+ " 驻波比"
+ '<span style="font-weight:700;">' + params[0].data[1] + "</span><br />";
return str;
}
},
},
dataset: data, dataset: data,
xAxis: { xAxis: {
type: "value", type: "value",
boundaryGap: false, boundaryGap: false,
axisLabel: { axisLabel: {
//show:true,
// interval:2
// rotate:60,
color: "#30eee9", color: "#30eee9",
}, },
axisLine: { axisLine: {
...@@ -135,8 +148,6 @@ export default { ...@@ -135,8 +148,6 @@ export default {
}, },
}, },
], ],
// Declare several bar series, each will be mapped
// to a column of dataset.source by default.
series: [ series: [
{ {
type: 'line', type: 'line',
...@@ -159,7 +170,10 @@ export default { ...@@ -159,7 +170,10 @@ export default {
}; };
this.lineOption = option this.lineOption = option
this.myChartLine.setOption(option) this.myChartLine.setOption(option)
// }) window.addEventListener("resize", () => {
this.myChartLine.resize()
})
}
}, },
cancel() { cancel() {
this.visible = false this.visible = false
...@@ -171,7 +185,7 @@ export default { ...@@ -171,7 +185,7 @@ export default {
<style> <style>
.chartLine { .chartLine {
width: 100%; width: 1000px;
height: 500px; height: 500px;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment