2024-04-17 16:17:07 +08:00
|
|
|
<!--
|
|
|
|
* @Author: zwq
|
|
|
|
* @Date: 2022-01-21 14:43:06
|
2024-05-22 16:28:47 +08:00
|
|
|
* @LastEditors: DY
|
2024-07-03 08:51:32 +08:00
|
|
|
* @LastEditTime: 2024-07-01 16:54:41
|
2024-04-17 16:17:07 +08:00
|
|
|
* @Description:
|
|
|
|
-->
|
|
|
|
<template>
|
|
|
|
<!-- <div> -->
|
|
|
|
<!-- <div :id="id" :class="className" :style="{ height: '65%', width:width}" /> -->
|
|
|
|
<div :id="id" :class="className" :style="{ height: height, width: width }" />
|
|
|
|
<!-- </div> -->
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
import 'echarts/theme/macarons' // echarts theme
|
|
|
|
import resize from '@/mixins/resize'
|
2024-06-19 16:04:42 +08:00
|
|
|
import { factoryListabbr } from "@/utils/constants";
|
|
|
|
|
2024-04-17 16:17:07 +08:00
|
|
|
export default {
|
|
|
|
name: 'OverviewBar',
|
|
|
|
mixins: [resize],
|
|
|
|
props: {
|
|
|
|
id: {
|
|
|
|
type: String,
|
|
|
|
default: 'reportChart'
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
type: String,
|
|
|
|
default: 'reportChart'
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: String,
|
|
|
|
default: '100%'
|
|
|
|
},
|
|
|
|
beilv: {
|
|
|
|
type: Number,
|
|
|
|
default: 1
|
|
|
|
},
|
|
|
|
height: {
|
|
|
|
type: String,
|
2024-06-24 16:57:15 +08:00
|
|
|
default: '35vh'
|
2024-04-17 16:17:07 +08:00
|
|
|
},
|
|
|
|
legendPosition: {
|
|
|
|
type: String,
|
|
|
|
default: 'center'
|
|
|
|
},
|
|
|
|
showLegend: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
legendData: {
|
|
|
|
type: Array,
|
|
|
|
default: () => []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
chart: null
|
|
|
|
}
|
|
|
|
},
|
2024-05-22 16:28:47 +08:00
|
|
|
// mounted() {
|
|
|
|
// this.$nextTick(() => {
|
|
|
|
// this.initChart()
|
|
|
|
// })
|
|
|
|
// },
|
2024-04-17 16:17:07 +08:00
|
|
|
beforeDestroy() {
|
|
|
|
if (!this.chart) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.chart.dispose()
|
|
|
|
this.chart = null
|
|
|
|
},
|
|
|
|
methods: {
|
2024-05-22 16:28:47 +08:00
|
|
|
initChart(xAxis, seriesList) {
|
2024-06-19 16:04:42 +08:00
|
|
|
if (xAxis.length === 0) {
|
|
|
|
this.chart.clear()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.chart = echarts.init(document.getElementById(this.id))
|
|
|
|
console.log(this.$parent);
|
|
|
|
this.chart.setOption({
|
2024-04-17 16:17:07 +08:00
|
|
|
title: {
|
|
|
|
text: '',
|
|
|
|
// subtext: 'Fake Data'
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
right: '90px',
|
|
|
|
top: '0%',
|
|
|
|
icon: 'rect',
|
|
|
|
itemWidth: 10,
|
|
|
|
itemHeight: 10,
|
|
|
|
itemGap: 40,
|
2024-06-19 16:04:42 +08:00
|
|
|
formatter(name) {
|
|
|
|
return name.split('-')[0]
|
|
|
|
},
|
|
|
|
data: ['玻璃芯片-0', '标准组件-0', 'BIPV-0']
|
2024-04-17 16:17:07 +08:00
|
|
|
},
|
2024-06-19 16:04:42 +08:00
|
|
|
tooltip: {
|
|
|
|
trigger: 'axis',
|
2024-07-03 08:51:32 +08:00
|
|
|
axisPointer: {
|
|
|
|
type: 'shadow',
|
|
|
|
color: "rgba(237,237,237,0.5)"
|
|
|
|
},
|
2024-06-19 16:04:42 +08:00
|
|
|
formatter: function(params) {
|
|
|
|
let result = `
|
|
|
|
<div style="width: 270px; display: flex">
|
|
|
|
<div style="width: 150px">${params[0].name}</div>
|
2024-07-03 08:51:32 +08:00
|
|
|
<div style="width: 60px; text-align: right">${factoryListabbr[0]}</div>
|
|
|
|
<div style="width: 60px; text-align: right">${factoryListabbr[1]}</div>
|
2024-06-19 16:04:42 +08:00
|
|
|
</div>`
|
|
|
|
const newArray = params.map(p => {
|
2024-07-03 16:28:41 +08:00
|
|
|
console.log(factoryListabbr[p.seriesName.split('-')[1]], p.seriesName.split('-')[0])
|
2024-06-19 16:04:42 +08:00
|
|
|
return {
|
|
|
|
glass: p.seriesName.split('-')[0], // 玻璃类型
|
|
|
|
factoryName: factoryListabbr[p.seriesName.split('-')[1]], // 工厂名称
|
|
|
|
value: p.value,
|
|
|
|
name: p.name,
|
2024-07-03 08:51:32 +08:00
|
|
|
marker: p.marker,
|
|
|
|
color: p.color
|
2024-06-19 16:04:42 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
const analyzeList = Object.groupBy(newArray, (member) => member.glass)
|
|
|
|
for (let g in analyzeList) {
|
|
|
|
// date => 玻璃类型
|
|
|
|
let oneData = `<div style="width: 270px; display: flex">
|
2024-07-03 08:51:32 +08:00
|
|
|
<div style="width: 150px; display: flex; align-items: center">
|
|
|
|
<div style="background-color: ${analyzeList[g][0].color}; width: 10px; height: 10px; margin-right: 5px"></div>
|
|
|
|
<div>${g}</div></div>`
|
2024-06-19 16:04:42 +08:00
|
|
|
for (let fac of factoryListabbr) {
|
|
|
|
let goodNum = 0
|
|
|
|
for (let ana of analyzeList[g]) {
|
|
|
|
if (ana.factoryName === fac && ana.value !== 0) {
|
|
|
|
goodNum = ana.value
|
|
|
|
}
|
|
|
|
}
|
2024-07-03 08:51:32 +08:00
|
|
|
oneData += `<div style="width: 60px; text-align: right">${goodNum}</div>`
|
2024-06-19 16:04:42 +08:00
|
|
|
}
|
|
|
|
result = result + oneData + '</div>'
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
},
|
|
|
|
grid: { top: 100, right: 90, bottom: 10, left: 10, containLabel: true },
|
2024-04-17 16:17:07 +08:00
|
|
|
calculable: true,
|
|
|
|
xAxis: [
|
|
|
|
{
|
|
|
|
type: 'category',
|
2024-06-24 16:57:15 +08:00
|
|
|
name: '日期',
|
|
|
|
data: xAxis,
|
|
|
|
axisLabel: {
|
|
|
|
rotate: 25
|
|
|
|
}
|
2024-04-17 16:17:07 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
yAxis: [
|
|
|
|
{
|
2024-06-24 16:57:15 +08:00
|
|
|
type: 'value',
|
2024-07-03 16:28:41 +08:00
|
|
|
name: '单位:片'
|
2024-04-17 16:17:07 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
grid: {
|
2024-06-24 16:57:15 +08:00
|
|
|
top: '10%',
|
2024-07-03 08:51:32 +08:00
|
|
|
left: "2%",
|
2024-06-24 16:57:15 +08:00
|
|
|
right: "5%",
|
|
|
|
bottom: "0%",
|
2024-04-17 16:17:07 +08:00
|
|
|
containLabel: true
|
|
|
|
},
|
2024-05-22 16:28:47 +08:00
|
|
|
series: seriesList
|
|
|
|
}, true)
|
2024-06-19 16:04:42 +08:00
|
|
|
}
|
2024-04-17 16:17:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2024-06-19 16:04:42 +08:00
|
|
|
.chartTooltipSpan {
|
|
|
|
width: 50px;
|
|
|
|
background: #787878;
|
|
|
|
}
|
2024-04-17 16:17:07 +08:00
|
|
|
/* .reportChart {
|
|
|
|
position: absolute;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
top: 10px;
|
|
|
|
} */
|
|
|
|
</style>
|