master
zhaoqiang 2024-07-14 15:15:17 +08:00
parent f0a2c23a87
commit 9f49493d83
3 changed files with 292 additions and 227 deletions

View File

@ -1,5 +1,6 @@
// 处理一些常用的方法
// 处理单位换算
export function handleUnit(data) {
if (Number(data) > 10000) {
@ -8,3 +9,31 @@ export function handleUnit(data) {
return data
}
}
// 处理echarts数据
export function handleEchartsData(data) {
// 间隔可以设置成动态的
let timeArray = [];
for (let hour = 0; hour < 24; hour++) {
for (let minute = 0; minute < 60; minute += 5) {
let timeString = (hour < 10 ? '0' + hour : hour) + ':' + (minute < 10 ? '0' + minute : minute);
timeArray.push(
{ datetime: timeString, measValue: '-' }
);
}
}
timeArray.forEach(item => {
data.forEach(ite => {
let iteTime = ite.datetime.split(' ')[1].split(':')[0] + ':' + ite.datetime.split(' ')[1].split(':')[1]
if (iteTime === item.datetime) {
item.measValue =ite.measValue
}
})
})
return timeArray
}

View File

@ -20,17 +20,17 @@
<div class="source_echart">
<div class="tabDate">
<div :class="[
sourcetabDateFlag === item.id
sourcetabDateFlagOne === item.id
? 'tab_active'
: 'tab_default',
'tab',
]" v-for="item in sourceEchart" @click="sourcehandleTabDate(item)">
]" v-for="(item,index) in sourceEchart" @click="sourcehandleTabDate(item)" :key="index">
{{ item.name }}
</div>
</div>
<div class="source_echart_box">
<!--光伏曲线 -->
<source_Photovoltaic_echart v-if="sourcetabDateFlag === 1"></source_Photovoltaic_echart>
<source_Photovoltaic_echart v-if="sourcetabDateFlagOne === 1"></source_Photovoltaic_echart>
<!-- 厂站曲线 -->
<source_factoryStation_echart v-else></source_factoryStation_echart>
</div>
@ -164,7 +164,7 @@
<div class="key">&nbsp;线路重过载&nbsp;:&nbsp;</div>
</div>
<div class="val">
<div class="ratekw">&nbsp;2</div>
<div class="ratekw">&nbsp;{{networkSonData.lineData.length|| 0}}</div>
<span></span>
</div>
</div>
@ -174,7 +174,7 @@
<div class="key">&nbsp;台区重过载&nbsp;:&nbsp;</div>
</div>
<div class="val">
<div class="ratekw">&nbsp;3</div>
<div class="ratekw">&nbsp;{{networkSonData.zoneAreaData.length|| 0}}</div>
<span></span>
</div>
</div>
@ -192,9 +192,9 @@
</div>
<div class="source_echart_box">
<!--光伏曲线 -->
<source_Photovoltaic_echart_Line v-if="sourcetabDateFlag === 1"></source_Photovoltaic_echart_Line>
<source_Photovoltaic_echart_Line :paramsData="networkSonData.lineData" v-if="sourcetabDateFlag === 1"></source_Photovoltaic_echart_Line>
<!-- 厂站曲线 -->
<source_Photovoltaic_echart_Line v-else></source_Photovoltaic_echart_Line>
<source_Photovoltaic_echart_Line :paramsData="networkSonData.zoneAreaData" v-else></source_Photovoltaic_echart_Line>
</div>
<!-- <div class="line">
<img
@ -355,6 +355,7 @@ import storage_echart from './oneLine.vue'
import threeEchart from './3Dechart.vue'
import { alert_api, statInfo_api, runAlarm_api } from '@/api/homePage/SoureceApi'
import { handleEchartsData } from '@/hooks/handleFun'
onMounted(() => {
getStatInfo()
@ -768,7 +769,8 @@ let runNetworkFlag = ref(true)
let runStorageFlag = ref(true)
//
// tabDate
let sourcetabDateFlag = ref(1)
let sourcetabDateFlag = ref(0)
let sourcetabDateFlagOne = ref(1)
let sourceEchart = reactive([
{
id: 1,
@ -925,8 +927,27 @@ let networkSonData = reactive<any>({
let getRunAlarm = () => {
runAlarm_api({
orgID: '8af8470a47aad8e20147aad92e400335'
}).then(res => {
console.log(res, '88888889999')
}).then((res: any) => {
// 线
res?.data?.feeder.forEach((item: any) => {
let result = handleEchartsData(item?.loadRate)
networkSonData.lineData.push({
mrid: item.mrid,
name: item.name,
data: result
})
})
//
res?.data?.transformer.forEach((item: any) => {
let result = handleEchartsData(item?.loadRate)
networkSonData.zoneAreaData.push({
mrid: item.mrid,
name: item.name,
data: result
})
})
sourcetabDateFlag.value = 1
console.log(networkSonData.lineData, networkSonData.zoneAreaData)
})
}
//

View File

@ -3,164 +3,179 @@
</template>
<script setup lang="ts">
import {
ref,
inject,
onBeforeUnmount,
getCurrentInstance,
onMounted,
watchEffect,
} from "vue";
import transformFontSize from "@/hooks/transFormSize.ts";
import "echarts/lib/component/dataZoom";
import { ref, inject, onBeforeUnmount, getCurrentInstance, onMounted, watchEffect } from 'vue'
import transformFontSize from '@/hooks/transFormSize.ts'
import 'echarts/lib/component/dataZoom'
onMounted(() => {
drawOneLine();
});
drawOneLine()
})
const props = defineProps<{
paramsData: any
}>()
// echartDOM
const ThreeLine: any = ref();
const ThreeLine: any = ref()
//
const { proxy }: any = getCurrentInstance();
const { proxy }: any = getCurrentInstance()
const drawOneLine = () => {
let myChart = proxy.$echarts.init(ThreeLine.value);
let legendData: any = []
let xData: any = []
let yData1: any = []
let yData2: any = []
let yData3: any = []
props.paramsData &&
props.paramsData.forEach((item,index) => {
legendData.push(item.name+index)
})
console.log(props.paramsData)
myChart.clear();
props.paramsData &&
props.paramsData[0]?.data.forEach(item => {
xData.push(item.datetime)
yData1.push(item.measValue)
})
props.paramsData &&
props.paramsData[1]?.data.forEach(item => {
yData2.push(item.measValue)
})
props.paramsData &&
props.paramsData[2]?.data.forEach(item => {
yData3.push(item.measValue)
})
console.log(legendData, xData, yData1, yData2, yData3, 'props.paramsData')
let myChart = proxy.$echarts.init(ThreeLine.value)
myChart.clear()
const option = {
tooltip: {
trigger: "axis",
trigger: 'axis',
// axisPointer: { type: 'cross' }
textStyle: {
color: "#FFFFFF",
color: '#FFFFFF'
},
// padding: transformFontSize(15),
backgroundColor: "rgba(0,163,166,.9)", //
borderColor: "rgba(0,163,166,.9)",
backgroundColor: 'rgba(0,163,166,.9)', //
borderColor: 'rgba(0,163,166,.9)',
borderRadius: 5,
formatter: function (param: any) {
let str = `
<div style="width:100%:height:100%">
<div style="display:flex;justify-content:space-between;"> ${
param[0].name.split(" ")[0]
}</div>
<div style="display:flex;justify-content:space-between;"> ${param[0].name.split(' ')[0]}</div>
${getDom(param)}
</div>`;
</div>`
function getDom(param: any) {
let newStr = "";
let newStr = ''
param.forEach((item: any) => {
newStr += `<div style="display:flex;"><div>${
item.seriesName
}负荷</div><div>${
item.value === undefined ? "0" : item.value
}kW</div></div>`;
});
return newStr;
newStr += `<div style="display:flex;"><div>${item.seriesName}负荷:</div><div>${item.value === undefined ? '0' : item.value}kW</div></div>`
})
return newStr
}
return str
}
return str;
},
},
legend: {
top: "10%",
right: "0%",
orient: "vertical",
data: ["55607", "55608", "55604"],
top: '10%',
right: '0%',
orient: 'vertical',
data: legendData,
itemWidth: transformFontSize(30),
itemHeight: transformFontSize(12),
itemGap: transformFontSize(8),
textStyle: {
fontSize: transformFontSize(30),
color: "#FFFFFF",
},
color: '#FFFFFF'
}
},
grid: {
top: "25%",
left: "10%",
right: "8%",
bottom: "13%",
top: '25%',
left: '10%',
right: '8%',
bottom: '13%'
},
xAxis: {
type: "category",
type: 'category',
axisTick: {
show: false,
alignWithLabel: true,
alignWithLabel: true
},
boundaryGap: false,
axisLabel: {
color: "#fff",
color: '#fff',
fontSize: transformFontSize(35),
padding: [0, 0, 0, 30],
padding: [0, 0, 0, 30]
// formatter: function (param: any) {
// return param.split(' ')[1].split(':')[0] + ':' + param.split(' ')[1].split(':')[1]
// },
},
offset: transformFontSize(15),
data: ["03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "24:00"],
data: xData
},
yAxis: {
splitLine: {
show: false,
show: false
},
axisLine: {
show: true, //y线
show: true //y线
},
type: "value",
name: "%",
type: 'value',
name: '%',
min: 0,
max: 100,
nameTextStyle: {
//yname
color: "#fff",
color: '#fff',
fontSize: transformFontSize(35),
padding: [0, 40, 10, 0],
padding: [0, 40, 10, 0]
},
position: "left",
position: 'left',
offset: transformFontSize(15),
axisLabel: {
//
color: "#fff",
color: '#fff',
fontSize: transformFontSize(35),
formatter: "{value}",
},
formatter: '{value}'
}
},
series: [
{
name: "55607",
type: "line",
name: legendData[0],
type: 'line',
barWidth: 2, //
smooth: true,
showSymbol: false,
itemStyle: {
color: "rgba(18, 231, 227, 1)",
color: 'rgba(18, 231, 227, 1)'
},
areaStyle: {
normal: {
color: new proxy.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgba(18, 231, 227, 0.4)",
color: 'rgba(18, 231, 227, 0.4)'
},
{
offset: 1,
color: "rgba(18, 231, 227, 0.01)",
color: 'rgba(18, 231, 227, 0.01)'
}
])
}
},
]),
},
},
data: [20, 42, 41, 24, 40, 30, 10],
data: yData1
},
{
name: "55608",
type: "line",
name: legendData[1],
type: 'line',
barWidth: 2, //
smooth: true,
showSymbol: false,
itemStyle: {
color: "rgba(251, 187, 111, 1)",
color: 'rgba(251, 187, 111, 1)'
},
areaStyle: {
normal: {
@ -168,27 +183,27 @@
{
offset: 0,
color: "rgba(251, 187, 111, 0.4)",
color: 'rgba(251, 187, 111, 0.4)'
},
{
offset: 1,
color: "rgba(251, 187, 111, 0.01)",
color: 'rgba(251, 187, 111, 0.01)'
}
])
}
},
]),
},
},
data: [30, 12, 11, 24, 20, 30, 30],
data: yData2
},
{
name: "55604",
type: "line",
name: legendData[2],
type: 'line',
barWidth: 2, //
smooth: true,
showSymbol: false,
itemStyle: {
color: "rgba(107, 255, 130, 1)",
color: 'rgba(107, 255, 130, 1)'
},
areaStyle: {
normal: {
@ -196,28 +211,28 @@
{
offset: 0,
color: "rgba(107, 255, 130, 0.4)",
color: 'rgba(107, 255, 130, 0.4)'
},
{
offset: 1,
color: "rgba(107, 255, 130, 0.01)",
color: 'rgba(107, 255, 130, 0.01)'
}
])
}
},
]),
},
},
data: [40, 18, 19, 23, 29, 33, 31],
},
],
};
myChart.setOption(option);
data: yData3
}
]
}
myChart.setOption(option)
//
window.addEventListener("resize", function () {
myChart.resize();
});
};
window.addEventListener('resize', function () {
myChart.resize()
})
}
</script>
<style scoped>