diff --git a/nezha-fronted/src/components/chart/ChartScreenHeader.vue b/nezha-fronted/src/components/chart/ChartScreenHeader.vue index 66c72218c..c61eed4d9 100644 --- a/nezha-fronted/src/components/chart/ChartScreenHeader.vue +++ b/nezha-fronted/src/components/chart/ChartScreenHeader.vue @@ -13,6 +13,19 @@ + + +
{{$t('dashboard.panel.moreTitle')}}{{$t('dashboard.panel.showAll')}}{{allDataLength}}
+ + + + +
+
{{chartInfo.name}}
@@ -33,25 +46,10 @@ diff --git a/nezha-fronted/src/components/chart/chartHeaderMixin.js b/nezha-fronted/src/components/chart/chartHeaderMixin.js new file mode 100644 index 000000000..e25e48d92 --- /dev/null +++ b/nezha-fronted/src/components/chart/chartHeaderMixin.js @@ -0,0 +1,79 @@ +export default { + props: { + chartInfo: Object, + from: String, + isGroup: { + type: Boolean, + default: false + }, + error: { + type: String, + default: '' + }, + isError: { + type: Boolean, + default: false + }, + chartData: {}, + showAllData: { + type: Boolean, + default: false + }, + allDataLength: { + type: Number, + default: 0 + } + }, + data () { + return { + dropdownMenuShow: false, + errorText: '' + } + }, + methods: { + showFullscreen () { + this.$emit('showFullscreen', true) + }, + refreshChart () { + this.$emit('refresh') + }, + editChart () { + // this.$emit('edit-chart', this.chartInfo) + this.$store.dispatch('dispatchEditChart', { + chart: this.chartInfo, + type: 'edit' + }) + }, + removeChart () { + this.$store.dispatch('dispatchDelChart', { + chart: this.chartInfo, + type: 'delete' + }) + }, + duplicate () { + this.$store.dispatch('dispatchEditChart', { + chart: this.chartInfo, + type: 'duplicate' + }) + }, + clickos () { + this.dropdownMenuShow = false + }, + groupShow () { + this.$emit('groupShow', !this.chartInfo.param.collapse) + }, + loadMore () { + this.$emit('loadMore') + } + }, + watch: { + isError: { + immediate: true, + handler (n) { + if (n) { + this.errorText = this.chartData.filter(item => item.error).map(item => item.error).join('\n') + } + } + } + } +} diff --git a/nezha-fronted/src/components/chart/chartMixin.js b/nezha-fronted/src/components/chart/chartMixin.js index 0b451367e..3fe36c118 100644 --- a/nezha-fronted/src/components/chart/chartMixin.js +++ b/nezha-fronted/src/components/chart/chartMixin.js @@ -15,14 +15,17 @@ export default { }, chartId: '', isNoData: true, - showAllData: false } }, props: { chartInfo: Object, chartData: Array, chartOption: Object, - isFullscreen: Boolean + isFullscreen: Boolean, + showAllData: { + type: Boolean, + default: false + } }, computed: { filterTime () { @@ -41,10 +44,11 @@ export default { let colorIndex = 0 originalDatas.forEach((originalData, expressionIndex) => { originalData.forEach((data, dataIndex) => { - // if (colorIndex >= 20 && !this.showAllData) { - // colorIndex++ - // return - // } + console.log(this.showAllData) + if (colorIndex >= 20 && !this.showAllData) { + colorIndex++ + return + } this.isNoData = false const s = lodash.cloneDeep(seriesTemplate) if (s) { diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index 7b28e59ef..467c6030f 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -8,6 +8,9 @@ :isError="isError" :chartData="chartData" :chart-info="chartInfo" + :showAllData.sync="showAllData" + :allDataLength="allDataLength" + @loadMore="loadMore" @edit-chart="$emit('edit-chart', chartInfo)" @refresh="refresh" @groupShow="groupShow" @@ -20,6 +23,9 @@ :isError="isError" :chartData="chartData" :chart-info="chartInfo" + :showAllData.sync="showAllData" + :allDataLength="allDataLength" + @loadMore="loadMore" @refresh="refresh" @dateChange="dateChange" @close="showFullscreen" @@ -38,6 +44,7 @@ :minusTime="minusTime" :multipleTime="multipleTime" :is-fullscreen="isFullscreen" + :showAllData="showAllData" v-if="!isGroup(chartInfo.type) || !chartInfo.param.collapse" >
@@ -77,7 +84,9 @@ export default { loading: true, isError: false, multipleTime: false, - minusTime: '' + minusTime: '', + showAllData: false, + allDataLength: 0 } }, computed: { @@ -139,6 +148,7 @@ export default { }, query (elements, startTime, endTime, step) { this.isError = false + this.allDataLength = 0 try { switch (this.chartInfo.datasource) { case 'metrics': @@ -187,6 +197,9 @@ export default { res.forEach((r, rIndex) => { if (rIndex < elements.length) { if (r.status === 'success') { + r.data.result.forEach(item => { + this.allDataLength++ + }) chartData.push(r.data.result) } else { chartData.push({ error: r.msg || r.error || r }) @@ -196,6 +209,7 @@ export default { if (r.status === 'success') { console.log(r.data.result) r.data.result.forEach(item => { + this.allDataLength++ item.values.forEach(values => { values[0] = values[0] + this.minusTime / 1000 }) @@ -360,6 +374,21 @@ export default { this.groupInit() bus.$emit('groupMove', '', '', true) this.$emit('groupShow', this.chartInfo) + }, + showMultiple (type) { + switch (type) { + case 'line' : + case 'area' : + case 'point' : + return true + default: return false + } + }, + loadMore () { + this.showAllData = true + this.$nextTick(() => { + this.$refs.chart && this.$refs.chart.$refs['chart' + this.chartInfo.id].initChart() + }) } }, watch: { @@ -378,6 +407,7 @@ export default { }, mounted () { this.chartInfo.loaded && this.getChartData() + this.showAllData = !this.showMultiple(this.chartInfo.type) } }