Merge branch 'dev-3.2' of https://git.mesalab.cn/nezha/nezha-fronted into dev-3.3

This commit is contained in:
zhangyu
2022-03-30 15:17:08 +08:00
24 changed files with 175 additions and 97 deletions

View File

@@ -1,7 +1,7 @@
<template> <template>
<div :style="showHeader&&chartInfo.param.showHeader ? '' : 'padding-top: 15px;'" class="nz-chart" :class="showHeader&&chartInfo.param.showHeader ? '' : 'no-header'" > <div :style="showHeader&&chartInfo.param.showHeader ? '' : 'padding-top: 15px;'" class="nz-chart" :class="showHeader&&chartInfo.param.showHeader ? '' : 'no-header'" >
<loading :loading="loading"></loading> <loading :loading="loading"></loading>
<chart-no-data v-if="isNoData || isError || chartChildrenData"></chart-no-data> <chart-no-data v-if="isNoData || isError || chartChildrenData"></chart-no-data>
<template v-else> <template v-else>
<chart-time-series <chart-time-series
v-if="isTimeSeries(chartInfo.type)" v-if="isTimeSeries(chartInfo.type)"
@@ -309,6 +309,7 @@ export default {
this.chartChildrenData = flag this.chartChildrenData = flag
}, },
resize () { resize () {
console.log(this.$refs['chart' + this.chartInfo.id])
this.$refs['chart' + this.chartInfo.id] && this.$refs['chart' + this.chartInfo.id].resize() this.$refs['chart' + this.chartInfo.id] && this.$refs['chart' + this.chartInfo.id].resize()
}, },
refreshLogs (params) { refreshLogs (params) {

View File

@@ -16,6 +16,11 @@ export default {
data () { data () {
return { return {
}
},
methods: {
resize () {
} }
} }
} }

View File

@@ -16,6 +16,11 @@ export default {
data () { data () {
return { return {
}
},
methods: {
resize () {
} }
} }
} }

View File

@@ -214,9 +214,11 @@ export default {
}) })
}, },
resize () { resize () {
this.getLayout().then(layout => { setTimeout(() => {
this.renderGauge(layout).then(() => { this.getLayout().then(layout => {
this.gaugeChartResize() this.renderGauge(layout).then(() => {
this.gaugeChartResize()
})
}) })
}) })
}, },

View File

@@ -54,9 +54,8 @@ export default {
setTimeout(() => { setTimeout(() => {
this.dataList = this.dataList.map(item => { this.dataList = this.dataList.map(item => {
return { return {
...item, ...item
// hide: item.name.indexOf(this.filter.searchName) === -1, // 搜索条件 // hide: item.name.indexOf(this.filter.searchName) === -1, // 搜索条件
loaded: false
} }
}) })
}, 100) }, 100)
@@ -70,9 +69,9 @@ export default {
const arr = JSON.parse(JSON.stringify(n)) const arr = JSON.parse(JSON.stringify(n))
this.dataList = arr.map(item => { this.dataList = arr.map(item => {
return { return {
...item, ...item
// hide: item.name.indexOf(this.filter.searchName) === -1, // 搜索条件 // hide: item.name.indexOf(this.filter.searchName) === -1, // 搜索条件
loaded: false // loaded: false
} }
}) })
}) })

View File

@@ -6,6 +6,11 @@
<script> <script>
export default { export default {
name: 'chartNoData' name: 'chartNoData',
methods: {
resize () {
}
}
} }
</script> </script>

View File

