249 lines
8.4 KiB
Vue
249 lines
8.4 KiB
Vue
<template>
|
|
<view>
|
|
<div class="header-form">
|
|
<uni-data-select
|
|
v-model="parity"
|
|
:localdata="parityOption"
|
|
@change="initEcharts"
|
|
style="flex: 1"
|
|
:clear="false"
|
|
></uni-data-select>
|
|
<!-- <uni-data-checkbox v-model="dataRadio" :localdata="dataOptions" @change="initEcharts"></uni-data-checkbox> -->
|
|
<uni-data-select
|
|
v-model="dataRadio"
|
|
:localdata="dataOptions"
|
|
@change="initEcharts"
|
|
style="flex: 2; margin-left: 20rpx"
|
|
:clear="false"
|
|
></uni-data-select>
|
|
</div>
|
|
<view class="charts-box">
|
|
<!-- <view class="data-time">{{ time }}</view> -->
|
|
<qiun-data-charts type="bar" :ontouch="true" :opts="opts" :chartData="chartData" />
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
basicData: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
dataTime: {
|
|
type: [String,Number],
|
|
default: '',
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
parityOption: [
|
|
{
|
|
text: '奇次',
|
|
value: 2,
|
|
},
|
|
{
|
|
text: '偶次',
|
|
value: 1,
|
|
},
|
|
],
|
|
parity: 2,
|
|
time: '',
|
|
dataOptions: [],
|
|
dataRadio: 0,
|
|
renderData: {
|
|
电网侧: {
|
|
Apf_HarmI: {},
|
|
Apf_HarmUR: {},
|
|
},
|
|
负载侧: {
|
|
Apf_HarmI: {},
|
|
Apf_HarmUR: {},
|
|
},
|
|
},
|
|
chartData: {},
|
|
//您可以通过修改 config-ucharts.js 文件中下标为 ['column'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
|
|
opts: {
|
|
// enableScroll: true,
|
|
dataLabel: false,
|
|
color: [
|
|
'#1890FF',
|
|
'#91CB74',
|
|
'#FAC858',
|
|
'#EE6666',
|
|
'#73C0DE',
|
|
'#3CA272',
|
|
'#FC8452',
|
|
'#9A60B4',
|
|
'#ea7ccc',
|
|
],
|
|
padding: [0, 10, 0, 0],
|
|
legend: {
|
|
position: 'top',
|
|
float: 'left',
|
|
},
|
|
xAxis: {
|
|
disableGrid: true,
|
|
itemCount: 8,
|
|
// scrollShow: true,
|
|
data: [
|
|
{
|
|
min: 0,
|
|
},
|
|
],
|
|
position: 'top',
|
|
},
|
|
yAxis: {},
|
|
extra: {
|
|
bar: {
|
|
type: 'group',
|
|
width: 30,
|
|
meterBorde: 1,
|
|
meterFillColor: '#FFFFFF',
|
|
activeBgColor: '#000000',
|
|
activeBgOpacity: 0.08,
|
|
seriesGap: 1,
|
|
categoryGap: 4,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
},
|
|
watch: {
|
|
basicData: {
|
|
handler(newVal, oldVal) {
|
|
console.log(this.basicData)
|
|
let basicData = JSON.parse(JSON.stringify(this.basicData))
|
|
// this.dataRadio = 0
|
|
this.renderData = {
|
|
电网侧: {
|
|
Apf_HarmI: {},
|
|
Apf_HarmUR: {},
|
|
},
|
|
负载侧: {
|
|
Apf_HarmI: {},
|
|
Apf_HarmUR: {},
|
|
},
|
|
}
|
|
let arr = [
|
|
{
|
|
name: '电网侧',
|
|
key: 'Apf_HarmI_Sys',
|
|
},
|
|
{
|
|
name: '电网侧',
|
|
key: 'Apf_HarmUR_Sys',
|
|
},
|
|
{
|
|
name: '负载侧',
|
|
key: 'Apf_HarmI_Load',
|
|
},
|
|
{
|
|
name: '负载侧',
|
|
key: 'Apf_HarmUR_Load',
|
|
},
|
|
]
|
|
basicData.forEach((item) => {
|
|
let have = arr.find((item2) => {
|
|
return item.statisticalName.indexOf(item2.key) > -1
|
|
})
|
|
if (!have) return
|
|
let name1 = have['name']
|
|
let name2 = have.key.split('_')[0] + '_' + have.key.split('_')[1]
|
|
if (this.renderData[name1][name2][item.phase]) {
|
|
this.renderData[name1][name2][item.phase][item.statisticalName] = item.statisticalData || 0
|
|
} else {
|
|
this.renderData[name1][name2][item.phase] = {
|
|
[item.statisticalName]: item.statisticalData || 0,
|
|
}
|
|
}
|
|
})
|
|
console.log(this.renderData)
|
|
let dataOptions = []
|
|
let type = [
|
|
{
|
|
name: '谐波电流幅值序列',
|
|
key: 'Apf_HarmI',
|
|
},
|
|
{
|
|
name: '谐波电压含有率序列',
|
|
key: 'Apf_HarmUR',
|
|
},
|
|
]
|
|
Object.keys(this.renderData['电网侧']['Apf_HarmI']).forEach((item, index) => {
|
|
type.forEach((item2) => {
|
|
dataOptions.push({
|
|
text: item + '相' + item2.name,
|
|
pointer: item2.key + '_' + item,
|
|
value: dataOptions.length,
|
|
})
|
|
})
|
|
})
|
|
this.dataOptions = dataOptions
|
|
console.log(dataOptions)
|
|
this.initEcharts()
|
|
this.time = this.$util.parseTime(this.dataTime - 8 * 60 * 60)
|
|
},
|
|
deep: true,
|
|
immediate: true,
|
|
},
|
|
},
|
|
methods: {
|
|
initEcharts() {
|
|
setTimeout(() => {
|
|
let obj = JSON.parse(
|
|
JSON.stringify(
|
|
this.renderData['电网侧']['Apf_HarmI'][Object.keys(this.renderData['电网侧']['Apf_HarmI'])[0]],
|
|
),
|
|
)
|
|
let key = this.dataOptions[this.dataRadio].pointer.split('_')
|
|
console.log(key)
|
|
let name1 = key[0] + '_' + key[1]
|
|
let name2 = key[2]
|
|
this.chartData = {
|
|
categories: Object.keys(obj)
|
|
.map((item) => {
|
|
// Apf_HarmI_Sys_36(A) 匹配36
|
|
return Number(item.match(/\d+/)[0])
|
|
})
|
|
.filter((item) => {
|
|
return item % 2 === this.parity - 1
|
|
}),
|
|
series: [
|
|
{
|
|
name: '电网侧',
|
|
data: Object.values(this.renderData['电网侧'][name1][name2]).filter((item, index) => {
|
|
return index % 2 === this.parity - 1
|
|
}),
|
|
},
|
|
{
|
|
name: '负载侧',
|
|
data: Object.values(this.renderData['负载侧'][name1][name2]).filter((item, index) => {
|
|
return index % 2 === this.parity - 1
|
|
}),
|
|
},
|
|
],
|
|
}
|
|
}, 100)
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.charts-box {
|
|
margin-top: 20rpx;
|
|
height: 100vh;
|
|
.data-time {
|
|
position: absolute;
|
|
right: 20rpx;
|
|
margin-top: 18rpx;
|
|
font-size: 24rpx;
|
|
}
|
|
}
|
|
.header-form {
|
|
display: flex;
|
|
}
|
|
</style>
|