Commit bb00d5e7 authored by wends's avatar wends

update 频域分析

parent eadf5a9f
......@@ -2,7 +2,7 @@ import request from '@/utils/request'
// const baseURL = process.env.VUE_APP_BASE_API
const baseURL = ''
// 获取数据集列表-分页
// 时域分析
export function getTimeDomainData(data) {
return request({
url: `${baseURL}/iot/dashboard/timeDomainData`,
......@@ -10,3 +10,19 @@ export function getTimeDomainData(data) {
data
})
}
// 频域分析
export function getFrequencyDomainData(data) {
return request({
url: `${baseURL}/iot/dashboard/frequencyDomainData`,
method: 'post',
data
})
}
// 获取指定实例采样数据列表
export function getDataPreview(data) {
return request({
url: `${baseURL}/iot/dashboard/dataPreview`,
method: 'post',
data
})
}
......@@ -75,23 +75,16 @@ export default {
this.chart = null
},
methods: {
dispatch(action) {
this.chart.dispatchAction(action)
},
updateChart(data) {
console.log(data)
const xAxis = []
const series = []
data.forEach(v => {
xAxis.push(v[0])
series.push(v[1])
})
this.chart.setOption({
xAxis: {
data: xAxis
},
series: [{
type: 'line',
showSymbol: false,
clip: true,
data: series
data: data
}]
})
},
......@@ -118,6 +111,12 @@ export default {
},
yAxis: {
name: 'y',
max: function(value) {
return (value.max + 2).toFixed(2)
},
min: function(value) {
return (value.min - 2).toFixed(2)
},
minorTick: {
show: true
},
......@@ -146,6 +145,13 @@ export default {
}
this.chart.setOption(config)
// this.chart.on('datazoom', (val) => {
// const params = {
// type: 'functionLine',
// val: val.batch[0]
// }
// this.$emit('datazoom', params)
// })
}
}
}
......
......@@ -55,6 +55,12 @@ export default {
step: {
type: Boolean,
default: false
},
functionList: {
type: Array,
default: () => {
return {}
}
}
},
data() {
......@@ -65,6 +71,18 @@ export default {
watch: {
lineData: function(val) {
this.updateChart(val)
},
functionList: function(val) {
const series = []
this.lineData.xAxis.forEach(i => {
let sum = 0
val.forEach(v => {
const { amplitude, frequency, phase } = v.func
sum += this.func(i, amplitude, frequency, phase)
})
series.push(sum)
})
this.secondChart(series)
}
},
mounted() {
......@@ -78,14 +96,50 @@ export default {
this.chart = null
},
methods: {
func(x, amplitude = 1, frequency = 1, phase = 0) {
return amplitude * Math.cos(2 * Math.PI * frequency * x + phase * Math.PI)
},
dispatch(action) {
this.chart.dispatchAction(action)
},
secondChart(chart) {
this.chart.setOption({
xAxis: {
data: this.lineData.xAxis
},
legend: {
data: ['时序数据', '拟合数据']
},
series: [
{
type: 'line',
showSymbol: false,
name: '时序数据',
clip: true,
data: this.lineData.series.map(v => this.strip(v))
},
{
type: 'line',
showSymbol: false,
name: '拟合数据',
clip: true,
data: chart
}
]
})
},
updateChart(data) {
this.chart.setOption({
legend: {
data: ['时序数据']
},
xAxis: {
data: data.xAxis
},
series: [{
type: 'line',
showSymbol: false,
name: '时序数据',
clip: true,
data: data.series.map(v => this.strip(v))
}]
......@@ -110,12 +164,16 @@ export default {
this.chart = echarts.init(document.getElementById(this.id))
let config = {
tooltip: {},
legend: {
data: ['时序数据']
},
xAxis: {
data: []
},
yAxis: {},
series: [{
type: 'line',
name: '时序数据',
data: []
}]
}
......@@ -125,6 +183,13 @@ export default {
}
this.chart.setOption(config)
this.chart.on('datazoom', (val) => {
const params = {
type: 'timeDomainLine',
val: val.batch[0]
}
this.$emit('datazoom', params)
})
}
}
}
......
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