2023-02-06 13:34:15 +08:00
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<uni-data-checkbox v-model="radio" :localdata="sex"></uni-data-checkbox>
|
|
|
|
|
<view class="charts-box">
|
2023-08-23 16:22:08 +08:00
|
|
|
<qiun-data-charts type="column" :ontouch='true' :opts="opts" :chartData="chartData"/>
|
2023-02-06 13:34:15 +08:00
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
2023-08-18 14:41:53 +08:00
|
|
|
props: {
|
|
|
|
|
basicData: {
|
|
|
|
|
type: Array,
|
2023-08-23 16:22:08 +08:00
|
|
|
default: () => [],
|
|
|
|
|
},
|
2023-08-18 14:41:53 +08:00
|
|
|
},
|
|
|
|
|
data() {
|
2023-02-06 13:34:15 +08:00
|
|
|
return {
|
|
|
|
|
radio: 0,
|
2023-08-18 14:41:53 +08:00
|
|
|
renderData: {
|
|
|
|
|
电网侧: {},
|
|
|
|
|
负载侧: {},
|
|
|
|
|
},
|
2023-02-06 13:34:15 +08:00
|
|
|
chartData: {},
|
|
|
|
|
//您可以通过修改 config-ucharts.js 文件中下标为 ['column'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
|
|
|
|
|
opts: {
|
|
|
|
|
enableScroll: true,
|
2023-08-23 16:22:08 +08:00
|
|
|
color: [
|
|
|
|
|
'#1890FF',
|
|
|
|
|
'#91CB74',
|
|
|
|
|
'#FAC858',
|
|
|
|
|
'#EE6666',
|
|
|
|
|
'#73C0DE',
|
|
|
|
|
'#3CA272',
|
|
|
|
|
'#FC8452',
|
|
|
|
|
'#9A60B4',
|
|
|
|
|
'#ea7ccc',
|
|
|
|
|
],
|
|
|
|
|
padding: [20, 10, 0, 0],
|
2023-02-06 13:34:15 +08:00
|
|
|
legend: {},
|
|
|
|
|
xAxis: {
|
|
|
|
|
disableGrid: true,
|
|
|
|
|
itemCount: 8,
|
2023-03-22 14:09:51 +08:00
|
|
|
// scrollShow: true,
|
2023-08-23 16:22:08 +08:00
|
|
|
data: [
|
|
|
|
|
{
|
|
|
|
|
min: 0,
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-02-06 13:34:15 +08:00
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
data: [
|
|
|
|
|
{
|
2023-08-23 16:22:08 +08:00
|
|
|
min: 0,
|
|
|
|
|
tofix: 4,
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-02-06 13:34:15 +08:00
|
|
|
},
|
|
|
|
|
extra: {
|
|
|
|
|
column: {
|
2023-08-23 16:22:08 +08:00
|
|
|
width: 10,
|
|
|
|
|
categoryGap: 1,
|
|
|
|
|
},
|
2023-02-06 13:34:15 +08:00
|
|
|
},
|
2023-08-23 16:22:08 +08:00
|
|
|
},
|
|
|
|
|
}
|
2023-02-06 13:34:15 +08:00
|
|
|
},
|
2023-08-18 14:41:53 +08:00
|
|
|
watch: {
|
|
|
|
|
basicData: {
|
|
|
|
|
handler: function (newVal, oldVal) {
|
|
|
|
|
let basicData = JSON.parse(JSON.stringify(this.basicData))
|
|
|
|
|
let arr = [
|
|
|
|
|
{
|
|
|
|
|
name: '电网侧',
|
|
|
|
|
linePostion: 'cb23b9ede3b652cd6da194fd7b318124',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '负载侧',
|
|
|
|
|
linePostion: '32624d4bb3a86f2b9a01bab272e50125',
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
basicData.forEach((item) => {
|
|
|
|
|
if (item.statisticalName.indexOf('Pq_HarmI_') === -1) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let index = arr.findIndex((item2) => {
|
|
|
|
|
return item2.linePostion === item.position
|
|
|
|
|
})
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
if (this.renderData[arr[index]['name']][item.phase]) {
|
2023-08-23 16:22:08 +08:00
|
|
|
this.renderData[arr[index]['name']][item.phase][item.statisticalName] =
|
|
|
|
|
item.statisticalData || 0
|
2023-08-18 14:41:53 +08:00
|
|
|
} else {
|
|
|
|
|
this.renderData[arr[index]['name']][item.phase] = {
|
|
|
|
|
phase: item.phase,
|
|
|
|
|
[item.statisticalName]: item.statisticalData || 0,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
console.log(this.renderData)
|
|
|
|
|
this.sex = Object.keys(this.renderData['电网侧']).map((item, index) => {
|
|
|
|
|
return {
|
|
|
|
|
text: item,
|
2023-08-23 16:22:08 +08:00
|
|
|
value: index,
|
2023-08-18 14:41:53 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2023-08-23 16:22:08 +08:00
|
|
|
let obj = JSON.parse(
|
|
|
|
|
JSON.stringify(this.renderData['电网侧'][Object.keys(this.renderData['电网侧'])[0]]),
|
|
|
|
|
)
|
2023-08-18 14:41:53 +08:00
|
|
|
delete obj['phase']
|
2023-08-23 16:22:08 +08:00
|
|
|
console.log(
|
|
|
|
|
Object.keys(obj).map((item) => {
|
2023-08-18 14:41:53 +08:00
|
|
|
return item.match(/Pq_HarmI_(\d+)/)[1]
|
|
|
|
|
}),
|
2023-08-23 16:22:08 +08:00
|
|
|
)
|
|
|
|
|
console.log(
|
|
|
|
|
Object.values(this.renderData['电网侧'][this.sex[this.radio].text]).filter((item) => {
|
|
|
|
|
return typeof item === 'number'
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
console.log(
|
|
|
|
|
Object.values(this.renderData['负载侧'][this.sex[this.radio].text]).filter((item) => {
|
|
|
|
|
return typeof item === 'number'
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
this.chartData = {
|
|
|
|
|
categories: Object.keys(obj).map((item) => {
|
|
|
|
|
return Number(item.match(/Pq_HarmI_(\d+)/)[1])
|
|
|
|
|
}),
|
2023-08-18 14:41:53 +08:00
|
|
|
series: [
|
|
|
|
|
{
|
2023-08-23 16:22:08 +08:00
|
|
|
name: '电网侧',
|
2023-08-18 14:41:53 +08:00
|
|
|
data: Object.values(this.renderData['电网侧'][this.sex[this.radio].text]).filter((item) => {
|
|
|
|
|
return typeof item === 'number'
|
2023-08-23 16:22:08 +08:00
|
|
|
}),
|
2023-08-18 14:41:53 +08:00
|
|
|
},
|
|
|
|
|
{
|
2023-08-23 16:22:08 +08:00
|
|
|
name: '负载侧',
|
2023-08-18 14:41:53 +08:00
|
|
|
data: Object.values(this.renderData['负载侧'][this.sex[this.radio].text]).filter((item) => {
|
|
|
|
|
return typeof item === 'number'
|
2023-08-23 16:22:08 +08:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-08-18 14:41:53 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
deep: true,
|
|
|
|
|
immediate: true,
|
2023-02-06 13:34:15 +08:00
|
|
|
},
|
2023-08-23 16:22:08 +08:00
|
|
|
},
|
2023-08-18 14:41:53 +08:00
|
|
|
}
|
2023-02-06 13:34:15 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.charts-box {
|
|
|
|
|
margin-top: 20rpx;
|
2023-08-23 16:22:08 +08:00
|
|
|
height: 800rpx;
|
2023-02-06 13:34:15 +08:00
|
|
|
}
|
2023-08-23 16:22:08 +08:00
|
|
|
</style>
|