diff --git a/nezha-fronted/src/components/chart/chart/chartStat.vue b/nezha-fronted/src/components/chart/chart/chartStat.vue
index 47d265878..5f8482bea 100644
--- a/nezha-fronted/src/components/chart/chart/chartStat.vue
+++ b/nezha-fronted/src/components/chart/chart/chartStat.vue
@@ -325,7 +325,16 @@ export default {
}]
if (this.chartInfo.param.sparklineMode === 'area') {
chartOption.series[0].areaStyle = {
- color
+ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
+ {
+ offset: 0,
+ color: this.hexToRgb(color, 0.1)
+ },
+ {
+ offset: 1,
+ color: this.hexToRgb(color, 1)
+ }
+ ])
}
}
chartOption.yAxis.max = this.maxValue
diff --git a/nezha-fronted/src/components/chart/chart/legend.vue b/nezha-fronted/src/components/chart/chart/legend.vue
index fb33924c1..9eda32fd5 100644
--- a/nezha-fronted/src/components/chart/chart/legend.vue
+++ b/nezha-fronted/src/components/chart/chart/legend.vue
@@ -43,47 +43,6 @@
{{(keepTwoDecimalFull(statistics.value))}}
-
-
-
-
-
-
-
- -
-
-
- {{item.alias ? item.alias : item.name.split('-')[0]}}
-
-
-
-
-
-
- -
-
-
- {{item.alias ? item.alias : item.name.split('-')[0]}}
-
-
-
-
diff --git a/nezha-fronted/src/components/chart/chartList.vue b/nezha-fronted/src/components/chart/chartList.vue
index a79faedcb..2fc400d61 100644
--- a/nezha-fronted/src/components/chart/chartList.vue
+++ b/nezha-fronted/src/components/chart/chartList.vue
@@ -44,6 +44,7 @@
@container-resized="containerResizedEvent"
>
{
- if (res.status === 'error') {
+ if (res.status === 'error' || !res.data.result.length) {
resolve([])
return
}
- const arr = res.data.result.map((metricData) => {
- let text = metricData.metric.__name__ || ''
- delete metricData.metric.__name__
- text += '{'
- const arr = []
- Object.keys(metricData.metric).forEach(key => {
- arr.push(key + '="' + metricData.metric[key] + '"')
+ const isObject = Object.prototype.toString.call(res.data.result[0]).toLowerCase() === '[object object]'
+ if (!isObject) {
+ resolve([
+ {
+ label: res.data.result[0],
+ value: res.data.result[0],
+ expandable: true
+ }
+ ])
+ } else {
+ const arr = res.data.result.map((metricData) => {
+ let text = ''
+ if (metricData.metric) {
+ text = metricData.metric.__name__ || ''
+ delete metricData.metric.__name__
+ }
+ text += '{'
+ const arr = []
+ Object.keys(metricData.metric).forEach(key => {
+ arr.push(key + '="' + metricData.metric[key] + '"')
+ })
+ text += arr.join(',')
+ text += '}'
+ text += ' ' + metricData.value[1] + ' ' + metricData.value[0] * 1000
+ return {
+ label: text,
+ value: text,
+ expandable: true
+ }
})
- text += arr.join(',')
- text += '}'
- text += ' ' + metricData.value[1] + ' ' + metricData.value[0] * 1000
- return {
- label: text,
- value: text,
- expandable: true
- }
- })
- resolve(arr)
+ resolve(arr)
+ }
})
})
},