feat: explore graph增加堆叠功能

This commit is contained in:
zyh
2024-04-26 17:17:49 +08:00
parent 650d0688f3
commit 0219704e8b
2 changed files with 24 additions and 1 deletions

View File

@@ -97,6 +97,9 @@
} }
} }
} }
.tool__icon-active {
color: $--color-primary;
}
} }
.el-collapse-item__wrap { .el-collapse-item__wrap {
background-color: $--background-color-empty; background-color: $--background-color-empty;

View File

@@ -225,6 +225,12 @@
<!--metric--> <!--metric-->
<template v-if="showMetrics"> <template v-if="showMetrics">
<el-collapse-item v-if="!allMatrix && showChart" name="1" :title="$t('explore.graph')" class="el-collapse-item__height"> <el-collapse-item v-if="!allMatrix && showChart" name="1" :title="$t('explore.graph')" class="el-collapse-item__height">
<!-- 堆叠 -->
<div slot="title" class="explore-table-title" style="display:flex; justify-content: flex-end;align-item:center;padding-right:30px;">
<span :title="$t('dashboard.dashboard.chartForm.stack')" @click.stop="changeStack" v-show="collapseValue.some(item=>item==1)" tabindex="0">
<i class="nz-icon nz-icon-duidiezhuzhuangtu tool__icon" :class="isStack ? 'tool__icon-active' : ''"/>
</span>
</div>
<div class="chart-room"> <div class="chart-room">
<uplotChart <uplotChart
:ref="'exploreChart'" :ref="'exploreChart'"
@@ -364,6 +370,12 @@
<!--log--> <!--log-->
<template v-else> <template v-else>
<el-collapse-item v-show="showTab.indexOf('1') > -1" name="1" :title="$t('explore.graph')" class="el-collapse-item__height"> <el-collapse-item v-show="showTab.indexOf('1') > -1" name="1" :title="$t('explore.graph')" class="el-collapse-item__height">
<!-- 堆叠 -->
<div slot="title" class="explore-table-title" style="display:flex; justify-content: flex-end;align-item:center;padding-right:30px;">
<span :title="$t('dashboard.dashboard.chartForm.stack')" @click.stop="changeStack" v-show="collapseValue.some(item=>item==2)" tabindex="0">
<i class="nz-icon nz-icon-duidiezhuzhuangtu tool__icon" :class="isStack ? 'tool__icon-active' : ''"/>
</span>
</div>
<div class="chart-room"> <div class="chart-room">
<!-- <chart ref="logChart" :unit="chartUnit" v-my-loading="chartLoading" :timeRange="filterTime"></chart>--> <!-- <chart ref="logChart" :unit="chartUnit" v-my-loading="chartLoading" :timeRange="filterTime"></chart>-->
<uplotChart <uplotChart
@@ -3776,7 +3788,8 @@ export default {
uplotChartInfoLog: logData, uplotChartInfoLog: logData,
uplotChartData: [], uplotChartData: [],
showAllData: false, showAllData: false,
supplementaryData: [] supplementaryData: [],
isStack: false
} }
}, },
async created () { async created () {
@@ -3795,6 +3808,10 @@ export default {
this.scrollbarWrap.removeEventListener('scroll', this.onScroll) this.scrollbarWrap.removeEventListener('scroll', this.onScroll)
}, },
methods: { methods: {
changeStack () {
this.isStack = !this.isStack
this.$refs.exploreChart.$children[0].changeStack()
},
async loadWebAssembly () { async loadWebAssembly () {
try { try {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
@@ -3853,6 +3870,7 @@ export default {
} else { } else {
label = 'Metrics' label = 'Metrics'
} }
this.isStack = false
this.changeType(label) this.changeType(label)
}, },
changeType (value) { changeType (value) {
@@ -4048,6 +4066,7 @@ export default {
this.uplotChartData = [] this.uplotChartData = []
this.uplotChartInfoLog.elements = [] this.uplotChartInfoLog.elements = []
this.uplotChartInfoLog.unit = this.chartUnit this.uplotChartInfoLog.unit = this.chartUnit
this.uplotChartInfoLog.param.stack = this.isStack
this.logData.forEach((response, index) => { this.logData.forEach((response, index) => {
if (response.resultType === 'matrix') { if (response.resultType === 'matrix') {
const promqlIndex = promqlInputIndexs[index] const promqlIndex = promqlInputIndexs[index]
@@ -4104,6 +4123,7 @@ export default {
this.uplotChartData = [] this.uplotChartData = []
this.uplotChartInfo.elements = [] this.uplotChartInfo.elements = []
this.uplotChartInfo.unit = this.chartUnit this.uplotChartInfo.unit = this.chartUnit
this.uplotChartInfo.param.stack = this.isStack
axios.all(requestArr).then(res => { axios.all(requestArr).then(res => {
const series = [] const series = []
const legend = [] const legend = []