diff --git a/nezha-fronted/src/components/charts/chart-table.vue b/nezha-fronted/src/components/charts/chart-table.vue
index edb8e4ca4..fd8186b98 100644
--- a/nezha-fronted/src/components/charts/chart-table.vue
+++ b/nezha-fronted/src/components/charts/chart-table.vue
@@ -65,7 +65,7 @@
- {{ scope.row.value}}
+ {{ scope.row.value}}
@@ -397,6 +397,7 @@
mapping=mappings.find(t=>{return t.from <= value&& t.to >= value});
}
this.mapping=mapping;
+ item.mapping=mapping;
item.value = mapping?mapping.text.replace('{{value}}', item.value):chartDataFormat.getUnit(chartItem.unit?chartItem.unit:2).compute(value,null,2);
}
return item;
diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue
index 72b7f575c..2a29aaf80 100644
--- a/nezha-fronted/src/components/charts/chartPreview.vue
+++ b/nezha-fronted/src/components/charts/chartPreview.vue
@@ -143,7 +143,7 @@
- {{ scope.row.value}}
+ {{ scope.row.value}}
@@ -368,6 +368,7 @@
// 获取一个图表具体数据
getChartData() {
const chartItem = this.chart;
+ console.log(chartItem);
if(chartItem.type === 'alertList'){
this.getAlertListChartData(chartItem,null);
return;
@@ -401,6 +402,9 @@
const axiosArr = chartItem.elements.map((ele) => {
const filterItem = ele;
let query = encodeURIComponent(filterItem.expression);
+ if(chartItem.type === 'table'&&chartItem.param&&chartItem.param.last == 1){
+ return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(endTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step);
+ }
return this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step);
});
// 一个图表的所有element单独获取数据
@@ -1049,6 +1053,7 @@
mapping=mappings.find(t=>{return t.from <= value&& t.to >= value});
}
this.mapping=mapping;
+ item.mapping=mapping;
item.value = mapping?mapping.text.replace('{{value}}', item.value):this.unit.compute(value,null,2);
}
return item;
@@ -1121,6 +1126,8 @@
// 查询数据,修改日期查询全屏数据
getQueryChart(type) {
let axiosArr = [];
+ const chartItem = this.chart;
+ console.log(chartItem);
this.$nextTick(() => {
let startTime = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss');
let endTime = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss');
@@ -1135,6 +1142,9 @@
axiosArr = this.chart.elements.map((ele) => {
const filterItem = ele;
let query = encodeURIComponent(filterItem.expression);
+ if(chartItem.type === 'table'&&chartItem.param&&chartItem.param.last == 1){
+ return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(endTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step);
+ }
return this.$get('/prom/api/v1/query_range?query='+query+"&start="+this.$stringTimeParseToUnix(startTime)+"&end="+this.$stringTimeParseToUnix(endTime)+'&step='+step);
});
// 一个图表
diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue
index 5144f11a0..37302bb87 100644
--- a/nezha-fronted/src/components/page/dashboard/chartBox.vue
+++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue
@@ -1432,6 +1432,7 @@
}
params.param.nullType=this.editChart.param.nullType;
params.param.legendValue=this.editChart.param.legendValue;
+ params.param.last=this.editChart.param.last;
} else {
delete params.param.threshold;
delete params.param.nullType;
@@ -1446,6 +1447,7 @@
});
});
params.elements = elements;
+ console.log(params,'params');
if (valid) {
this.$refs.chartsPreview.show(params);
}