fix: bug修复、地图色阶初版

This commit is contained in:
chenjinsong
2021-08-13 18:57:49 +08:00
parent c1bcc9394d
commit aa2d485f48
8 changed files with 51 additions and 46 deletions

View File

@@ -245,39 +245,23 @@ const singleValueLine = {
animation: false, animation: false,
grid: { grid: {
left: 0, left: 0,
bottom: 0, bottom: 2,
top: 5, top: 5,
right: 0 right: 0
}, },
color: chartColor, color: chartColor,
legend: { legend: {
tooltip: { show: false
show: true,
formatter: '{a}'
},
show: false,
right: 23,
top: 8,
orient: 'horizontal',
icon: 'circle',
itemGap: 20,
itemWidth: 10,
textStyle: {
padding: [0, 0, 0, 5],
fontSize: 14
},
formatter: tooLongFormatter
}, },
series: [ series: [
{ {
name: '访问用户量',
type: 'line', type: 'line',
smooth: true, legendHoverLink: false,
itemStyle: { itemStyle: {
normal: { normal: {
color: '#81C9FF', color: '#81C9FF',
lineStyle: { lineStyle: {
width:2 width: 2
} }
} }
}, },

View File

@@ -40,6 +40,11 @@
border-radius: 2px; border-radius: 2px;
height: 100%; height: 100%;
width: 100%; width: 100%;
.chart-drawing {
height: 100%;
width: 100%;
}
} }
&>.cn-chart__echarts, &>.cn-chart__table, &>.cn-chart__map { &>.cn-chart__echarts, &>.cn-chart__table, &>.cn-chart__map {
display: flex; display: flex;
@@ -62,11 +67,6 @@
} }
.cn-chart__body { .cn-chart__body {
flex: auto; flex: auto;
.chart-drawing {
height: 100%;
width: 100%;
}
} }
} }
&>.cn-chart__single-value.cn-chart__single-value--icon-left { &>.cn-chart__single-value.cn-chart__single-value--icon-left {

View File

@@ -43,7 +43,7 @@
} }
.cn-entity { .cn-entity {
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 30px; margin: 0 10px 30px;
width: 240px; width: 240px;
height: 315px; height: 315px;
background: #FFFFFF; background: #FFFFFF;

View File

@@ -125,12 +125,20 @@ export default {
}, },
entityName () { entityName () {
return this.$store.getters.entityName return this.$store.getters.entityName
},
storeFrom () {
return this.$store.getters.from
} }
}, },
watch: { watch: {
from (n) { from (n) {
this.$store.commit('entityTypeChange', n) this.$store.commit('entityTypeChange', n)
}, },
storeFrom (n) {
if (this.from !== n) {
this.from = n
}
},
entityName (n) { entityName (n) {
const breadcrumb = this.breadcrumbMap.find(b => b.path === '/entityExplorer') const breadcrumb = this.breadcrumbMap.find(b => b.path === '/entityExplorer')
breadcrumb.childName = n breadcrumb.childName = n

View File

@@ -41,8 +41,8 @@ axios.interceptors.request.use(
axios.interceptors.response.use( axios.interceptors.response.use(
response => { response => {
if (licenceErrorCode.indexOf(response.data.code) !== -1) { if (licenceErrorCode.indexOf(response.data.code) !== -1) {
window.location.href = '/'
sessionStorage.removeItem(storageKey.token) sessionStorage.removeItem(storageKey.token)
window.location.href = '/'
} else if (response.status === 200) { } else if (response.status === 200) {
if (accountErrorCode.indexOf(response.data.code) !== -1) { if (accountErrorCode.indexOf(response.data.code) !== -1) {
window.location.href = '/' window.location.href = '/'

View File

@@ -88,7 +88,7 @@
> >
<template #title><span :title="chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name">{{chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name}}</span></template> <template #title><span :title="chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name">{{chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name}}</span></template>
<template #data> <template #data>
<span>{{handleSingleValue[0]}}</span> <span>{{isNaN(handleSingleValue[0]) ? '-' : handleSingleValue[0]}}</span>
<span class="single-value__unit">{{handleSingleValue[1]}}</span> <span class="single-value__unit">{{handleSingleValue[1]}}</span>
</template> </template>
<template #chart> <template #chart>
@@ -275,17 +275,8 @@ export default {
this.chartOption = this.$_.cloneDeep(getOption(this.chart.type)) this.chartOption = this.$_.cloneDeep(getOption(this.chart.type))
const seriesTemplate = this.chartOption.series[0] const seriesTemplate = this.chartOption.series[0]
const queryParams = { startTime: parseInt(this.timeFilter.startTime / 1000), endTime: parseInt(this.timeFilter.endTime / 1000) }
get(replaceUrlPlaceholder(chartParams.urlLine, queryParams)).then(response => { get(replaceUrlPlaceholder(chartParams.urlLine, queryParams)).then(response => {
if (response.code === 200) { if (response.code === 200) {
/*response.data.result = [
{
legend: "session_rate",
values:[
["1625122200","2"],["1625122500","2"],["1625122800","1"],["1625123100","1"],["1625123400","2"],["1625123700","2"],["1625124000","2"],["1625124300","3"],["1625124600","3"],["1625124900","3"]
]
}
]*/
this.chartOption.series = response.data.result.map((r, i) => { this.chartOption.series = response.data.result.map((r, i) => {
return { return {
...seriesTemplate, ...seriesTemplate,
@@ -301,11 +292,14 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.myChart.resize() this.myChart.resize()
}) })
setTimeout(() => { this.loading = false }, 250)
}) })
} else { } else {
this.loading = false this.loading = false
} }
}).catch(() => {
this.singleValue.value = ''
}).finally(() => {
setTimeout(() => { this.loading = false }, 250)
}) })
} }
} else if (this.isTabs) { } else if (this.isTabs) {
@@ -447,9 +441,10 @@ export default {
polygonSeries.heatRules.push({ polygonSeries.heatRules.push({
property: 'fill', property: 'fill',
target: polygonSeries.mapPolygons.template, target: polygonSeries.mapPolygons.template,
min: am4Core.color('#FFFF00'), min: am4Core.color('#EABA2B'),
max: am4Core.color('#E66767') max: am4Core.color('#D95D41')
}) })
polygonSeries.data = response.data.result.map(r => { polygonSeries.data = response.data.result.map(r => {
return { return {
id: r.serverId, id: r.serverId,
@@ -457,6 +452,21 @@ export default {
value: r.establishLatency || r.httpResponseLatency || r.sslConLatency || r.sequenceGapLossPercent || r.pktRetransPercent || r.sessions value: r.establishLatency || r.httpResponseLatency || r.sslConLatency || r.sequenceGapLossPercent || r.pktRetransPercent || r.sessions
} }
}) })
const sorted = polygonSeries.data.sort((a, b) => b.value - a.value)
const heatLegend = this.myChart.createChild(am4Maps.HeatLegend)
heatLegend.series = polygonSeries
heatLegend.align = 'center'
console.info(sorted)
if (!this.$_.isEmpty(sorted)) {
heatLegend.minValue = 0
heatLegend.maxValue = Number(sorted[0].value)
}
heatLegend.markerContainer.height = 6
heatLegend.width = am4Core.percent(25)
heatLegend.marginLeft = am4Core.percent(4)
heatLegend.valign = 'bottom'
const polygonTemplate = polygonSeries.mapPolygons.template const polygonTemplate = polygonSeries.mapPolygons.template
polygonTemplate.tooltipText = '{name}{title}' polygonTemplate.tooltipText = '{name}{title}'
// polygonTemplate.numberFormatter = new am4Core.NumberFormatter().bigNumberPrefixes // polygonTemplate.numberFormatter = new am4Core.NumberFormatter().bigNumberPrefixes
@@ -464,6 +474,7 @@ export default {
polygonTemplate.strokeWidth = 0.5 polygonTemplate.strokeWidth = 0.5
} }
} }
}).finally(() => {
setTimeout(() => { this.loading = false }, 250) setTimeout(() => { this.loading = false }, 250)
}) })
}, },
@@ -526,6 +537,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.myChart.resize() this.myChart.resize()
}) })
}).finally(() => {
setTimeout(() => { this.loading = false }, 250) setTimeout(() => { this.loading = false }, 250)
}) })
}, },
@@ -555,6 +567,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.myChart.resize() this.myChart.resize()
}) })
}).finally(() => {
setTimeout(() => { this.loading = false }, 250) setTimeout(() => { this.loading = false }, 250)
}) })
}, },
@@ -590,12 +603,11 @@ export default {
if (response2.code === 200) { if (response2.code === 200) {
this.pieTableData = response2.data.result this.pieTableData = response2.data.result
} }
this.loading = false
}) })
} else {
setTimeout(() => { this.loading = false }, 250)
} }
} }
}).finally(() => {
setTimeout(() => { this.loading = false }, 250)
}) })
// legend点击事件 // legend点击事件
this.myChart.off('legendselectchanged') this.myChart.off('legendselectchanged')
@@ -656,7 +668,8 @@ export default {
this.table.tableColumns = this.getTableTitle(response.data.result) this.table.tableColumns = this.getTableTitle(response.data.result)
this.table.currentPageData = this.getTargetPageData(1, this.table.pageSize, this.table.tableData) this.table.currentPageData = this.getTargetPageData(1, this.table.pageSize, this.table.tableData)
} }
this.loading = false }).finally(() => {
setTimeout(() => { this.loading = false }, 250)
}) })
}, },
echartsResize () { echartsResize () {

View File

@@ -9,7 +9,7 @@
<el-radio-button v-for="tab in tabs" :key="tab.key" :label="tab.label"></el-radio-button> <el-radio-button v-for="tab in tabs" :key="tab.key" :label="tab.label"></el-radio-button>
</el-radio-group> </el-radio-group>
</div> </div>
<div class="cn-panel" id="cn-panel"> <div class="cn-panel" id="cn-panel" :style="{height: typeName ? 'calc(100% - 80px)' : ''}">
<div class="panel__time"> <div class="panel__time">
<DateTimeRange class="date-time-range" :start-time="timeFilter.startTime" :end-time="timeFilter.endTime" ref="dateTimeRange" @change="reload"/> <DateTimeRange class="date-time-range" :start-time="timeFilter.startTime" :end-time="timeFilter.endTime" ref="dateTimeRange" @change="reload"/>
<TimeRefresh class="date-time-range" @change="timeRefreshChange" :end-time="timeFilter.endTime"/> <TimeRefresh class="date-time-range" @change="timeRefreshChange" :end-time="timeFilter.endTime"/>

View File

@@ -309,7 +309,6 @@ export default {
} }
}, },
pageNoRight (val) { pageNoRight (val) {
console.info(val)
this.pageObjRight.pageNo = val this.pageObjRight.pageNo = val
this.search() this.search()
}, },
@@ -471,6 +470,7 @@ export default {
} }
}, },
beforeUnmount () { beforeUnmount () {
this.$store.commit('entityTypeChange', Object.keys(entityType)[0])
this.$store.commit('showEntityTypeSelector', false) this.$store.commit('showEntityTypeSelector', false)
} }
} }