@@ -21,6 +21,9 @@ export default {
} }
}, },
methods: { methods: {
resize () {
}
}, },
watch: { watch: {
chartInfo: { chartInfo: {

View File

@@ -98,6 +98,9 @@ export default {
chartOption.yAxis.axisLabel.formatter = this.yAxisLabelFormatter(minValue, maxValue, copies, unit, decimals) chartOption.yAxis.axisLabel.formatter = this.yAxisLabelFormatter(minValue, maxValue, copies, unit, decimals)
chartOption.yAxis.minInterval = chartDataFormat.Interval(maxValue, copies, unit.type, 'min') chartOption.yAxis.minInterval = chartDataFormat.Interval(maxValue, copies, unit.type, 'min')
chartOption.yAxis.maxInterval = chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(chartOption.series.length / 5) chartOption.yAxis.maxInterval = chartDataFormat.Interval(maxValue, copies, unit.type, 'max') * Math.ceil(chartOption.series.length / 5)
if (this.chartInfo.param.stack) {
chartOption.yAxis.maxInterval = chartOption.yAxis.maxInterval * (Math.ceil(chartOption.series.length / 5) + 1)
}
if (unit.type === 'Time') { if (unit.type === 'Time') {
delete chartOption.yAxis.minInterval delete chartOption.yAxis.minInterval
delete chartOption.yAxis.maxInterval delete chartOption.yAxis.maxInterval
@@ -169,7 +172,6 @@ export default {
maxValue = Math.floor(oldValue) / Math.pow(10, dot) maxValue = Math.floor(oldValue) / Math.pow(10, dot)
dot++ dot++
} }
console.log(oldValue)
const copies = chartDataFormat.copies(Number(oldValue), unit.type) const copies = chartDataFormat.copies(Number(oldValue), unit.type)
return { minTime, maxTime, minValue, maxValue, copies, unit, dot } return { minTime, maxTime, minValue, maxValue, copies, unit, dot }
}, },
@@ -210,7 +212,11 @@ export default {
let sum = 0 let sum = 0
let flag = true let flag = true
params.forEach((item, i) => { params.forEach((item, i) => {
const seriesName = item.seriesName.split('-')[0] const nameArr = item.seriesName.split('-')
if (nameArr.length > 1) {
nameArr.splice(nameArr.length - 1, 1)
}
const seriesName = nameArr.join('-')
if (i === 0 && item.seriesName.indexOf('Previous') === -1) { if (i === 0 && item.seriesName.indexOf('Previous') === -1) {
const value = bus.computeTimezone(item.data[0] * 1000) const value = bus.computeTimezone(item.data[0] * 1000)
const tData = new Date(value) const tData = new Date(value)
@@ -326,11 +332,19 @@ export default {
self.isStack = !self.isStack self.isStack = !self.isStack
// 改变tooltip // 改变tooltip
option.tooltip[0].formatter = self.tooltipFormatter(self.isStack) option.tooltip[0].formatter = self.tooltipFormatter(self.isStack)
if (!self.chartInfo.param.stack) {
option.yAxis.maxInterval = option.yAxis.maxInterval / (Math.ceil(option.series.length / 5) + 1)
} else {
option.yAxis.maxInterval = option.yAxis.maxInterval * (Math.ceil(option.series.length / 5) + 1)
}
myChart.setOption(option) myChart.setOption(option)
} }
}, },
resize () { resize () {
getChart(this.chartId).resize() console.log(213)
setTimeout(() => {
getChart(this.chartId) && getChart(this.chartId).resize()
}, 100)
} }
}, },
mounted () { mounted () {

View File

@@ -5,7 +5,10 @@
<div class="legend--table"> <div class="legend--table">
<div class="legend--table-row table-header"> <div class="legend--table-row table-header">
<div class="legend--table-cell"></div> <div class="legend--table-cell"></div>
<div v-for="statistics in chartInfo.param.legend.values" :key="statistics" class="legend--table-cell">{{statistics}}</div> <div v-for="statistics in chartInfo.param.legend.values" :key="statistics" class="legend--table-cell">
<span v-if="statisticsList.find(key=>key.value === statistics)">{{$t(statisticsList.find(key=>key.value === statistics).label)}}</span>
<span v-else>--</span>
</div>
</div> </div>
<div v-for="(item, index) in legends" <div v-for="(item, index) in legends"
:key="index" :key="index"
@@ -40,6 +43,7 @@
import lodash from 'lodash' import lodash from 'lodash'
import { getChart } from '@/components/common/js/common' import { getChart } from '@/components/common/js/common'
import chartDataFormat from '@/components/charts/chartDataFormat' import chartDataFormat from '@/components/charts/chartDataFormat'
import { statisticsList } from '@/components/common/js/constants'
export default { export default {
name: 'chartLegend', name: 'chartLegend',
props: { props: {
@@ -51,6 +55,7 @@ export default {
}, },
data () { data () {
return { return {
statisticsList,
isGrey: [], isGrey: [],
legendDefaultCount: 20, // 初始显示的legend条数 legendDefaultCount: 20, // 初始显示的legend条数
showLegends: [], // 要显示的legend若legend数量过多初始时这个数据里只有前20条legend showLegends: [], // 要显示的legend若legend数量过多初始时这个数据里只有前20条legend

View File

@@ -47,6 +47,7 @@
:chart-info="item" :chart-info="item"
:from="from" :from="from"
:time-range="timeRange" :time-range="timeRange"
@groupShow="groupShow"
:chart-detail-info="chartDetailInfo" :chart-detail-info="chartDetailInfo"
@refreshPanel="refreshPanel" @refreshPanel="refreshPanel"
@showFullscreen="showFullscreen" @showFullscreen="showFullscreen"
@@ -232,7 +233,7 @@ export default {
this.copyDataList = [...this.copyDataList] this.copyDataList = [...this.copyDataList]
// this.$refs.layout.layoutUpdate() // this.$refs.layout.layoutUpdate()
} }
this.moveChart() this.onScroll(this.scrollTop)
}, },
cleanData () { cleanData () {
@@ -243,51 +244,46 @@ export default {
this.onScroll(this.scrollTop) this.onScroll(this.scrollTop)
}, },
moveChart () { moveChart () {
if (this.timer) { this.onScroll(this.scrollTop)
clearTimeout(this.timer) const arr = this.copyDataList.filter(item => !item.staic)
this.timer = null const charts = []
} let weight = 0
this.timer = setTimeout(() => { arr.forEach(item => {
const arr = this.copyDataList.filter(item => !item.staic) charts.push({
const charts = [] id: item.id,
let weight = 0 x: item.x,
arr.forEach(item => { y: item.y,
charts.push({ span: item.span,
id: item.id, height: item.height,
x: item.x, groupId: item.groupId,
y: item.y, weight: weight
span: item.span,
height: item.height,
groupId: item.groupId,
weight: weight
})
weight++
if (item.type === 'group') {
item.children && item.children.forEach(children => {
charts.push({
id: children.id,
x: children.x,
y: children.y,
span: children.span,
height: children.height,
groupId: children.groupId,
weight: weight
})
weight++
})
}
}) })
const params = { weight++
panelId: this.panelId, if (item.type === 'group') {
charts: charts item.children && item.children.forEach(children => {
} charts.push({
if (charts && charts.length) { id: children.id,
this.$put('/visual/panel/chart/weights', params).then(() => { x: children.x,
const position = getLayoutPosition(this.copyDataList) y: children.y,
this.$store.commit('setChartLastPosition', position) span: children.span,
height: children.height,
groupId: children.groupId,
weight: weight
})
weight++
}) })
} }
}, 1000) })
const params = {
panelId: this.panelId,
charts: charts
}
if (charts && charts.length) {
this.$put('/visual/panel/chart/weights', params).then(() => {
const position = getLayoutPosition(this.copyDataList)
this.$store.commit('setChartLastPosition', position)
})
}
}, },
onScroll (scrollTop = 0, groupTop = 0) { onScroll (scrollTop = 0, groupTop = 0) {
const self = this const self = this
@@ -298,14 +294,19 @@ export default {
this.scrollTopTimer = setTimeout(() => { this.scrollTopTimer = setTimeout(() => {
this.copyDataList.forEach(item => { this.copyDataList.forEach(item => {
if (!this.$refs['grid-item' + item.id] || !this.$refs['grid-item' + item.id][0]) { if (!this.$refs['grid-item' + item.id] || !this.$refs['grid-item' + item.id][0]) {
return; return
} }
const dom = this.$refs['grid-item' + item.id][0].$el const dom = this.$refs['grid-item' + item.id][0].$el
if (dom) { if (dom) {
let top = dom.style.top let top = dom.style.top
top = Number(top.substring(0, top.length - 2)) + groupTop top = Number(top.substring(0, top.length - 2)) + groupTop
if (item.type === 'group') { if (item.type === 'group' && item.loaded) {
this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].$refs.chart && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id] && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id].$refs.chartList.onScroll(scrollTop, top) this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].$refs.chart && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id] && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id].$refs.chartList.onScroll(scrollTop, top)
return
}
if (item.type === 'group' && !item.loaded) {
item.loaded = true
this.$refs['chart' + item.id][0].getChartData()
} }
if (item.loaded) { if (item.loaded) {
return return
@@ -333,6 +334,16 @@ export default {
}) })
}, 200) }, 200)
}, },
resize () {
this.init()
this.copyDataList.forEach(item => {
if (item.type === 'group') {
this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].groupShow(item.param.collapse)
this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].$refs.chart && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id] && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id].$refs.chartList.resize()
}
this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].resize()
})
},
refreshPanel () { refreshPanel () {
bus.$emit('refreshPanel') bus.$emit('refreshPanel')
} }
@@ -345,8 +356,12 @@ export default {
if (!this.isGroup) { if (!this.isGroup) {
bus.$on('groupMove', this.changeGroupHeight) bus.$on('groupMove', this.changeGroupHeight)
this.$store.commit('setChartListId', `chartList${this.timestamp}`) this.$store.commit('setChartListId', `chartList${this.timestamp}`)
window.addEventListener('resize', this.resize)
} }
}, },
beforeDestroy () {
window.removeEventListener('resize', this.resize)
},
watch: { watch: {
dataList: { dataList: {
deep: true, deep: true,
@@ -397,7 +412,9 @@ export default {
this.copyDataList = JSON.parse(JSON.stringify(tempList)) this.copyDataList = JSON.parse(JSON.stringify(tempList))
setTimeout(() => { setTimeout(() => {
this.gridLayoutShow = true this.gridLayoutShow = true
this.onScroll() if (!this.isGroup) {
this.onScroll()
}
}) })
setTimeout(() => { setTimeout(() => {
this.firstInit = false this.firstInit = false

View File

@@ -110,16 +110,17 @@ export default {
if (data.metric.__name__) { if (data.metric.__name__) {
legend += '}' legend += '}'
} }
if (!legend && chartInfo.elements) { // if (!legend && chartInfo.elements) {
legend = chartInfo.elements[expressionIndex].expression // // legend = chartInfo.elements[expressionIndex].expression
} // legend = ''
// }
// 处理legend别名 // 处理legend别名
alias = alias + this.handleLegendAlias(legend, chartInfo.elements[expressionIndex].legend) alias = alias + this.handleLegendAlias(legend, chartInfo.elements[expressionIndex].legend)
if (!alias) { if (!alias) {
alias = legend alias = chartInfo.elements[expressionIndex].expression
} }
if (alias == 'Previous ') { if (alias == 'Previous ') {
alias += legend alias += chartInfo.elements[expressionIndex].expression
} }
// proj_status_ // proj_status_
const name = alias + '-' + dataIndex const name = alias + '-' + dataIndex
@@ -146,6 +147,9 @@ export default {
if (/\{\{.+\}\}/.test(aliasExpression)) { if (/\{\{.+\}\}/.test(aliasExpression)) {
const labelValue = aliasExpression.replace(/(\{\{.+?\}\})/g, function (i) { const labelValue = aliasExpression.replace(/(\{\{.+?\}\})/g, function (i) {
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2) const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
if (!legend) {
return label
}
const reg = new RegExp(label + '=".+?"') const reg = new RegExp(label + '=".+?"')
let value = null let value = null
if (reg.test(legend)) { if (reg.test(legend)) {
@@ -257,7 +261,10 @@ export default {
} }
}, },
resize () { resize () {
getChart(this.chartId) && getChart(this.chartId).resize() console.log('reszie')
setTimeout(() => {
getChart(this.chartId) && getChart(this.chartId).resize()
}, 100)
} }
}, },
watch: { watch: {

View File

@@ -420,7 +420,7 @@ export default {
}) })
}, },
resize () { resize () {
this.$refs.chart.resize() this.$refs.chart && this.$refs.chart.resize()
}, },
refresh () { refresh () {
this.getChartData(true) this.getChartData(true)
@@ -532,7 +532,7 @@ export default {
timeRange: { timeRange: {
deep: true, deep: true,
handler (n) { handler (n) {
this.refresh() // this.refresh()
} }
}, },
loading: { loading: {

View File

@@ -495,7 +495,7 @@ export default {
}) })
break break
} }
case 'average': { case 'avg': {
result = classifies.map(group => { result = classifies.map(group => {
const groupData = group.map(t => parseFloat(t.data[1])) const groupData = group.map(t => parseFloat(t.data[1]))
const sum = eval(groupData.join('+')) const sum = eval(groupData.join('+'))

View File

@@ -397,6 +397,9 @@ function asciiCompute2 (num, ascii, units, dot = 2, unitIndex = 0) {
* unit:设置的单位 * unit:设置的单位
* */ * */
function timeCompute (value, unit, dot = 0) { function timeCompute (value, unit, dot = 0) {
if (isNaN(value)) {
return `0 ${unit}`
}
if (unit == 'year') { if (unit == 'year') {
return `${value.toFixed(dot)} ${unit}` return `${value.toFixed(dot)} ${unit}`
} }

View File

@@ -1449,7 +1449,7 @@ export default {
}) })
break break
} }
case 'average': { case 'avg': {
result = classifies.map(group => { result = classifies.map(group => {
const groupData = group.map(t => parseFloat(t.data[1])) const groupData = group.map(t => parseFloat(t.data[1]))
const sum = eval(groupData.join('+')) const sum = eval(groupData.join('+'))

View File

@@ -212,7 +212,7 @@ export const alertMessage = {
export const statisticsList = [ export const statisticsList = [
{ value: 'min', label: i18n.t('dashboard.panel.chartForm.statisticsVal.min') }, { value: 'min', label: i18n.t('dashboard.panel.chartForm.statisticsVal.min') },
{ value: 'max', label: i18n.t('dashboard.panel.chartForm.statisticsVal.max') }, { value: 'max', label: i18n.t('dashboard.panel.chartForm.statisticsVal.max') },
{ value: 'average', label: i18n.t('dashboard.panel.chartForm.statisticsVal.average') }, { value: 'avg', label: i18n.t('dashboard.panel.chartForm.statisticsVal.average') },
{ value: 'total', label: i18n.t('dashboard.panel.chartForm.statisticsVal.total') }, { value: 'total', label: i18n.t('dashboard.panel.chartForm.statisticsVal.total') },
{ value: 'first', label: i18n.t('dashboard.panel.chartForm.statisticsVal.first') }, { value: 'first', label: i18n.t('dashboard.panel.chartForm.statisticsVal.first') },
{ value: 'last', label: i18n.t('dashboard.panel.chartForm.statisticsVal.last') }, { value: 'last', label: i18n.t('dashboard.panel.chartForm.statisticsVal.last') },

View File

@@ -13,6 +13,7 @@ export const clickoutside = {
let oldValue let oldValue
try { try {
oldValue = JSON.parse(JSON.stringify(binding.value.obj)) oldValue = JSON.parse(JSON.stringify(binding.value.obj))
el.__newValue__ = oldValue
} catch (e) { } catch (e) {
} }
@@ -36,8 +37,8 @@ export const clickoutside = {
return false return false
} }
if (oldValue) { if (oldValue) {
const newValue = JSON.parse(JSON.stringify(binding.value.obj)) // const newValue = JSON.parse(JSON.stringify(binding.value.obj))
if (unsavedChange == 'on' && !isEqual(oldValue, newValue)) { if (unsavedChange == 'on' && !isEqual(oldValue, el.__newValue__)) {
MessageBox.confirm(i18n.t('tip.confirmCancel'), { MessageBox.confirm(i18n.t('tip.confirmCancel'), {
confirmButtonText: i18n.t('tip.yes'), confirmButtonText: i18n.t('tip.yes'),
cancelButtonText: i18n.t('tip.no'), cancelButtonText: i18n.t('tip.no'),
@@ -66,6 +67,9 @@ export const clickoutside = {
el.__vueClickOutside__ = documentHandler el.__vueClickOutside__ = documentHandler
document.addEventListener('mousedown', documentHandler) document.addEventListener('mousedown', documentHandler)
}, },
update (el, binding, vnode) {
el.__newValue__ = binding.value.obj
},
unbind (el, binding) { unbind (el, binding) {
// 解除事件监听 // 解除事件监听
document.removeEventListener('mousedown', el.__vueClickOutside__) document.removeEventListener('mousedown', el.__vueClickOutside__)
@@ -907,7 +911,7 @@ export function getMetricTypeValue (queryItem, type) {
const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1] const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
return max return max
} }
case 'average': { case 'avg': {
copy = copy.map(t => parseFloat(t[1])) copy = copy.map(t => parseFloat(t[1]))
const sum = eval(copy.join('+')) const sum = eval(copy.join('+'))
const avg = sum / copy.length const avg = sum / copy.length

View File

@@ -349,7 +349,7 @@ const cn = {
statisticsVal: { statisticsVal: {
min: 'Min', min: 'Min',
max: 'Max', max: 'Max',
average: 'Average', avg: 'Avg',
total: 'Total', total: 'Total',
first: 'First', first: 'First',
last: 'Last', last: 'Last',

View File

@@ -365,7 +365,7 @@ const en = {
statisticsVal: { statisticsVal: {
min: 'Min', min: 'Min',
max: 'Max', max: 'Max',
average: 'Average', avg: 'Avg',
total: 'Total', total: 'Total',
first: 'First', first: 'First',
last: 'Last', last: 'Last',

View File

@@ -487,7 +487,7 @@
<span @click="addColumns('')"> <span @click="addColumns('')">
<i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i> <i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i>
</span> </span>
<span class="nz-icon-copy"> <span style="margin-right: 5px">
<i @click="copyColumns(index)" class="nz-icon nz-icon-override"></i> <i @click="copyColumns(index)" class="nz-icon nz-icon-override"></i>
</span> </span>
<span class="nz-icon-minus-medium"> <span class="nz-icon-minus-medium">

View File

@@ -1,5 +1,5 @@
<template> <template>
<div v-clickoutside="{obj:editChart, func:clickOutside}" :class="boxClass" class="right-box right-box-chart"> <div v-clickoutside="{obj: editChart, func:clickOutside}" :class="boxClass" class="right-box right-box-chart">
<transition v-if="from !== 'chartTemp'" name="right-box"> <transition v-if="from !== 'chartTemp'" name="right-box">
<!-- <panel-box v-if="!showPanel.type" ref="panelBox2" :panel="panel" @reload="panelReload"></panel-box>--> <!-- <panel-box v-if="!showPanel.type" ref="panelBox2" :panel="panel" @reload="panelReload"></panel-box>-->
</transition> </transition>
@@ -457,42 +457,42 @@ export default {
if (obj.param && !obj.param.thresholds) { if (obj.param && !obj.param.thresholds) {
obj.param.thresholds = [] obj.param.thresholds = []
} }
this.editChart = obj if (obj.groupId === -1) {
if (this.editChart.groupId === -1) { obj.groupId = ''
this.editChart.groupId = ''
} }
if (this.editChart.param) { if (obj.param) {
if (!this.editChart.param.min) { if (!obj.param.min) {
this.editChart.param.min = 0 obj.param.min = 0
} }
if (!this.editChart.param.max) { if (!obj.param.max) {
this.editChart.param.max = 100 obj.param.max = 100
} }
if (!this.editChart.param.link) { if (!obj.param.link) {
this.$set(this.editChart.param, 'link', '') this.$set(obj.param, 'link', '')
} }
if (!this.editChart.param.enable) { if (!obj.param.enable) {
this.editChart.param.enable = { obj.param.enable = {
thresholds: false, thresholds: false,
legend: false, legend: false,
valueMapping: false valueMapping: false
} }
} }
// this.editChart.varType = 1 // this.editChart.varType = 1
if (this.editChart.param.enable.legend && !this.editChart.param.legend) { if (obj.param.enable.legend && !obj.param.legend) {
this.editChart.param.legend = { placement: 'bottom', values: [], show: true } obj.param.legend = { placement: 'bottom', values: [], show: true }
} }
if (this.editChart.param.datasource && !this.editChart.param.datasource[0].legend) { if (obj.param.datasource && !obj.param.datasource[0].legend) {
this.editChart.param.datasource[0].legend = '' obj.param.datasource[0].legend = ''
} }
if (this.editChart.param.valueMapping) { if (obj.param.valueMapping) {
this.editChart.param.valueMapping.forEach(item => { obj.param.valueMapping.forEach(item => {
if (!item.show) { if (!item.show) {
item.show = false item.show = false
} }
}) })
} }
} }
this.editChart = obj
} }
}, },
'editChart.type': { 'editChart.type': {
@@ -501,6 +501,12 @@ export default {
this.editChart.groupId = '' this.editChart.groupId = ''
} }
} }
},
editChart: {
deep: true,
handler () {
}
} }
} }
} }

View File

@@ -346,6 +346,7 @@ export default {
}, },
showMapping (index) { showMapping (index) {
this.chartConfig.param.valueMapping[index].show = !this.chartConfig.param.valueMapping[index].show this.chartConfig.param.valueMapping[index].show = !this.chartConfig.param.valueMapping[index].show
this.change()
}, },
mappingItemChange (index, type) { mappingItemChange (index, type) {
const mapping = this.chartConfig.param.valueMapping[index] const mapping = this.chartConfig.param.valueMapping[index]
@@ -416,6 +417,7 @@ export default {
}, },
showColumns (index) { showColumns (index) {
this.chartConfig.param.columns[index].show = !this.chartConfig.param.columns[index].show this.chartConfig.param.columns[index].show = !this.chartConfig.param.columns[index].show
this.change()
}, },
tagsChange (newTags) { tagsChange (newTags) {
this.chartConfig.param.tags = newTags this.chartConfig.param.tags = newTags

View File

@@ -449,7 +449,7 @@
<span @click="addColumns('')"> <span @click="addColumns('')">
<i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i> <i class="nz-icon nz-icon-create-square" style="font-weight: normal; font-size: 17px; cursor: pointer;"></i>
</span> </span>
<span class="nz-icon-copy"> <span style="margin-right: 5px">
<i @click="copyColumns(index)" class="nz-icon nz-icon-override"></i> <i @click="copyColumns(index)" class="nz-icon nz-icon-override"></i>
</span> </span>
<span class="nz-icon-minus-medium"> <span class="nz-icon-minus-medium">

View File

@@ -192,7 +192,7 @@ export default new Vue({
statisticsRlt = dataArray.reduce(function (a, b) { statisticsRlt = dataArray.reduce(function (a, b) {
return b > a ? b : a return b > a ? b : a
}) })
} else if (statistics === 'average') { // average:平均值 } else if (statistics === 'avg') { // avg:平均值
let sum = 0 let sum = 0
dataArray.forEach((item) => { dataArray.forEach((item) => {
sum = Number(sum) + Number(item) sum = Number(sum) + Number(item)