feat: 右上角条件筛选和刷新

This commit is contained in:
chenjinsong
2022-08-23 21:42:42 +08:00
parent 537ddd8ad3
commit e3db8caf63
12 changed files with 249 additions and 161 deletions

View File

@@ -162,7 +162,14 @@ export const api = {
// 各维度下钻会话统计 // 各维度下钻会话统计
relatedSessions: '/interface/application/performance/relatedSessions', relatedSessions: '/interface/application/performance/relatedSessions',
// 各维度下钻流量曲线图 // 各维度下钻流量曲线图
trafficGraph: '/interface/application/performance/overview/drilldown/drilldown/dimension/trafficGraph' trafficGraph: '/interface/application/performance/overview/drilldown/drilldown/dimension/trafficGraph',
// 下钻地图
map: '/interface/application/performance/overview/drilldown/dimension/clientLocations/world/trafficAnalysis',
mapTcp: '/interface/application/performance/overview/drilldown/dimension/clientLocations/world/tcpSessionDelay',
mapHttp: '/interface/application/performance/overview/drilldown/dimension/clientLocations/world/httpResponseDelay',
mapSsl: '/interface/application/performance/overview/drilldown/dimension/clientLocations/world/sslConDelay',
mapPacketLoss: '/interface/application/performance/overview/drilldown/dimension/clientLocations/world/tcpSessionDelay',
mapPacketRetrans: '/interface/application/performance/overview/drilldown/dimension/clientLocations/world/tcpSessionDelay'
}, },
location: { location: {
// 折线图 // 折线图

View File

@@ -31,7 +31,7 @@
</template> </template>
<script> <script>
import {useRoute, useRouter} from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { ref } from 'vue' import { ref } from 'vue'
import { panelTypeAndRouteMapping } from '@/utils/constants' import { panelTypeAndRouteMapping } from '@/utils/constants'
import { getPanelList, getChartList } from '@/utils/api' import { getPanelList, getChartList } from '@/utils/api'
@@ -131,11 +131,17 @@ export default {
}) })
} }
}, },
timeRefreshChange (startTime, endTime, dateRangeValue) { reload (startTime, endTime, dateRangeValue) {
this.timeFilter = { startTime: startTime, endTime: endTime, dateRangeValue: dateRangeValue }
}, },
reload () { timeRefreshChange () {
// 不是自选时间
if (!this.$refs.dateTimeRange.isCustom) {
const value = this.timeFilter.dateRangeValue
this.$refs.dateTimeRange.quickChange(value)
} else {
this.timeFilter = JSON.parse(JSON.stringify(this.timeFilter))
}
} }
} }
} }

View File

