diff --git a/src/assets/css/components/views/charts2/npmEventsByType.scss b/src/assets/css/components/views/charts2/npmEventsByType.scss index 1d69a12d..bffab862 100644 --- a/src/assets/css/components/views/charts2/npmEventsByType.scss +++ b/src/assets/css/components/views/charts2/npmEventsByType.scss @@ -13,63 +13,68 @@ border: 1px solid #E2E5EC; border-radius: 4px; display: flex; - align-items: center; - .npm-event-pie-legends { + .npm-event-pies { + height: 100%; + width: 100%; display: flex; - width: 40%; - justify-content: space-around; - .npm-event-pie-legend { - .npm-event-pie-legend-title { - font-size: 12px; - color: #575757; - line-height: 12px; - font-weight: 400; - margin-bottom: 15px; - } - .npm-event-pie-legend-type { - font-size: 12px; - color: #353636; - line-height: 12px; - font-weight: 500; - display: flex; - align-items: center; - margin-bottom: 11px; - .npm-event-pie-legend-type-icon { - width: 8px; - height: 8px; - margin-right: 5px; + align-items: center; + .chart-drawing { + height: 100%; + width: 50%; + } + .npm-event-pie-legends { + display: flex; + width: 40%; + justify-content: space-around; + .npm-event-pie-legend { + .npm-event-pie-legend-title { + font-size: 12px; + color: #575757; + line-height: 12px; + font-weight: 400; + margin-bottom: 15px; } - .npm-event-pie-legend-type-severity { - text-transform: capitalize; + .npm-event-pie-legend-type { + font-size: 12px; + color: #353636; + line-height: 12px; + font-weight: 500; + display: flex; + align-items: center; + margin-bottom: 11px; + .npm-event-pie-legend-type-icon { + width: 8px; + height: 8px; + margin-right: 5px; + } + .npm-event-pie-legend-type-severity { + text-transform: capitalize; + } + .critical { + background: rgb(226,97,84); + } + .high { + background: rgb(228,142,77); + } + .info { + background: rgb(136,175,101); + } + .medium { + background: rgb(231,179,78); + } + .low { + background: rgb(218,199,75); + } } - .critical { - background: rgb(226,97,84); + .npm-event-pie-legend-total { + font-size: 12px; + color: #353636; + line-height: 12px; + font-weight: 600; + margin-bottom: 11px; } - .high { - background: rgb(228,142,77); - } - .info { - background: rgb(136,175,101); - } - .medium { - background: rgb(231,179,78); - } - .low { - background: rgb(218,199,75); - } - } - .npm-event-pie-legend-total { - font-size: 12px; - color: #353636; - line-height: 12px; - font-weight: 600; - margin-bottom: 11px; } } } - .chart-drawing { - height: 100%; - width: 50%; - } } } diff --git a/src/views/charts2/charts/npm/NpmEventsByType.vue b/src/views/charts2/charts/npm/NpmEventsByType.vue index b30ead1c..71d08211 100644 --- a/src/views/charts2/charts/npm/NpmEventsByType.vue +++ b/src/views/charts2/charts/npm/NpmEventsByType.vue @@ -2,22 +2,25 @@
{{$t('network.eventByType')}}
-
-
-
-
{{ $t('overall.type') }}
- -
-
-
{{ $t('network.total') }}
- + +
+
+
+
+
{{ $t('overall.type') }}
+ +
+
+
{{ $t('network.total') }}
+ +
@@ -31,6 +34,7 @@ import { api } from '@/utils/api' import * as echarts from 'echarts' import { pieChartOption3 } from '@/views/charts2/charts/options/echartOption' import { getSecond } from '@/utils/date-util' +import ChartNoData from '@/views/charts/charts/ChartNoData' export default { name: 'NpmEventsByType', @@ -39,6 +43,9 @@ export default { timeFilter: Object, type: String }, + components: { + ChartNoData + }, setup () { return { myChart: shallowRef(null) @@ -47,7 +54,8 @@ export default { data () { return { chartData: [], - timer: null + timer: null, + isNoData: false } }, methods: { @@ -89,6 +97,9 @@ export default { } get(api.npm.events.list, params).then(res => { if (res.code === 200) { + if (res.data.result.length <= 0) { + this.isNoData = true + } res.data.result.forEach(t => { if (t.eventSeverity === 'critical') { t.index = 0 @@ -109,6 +120,9 @@ export default { value: t.count } }) + this.init() + } else { + this.isNoData = true } }) }, @@ -118,9 +132,8 @@ export default { }, mounted () { this.timer = setTimeout(() => { - this.init() + this.eventsVyTypeData() }, 100) - this.eventsVyTypeData() window.addEventListener('resize', this.resize) }, beforeUnmount () { diff --git a/src/views/charts2/charts/npm/NpmLine.vue b/src/views/charts2/charts/npm/NpmLine.vue index 2dd4d3a9..3244f2ca 100644 --- a/src/views/charts2/charts/npm/NpmLine.vue +++ b/src/views/charts2/charts/npm/NpmLine.vue @@ -1,12 +1,37 @@ @@ -16,11 +41,18 @@ import { npmLineChartOption } from '@/views/charts2/charts/options/echartOption. import { shallowRef } from 'vue' import _ from 'lodash' import { stackedLineTooltipFormatter } from '@/views/charts/charts/tools' +import { getSecond } from '@/utils/date-util' +import { get } from '@/utils/http' +import { api } from '@/utils/api' export default { name: 'NpmLine', props: { - chart: Object + chart: Object, + timeFilter: Object, + // side: String, + // country: String, + // province: String }, setup () { return { @@ -36,32 +68,49 @@ export default { { legend: 'network.outbound', index: 2, invertTab: true } ], timer: null, - myChartArray: [] + myChartArray: [], + side: 'server', + country: '北京', + province: '北京' } }, methods: { init () { + const params = { + startTime: getSecond(this.timeFilter.startTime), + endTime: getSecond(this.timeFilter.endTime), + side: this.side, + country: this.country, + province: this.province + } + console.log(this.chartData) + if (this.chartData.id === 11) { + get(api.npm.location.thoughput, params).then(res => { + if (res.code === 200) { + console.log(res) + } + }) + } + this.echartsInit() + }, + echartsInit () { const dom = document.getElementById(`chart${this.chartData.name}`) this.myChart = echarts.init(dom) this.chartOption = npmLineChartOption const seriesTemplate = this.chartOption.series[0] - this.chartOption.title.text = this.chartData.i18n ? this.chartData.i18n : this.chartData.name this.chartOption.color = this.chartData.params.color let result = [ { - values: [[1435781430781, '1'], [1435781431781, '2']], - legend: 'network.total', - color: '#749F4D' + type: 'inboundBytesRate', + values: [[1435781430781, '3'], [1435781431781, '4']] }, { - values: [[1435781430781, '1'], [1435781431781, '2']], - legend: 'network.inbound', - color: '#98709B' + type: 'totalBytesRate', + values: [[1435781430781, '5'], [1435781431781, '6']] }, { - values: [[1435781430781, '1'], [1435781431781, '2']], - legend: 'network.outbound', - color: '#E5A219' + type: 'outboundBytesRate', + values: [[1435781430781, '2'], [1435781431781, '9']] } ] result = result.filter(item => this.chartData.params.color.indexOf(item.color) > -1) diff --git a/src/views/charts2/charts/options/echartOption.js b/src/views/charts2/charts/options/echartOption.js index ffe2415e..23192bc4 100644 --- a/src/views/charts2/charts/options/echartOption.js +++ b/src/views/charts2/charts/options/echartOption.js @@ -256,16 +256,6 @@ export const appListChartOption = { } export const npmLineChartOption = { - title: { - text: '', - top: 14.5, - left: 20, - textStyle: { - fontSize: 14, - color: '#353636', - fontWeight: 500 - } - }, tooltip: { trigger: 'axis', className: 'echarts-tooltip echarts-tooltip-dark'