11-mes-new/src/views/QualityManager/components/charts/newLineStack.vue

335 lines
8.6 KiB
Vue
Raw Normal View History

2022-11-07 08:45:49 +08:00
<template>
2022-11-18 14:50:57 +08:00
<div ref="chartContainer" class="chartContainer" style="position: relative; width: 100%; height: 100%;" />
2022-11-07 08:45:49 +08:00
</template>
<script>
import echarts from 'echarts'
import resize from '@/views/OperationalOverview/components/mixins/resize'
export default {
name: 'PlFaultAnalysisPieChart',
mixins: [resize],
2022-11-17 16:42:24 +08:00
props: {
dataUpdateToken: {
type: String,
default: 'default-token'
}
},
2022-11-07 08:45:49 +08:00
data() {
return {
chart: null,
configs: {
color: ['#FB418C', '#DDB112', '#1A99FF', '#A691FF', '#49FBD6'],
tooltip: {
trigger: 'axis',
2022-11-17 16:42:24 +08:00
extraCssText: 'width: 180px !important; ',
2022-11-07 08:45:49 +08:00
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
grid: {
2022-11-18 14:50:57 +08:00
top: '25%',
2022-11-07 08:45:49 +08:00
left: '2%',
2022-11-18 14:50:57 +08:00
right: '5%',
bottom: '5%',
2022-11-07 08:45:49 +08:00
containLabel: true
},
xAxis: [
{
type: 'category',
boundaryGap: false,
axisLine: {
lineStyle: {
color: '#ffffff66'
}
},
axisTick: { show: false },
axisLabel: {
textStyle: {
color: 'rgba(255,255,255,1)' //
},
2022-11-18 14:50:57 +08:00
margin: 12
2022-11-07 08:45:49 +08:00
},
data: ['A', 'B', 'C', 'D', 'E', 'F', 'G']
}
],
yAxis: [
{
name: '成品率',
type: 'value',
2022-11-18 14:50:57 +08:00
min: 'dataMin',
2022-11-18 15:03:18 +08:00
splitNumber: 4,
2022-11-07 08:45:49 +08:00
nameTextStyle: {
color: 'rgba(255,255,255,0.7)',
2022-11-18 14:50:57 +08:00
fontSize: 12,
2022-11-07 08:45:49 +08:00
align: 'right'
},
axisLine: {
lineStyle: {
type: 'solid',
color: 'rgba(119, 255, 242, 0.6)', // 左边线的颜色
width: '1' // 坐标线的宽度
}
},
axisTick: {
show: false
},
axisLabel: {
2022-11-17 16:42:24 +08:00
formatter: '{value} %',
2022-11-07 08:45:49 +08:00
textStyle: {
color: 'rgba(255,255,255,0.5)' // 坐标值得具体的颜色
}
},
splitLine: {
lineStyle: {
type: 'dotted',
color: 'rgba(119, 255, 242, 0.2)'
}
}
}
],
series: [
{
name: 'A1下片机',
type: 'line',
symbol: 'none',
areaStyle: {
// color: 'rgba(50,145,152,0.5)'
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
2022-11-08 14:40:04 +08:00
color: '#FB418C66' // 0% 处的颜色
2022-11-07 08:45:49 +08:00
},
{
offset: 1,
color: 'transparent' // 100% 处的颜色
}
],
global: false // 缺省为 false
}
},
emphasis: {
focus: 'series'
},
2022-11-17 16:42:24 +08:00
data: [11, 199, 140, 63, 185, 5, 78].map(_ => {
let v = Math.floor(Math.random() * 100)
2022-11-18 14:50:57 +08:00
while (v < 80) {
v = Math.floor(Math.random() * 100)
}
2022-11-17 16:42:24 +08:00
return v
})
2022-11-07 08:45:49 +08:00
},
{
name: '磨边机',
type: 'line',
symbol: 'none',
areaStyle: {
// color: 'rgba(50,145,152,0.5)'
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
2022-11-08 14:40:04 +08:00
color: '#DDB11266' // 0% 处的颜色
2022-11-07 08:45:49 +08:00
},
{
offset: 1,
color: 'transparent' // 100% 处的颜色
}
],
global: false // 缺省为 false
}
},
emphasis: {
focus: 'series'
},
2022-11-17 16:42:24 +08:00
data: [151, 57, 31, 7, 77, 88, 119].map(_ => {
let v = Math.floor(Math.random() * 100)
2022-11-18 14:50:57 +08:00
while (v < 80) {
v = Math.floor(Math.random() * 100)
}
2022-11-17 16:42:24 +08:00
return v
})
2022-11-07 08:45:49 +08:00
},
{
name: '镀膜机',
type: 'line',
symbol: 'none',
areaStyle: {
// color: 'rgba(50,145,152,0.5)'
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
2022-11-08 14:40:04 +08:00
color: '#1A99FF66' // 0% 处的颜色
2022-11-07 08:45:49 +08:00
},
{
offset: 1,
color: 'transparent' // 100% 处的颜色
}
],
global: false // 缺省为 false
}
},
emphasis: {
focus: 'series'
},
2022-11-17 16:42:24 +08:00
data: [58, 3, 67, 100, 42, 96, 124].map(_ => {
let v = Math.floor(Math.random() * 100)
2022-11-18 14:50:57 +08:00
while (v < 80) {
v = Math.floor(Math.random() * 100)
}
2022-11-17 16:42:24 +08:00
return v
})
2022-11-07 08:45:49 +08:00
},
{
name: '包装纸',
type: 'line',
symbol: 'none',
areaStyle: {
// color: 'rgba(50,145,152,0.5)'
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
2022-11-08 14:40:04 +08:00
color: '#A691FF66' // 0% 处的颜色
2022-11-07 08:45:49 +08:00
},
{
offset: 1,
color: 'transparent' // 100% 处的颜色
}
],
global: false // 缺省为 false
}
},
emphasis: {
focus: 'series'
},
2022-11-17 16:42:24 +08:00
data: [92, 88, 122, 169, 108, 130, 147].map(_ => {
let v = Math.floor(Math.random() * 100)
2022-11-18 14:50:57 +08:00
while (v < 80) {
v = Math.floor(Math.random() * 100)
}
2022-11-17 16:42:24 +08:00
return v
})
2022-11-07 08:45:49 +08:00
},
{
name: '丝印',
type: 'line',
symbol: 'none',
label: {
show: true,
position: 'top'
},
areaStyle: {
// color: 'rgba(50,145,152,0.5)'
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
2022-11-08 14:40:04 +08:00
color: '#49FBD666' // 0% 处的颜色
2022-11-07 08:45:49 +08:00
},
{
offset: 1,
color: 'transparent' // 100% 处的颜色
}
],
global: false // 缺省为 false
}
},
emphasis: {
focus: 'series'
},
2022-11-17 16:42:24 +08:00
data: [44, 40, 118, 197, 123, 95, 96].map(_ => {
let v = Math.floor(Math.random() * 100)
2022-11-18 14:50:57 +08:00
while (v < 80) {
v = Math.floor(Math.random() * 100)
}
2022-11-17 16:42:24 +08:00
return v
})
2022-11-07 08:45:49 +08:00
}
]
}
}
},
2022-11-17 16:42:24 +08:00
watch: {
dataUpdateToken(val) {
this.refreshData()
}
},
2022-11-07 08:45:49 +08:00
mounted() {
window.addEventListener('resize', function() {
if (this.chart) {
this.chart.resize()
}
})
this.$nextTick(() => {
// if (!this.chart) this.chart = echarts.init(this.$refs.chartContainer, { width: '100%', height: '100%' })
if (!this.chart) this.chart = echarts.init(this.$refs.chartContainer)
this.chart.setOption(this.configs)
this.chart.resize()
})
},
2022-11-17 16:42:24 +08:00
methods: {
refreshData() {
this.configs.series.forEach(item => {
item.data = [44, 40, 118, 197, 123, 95, 96].map(_ => {
let v = Math.floor(Math.random() * 100)
2022-11-18 15:03:18 +08:00
while (v < 80) {
v = Math.floor(Math.random() * 100)
}
2022-11-17 16:42:24 +08:00
return v
})
})
if (this.chart) this.chart.setOption(this.configs)
}
}
2022-11-07 08:45:49 +08:00
}
</script>
<style scoped>
.chartContainer >>> div {
width: 100% !important;
}
2022-11-17 16:42:24 +08:00
.diy-linestack-tooltip {
color: red;
}
2022-11-07 08:45:49 +08:00
</style>