@@ -118,19 +118,20 @@
<script> <script>
import unitConvert from '@/utils/unit-convert' import unitConvert from '@/utils/unit-convert'
import { storageKey, unitTypes } from '@/utils/constants' import {storageKey, unitTypes} from '@/utils/constants'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { appListChartOption } from '@/views/charts2/charts/options/echartOption' import {appListChartOption} from '@/views/charts2/charts/options/echartOption'
import { shallowRef } from 'vue' import {shallowRef} from 'vue'
import { get, put } from '@/utils/http' import {get, put} from '@/utils/http'
import { api } from '@/utils/api' import {api} from '@/utils/api'
import _ from 'lodash' import _ from 'lodash'
import { getSecond } from '@/utils/date-util' import {getSecond} from '@/utils/date-util'
import { getChainRatio } from '@/utils/tools' import {getChainRatio} from '@/utils/tools'
import loading from '@/components/common/Loading' import loading from '@/components/common/Loading'
import ChartNoData from '@/views/charts/charts/ChartNoData' import ChartNoData from '@/views/charts/charts/ChartNoData'
import { appStackedLineTooltipFormatter } from '@/views/charts/charts/tools' import {appStackedLineTooltipFormatter} from '@/views/charts/charts/tools'
import chartMixin from '@/views/charts2/chart-mixin' import chartMixin from '@/views/charts2/chart-mixin'
export default { export default {
name: 'NetworkOverviewApps', name: 'NetworkOverviewApps',
components: { components: {
@@ -198,6 +199,12 @@ export default {
window.removeEventListener('scroll', this.handleScroll, true) window.removeEventListener('scroll', this.handleScroll, true)
} }
} }
},
timeFilter: {
deep: true,
handler (n) {
this.init()
}
} }
}, },
methods: { methods: {
@@ -320,8 +327,7 @@ export default {
params.forEach(t => { params.forEach(t => {
t.seriesName = this.$t(t.seriesName) t.seriesName = this.$t(t.seriesName)
}) })
const str = appStackedLineTooltipFormatter(params) return appStackedLineTooltipFormatter(params)
return str
} }
chart.setOption(chartOption) chart.setOption(chartOption)
this.myChart.push(chart) this.myChart.push(chart)

View File

@@ -40,6 +40,14 @@ export default {
isNoData: false isNoData: false
} }
}, },
watch: {
timeFilter: {
deep: true,
handler (n) {
this.ddosDetectDataRequests()
}
}
},
methods: { methods: {
ddosDetectDataRequests () { ddosDetectDataRequests () {
const params = { const params = {

View File

@@ -145,6 +145,12 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.handleActiveBar(n) this.handleActiveBar(n)
}) })
},
timeFilter: {
deep: true,
handler (n) {
this.init(this.echartsType, this.showMarkLine, 'active')
}
} }
}, },
methods: { methods: {

View File

@@ -140,6 +140,12 @@ export default {
watch: { watch: {
loading (n) { loading (n) {
this.toggleLoading(n) this.toggleLoading(n)
},
timeFilter: {
deep: true,
handler (n) {
this.init()
}
} }
}, },
mounted () { mounted () {

View File

@@ -128,13 +128,19 @@ export default {
} }
}, },
mixins: [chartMixin], mixins: [chartMixin],
watch: {
timeFilter: {
deep: true,
handler (n) {
this.init()
}
}
},
methods: { methods: {
init (params) { init () {
if (!params) { const params = {
params = { startTime: getSecond(this.timeFilter.startTime),
startTime: getSecond(this.timeFilter.startTime), endTime: getSecond(this.timeFilter.endTime)
endTime: getSecond(this.timeFilter.endTime)
}
} }
// 获取table后三列内容 // 获取table后三列内容
const currentTrafficRequest = get(api.npm.overview.appTrafficAnalysis, { ...params, cycle: 0 }) const currentTrafficRequest = get(api.npm.overview.appTrafficAnalysis, { ...params, cycle: 0 })

View File

@@ -24,6 +24,14 @@ export default {
type: 'severity' type: 'severity'
} }
}, },
watch: {
timeFilter: {
deep: true,
handler (n) {
this.recentEventsListData()
}
}
},
methods: { methods: {
recentEventsListData () { recentEventsListData () {
const params = { const params = {

View File

@@ -1,117 +1,58 @@
<template> <template>
<div class="cn-chart__map"> <div class="cn-chart__map">
<div class="map-canvas" id="npmMap"></div> <div class="map-canvas" id="npmDrillDownMap"></div>
<div class="map-filter">
<el-select
size="mini"
v-model="trafficDirection"
class="map-select map-select__direction"
>
<el-option value="Server">Server</el-option>
<el-option value="Client">Client</el-option>
</el-select>
<el-select
size="mini"
v-model="location"
class="map-select map-select__location"
clearable
placeholder="All"
filterable
>
<template #prefix><i class="cn-icon cn-icon-location" style="color: #575757;"></i></template>
<el-option v-for="(country, index) in locationOptions" :key="index" :value="country.value">{{country.label}}</el-option>
</el-select>
</div>
<div class="map-legend">
<div class="map-legend__row">
<div class="map-legend__symbol map-legend__symbol--green"></div>
<div class="map-legend__desc">{{$t('npm.highScore')}}</div>
</div>
<div class="map-legend__row">
<div class="map-legend__symbol map-legend__symbol--yellow"></div>
<div class="map-legend__desc">{{$t('npm.middleScore')}}</div>
</div>
<div class="map-legend__row">
<div class="map-legend__symbol map-legend__symbol--red"></div>
<div class="map-legend__desc">{{$t('npm.lowScore')}}</div>
</div>
</div>
</div> </div>
</template> </template>
<script> <script>
import { mapData, drillDownData } from '@/views/charts2/charts/mapTestData'
import { shallowRef } from 'vue' import { shallowRef } from 'vue'
import * as am4Core from '@amcharts/amcharts4/core' import * as am4Core from '@amcharts/amcharts4/core'
import * as am4Maps from '@amcharts/amcharts4/maps' import * as am4Maps from '@amcharts/amcharts4/maps'
import { getGeoData } from '@/utils/tools' import { computeScore, getGeoData } from '@/utils/tools'
import { storageKey, unitTypes } from '@/utils/constants' import { storageKey, unitTypes, countryNameIdMapping } from '@/utils/constants'
import locationOptions from '@/views/charts2/charts/locationOptions' import { valueToRangeValue } from '@/utils/unit-convert'
import unitConvert, { valueToRangeValue } from '@/utils/unit-convert' import { getSecond } from '@/utils/date-util'
import { api, getData } from '@/utils/api'
import { get } from '@/utils/http'
import chartMixin from '@/views/charts2/chart-mixin'
export default { export default {
name: 'NpmMap', name: 'NpmIpMap',
data () { data () {
return { return {
locationOptions,
mapData,
drillDownData,
myChart: null, myChart: null,
polygonSeries: null, polygonSeries: null,
countrySeries: null, countrySeries: null,
worldImageSeries: null, worldImageSeries: null,
countryImageSeries: null, countryImageSeries: null,
// Server | Client // Server | Client
trafficDirection: 'Server', trafficDirection: 'Server'
location: ''
} }
}, },
mixins: [chartMixin],
methods: { methods: {
initMap () { async initMap () {
// 初始化插件 // 初始化插件
const chart = am4Core.create('npmMap', am4Maps.MapChart) this.toggleLoading(true)
chart.geodata = getGeoData(storageKey.iso36112WorldLow) const geoData = await getGeoData(storageKey.iso36112WorldLow)
const chart = am4Core.create('npmDrillDownMap', am4Maps.MapChart)
chart.geodata = geoData
chart.projection = new am4Maps.projections.Miller() chart.projection = new am4Maps.projections.Miller()
chart.homeZoomLevel = 2 chart.homeZoomLevel = 1.5
chart.homeGeoPoint = { chart.homeGeoPoint = {
latitude: 21, latitude: 21,
longitude: 0 longitude: 0
} }
this.myChart = shallowRef(chart) this.myChart = shallowRef(chart)
this.polygonSeries = shallowRef(this.polygonSeriesFactory()) this.polygonSeries = shallowRef(this.polygonSeriesFactory())
this.worldImageSeries = shallowRef(this.imageSeriesFactory('score')) this.worldImageSeries = shallowRef(this.imageSeriesFactory('score', this.polygonSeries))
// 渲染 // 渲染
this.loadAm4ChartMap(this.polygonSeries, this.worldImageSeries) this.loadAm4ChartMap(this.polygonSeries, this.worldImageSeries)
this.worldImageSeries.mapImages.template.events.on('hit', async ev => {
const countryId = ev.target.dataItem.dataContext.id
ev.target.isHover = false
if (countryId) {
const targetMapObject = this.polygonSeries.getPolygonById(countryId)
targetMapObject.series.chart.zoomToMapObject(targetMapObject)
const geoData = getGeoData(countryId)
if (geoData) {
this.countrySeries = shallowRef(this.polygonSeriesFactory())
this.countrySeries.geodata = geoData
this.countryImageSeries = shallowRef(this.imageSeriesFactory('score'))
this.polygonSeries.hide()
this.worldImageSeries.hide()
const country = ev.target.dataItem.dataContext.name
const queryParams = { ...this.queryParams, ipLocationCountry: country }
const chartData = this.drillDownData
this.loadAm4ChartMap(this.countrySeries, this.countryImageSeries, country, chartData)
}
}
})
}, },
loadAm4ChartMap (polygonSeries, imageSeries, country, chartData) { loadAm4ChartMap (polygonSeries, imageSeries) {
// chartData不为空是下钻
if (chartData) {
this.$emit('showLoading', true)
}
try { try {
// 清除数据 // 清除数据
polygonSeries.data.splice(0) // polygonSeries.data.splice(0)
this.toggleLoading(true)
// 清除legend // 清除legend
this.myChart.children.each((s, i) => { this.myChart.children.each((s, i) => {
if (s && s.className !== 'Container') { if (s && s.className !== 'Container') {
@@ -119,25 +60,62 @@ export default {
} }
}) })
this.showMapBackButton = !!country const params = {
const data = chartData || this.mapData startTime: getSecond(this.timeFilter.startTime),
imageSeries.data = data.map(r => ({ endTime: getSecond(this.timeFilter.endTime),
score: r.score, type: this.$store.getters.getDimensionType,
id: r.locationId, typeVal: this.$store.getters.getBreadcrumbColumnValue
color: this.scoreColor(r.score), }
border: this.scoreColor(r.score) getData(api.npm.overview.map, params).then(res => {
})) // 计算分数
const tcpRequest = get(api.npm.overview.mapTcp, params)
const httpRequest = get(api.npm.overview.mapHttp, params)
const sslRequest = get(api.npm.overview.mapSsl, params)
const tcpLostRequest = get(api.npm.overview.mapPacketLoss, params)
const packetRetransRequest = get(api.npm.overview.mapPacketRetrans, params)
Promise.all([tcpRequest, httpRequest, sslRequest, tcpLostRequest, packetRetransRequest]).then(res2 => {
const keyPre = ['tcp', 'http', 'ssl', 'tcpLost', 'packetRetrans']
const mapData = res
res2.forEach((r, i) => {
if (r.code === 200) {
mapData.forEach(t => {
let score = 0
const find = r.data.result.find(d => d.country === t.country)
if (find) {
score = computeScore(find, i)
}
t[keyPre[i] + 'Score'] = score
})
} else {
mapData.forEach(t => {
t[keyPre[i] + 'Score'] = 0
})
}
})
mapData.forEach(t => {
t.score = Math.ceil((t.tcpScore + t.httpScore + t.sslScore + t.tcpLostScore + t.packetRetransScore) * 6)
if (t.score > 6) {
t.score = 6
}
})
this.loadMarkerData(imageSeries, mapData)
})
}).finally(() => {
this.toggleLoading(false)
})
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} finally {
if (chartData) {
setTimeout(() => {
this.$emit('showLoading', false)
}, 200)
}
} }
}, },
convertMapData (data) { loadMarkerData (imageSeries, data) {
imageSeries.data = data.map(r => ({
score: r.score,
name: r.province || r.country,
throughput: valueToRangeValue(r.throughBitsRate, unitTypes.bps).join(' '),
id: r.serverId,
color: this.scoreColor(r.score),
border: this.scoreColor(r.score)
}))
}, },
scoreColor (score) { scoreColor (score) {
if (score >= 0 && score <= 2) { if (score >= 0 && score <= 2) {
@@ -148,6 +126,23 @@ export default {
return '#7E9F54' return '#7E9F54'
} }
}, },
generatePolygonTooltipHTML () {
const html = `
<div class="map-tooltip" style="padding-bottom: 10px;">
<div class="map-tooltip__title">{name}</div>
<div class="map-tooltip__content">
<div class="content-row">
<div class="row__label">Score</div>
<div class="row__value">{score}</div>
</div>
<div class="content-row">
<div class="row__label">Throughput</div>
<div class="row__value">{throughput}</div>
</div>
</div>
</div>`
return html
},
polygonSeriesFactory () { polygonSeriesFactory () {
const polygonSeries = this.myChart.series.push(new am4Maps.MapPolygonSeries()) const polygonSeries = this.myChart.series.push(new am4Maps.MapPolygonSeries())
polygonSeries.useGeodata = true polygonSeries.useGeodata = true
@@ -163,8 +158,7 @@ export default {
polygonTemplate.fill = am4Core.color('#EFEFEF') polygonTemplate.fill = am4Core.color('#EFEFEF')
return polygonSeries return polygonSeries
}, },
imageSeriesFactory (dataField) { imageSeriesFactory (dataField, polygonSeries) {
const vm = this
// amcharts实例中增加地图图案series用来在地图上画圆点、方块、连线等 // amcharts实例中增加地图图案series用来在地图上画圆点、方块、连线等
const imageSeries = this.myChart.series.push(new am4Maps.MapImageSeries()) const imageSeries = this.myChart.series.push(new am4Maps.MapImageSeries())
// 指定接口数据中哪个字段名代表数值 // 指定接口数据中哪个字段名代表数值
@@ -174,14 +168,14 @@ export default {
imageTemplate.nonScaling = true imageTemplate.nonScaling = true
// 通过地区ID来获取经纬度设置后无需自己提供经纬度 // 通过地区ID来获取经纬度设置后无需自己提供经纬度
imageTemplate.adapter.add('latitude', function (latitude, target) { imageTemplate.adapter.add('latitude', function (latitude, target) {
const polygon = vm.polygonSeries.getPolygonById(target.dataItem.dataContext.id) const polygon = polygonSeries.getPolygonById(target.dataItem.dataContext.id)
if (polygon) { if (polygon) {
return polygon.visualLatitude return polygon.visualLatitude
} }
return latitude return latitude
}) })
imageTemplate.adapter.add('longitude', function (longitude, target) { imageTemplate.adapter.add('longitude', function (longitude, target) {
const polygon = vm.polygonSeries.getPolygonById(target.dataItem.dataContext.id) const polygon = polygonSeries.getPolygonById(target.dataItem.dataContext.id)
if (polygon) { if (polygon) {
return polygon.visualLongitude return polygon.visualLongitude
} }
@@ -193,11 +187,12 @@ export default {
circle.propertyFields.fill = 'color' circle.propertyFields.fill = 'color'
circle.propertyFields.stroke = 'border' circle.propertyFields.stroke = 'border'
circle.strokeWidth = 1 circle.strokeWidth = 1
// circle.tooltipHTML = this.generatePolygonTooltipHTML() circle.fillOpacity = 0.8
circle.tooltipHTML = this.generatePolygonTooltipHTML()
imageSeries.tooltip.getFillFromObject = false imageSeries.tooltip.getFillFromObject = false
imageSeries.tooltip.background.fill = am4Core.color('#41495D') imageSeries.tooltip.background.fill = am4Core.color('#FFFFFF')
imageSeries.tooltip.background.filters.clear() imageSeries.tooltip.background.filters.clear()
imageSeries.tooltip.background.stroke = '#41495D' imageSeries.tooltip.background.stroke = '#C5C5C5'
imageSeries.heatRules.push({ imageSeries.heatRules.push({
target: circle, target: circle,
@@ -212,6 +207,14 @@ export default {
}, },
mounted () { mounted () {
this.initMap() this.initMap()
},
beforeUnmount () {
this.polygonSeries = null
this.countrySeries = null
this.worldImageSeries = null
this.countryImageSeries = null
this.myChart && this.myChart.dispose()
this.myChart = null
} }
} }
</script> </script>

View File

@@ -2,7 +2,7 @@
<div class="npm-line"> <div class="npm-line">
<template v-if="chartData.id === 11"> <template v-if="chartData.id === 11">
<div class="npm-line-header"> <div class="npm-line-header">
<div class="npm-line-header-title">{{$_.get(chartData, 'i18n') || chartData.name}}</div> <div class="npm-line-header-title">{{$t(chartData.i18n) || chartData.name}}</div>
<div class="npm-line-header-rights" v-if="chartData.params && chartData.params.showLegend && !throughputName"> <div class="npm-line-header-rights" v-if="chartData.params && chartData.params.showLegend && !throughputName">
<div class="npm-line-header-right" :class="{'active': item.show}" v-for="(item, index) in chartOptionLineData" :key="index" @click="highlightEvent(item)"> <div class="npm-line-header-right" :class="{'active': item.show}" v-for="(item, index) in chartOptionLineData" :key="index" @click="highlightEvent(item)">
<div class="npm-line-header-icon" :class="'icon' + index"></div> <div class="npm-line-header-icon" :class="'icon' + index"></div>
@@ -14,27 +14,27 @@
<div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div> <div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div>
</template> </template>
<template v-else-if="chartData.id === 12"> <template v-else-if="chartData.id === 12">
<div class="npm-line-title">{{$_.get(chartData, 'i18n') || chartData.name}}</div> <div class="npm-line-title">{{$t(chartData.i18n) || chartData.name}}</div>
<chart-no-data v-if="tcpName"></chart-no-data> <chart-no-data v-if="tcpName"></chart-no-data>
<div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div> <div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div>
</template> </template>
<template v-else-if="chartData.id === 13"> <template v-else-if="chartData.id === 13">
<div class="npm-line-title">{{$_.get(chartData, 'i18n') || chartData.name}}</div> <div class="npm-line-title">{{$t(chartData.i18n) || chartData.name}}</div>
<chart-no-data v-if="httpName"></chart-no-data> <chart-no-data v-if="httpName"></chart-no-data>
<div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div> <div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div>
</template> </template>
<template v-else-if="chartData.id === 14"> <template v-else-if="chartData.id === 14">
<div class="npm-line-title">{{$_.get(chartData, 'i18n') || chartData.name}}</div> <div class="npm-line-title">{{$t(chartData.i18n) || chartData.name}}</div>
<chart-no-data v-if="sslName"></chart-no-data> <chart-no-data v-if="sslName"></chart-no-data>
<div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div> <div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div>
</template> </template>
<template v-else-if="chartData.id === 15"> <template v-else-if="chartData.id === 15">
<div class="npm-line-title">{{$_.get(chartData, 'i18n') || chartData.name}}</div> <div class="npm-line-title">{{$t(chartData.i18n) || chartData.name}}</div>
<chart-no-data v-if="packetsLossName"></chart-no-data> <chart-no-data v-if="packetsLossName"></chart-no-data>
<div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div> <div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div>
</template> </template>
<template v-else-if="chartData.id === 16"> <template v-else-if="chartData.id === 16">
<div class="npm-line-title">{{$_.get(chartData, 'i18n') || chartData.name}}</div> <div class="npm-line-title">{{$t(chartData.i18n) || chartData.name}}</div>
<chart-no-data v-if="packetsRetrainsName"></chart-no-data> <chart-no-data v-if="packetsRetrainsName"></chart-no-data>
<div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div> <div v-else class="chart-drawing" :id="`chart${chartData.name}`"></div>
</template> </template>
@@ -199,7 +199,7 @@ export default {
this.chartOption.series = data.map((t, i) => { this.chartOption.series = data.map((t, i) => {
return { return {
...seriesTemplate, ...seriesTemplate,
name: t.legend ? t.legend : this.$_.get(chartData, 'i18n') || chartData.name, name: t.legend ? t.legend : this.$t(chartData.i18n) || chartData.name,
stack: this.chartData.params.isStack ? 'network.total' : '', stack: this.chartData.params.isStack ? 'network.total' : '',
lineStyle: { lineStyle: {
width: 1 width: 1

View File

@@ -40,7 +40,6 @@
</template> </template>
<script> <script>
import { mapData, drillDownData } from '@/views/charts2/charts/mapTestData'
import { shallowRef } from 'vue' import { shallowRef } from 'vue'
import * as am4Core from '@amcharts/amcharts4/core' import * as am4Core from '@amcharts/amcharts4/core'
import * as am4Maps from '@amcharts/amcharts4/maps' import * as am4Maps from '@amcharts/amcharts4/maps'
@@ -52,13 +51,12 @@ import { getSecond } from '@/utils/date-util'
import { api, getData } from '@/utils/api' import { api, getData } from '@/utils/api'
import { get } from '@/utils/http' import { get } from '@/utils/http'
import chartMixin from '@/views/charts2/chart-mixin' import chartMixin from '@/views/charts2/chart-mixin'
import {Rectangle3D} from '@amcharts/amcharts4/.internal/core/elements/3d/Rectangle3D'
export default { export default {
name: 'NpmMap', name: 'NpmMap',
data () { data () {
return { return {
locationOptions, locationOptions,
mapData,
drillDownData,
myChart: null, myChart: null,
polygonSeries: null, polygonSeries: null,
countrySeries: null, countrySeries: null,
@@ -88,6 +86,20 @@ export default {
this.worldImageSeries = shallowRef(this.imageSeriesFactory('score', this.polygonSeries)) this.worldImageSeries = shallowRef(this.imageSeriesFactory('score', this.polygonSeries))
// 渲染 // 渲染
this.loadAm4ChartMap(this.polygonSeries, this.worldImageSeries) this.loadAm4ChartMap(this.polygonSeries, this.worldImageSeries)
this.worldImageSeries.mapImages.template.events.on('hit', async ev => {
this.$store.commit('setNpmLocationCountry', ev.target.dataItem.dataContext.name)
this.location = ev.target.dataItem.dataContext.name
if (this.countrySeries) {
this.countrySeries.dispose()
}
if (this.countryImageSeries) {
this.countryImageSeries.dispose()
}
const countryId = ev.target.dataItem.dataContext.id
ev.target.isHover = false
await this.drill(countryId)
})
}, },
loadAm4ChartMap (polygonSeries, imageSeries) { loadAm4ChartMap (polygonSeries, imageSeries) {
try { try {
@@ -157,8 +169,6 @@ export default {
color: this.scoreColor(r.score), color: this.scoreColor(r.score),
border: this.scoreColor(r.score) border: this.scoreColor(r.score)
})) }))
console.info(imageSeries)
console.info(this.countryImageSeries)
}, },
scoreColor (score) { scoreColor (score) {
if (score >= 0 && score <= 2) { if (score >= 0 && score <= 2) {
@@ -246,49 +256,71 @@ export default {
}) })
return imageSeries return imageSeries
},
async drill (countryId) {
if (countryId) {
const targetMapObject = this.polygonSeries.getPolygonById(countryId)
targetMapObject.series.chart.zoomToMapObject(targetMapObject)
const geoData = await getGeoData(countryId)
if (geoData) {
this.countrySeries = shallowRef(this.polygonSeriesFactory())
this.countrySeries.geodata = geoData
this.countryImageSeries = shallowRef(this.imageSeriesFactory('score', this.countrySeries))
this.polygonSeries.hide()
this.worldImageSeries.hide()
this.$nextTick(() => {
this.loadAm4ChartMap(this.countrySeries, this.countryImageSeries)
})
}
}
} }
}, },
watch: { watch: {
trafficDirection (n) { trafficDirection (n) {
this.$store.commit('setNpmLocationSide', n.toLowerCase()) this.$store.commit('setNpmLocationSide', n.toLowerCase())
this.loadAm4ChartMap(this.countrySeries || this.polygonSeries, this.countryImageSeries || this.worldImageSeries) if (this.location) {
this.loadAm4ChartMap(this.countrySeries, this.countryImageSeries)
} else {
this.loadAm4ChartMap(this.polygonSeries, this.worldImageSeries)
}
}, },
async location (n) { async location (n) {
this.$store.commit('setNpmLocationCountry', n) this.$store.commit('setNpmLocationCountry', n)
if (this.countrySeries) { this.countrySeries.dispose()
this.countrySeries.dispose() this.countryImageSeries.dispose()
}
if (this.countryImageSeries) {
this.countryImageSeries.dispose()
}
if (n) { if (n) {
const countryId = countryNameIdMapping[n] const countryId = countryNameIdMapping[n]
if (countryId) { await this.drill(countryId)
const targetMapObject = this.polygonSeries.getPolygonById(countryId)
targetMapObject.series.chart.zoomToMapObject(targetMapObject)
const geoData = await getGeoData(countryId)
if (geoData) {
this.countrySeries = shallowRef(this.polygonSeriesFactory())
this.countrySeries.geodata = geoData
this.countryImageSeries = shallowRef(this.imageSeriesFactory('score', this.countrySeries))
this.polygonSeries.hide()
this.worldImageSeries.hide()
this.$nextTick(() => {
this.loadAm4ChartMap(this.countrySeries, this.countryImageSeries)
})
}
}
} else { } else {
this.polygonSeries.show() this.polygonSeries.show()
this.worldImageSeries.show() this.worldImageSeries.show()
this.countrySeries = null
this.countryImageSeries = null
this.myChart.zoomToGeoPoint(this.myChart.homeGeoPoint, this.myChart.homeZoomLevel, true) this.myChart.zoomToGeoPoint(this.myChart.homeGeoPoint, this.myChart.homeZoomLevel, true)
} }
},
timeFilter: {
deep: true,
handler (n) {
if (this.location) {
this.loadAm4ChartMap(this.countrySeries, this.countryImageSeries)
} else {
this.loadAm4ChartMap(this.polygonSeries, this.worldImageSeries)
}
}
} }
}, },
mounted () { mounted () {
this.initMap() this.initMap()
},
beforeUnmount () {
if (this.polygonSeries) {
this.polygonSeries.mapPolygons.template.events.off('hit', this.mapBlockHitEvent)
}
this.polygonSeries = null
this.countrySeries = null
this.worldImageSeries = null
this.countryImageSeries = null
this.myChart && this.myChart.dispose()
this.myChart = null
} }
} }
</script> </script>

View File

@@ -31,7 +31,7 @@
</el-table-column> </el-table-column>
</template> </template>
<template v-slot:empty> <template v-slot:empty>
<div class="table-no-data"> <div class="table-no-data" v-show="isNoData">
<svg class="icon" aria-hidden="true"> <svg class="icon" aria-hidden="true">
<use xlink:href="#cn-icon-a-allclear"></use> <use xlink:href="#cn-icon-a-allclear"></use>
</svg> </svg>