diff --git a/src/assets/css/chart.scss b/src/assets/css/chart.scss index e0b64e3f..6ee893d6 100644 --- a/src/assets/css/chart.scss +++ b/src/assets/css/chart.scss @@ -1,13 +1,21 @@ -.nz-chart-tooltip > div > div:nth-of-type(1) > div:nth-of-type(2) > div > div:nth-of-type(1){ +.nz-chart-tooltip .cn-chart-tooltip-box{ display: flex; - span { - float: none; - } - > span:nth-of-type(2){ + .cn-chart-tooltip-content{ flex: 1; display: inline-block; overflow: hidden; text-overflow:ellipsis; white-space: nowrap; + font-size:14px; + color:#666; + font-weight:400; + margin-left:2px ; + } + .cn-chart-tooltip-value{ + float:right; + margin-left:20px; + font-size:14px; + color:#666; + font-weight:900; } } diff --git a/src/assets/css/tableCommon.scss b/src/assets/css/tableCommon.scss index 901d3bd5..a9798238 100644 --- a/src/assets/css/tableCommon.scss +++ b/src/assets/css/tableCommon.scss @@ -44,7 +44,7 @@ height: 44px; background-color: white; border: 1px solid #E6EAED; - + } .top-tool-right { @@ -134,7 +134,7 @@ color: #666666; font-size: 14px; text-align: center; - + line-height: 40px; &.sub-list-tab--active { @@ -156,7 +156,7 @@ background-color: #e6eaed; position: absolute; z-index: 1; - + user-select: none; color: #5f6368; cursor: ns-resize; @@ -188,7 +188,7 @@ position: relative; padding: 0 20px; width: 100%; - + flex: auto; height: calc(100% - 58px); @@ -356,7 +356,7 @@ left: 270px !important; margin-top: -3px !important; box-shadow: none; - + border-radius: 0; border-color: #c7c7c7; @@ -391,3 +391,6 @@ .margin-r-20{ margin-right: 20px; } +.margin-l-10{ + margin-left: 10px; +} diff --git a/src/components/charts/PieTable.vue b/src/components/charts/PieTable.vue index 7a31de6e..63c0727b 100644 --- a/src/components/charts/PieTable.vue +++ b/src/components/charts/PieTable.vue @@ -1,9 +1,11 @@ @@ -33,51 +45,144 @@ :key="index" :min-width="item.width" :label="item.label" - :prop="item.prop"> + :prop="item.prop" + #default="{row}"> + + {{nameColumn === 'fqdnCategoryName' ? row['categoryName'] : row['reputationLevel'] }} + + + {{shortFormatter(row[item.prop])}} + + + {{row[item.prop]}} + diff --git a/src/components/charts/StatisticsLegend.vue b/src/components/charts/StatisticsLegend.vue index b8897136..7b611d6a 100644 --- a/src/components/charts/StatisticsLegend.vue +++ b/src/components/charts/StatisticsLegend.vue @@ -13,7 +13,6 @@ export default { immediate: true, deep: true, handler (n) { - // console.info(n) } } } @@ -22,4 +21,4 @@ export default { \ No newline at end of file + diff --git a/src/components/charts/chart-options.js b/src/components/charts/chart-options.js index da2ab6ba..8cc78fc4 100644 --- a/src/components/charts/chart-options.js +++ b/src/components/charts/chart-options.js @@ -4,6 +4,7 @@ * @description chart option和一些工具 */ import { format } from 'echarts' +import { shortFormatter } from './chartFormatter' import _ from 'lodash' export const chartColor = ['#73A0FA', '#73DEB3', '#F7C739', '#EB7E65', '#FFAB67', '#A285D2', '#FFA8CB'] export function getChartColor (index) { @@ -17,9 +18,7 @@ const line = { width: '20px', overflow: 'truncate' }, - // formatter: () =>{ - // return '1' - // } + formatter: axiosFormatter, className: 'nz-chart-tooltip', extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);max-width: 300px !important' }, @@ -27,7 +26,11 @@ const line = { type: 'time' }, yAxis: { - type: 'value' + type: 'value', + axisLabel: { + formatter: shortFormatter + } + }, animation: false, grid: { @@ -71,9 +74,7 @@ const lineWithStatistics = { width: '20px', overflow: 'truncate' }, - // formatter: () =>{ - // return '1' - // } + formatter: axiosFormatter, className: 'nz-chart-tooltip', extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);max-width: 300px !important' }, @@ -82,7 +83,11 @@ const lineWithStatistics = { }, animation: false, yAxis: { - type: 'value' + type: 'value', + axisLabel: { + formatter: shortFormatter + } + }, color: chartColor, grid: { @@ -114,9 +119,7 @@ const lineStack = { width: '20px', overflow: 'truncate' }, - // formatter: () =>{ - // return '1' - // } + formatter: axiosFormatter, className: 'nz-chart-tooltip', extraCssText: 'box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);max-width: 300px !important' }, @@ -125,7 +128,11 @@ const lineStack = { }, color: chartColor, yAxis: { - type: 'value' + type: 'value', + axisLabel: { + formatter: shortFormatter + } + }, grid: { left: 55, @@ -183,6 +190,7 @@ const pieWithTable = { series: [ { type: 'pie', + selectedMode: 'single', radius: ['42%', '70%'], center: ['30%', '50%'], data: [], @@ -290,6 +298,26 @@ export function getLayout (type) { function tooLongFormatter (name) { return format.truncateText(name, 110, '12') } -// function axiosFormatter(params) { -// -// } +function axiosFormatter (params) { + let str = '
' + const sum = 0 + params.forEach((item, i) => { + const tData = item.data[0] + if (i === 0) { + str += '
' + str += window.$dayJs.tz(tData).format('YYYY-MM-DD HH:mm:ss') + str += '
' + } + str += '
' + str += item.marker + str += ` + ${item.seriesName} + ` + str += ` + ${shortFormatter(item.data[1])} + ` + str += '
' + }) + str += '
' + return str +} diff --git a/src/components/charts/chartFormatter.js b/src/components/charts/chartFormatter.js new file mode 100644 index 00000000..65ed67a4 --- /dev/null +++ b/src/components/charts/chartFormatter.js @@ -0,0 +1,21 @@ +const shortList = [' ', 'K', 'Mil', 'Bil', 'Til', 'Quadrillion', 'Quintillion'] +function asciiCompute (num, ascii, units, dot = 2) { + if (!num && num !== 0 && num !== '0') { + return '' + } + num = Number(num) + let carry = 0 + if (num > 1) { + const log = Math.log(num) / Math.log(ascii) + carry = parseInt(log) + num = num / Math.pow(ascii, carry) + } + if (Number.isInteger(num)) { + return num + ' ' + units[carry] + } else { + return num.toFixed(dot) + ' ' + units[carry] + } +} +export function shortFormatter (value, index, dot = 2) { + return asciiCompute(value, 1000, shortList, dot) +} diff --git a/src/components/charts/panel.scss b/src/components/charts/panel.scss index 3f72a5a3..d592682c 100644 --- a/src/components/charts/panel.scss +++ b/src/components/charts/panel.scss @@ -257,6 +257,110 @@ flex: auto; overflow-y: auto; + .el-table { + padding: 0 10px; + + &:before { + height: 0; + } + thead { + color: #333; + } + th.is-leaf, td { + border-bottom: none; + } + th { + padding-bottom: 5px; + } + td { + padding: 4px 0; + color: #333; + } + } + } + } + &>.cn-chart__echarts { + .cn-chart__header { + border-bottom: 1px solid $--content-right-background-color; + .header__operations { + display: flex; + justify-content: end; + align-items: center; + + .header__operation.header__operation--table { + display: flex; + align-items: center; + height: 22px; + margin-left: 10px; + color: $--color-primary; + border: 1px solid $--color-primary; + border-radius: $--border-radius-primary; + + .option__button { + display: flex; + align-items: center; + height: 100%; + padding: 0 5px; + cursor: pointer; + background-color: white; + transition: all linear .2s; + } + .option__button:hover { + background-color: #EFF2F5; + } + .option__button.icon-group-item:first-of-type:not(:last-of-type) { + padding: 0 5px 0 0; + } + .option__button.icon-group-item:last-of-type:not(:first-of-type) { + padding: 0 0 0 5px; + } + .option__select { + .el-input__inner { + width: 120px; + padding-right: 20px; + border: none; + height: 100%; + line-height: 20px; + color: $--color-primary; + } + .el-input__prefix > div { + font-weight: normal; + line-height: 19px; + color: $--color-primary; + } + .el-input__suffix { + display: flex; + .el-input__suffix-inner { + line-height: 14px; + .el-select__caret { + line-height: 14px; + width: 16px; + color: $--color-primary; + } + } + } + } + .option__select.select-column { + .el-input__inner { + width: 120px; + padding-left: 8px; + } + } + .icon-group-divide { + height: 14px; + width: 1px; + background-color: $--color-primary; + } + i { + font-size: 12px; + } + } + } + } + .cn-chart__body { + flex: auto; + overflow-y: auto; + .el-table { padding: 0 10px; @@ -287,3 +391,12 @@ font-size: 12px; } } +//.cn-chart-select{ +// display: flex; +// align-items: center; +// height: 22px; +// margin-left: 10px; +// color: #0091ff; +// border: 1px solid #0091ff; +// border-radius: 2px; +//} diff --git a/src/components/common/Pagination.vue b/src/components/common/Pagination.vue index 14399080..c5600d04 100644 --- a/src/components/common/Pagination.vue +++ b/src/components/common/Pagination.vue @@ -231,7 +231,6 @@ export default { immediate: true, deep: true, handler (n, o) { - // console.log(n) } } } diff --git a/src/utils/constants.js b/src/utils/constants.js index 7dd27eb5..28558f64 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -46,3 +46,4 @@ export const position = { export const chartTableDefaultPageSize = 10 // table类型图表默认每页数据量 export const chartTableTopOptions = [10, 100] // table类型图表的TOP-N选项 +export const chartPieTableTopOptions = [{ name: 'Sessions', value: 'sessions' }, { name: 'Packets', value: 'packets' }, { name: 'Bytes', value: 'bytes' }] // table类型图表的TOP-N选项 diff --git a/src/views/charts/Chart.vue b/src/views/charts/Chart.vue index c190f113..2aa7bd47 100644 --- a/src/views/charts/Chart.vue +++ b/src/views/charts/Chart.vue @@ -44,21 +44,22 @@ > + -