# Conflicts:
#	src/views/charts/PanelChart.vue
This commit is contained in:
@changcode
2022-01-26 17:10:41 +08:00
3 changed files with 16 additions and 7 deletions

View File

@@ -175,7 +175,6 @@
v-else-if="isIpHostedDomain" v-else-if="isIpHostedDomain"
:chart-info="chartInfo" :chart-info="chartInfo"
:chart-data="chartData" :chart-data="chartData"
:query-params="queryParams"
@showLoading="showLoading" @showLoading="showLoading"
:entity="entity" :entity="entity"
></chart-echart-ip-hosted-domain> ></chart-echart-ip-hosted-domain>
@@ -184,7 +183,6 @@
v-else-if="isAppRelatedDomain" v-else-if="isAppRelatedDomain"
:chart-info="chartInfo" :chart-info="chartInfo"
:chart-data="chartData" :chart-data="chartData"
:query-params="queryParams"
@showLoading="showLoading" @showLoading="showLoading"
:entity="entity" :entity="entity"
></chart-echart-app-relate-domain> ></chart-echart-app-relate-domain>

View File

@@ -75,7 +75,7 @@ import {
isAppRelatedDomain, isAppRelatedDomain,
isBlock isBlock
} from './charts/tools' } from './charts/tools'
import { tableTitleMapping } from '@/components/charts/chart-table-title' import { tableTitleMapping, legendMapping } from '@/components/charts/chart-table-title'
import { replaceUrlPlaceholder } from '@/utils/tools' import { replaceUrlPlaceholder } from '@/utils/tools'
import { getNowTime, getSecond } from '@/utils/date-util' import { getNowTime, getSecond } from '@/utils/date-util'
import { chartPieTableTopOptions, chartTableDefaultPageSize, chartTableTopOptions } from '@/utils/constants' import { chartPieTableTopOptions, chartTableDefaultPageSize, chartTableTopOptions } from '@/utils/constants'
@@ -166,6 +166,7 @@ export default {
methods: { methods: {
/* 参数 extraParams 额外请求参数isRefresh 是否是刷新 */ /* 参数 extraParams 额外请求参数isRefresh 是否是刷新 */
getChartData (url, extraParams = {}, isRefresh) { getChartData (url, extraParams = {}, isRefresh) {
const vm = this
this.loading = true this.loading = true
this.standaloneTimeRange.use = !!isRefresh this.standaloneTimeRange.use = !!isRefresh
try { try {
@@ -194,6 +195,13 @@ export default {
response = testData.data2 response = testData.data2
} }
if (response.code === 200) { if (response.code === 200) {
if (Array.isArray(response.data.result)) {
response.data.result.forEach(item => {
if (item.legend && legendMapping[`${this.entity && this.entity.ip ? 'ip_' : ''}${item.legend}`]) {
item.legend = vm.$t(legendMapping[`${this.entity && this.entity.ip ? 'ip_' : ''}${item.legend}`])
}
})
}
this.chartData = response.data.result this.chartData = response.data.result
this.table.tableData = response.data.result this.table.tableData = response.data.result
this.table.tableColumns = this.getTableTitle(response.data.result) this.table.tableColumns = this.getTableTitle(response.data.result)

View File

@@ -4,7 +4,7 @@
<div class="chart-drawing" :id="`chart${chartInfo.id}`"></div> <div class="chart-drawing" :id="`chart${chartInfo.id}`"></div>
</div> </div>
<div class="cn-chart__footer pie-with-table" > <div class="cn-chart__footer pie-with-table" >
<pie-table :tableData="pieTableData" ref="pieTable" :chartInfo="chartInfo" :time-filter="queryParams" :order="orderPieTable"/> <pie-table :tableData="pieTableData" ref="pieTable" :chartInfo="chartInfo" :time-filter="handleQueryParams(queryParams)" :order="orderPieTable"/>
</div> </div>
</div> </div>
</template> </template>
@@ -43,6 +43,12 @@ export default {
mounted () { mounted () {
}, },
methods: { methods: {
handleQueryParams(queryParams) {
return this.timeFilter = {
startTime:Number(queryParams.startTime)*1000,
endTime:Number(queryParams.endTime)*1000
}
},
initEchartsWithTable (id) { initEchartsWithTable (id) {
const chartParams = this.chartInfo.params const chartParams = this.chartInfo.params
const dom = document.getElementById(id) const dom = document.getElementById(id)
@@ -81,9 +87,6 @@ export default {
if (this.chartOption.series[0].data && this.chartOption.series[0].data.length > 10) { // pieWithTable 图例超过10个改为滚动显示 if (this.chartOption.series[0].data && this.chartOption.series[0].data.length > 10) { // pieWithTable 图例超过10个改为滚动显示
this.chartOption.legend.type = 'scroll' this.chartOption.legend.type = 'scroll'
} }
console.log('table===' + JSON.stringify(this.chartOption))
this.loadEchartWithTable() this.loadEchartWithTable()
if (!this.$_.isEmpty(data)) { if (!this.$_.isEmpty(data)) {