irc_web/.svn/pristine/e9/e983df5024e884de1467c729a18...

267 lines
6.7 KiB
Plaintext

<template>
<div ref="reading_rank" class="reading-rank" />
</template>
<script>
import echarts from 'echarts'
import { getReadingDataRank } from '@/api/dashboard'
import { fontSize } from 'utils/fontsize'
const Count = 5
export default {
props: {
area: { type: String, default: '' }
},
data() {
return {
myChart: ''
}
},
watch: {
area() {
const that = this
this.$nextTick(function() {
if (that.myChart) {
that.myChart.resize()
}
})
}
},
mounted() {
this.getData()
},
methods: {
initChart(xData, tpArr, adjArr, gArr, totalArr) {
const option = {
// backgroundColor: '#344b58',
title: {
text: 'Workload of Top 5 Reviewers',
x: '4%',
top: 5,
textStyle: {
color: '#fff',
fontSize: fontSize(0.16)
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
textStyle: {
color: '#999'
}
}
},
grid: {
// borderWidth: 0,
top: '33%',
left: 60,
bottom: 25,
textStyle: {
color: '#999'
}
},
legend: {
x: '4%',
top: '13%',
icon: 'circle',
itemWidth: fontSize(0.1),
textStyle: {
color: '#fff',
fontSize: fontSize(0.14)
},
data: ['TP', 'AD', 'GL', 'Total']
},
calculable: true,
xAxis: [
{
axisLine: {
show: true,
lineStyle: {
color: 'rgba(255,255,255,.1)',
// width: 1,
type: 'solid'
}
},
axisTick: {
show: false
},
axisLabel: {
interval: 0,
show: true,
// splitNumber: 15,
textStyle: {
color: '#fff',
fontSize: fontSize(0.14)
}
},
data: xData
}
],
yAxis: [
{
type: 'value',
axisLabel: {
show: true,
textStyle: {
color: '#fff',
fontSize: fontSize(0.14)
}
},
axisTick: {
show: false
},
axisLine: {
show: true,
lineStyle: {
color: 'rgba(255,255,255,.1 )',
// width: 1,
type: 'solid'
}
},
splitLine: {
lineStyle: {
color: 'rgba(255,255,255,.1)'
}
}
}
],
series: [
{
name: 'TP',
type: 'bar',
stack: 'Total',
barMaxWidth: fontSize(0.4),
itemStyle: {
normal: {
color: '#2fA2FF',
label: {
show: true,
textStyle: {
color: '#fff',
fontSize: fontSize(0.14)
},
position: 'inside',
formatter: function(p) {
return p.value > 0 ? p.value : ''
}
}
}
},
data: tpArr
},
{
name: 'AD',
type: 'bar',
stack: 'Total',
itemStyle: {
normal: {
color: '#27d08a',
label: {
show: true,
textStyle: {
color: '#fff',
fontSize: fontSize(0.14)
},
position: 'inside',
formatter: function(p) {
return p.value > 0 ? p.value : ''
}
}
}
},
data: adjArr
},
{
name: 'GL',
type: 'bar',
stack: 'Total',
itemStyle: {
normal: {
color: '#2f89cf',
label: {
show: true,
textStyle: {
color: '#fff',
fontSize: fontSize(0.14)
},
position: 'inside',
formatter: function(p) {
return p.value > 0 ? p.value : ''
}
}
}
},
data: gArr
},
{
name: 'Total',
type: 'line',
smooth: true, // 平滑曲线显示
symbolSize: 10,
symbol: 'circle',
itemStyle: {
normal: {
color: 'rgba(252,230,48,1)',
label: {
show: true,
position: 'top',
textStyle: {
color: '#fff',
fontSize: fontSize(0.14)
},
formatter: function(p) {
return p.value > 0 ? p.value : ''
}
}
}
},
data: totalArr
}
]
}
if (this.$refs.reading_rank) {
this.myChart = echarts.init(this.$refs.reading_rank)
this.myChart.setOption(option)
}
},
getData() {
getReadingDataRank(Count).then(res => {
if (res.IsSuccess) {
if (res.Result) {
const xData = []
const tpArr = []
const adjArr = []
const gArr = []
const totalArr = []
for (let i = 0; i < res.Result.length; i++) {
xData.push(res.Result[i].ReviewerCode)
tpArr.push(res.Result[i].Timepoint)
adjArr.push(res.Result[i].Adjudication)
gArr.push(res.Result[i].Global)
totalArr.push(res.Result[i].TotalReadingCount)
}
this.initChart(xData, tpArr, adjArr, gArr, totalArr)
}
} else {
this.$message({ message: res.ErrorMessage, type: 'error' })
}
})
// .catch(error => {
// this.$message({ message: error, type: 'error' })
// })
}
}
}
</script>
<style scoped>
.reading-rank {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>