diff --git a/nezha-fronted/src/components/page/dashboard/overview/chart.vue b/nezha-fronted/src/components/page/dashboard/overview/chart.vue index d88df07e9..c412211e0 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chart.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chart.vue @@ -16,13 +16,15 @@ import loading from "../../../common/loading"; import uuidv1 from "uuid/v1"; import chartConfig from './chartConfig' + import json from "./geoJson"; export default { name: "chart", components:{ 'loading':loading, }, props:{ - chartTitle:{type:String} + chartTitle:{type:String}, + chartType:{type:String,default:'line'}, }, data(){ return { @@ -32,11 +34,13 @@ } }, created() { - chartConfig.setSeries(this.series); - chartConfig.setTooltipFormatter(this.tooltipFormatter); - chartConfig.setTooltipPostion(this.tooltipPosition); - chartConfig.setYAxisLabelFormatter(this.yAxisFormatter); - this.option=chartConfig.getCommonOption(); + this.option=chartConfig.getOption(this.chartType); + this.$set(this.option,'series',this.series); + if(this.chartType == 'line'){ + this.$set(this.option.tooltip,'formatter',this.tooltipFormatter); + this.$set(this.option.tooltip,'position',this.tooltipPosition); + this.$set(this.option.yAxis,'formatter',this.yAxisFormatter); + } }, methods:{ tooltipPosition:function(point,params,dom,rect,size){ @@ -108,6 +112,11 @@ if(!this.chart){ this.chart=echarts.init(document.getElementById(this.chartId)); } + if(this.chartType == 'map'){ + console.log(json) + console.log(this.option) + echarts.registerMap('map',json); + } this.chart.clear(); this.chart.setOption(this.option) }, @@ -120,7 +129,6 @@ }, mounted() { this.chart=echarts.init(document.getElementById(this.chartId)); - this.chart.setOption(this.option); }, watch:{ diff --git a/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue b/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue index 0ca93bfe4..5ad821d49 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue @@ -1,5 +1,6 @@ diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview.scss b/nezha-fronted/src/components/page/dashboard/overview/overview.scss index 0081ddd7e..0d6dcb9fa 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview.scss +++ b/nezha-fronted/src/components/page/dashboard/overview/overview.scss @@ -63,7 +63,7 @@ width: 100%; } .overview-content .content-row-box{ - width: 99%; + width: 100%; display: flex; justify-content: space-between; align-content: flex-start; @@ -118,7 +118,6 @@ display: flex; align-items: center; justify-content: space-between; - padding: 5px; } .sub-title{ display: inline-block; diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview.vue b/nezha-fronted/src/components/page/dashboard/overview/overview.vue index 30bb3e4d0..7ab90ffa1 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/overview.vue @@ -46,7 +46,9 @@
-
+
+ +
@@ -60,13 +62,13 @@ --> - {{topNFilter.options.find((item)=>{return item.value==topNFilter.default})['label']}} + {{topNFilter.options.find((item)=>{return item.value==topNFilter.default})['label']}} {{item.label}} - {{topNFilter.tops.find((item)=>{return item.value==topNFilter.defaultTop})['label']}} + {{topNFilter.tops.find((item)=>{return item.value==topNFilter.defaultTop})['label']}} {{item.label}} @@ -91,6 +93,7 @@ import tableBox from "./tableBox"; import chart from "./chart"; import axios from 'axios'; + import json from './geoJson' export default { name: "overview", components:{ @@ -121,6 +124,7 @@ }, chartSeries:[], alertRuleStatData:{}, + dataCenterMapSeries:[], isGodView:false, sysTime:'', sysDate:'', @@ -139,6 +143,7 @@ this.topNChange(); this.queryAlertRuleStatData(); this.queryAlertTrendData(); + this.queryDataCenterMapData(); }, queryAssetData:function(){ this.$refs.assetTab.startLoading(); @@ -166,11 +171,15 @@ total:{ //左侧上方大图标及total信息 show:true, direction:'row', - num:`${totalData.total}/${totalData.inStock}`, + num:totalData.inStock, title:this.$t('dashboard.overview.asset.title'), showPopover:true, icon:'nz-icon nz-icon-asset', popover:[ + { + label:this.$t('dashboard.overview.asset.alertTotal'), + value:totalData.total + }, { label:this.$t('dashboard.overview.asset.inStock'), value:totalData.inStock @@ -731,6 +740,41 @@ } }) }, + queryDataCenterMapData:function(){ + this.dataCenterMapSeries=[{ + name: 'DataCenter', + type: 'map', + map:'map', + roam:true, + label: { + normal: { + show: true + }, + emphasis: { + show: true + } + }, + layoutCenter: ['50%', '50%'], //属性定义地图中心在屏幕中的位置,一般结合layoutSize 定义地图的大小 + layoutSize:500, + itemStyle:{ + normal:{label:{show:true}}, + emphasis:{label:{show:true}} + }, + data:[ + {name:'Alabama', value: 40000.34,}, + {name:'Alaska', value: 38000}, + {name:'Arizona', value: 18000}, + {name:'Arkansas', value: 15092}, + {name:'California', value: 28000}, + {name:'Colorado', value: 12000}, + {name:'Connecticut', value: 32000}, + {name:'Delaware', value: 5100}, + {name:'District of Columbia', value: 2200}, + {name:'Florida', value: 4918} + ] + }] + this.$refs.dataCenterMap.setSeries(this.dataCenterMapSeries); + }, /*加载数据 end*/ getAssetTabTitle:function(){ switch (this.typeFilter) {