mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
203 lines
4.1 KiB
Vue
203 lines
4.1 KiB
Vue
|
|
<template>
|
||
|
|
<div class="disCharge">
|
||
|
|
<div id="disCharge-chart"></div>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
export default {
|
||
|
|
name: '',
|
||
|
|
props: {
|
||
|
|
deviceInfo: {
|
||
|
|
type: Array,
|
||
|
|
default: () => []
|
||
|
|
}
|
||
|
|
},
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
curList: [
|
||
|
|
{
|
||
|
|
name: '日充电电量',
|
||
|
|
key: 'key1',
|
||
|
|
lineColor: '#9BD801',
|
||
|
|
value:0,
|
||
|
|
d:'kW·h'
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: '日放电电量',
|
||
|
|
key: 'key2',
|
||
|
|
lineColor: '#3DFEFA',
|
||
|
|
value:0,
|
||
|
|
d:'kW·h'
|
||
|
|
},
|
||
|
|
],
|
||
|
|
|
||
|
|
disChargeChart: null,
|
||
|
|
lineChartData: {
|
||
|
|
ydata: [],
|
||
|
|
xdata: []
|
||
|
|
},
|
||
|
|
|
||
|
|
}
|
||
|
|
},
|
||
|
|
watch: {
|
||
|
|
deviceInfo: {
|
||
|
|
handler(n) {
|
||
|
|
this.$nextTick(() => {
|
||
|
|
this.drawLineChart()
|
||
|
|
})
|
||
|
|
}
|
||
|
|
// immediate: true
|
||
|
|
}
|
||
|
|
},
|
||
|
|
mounted() {},
|
||
|
|
onBeforeUnmount() {
|
||
|
|
this.disChargeChart = null
|
||
|
|
window.removeEventListener('resize', this.handleResize)
|
||
|
|
},
|
||
|
|
|
||
|
|
methods: {
|
||
|
|
handleResize() {
|
||
|
|
this.disChargeChart.resize()
|
||
|
|
},
|
||
|
|
processData(data, keys) {
|
||
|
|
data.sort((a, b) => {
|
||
|
|
return new Date(a.date) - new Date(b.date)
|
||
|
|
})
|
||
|
|
const dates = data.map((item) => item.date)
|
||
|
|
const values=[]
|
||
|
|
keys.forEach((item,index)=>{
|
||
|
|
|
||
|
|
values[index]= data.map((dataValue)=>dataValue[keys[index]])
|
||
|
|
})
|
||
|
|
|
||
|
|
return {
|
||
|
|
dates,
|
||
|
|
values,
|
||
|
|
}
|
||
|
|
},
|
||
|
|
getDisChargeData() {
|
||
|
|
const arr=this.curList
|
||
|
|
const keyList=this.curList.map((item)=>item.key)
|
||
|
|
const result = this.processData(this.deviceInfo, keyList)
|
||
|
|
|
||
|
|
this.lineChartData.xdata = result.dates
|
||
|
|
arr.forEach((item, index) => {
|
||
|
|
this.lineChartData.ydata[index] = {
|
||
|
|
name: item.name,
|
||
|
|
smooth: false,
|
||
|
|
type: 'line',
|
||
|
|
barWidth: 10,
|
||
|
|
itemStyle: {
|
||
|
|
borderRadius: 10,
|
||
|
|
color: item.lineColor
|
||
|
|
},
|
||
|
|
emphasis: {
|
||
|
|
focus: 'series'
|
||
|
|
},
|
||
|
|
|
||
|
|
global: false,
|
||
|
|
showSymbol: false,
|
||
|
|
data:result.values[index]
|
||
|
|
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
|
||
|
|
drawLineChart(activeKey) {
|
||
|
|
this.getDisChargeData(activeKey)
|
||
|
|
const chartDom = document.getElementById('disCharge-chart')
|
||
|
|
let disChargeChart = this.$echarts.init(chartDom)
|
||
|
|
this.disChargeChart = disChargeChart
|
||
|
|
const option = {
|
||
|
|
tooltip: {
|
||
|
|
trigger: 'axis',
|
||
|
|
axisPointer: {
|
||
|
|
type: 'shadow'
|
||
|
|
}
|
||
|
|
},
|
||
|
|
legend: {
|
||
|
|
top: 20,
|
||
|
|
textStyle: {
|
||
|
|
color: '#fff'
|
||
|
|
}
|
||
|
|
},
|
||
|
|
grid: {
|
||
|
|
left: '3%',
|
||
|
|
right: '4%',
|
||
|
|
bottom: '5%',
|
||
|
|
containLabel: true
|
||
|
|
},
|
||
|
|
xAxis: {
|
||
|
|
type: 'category',
|
||
|
|
data: this.lineChartData.xdata,
|
||
|
|
axisLine: {
|
||
|
|
lineStyle: { type: 'dashed', color: '#435463' }
|
||
|
|
},
|
||
|
|
axisLabel: {
|
||
|
|
color: '#fff'
|
||
|
|
}
|
||
|
|
},
|
||
|
|
yAxis: {
|
||
|
|
type: 'value',
|
||
|
|
splitLine: {
|
||
|
|
lineStyle: { type: 'dashed', color: '#435463' }
|
||
|
|
},
|
||
|
|
axisLabel: {
|
||
|
|
color: '#fff'
|
||
|
|
}
|
||
|
|
},
|
||
|
|
series: this.lineChartData.ydata
|
||
|
|
}
|
||
|
|
option && disChargeChart.setOption(option)
|
||
|
|
window.addEventListener('resize', this.handleResize)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
.disCharge {
|
||
|
|
height:calc(100% - 45px);
|
||
|
|
|
||
|
|
|
||
|
|
#disCharge-chart {
|
||
|
|
height: 100%;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
.text_Cur {
|
||
|
|
border-bottom: 1px solid transparent;
|
||
|
|
border-top: 1px solid transparent;
|
||
|
|
border-image: linear-gradient(to right, transparent, #1d8a7b, transparent) 1;
|
||
|
|
padding: 0px 15px;
|
||
|
|
font-size: 14px;
|
||
|
|
margin: 3px 0px;
|
||
|
|
height: 45px;
|
||
|
|
display: flex;
|
||
|
|
justify-content: space-between;
|
||
|
|
align-items: center;
|
||
|
|
& > div:last-child{
|
||
|
|
display: flex;
|
||
|
|
flex-direction: column;
|
||
|
|
justify-content: center;
|
||
|
|
align-items: end;
|
||
|
|
}
|
||
|
|
.mark {
|
||
|
|
font-size: 16px;
|
||
|
|
margin-right: 2px;
|
||
|
|
}
|
||
|
|
|
||
|
|
background: linear-gradient(
|
||
|
|
90deg,
|
||
|
|
rgba(0, 186, 173, 0.15) 0%,
|
||
|
|
rgba(61, 254, 250, 0.15) 49.2%,
|
||
|
|
rgba(61, 254, 250, 0) 100%
|
||
|
|
);
|
||
|
|
.d{
|
||
|
|
margin-left: 1px;
|
||
|
|
font-size: 12px;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|