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-18 14:41:53 +08:00
|
|
|
<qiun-data-charts type="bar" :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,
|
|
|
|
|
default: () => []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
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,
|
|
|
|
|
color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
|
2023-08-18 14:41:53 +08:00
|
|
|
padding: [10, 0, 10, 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-02-06 13:34:15 +08:00
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
data: [
|
|
|
|
|
{
|
|
|
|
|
min: 0
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
extra: {
|
|
|
|
|
column: {
|
|
|
|
|
type: "group",
|
|
|
|
|
width: 30,
|
|
|
|
|
activeBgColor: "#000000",
|
|
|
|
|
activeBgOpacity: 0.08
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-08-18 14:41:53 +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]) {
|
|
|
|
|
this.renderData[arr[index]['name']][item.phase][item.statisticalName] = item.statisticalData || 0
|
|
|
|
|
} 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,
|
|
|
|
|
value: index
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
let obj = JSON.parse(JSON.stringify(this.renderData['电网侧'][Object.keys(this.renderData['电网侧'])[0]]))
|
|
|
|
|
delete obj['phase']
|
|
|
|
|
console.log(Object.keys(obj).map(item => {
|
|
|
|
|
return Number(item.match(/Pq_HarmI_(\d+)/)[1])
|
|
|
|
|
}))
|
|
|
|
|
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 item.match(/Pq_HarmI_(\d+)/)[1]
|
|
|
|
|
}),
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: "电网侧",
|
|
|
|
|
data: Object.values(this.renderData['电网侧'][this.sex[this.radio].text]).filter((item) => {
|
|
|
|
|
return typeof item === 'number'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "负载侧",
|
|
|
|
|
data: Object.values(this.renderData['负载侧'][this.sex[this.radio].text]).filter((item) => {
|
|
|
|
|
return typeof item === 'number'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
deep: true,
|
|
|
|
|
immediate: true,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
// this.getServerData();
|
2023-02-06 13:34:15 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2023-08-18 14:41:53 +08:00
|
|
|
getServerData() {
|
2023-02-06 13:34:15 +08:00
|
|
|
//模拟从服务器获取数据时的延时
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
//模拟服务器返回数据,如果数据格式和标准格式不同,需自行按下面的格式拼接
|
|
|
|
|
let res = {
|
|
|
|
|
categories: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"],
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: "电网侧",
|
2023-03-22 14:09:51 +08:00
|
|
|
data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 7]
|
2023-02-06 13:34:15 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "负载册",
|
2023-03-22 14:09:51 +08:00
|
|
|
data: [5, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
|
2023-02-06 13:34:15 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
this.chartData = JSON.parse(JSON.stringify(res));
|
2023-02-07 17:59:54 +08:00
|
|
|
}, 500);
|
2023-02-06 13:34:15 +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-18 14:41:53 +08:00
|
|
|
height: 600px;
|
2023-02-06 13:34:15 +08:00
|
|
|
}
|
|
|
|
|
</style>
|