This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/views/charts2/charts/options/echartOption.js

323 lines
5.9 KiB
JavaScript
Raw Normal View History

import {
chartColor,
chartColor1,
chartColor2,
chartColor3,
chartColor5,
unitTypes
} from '@/utils/constants'
import unitConvert from '@/utils/unit-convert'
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 = {
tooltip: {
show: false
},
2022-07-08 09:34:09 +08:00
color: chartColor1,
legend: {
orient: 'vertical',
top: 35,
left: '50%',
itemGap: 4,
2022-07-08 09:34:09 +08:00
itemWidth: 15,
itemHeight: 7,
textStyle: {
fontFamily: 'SimHei',
rich: {
a: {
width: 60,
align: 'left',
fontWeight: 'bold'
},
b: {
align: 'left',
fontSize: 12,
color: '#575757'
}
}
},
tooltip: {
show: true
},
formatter: function (name) {
const data = pieChartOption1.series[0].data
let value
data.forEach(t => {
if (t.name == name) {
value = t.value
}
})
name = name.length > 9 ? name.substr(0, 9) + '...' : name
const arr = ['{a|' + ' ' + value + '}' + '{b|' + name + '}']
return arr
}
2022-07-08 09:34:09 +08:00
},
series: [
{
right: '50%',
2022-07-08 09:34:09 +08:00
name: 'Access From',
type: 'pie',
radius: ['40%', '60%'],
2022-07-08 09:34:09 +08:00
avoidLabelOverlap: false,
label: {
show: false
},
labelLine: {
show: false
},
data: []
2022-07-08 09:34:09 +08:00
}
]
}
export const pieChartOption2 = {
tooltip: {
show: false
},
2022-07-08 09:34:09 +08:00
legend: {
orient: 'vertical',
top: 35,
left: '50%',
itemGap: 4,
2022-07-08 09:34:09 +08:00
itemWidth: 15,
itemHeight: 7,
textStyle: {
fontFamily: 'SimHei',
rich: {
a: {
width: 60,
align: 'left',
fontWeight: 'bold'
},
b: {
align: 'left',
fontSize: 12,
color: '#575757'
}
}
},
tooltip: {
show: true
},
formatter: function (name) {
const data = pieChartOption2.series[0].data
let value
data.forEach(t => {
if (t.name == name) {
value = t.value
}
})
name = name.length > 9 ? name.substr(0, 9) + '...' : name
const arr = ['{a|' + ' ' + value + '}' + '{b|' + name + '}']
return arr
}
2022-07-08 09:34:09 +08:00
},
color: chartColor2,
series: [
{
right: '50%',
2022-07-08 09:34:09 +08:00
name: 'Access From',
type: 'pie',
radius: ['40%', '60%'],
2022-07-08 09:34:09 +08:00
avoidLabelOverlap: false,
label: {
show: false
},
labelLine: {
show: false
},
data: []
2022-07-08 09:34:09 +08:00
}
]
}
export const pieChartOption3 = {
color: chartColor5,
series: [
{
name: 'Access From',
type: 'pie',
radius: ['45%', '50%'],
avoidLabelOverlap: false,
emphasis: {
label: {
show: true,
fontSize: 20,
fontWeight: 500,
fontFamily: 'NotoSansHans-Medium',
color: '#353636',
formatter: function (params) {
return params.data.value
}
}
},
labelLine: {
show: false
},
data: []
}
]
}
2022-07-08 09:34:09 +08:00
export const stackedLineChartOption = {
color: chartColor3,
2022-07-08 09:34:09 +08:00
tooltip: {
trigger: 'axis',
className: 'echarts-tooltip echarts-tooltip-dark'
2022-07-08 09:34:09 +08:00
},
legend: {
show: false
2022-07-08 09:34:09 +08:00
},
grid: {
top: '12%',
left: '2%',
right: '1.5%',
2022-07-08 09:34:09 +08:00
bottom: 15,
containLabel: true
},
xAxis: [
{
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: [
{
type: 'value',
2022-08-05 17:40:39 +08:00
splitLine: {
show: false
},
axisLabel: {
formatter: function (value) {
return unitConvert(value, unitTypes.number).join('')
}
}
2022-07-08 09:34:09 +08:00
}
],
series: [
{
type: 'line',
symbol: 'circle',
2022-07-08 09:34:09 +08:00
smooth: true,
showSymbol: false,
emphasis: {
focus: 'series'
},
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,
2022-08-08 22:31:08 +08:00
right: 1,
top: 2,
bottom: 0
2022-07-19 17:53:22 +08:00
},
animation: false,
color: chartColor,
axisLabel: {},
series: [
{
name: '',
type: 'line',
smooth: false,
symbol: 'none',
data: [],
markLine: {}
}
]
}
export const npmLineChartOption = {
title: {
text: '',
top: 20,
left: 20,
textStyle: {
fontSize: 14,
color: '#353636',
2022-08-08 18:30:41 +08:00
fontWeight: 500
}
},
tooltip: {
trigger: 'axis',
className: 'echarts-tooltip echarts-tooltip-dark'
},
legend: {
show: false
},
grid: {
top: '25%',
left: '4%',
right: '4%',
bottom: 15,
containLabel: true
},
xAxis: [
{
type: 'time',
2022-08-08 18:30:41 +08:00
splitNumber: 8,
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
}
}
}
],
yAxis: [
{
type: 'value',
2022-08-08 18:30:41 +08:00
splitLine: {
show: false
},
axisLabel: {
formatter: function (value) {
return unitConvert(value, unitTypes.number).join('')
}
}
}
],
series: [
{
type: 'line',
symbol: 'circle',
smooth: true,
showSymbol: false,
emphasis: {
focus: 'series'
},
data: []
}
]
}