@@ -454,7 +460,7 @@ export default {
})
},
chartClick (e, data) {
- if (this.dataLink.length) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
this.tooltip.title = data.data.alias
this.tooltip.value = data.data.mapping && data.data.mapping.display ? this.handleDisplay(data.data.mapping.display, { ...data.data.labels, value: data.data.showValue }) : data.data.showValue
this.tooltip.mapping = data.data.mapping
@@ -466,12 +472,12 @@ export default {
}
},
chartMousedown (e) {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
e.stopPropagation()
}
},
clickout () {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.tooltip.dataLinkShow) {
this.tooltip.show = false
this.tooltip.dataLinkShow = false
}
diff --git a/nezha-fronted/src/components/chart/chart/chartSankey.vue b/nezha-fronted/src/components/chart/chart/chartSankey.vue
index bfb887bdc..50b8c8ecc 100644
--- a/nezha-fronted/src/components/chart/chart/chartSankey.vue
+++ b/nezha-fronted/src/components/chart/chart/chartSankey.vue
@@ -4,7 +4,7 @@
class="nz-chart__component nz-chart__component--time-series" @mouseenter="mouseEnterChart"
@mouseleave="mouseLeaveChart"
>
-
+
+
+
+ {{$t('overall.copy')}} PromQL
+ {{$t('overall.copy')}} LogQL
+
{{item.title}}
@@ -441,7 +447,7 @@ export default {
})
},
chartClick (e, data) {
- if (this.dataLink.length) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
this.tooltip.title = data.node ? data.node : data.source.node + ' ——> ' + data.target.node
this.tooltip.value = data.mapping && data.mapping.display ? this.handleDisplay(data.mapping.display, { ...data.labels, value: data.showValue }) : data.showValue
this.tooltip.mapping = data.mapping
@@ -453,12 +459,12 @@ export default {
}
},
chartMousedown (e) {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
e.stopPropagation()
}
},
clickout () {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.tooltip.dataLinkShow) {
this.tooltip.show = false
this.tooltip.dataLinkShow = false
}
diff --git a/nezha-fronted/src/components/chart/chart/chartStat.vue b/nezha-fronted/src/components/chart/chart/chartStat.vue
index 7c34323e2..c7bf3601f 100644
--- a/nezha-fronted/src/components/chart/chart/chartStat.vue
+++ b/nezha-fronted/src/components/chart/chart/chartStat.vue
@@ -9,7 +9,10 @@
@mouseleave="statMouseleave(item)"
@click="chartClick($event,item)"
@mousedown="chartMousedown($event)"
- :class="{'only-stat':statData.length===1,'chart-cursor-pointer':dataLink.length}"
+ :class="{
+ 'only-stat':statData.length===1,
+ 'chart-cursor-pointer':(dataLink.length || chartInfo.datasource === 'metrics' || chartInfo.datasource === 'logs')
+ }"
:style="{
background:item.mapping ? item.mapping.color.bac : (statData.length===1 ? '' : colorList[index]),
height:item.height+'px',
@@ -90,6 +93,12 @@
+
+
+
+ {{$t('overall.copy')}} PromQL
+ {{$t('overall.copy')}} LogQL
+
{{item.title}}
@@ -390,16 +399,8 @@ export default {
}]
if (this.chartInfo.param.sparklineMode === 'area') {
chartOption.series[0].areaStyle = {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: this.hexToRgb(color, 0.1)
- },
- {
- offset: 1,
- color: this.hexToRgb(color, 1)
- }
- ])
+ color: color,
+ opacity: 0.1
}
}
chartOption.yAxis.max = this.maxValue
@@ -528,7 +529,7 @@ export default {
})
},
chartClick (e, data) {
- if (this.dataLink.length) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
this.tooltip.title = data.legend
this.tooltip.value = data.mapping && data.mapping.display ? this.handleDisplay(data.mapping.display, { ...data.label, value: data.showValue }) : data.showValue
this.tooltip.mapping = data.mapping
@@ -540,12 +541,12 @@ export default {
}
},
chartMousedown (e) {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
e.stopPropagation()
}
},
clickout () {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.tooltip.dataLinkShow) {
this.tooltip.show = false
this.tooltip.dataLinkShow = false
}
diff --git a/nezha-fronted/src/components/chart/chart/chartTable.vue b/nezha-fronted/src/components/chart/chart/chartTable.vue
index ce451e9d4..a0a22807f 100644
--- a/nezha-fronted/src/components/chart/chart/chartTable.vue
+++ b/nezha-fronted/src/components/chart/chart/chartTable.vue
@@ -33,7 +33,7 @@
}"
class="value-mapping-table"
:title="showValueMapping(scope.row,col.title, col)"
- :class="{'chart-cursor-pointer':dataLink.length}"
+ :class="{'chart-cursor-pointer':(dataLink.length || chartInfo.datasource === 'metrics' || chartInfo.datasource === 'logs')}"
@click="chartClick($event,col,scope.row)"
@mousedown="chartMousedown($event)"
>
@@ -42,7 +42,7 @@
{{showValueMapping(scope.row,col.title, col)}}
-
+
{{scope.row.display[col.title + 'display'].display}}
@@ -68,6 +68,12 @@
+
+
+
+ {{$t('overall.copy')}} PromQL
+ {{$t('overall.copy')}} LogQL
+
{{item.title}}
@@ -488,7 +494,7 @@ export default {
})
},
chartClick (e, col, row) {
- if (this.dataLink.length) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
// 对象扁平化
let flattenedObject
for (const key in row) {
@@ -513,12 +519,12 @@ export default {
}
},
chartMousedown (e) {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') {
e.stopPropagation()
}
},
clickout () {
- if (this.dataLink.length && this.tooltip.dataLinkShow) {
+ if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.tooltip.dataLinkShow) {
this.tooltip.show = false
this.tooltip.dataLinkShow = false
}
diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue
index 116a8597f..83dc62ce5 100644
--- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue
+++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue
@@ -26,6 +26,12 @@
+
+
+
+ {{$t('overall.copy')}} PromQL
+ {{$t('overall.copy')}} LogQL
+
diff --git a/nezha-fronted/src/components/chart/chart/chartTreemap.vue b/nezha-fronted/src/components/chart/chart/chartTreemap.vue
index 9d863e42b..aa320052f 100644
--- a/nezha-fronted/src/components/chart/chart/chartTreemap.vue
+++ b/nezha-fronted/src/components/chart/chart/chartTreemap.vue
@@ -5,7 +5,7 @@
class="nz-chart__component nz-chart__component--time-series" @mouseenter="mouseEnterChart"
@mouseleave="mouseLeaveChart"
>
-
+
+
+
+
+ {{$t('overall.copy')}} PromQL
+ {{$t('overall.copy')}} LogQL
+
{{item.title}}
@@ -119,7 +125,7 @@ export default {
}
myChart.setOption(chartOption)
this.isInit && setChart(this.chartId, myChart) // 缓存;不使用vue的data是为避免整个chart被监听导致卡顿
- if (this.isInit && this.dataLink.length) {
+ if (this.isInit && (this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs')) {
myChart.on('click', this.chartClick)
myChart.on('mousedown', (params) => {
if (this.tooltip.dataLinkShow && params.dataIndex) {
@@ -237,7 +243,7 @@ export default {
this.datalinkPosition(e)
},
clickout () {
- if (this.dataLink.length) {
+ if ((this.dataLink.length || this.chartInfo.datasource === 'metrics' || this.chartInfo.datasource === 'logs') && this.tooltip.dataLinkShow) {
this.tooltip.show = false
this.tooltip.dataLinkShow = false
const option = {
diff --git a/nezha-fronted/src/components/chart/chartMixin.js b/nezha-fronted/src/components/chart/chartMixin.js
index 79819d323..39928edea 100644
--- a/nezha-fronted/src/components/chart/chartMixin.js
+++ b/nezha-fronted/src/components/chart/chartMixin.js
@@ -169,16 +169,7 @@ export default {
// 判断如果是面积图 颜色设为渐变色
if (s.areaStyle && this.colorList.length) {
s.areaStyle = {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: this.hexToRgb(this.colorList[colorIndex], 0.1)
- },
- {
- offset: 1,
- color: this.hexToRgb(this.colorList[colorIndex], 1)
- }
- ])
+ opacity: 0.1
}
}
series.push(s)
@@ -487,6 +478,13 @@ export default {
}
this.clickout()
},
+ copyExpr () {
+ const expr = this.chartInfo.elements[this.tooltip.metric.expressionIndex].expression || ''
+ this.$copyText(expr).then(() => {
+ this.$message.success({ message: this.$t('overall.copySuccess') })
+ this.clickout()
+ })
+ },
beforeDownloadCSV (chart) {
let csv = ''
switch (chart.type) {