2022-07-19 17:53:22 +08:00
|
|
|
import { chartColor, chartColor1, chartColor2, chartColor3, chartColor4, unitTypes } from '@/utils/constants'
|
2022-07-12 20:13:51 +08:00
|
|
|
import unitConvert from '@/utils/unit-convert'
|
2022-07-11 16:36:11 +08:00
|
|
|
import * as echarts from 'echarts'
|
2022-07-19 17:53:22 +08:00
|
|
|
import { axisFormatter } from '@/views/charts/charts/tools'
|
2022-07-08 09:34:09 +08:00
|
|
|
|
|
|
|
|
export const pieChartOption1 = {
|
|
|
|
|
color: chartColor1,
|
|
|
|
|
legend: {
|
|
|
|
|
orient: 'vertical',
|
2022-07-18 11:21:22 +08:00
|
|
|
top: 35,
|
2022-07-11 16:36:11 +08:00
|
|
|
left: '50%',
|
|
|
|
|
itemGap: 4,
|
2022-07-08 09:34:09 +08:00
|
|
|
itemWidth: 15,
|
2022-07-11 16:36:11 +08:00
|
|
|
itemHeight: 7,
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontFamily: 'SimHei',
|
|
|
|
|
rich: {
|
|
|
|
|
a: {
|
|
|
|
|
width: 35,
|
2022-07-15 10:04:22 +08:00
|
|
|
align: 'left',
|
|
|
|
|
fontWeight: 'bold'
|
2022-07-11 16:36:11 +08:00
|
|
|
},
|
|
|
|
|
b: {
|
|
|
|
|
width: 6,
|
|
|
|
|
align: 'left',
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: '#575757'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
formatter: function (name) {
|
|
|
|
|
const data = pieChartOption1.series[0].data
|
|
|
|
|
let value
|
|
|
|
|
data.forEach(t => {
|
|
|
|
|
if (t.name === name) {
|
|
|
|
|
value = t.describe
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const arr = ['{a|' + ' ' + name + '}' + '{b|' + value + '}']
|
|
|
|
|
return arr
|
|
|
|
|
}
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
series: [
|
|
|
|
|
{
|
2022-07-11 16:36:11 +08:00
|
|
|
right: '50%',
|
2022-07-08 09:34:09 +08:00
|
|
|
name: 'Access From',
|
|
|
|
|
type: 'pie',
|
2022-07-11 16:36:11 +08:00
|
|
|
radius: ['40%', '60%'],
|
2022-07-08 09:34:09 +08:00
|
|
|
avoidLabelOverlap: false,
|
|
|
|
|
label: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
|
|
|
|
labelLine: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
data: []
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
export const pieChartOption2 = {
|
|
|
|
|
legend: {
|
|
|
|
|
orient: 'vertical',
|
2022-07-18 11:21:22 +08:00
|
|
|
top: 35,
|
2022-07-11 16:36:11 +08:00
|
|
|
left: '50%',
|
|
|
|
|
itemGap: 4,
|
2022-07-08 09:34:09 +08:00
|
|
|
itemWidth: 15,
|
2022-07-11 16:36:11 +08:00
|
|
|
itemHeight: 7,
|
|
|
|
|
textStyle: {
|
|
|
|
|
fontFamily: 'SimHei',
|
|
|
|
|
rich: {
|
|
|
|
|
a: {
|
|
|
|
|
width: 35,
|
2022-07-15 10:04:22 +08:00
|
|
|
align: 'left',
|
|
|
|
|
fontWeight: 'bold'
|
2022-07-11 16:36:11 +08:00
|
|
|
},
|
|
|
|
|
b: {
|
|
|
|
|
width: 6,
|
|
|
|
|
align: 'left',
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
color: '#575757'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
formatter: function (name) {
|
|
|
|
|
const data = pieChartOption2.series[0].data
|
|
|
|
|
let value
|
|
|
|
|
data.forEach(t => {
|
|
|
|
|
if (t.name === name) {
|
|
|
|
|
value = t.describe
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
const arr = ['{a|' + ' ' + name + '}' + '{b|' + value + '}']
|
|
|
|
|
return arr
|
|
|
|
|
}
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
color: chartColor2,
|
|
|
|
|
series: [
|
|
|
|
|
{
|
2022-07-11 16:36:11 +08:00
|
|
|
right: '50%',
|
2022-07-08 09:34:09 +08:00
|
|
|
name: 'Access From',
|
|
|
|
|
type: 'pie',
|
2022-07-11 16:36:11 +08:00
|
|
|
radius: ['40%', '60%'],
|
2022-07-08 09:34:09 +08:00
|
|
|
avoidLabelOverlap: false,
|
|
|
|
|
label: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
|
|
|
|
labelLine: {
|
|
|
|
|
show: false
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
data: []
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-07-14 17:07:07 +08:00
|
|
|
const sizes = [3, 6, 8, 9, 10]
|
2022-07-08 09:34:09 +08:00
|
|
|
export const stackedLineChartOption = {
|
2022-07-08 14:11:30 +08:00
|
|
|
color: chartColor3,
|
2022-07-08 09:34:09 +08:00
|
|
|
tooltip: {
|
2022-07-15 10:04:22 +08:00
|
|
|
trigger: 'axis',
|
|
|
|
|
className: 'echarts-tooltip echarts-tooltip-dark'
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
legend: {
|
2022-07-14 17:07:07 +08:00
|
|
|
show: false
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
grid: {
|
2022-07-08 14:11:30 +08:00
|
|
|
top: '30%',
|
2022-07-08 09:34:09 +08:00
|
|
|
left: '1%',
|
|
|
|
|
right: '2%',
|
|
|
|
|
bottom: 15,
|
|
|
|
|
containLabel: true
|
|
|
|
|
},
|
|
|
|
|
xAxis: [
|
|
|
|
|
{
|
2022-07-11 16:36:11 +08:00
|
|
|
type: 'time',
|
|
|
|
|
splitNumber: 12,
|
|
|
|
|
axisLabel: {
|
|
|
|
|
formatter: function (value) {
|
|
|
|
|
const data = new Date(value)
|
|
|
|
|
const h = data.getHours() > 9 ? data.getHours() : '0' + data.getHours()
|
|
|
|
|
const m = data.getMinutes() > 9 ? data.getMinutes() : '0' + data.getMinutes()
|
|
|
|
|
return h + ':' + m
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
yAxis: [
|
|
|
|
|
{
|
2022-07-12 20:13:51 +08:00
|
|
|
type: 'value',
|
|
|
|
|
axisLabel: {
|
|
|
|
|
formatter: function (value) {
|
|
|
|
|
return unitConvert(value, unitTypes.number).join('')
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
type: 'line',
|
2022-07-11 16:36:11 +08:00
|
|
|
symbol: 'circle',
|
2022-07-08 09:34:09 +08:00
|
|
|
smooth: true,
|
2022-07-12 20:13:51 +08:00
|
|
|
symbolSize: function (value, params) {
|
|
|
|
|
return symbolSizeSortChange(0, value[0])
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
showSymbol: false,
|
|
|
|
|
emphasis: {
|
|
|
|
|
focus: 'series'
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
lineStyle: {
|
|
|
|
|
color: chartColor3[0],
|
|
|
|
|
width: 1
|
|
|
|
|
},
|
2022-07-14 17:07:07 +08:00
|
|
|
itemStyle: {
|
|
|
|
|
emphasis: {
|
|
|
|
|
borderColor: chartColor4[0],
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
shadowColor: chartColor4[0],
|
|
|
|
|
shadowBlur: sizes[0] + 2
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
areaStyle: {
|
|
|
|
|
opacity: 0.1,
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: chartColor3[0]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: chartColor3[0]
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
},
|
|
|
|
|
data: []
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'line',
|
2022-07-11 16:36:11 +08:00
|
|
|
symbol: 'circle',
|
2022-07-08 09:34:09 +08:00
|
|
|
smooth: true,
|
2022-07-12 20:13:51 +08:00
|
|
|
symbolSize: function (value, params) {
|
|
|
|
|
return symbolSizeSortChange(1, value[0])
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
showSymbol: false,
|
|
|
|
|
emphasis: {
|
|
|
|
|
focus: 'series'
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
lineStyle: {
|
|
|
|
|
color: chartColor3[1],
|
|
|
|
|
width: 1
|
|
|
|
|
},
|
2022-07-14 17:07:07 +08:00
|
|
|
itemStyle: {
|
|
|
|
|
emphasis: {
|
|
|
|
|
borderColor: chartColor4[1],
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
shadowColor: chartColor4[1],
|
|
|
|
|
shadowBlur: sizes[1] + 2
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
areaStyle: {
|
|
|
|
|
opacity: 0.1,
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: chartColor3[1]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: chartColor3[1]
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
},
|
|
|
|
|
data: []
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'line',
|
2022-07-11 16:36:11 +08:00
|
|
|
symbol: 'circle',
|
2022-07-08 09:34:09 +08:00
|
|
|
smooth: true,
|
2022-07-12 20:13:51 +08:00
|
|
|
symbolSize: function (value, params) {
|
|
|
|
|
return symbolSizeSortChange(2, value[0])
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
showSymbol: false,
|
|
|
|
|
emphasis: {
|
|
|
|
|
focus: 'series'
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
lineStyle: {
|
|
|
|
|
color: chartColor3[2],
|
|
|
|
|
width: 1
|
|
|
|
|
},
|
2022-07-14 17:07:07 +08:00
|
|
|
itemStyle: {
|
|
|
|
|
emphasis: {
|
|
|
|
|
borderColor: chartColor4[2],
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
shadowColor: chartColor4[2],
|
|
|
|
|
shadowBlur: sizes[2] + 2
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
areaStyle: {
|
|
|
|
|
opacity: 0.1,
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: chartColor3[2]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: chartColor3[2]
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
},
|
|
|
|
|
data: []
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'line',
|
2022-07-11 16:36:11 +08:00
|
|
|
symbol: 'circle',
|
2022-07-08 09:34:09 +08:00
|
|
|
smooth: true,
|
2022-07-12 20:13:51 +08:00
|
|
|
symbolSize: function (value, params) {
|
|
|
|
|
return symbolSizeSortChange(3, value[0])
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
showSymbol: false,
|
2022-07-11 16:36:11 +08:00
|
|
|
emphasis: {
|
|
|
|
|
focus: 'series'
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
lineStyle: {
|
2022-07-11 16:36:11 +08:00
|
|
|
color: chartColor3[3],
|
|
|
|
|
width: 1
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
2022-07-14 17:07:07 +08:00
|
|
|
itemStyle: {
|
|
|
|
|
emphasis: {
|
|
|
|
|
borderColor: chartColor4[3],
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
shadowColor: chartColor4[3],
|
|
|
|
|
shadowBlur: sizes[3] + 2
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
areaStyle: {
|
2022-07-11 16:36:11 +08:00
|
|
|
opacity: 0.1,
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: chartColor3[3]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: chartColor3[3]
|
|
|
|
|
}
|
|
|
|
|
])
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
data: []
|
2022-07-08 09:34:09 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'line',
|
2022-07-11 16:36:11 +08:00
|
|
|
symbol: 'circle',
|
2022-07-08 09:34:09 +08:00
|
|
|
smooth: true,
|
2022-07-12 20:13:51 +08:00
|
|
|
symbolSize: function (value, params) {
|
|
|
|
|
return symbolSizeSortChange(4, value[0])
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
showSymbol: false,
|
|
|
|
|
emphasis: {
|
|
|
|
|
focus: 'series'
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
lineStyle: {
|
|
|
|
|
color: chartColor3[4],
|
|
|
|
|
width: 1
|
|
|
|
|
},
|
2022-07-14 17:07:07 +08:00
|
|
|
itemStyle: {
|
|
|
|
|
emphasis: {
|
|
|
|
|
borderColor: chartColor4[4],
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
shadowColor: chartColor4[4],
|
|
|
|
|
shadowBlur: sizes[4] + 2
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-07-11 16:36:11 +08:00
|
|
|
areaStyle: {
|
|
|
|
|
opacity: 0.1,
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
|
|
{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: chartColor3[4]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
offset: 1,
|
|
|
|
|
color: chartColor3[4]
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
},
|
|
|
|
|
data: []
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-07-19 17:53:22 +08:00
|
|
|
|
|
|
|
|
export const appListChartOption = {
|
|
|
|
|
tooltip: {
|
|
|
|
|
appendToBody: true,
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
formatter: axisFormatter,
|
|
|
|
|
show: true
|
|
|
|
|
},
|
|
|
|
|
xAxis: {
|
|
|
|
|
show: false,
|
|
|
|
|
type: 'time'
|
|
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
show: false,
|
|
|
|
|
type: 'value',
|
|
|
|
|
axisLabel: {
|
|
|
|
|
formatter: function (value) {
|
|
|
|
|
return unitConvert(value, unitTypes.number, null, null, 0).join(' ')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
|
|
|
|
left: 0,
|
|
|
|
|
right: 0
|
|
|
|
|
},
|
|
|
|
|
animation: false,
|
|
|
|
|
color: chartColor,
|
|
|
|
|
axisLabel: {},
|
|
|
|
|
series: [
|
|
|
|
|
{
|
|
|
|
|
name: '',
|
|
|
|
|
type: 'line',
|
|
|
|
|
smooth: false,
|
|
|
|
|
symbol: 'none',
|
|
|
|
|
data: [],
|
|
|
|
|
markLine: {}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-12 20:13:51 +08:00
|
|
|
function symbolSizeSortChange (index, time) {
|
|
|
|
|
const totalData = stackedLineChartOption.series[0].data.find(t => t[0] === time) // [time, value]
|
|
|
|
|
const inboundData = stackedLineChartOption.series[1].data.find(t => t[0] === time)
|
|
|
|
|
const outboundData = stackedLineChartOption.series[2].data.find(t => t[0] === time)
|
|
|
|
|
const internalData = stackedLineChartOption.series[3].data.find(t => t[0] === time)
|
|
|
|
|
const otherData = stackedLineChartOption.series[4].data.find(t => t[0] === time)
|
|
|
|
|
totalData[2] = 0
|
|
|
|
|
inboundData[2] = 1
|
|
|
|
|
outboundData[2] = 2
|
|
|
|
|
internalData[2] = 3
|
|
|
|
|
otherData[2] = 4
|
|
|
|
|
const dataIntegrationArray = [totalData, inboundData, outboundData, internalData, otherData]
|
|
|
|
|
dataIntegrationArray.sort((a, b) => { return a[1] - b[1] })
|
|
|
|
|
const sortIndex = dataIntegrationArray.findIndex(a => a[2] === index)
|
|
|
|
|
return sizes[sortIndex]
|
|
|
|
|
}
|