diff --git a/nezha-fronted/src/assets/css/common.scss b/nezha-fronted/src/assets/css/common.scss index 452cf16ed..42ba930a3 100644 --- a/nezha-fronted/src/assets/css/common.scss +++ b/nezha-fronted/src/assets/css/common.scss @@ -431,3 +431,8 @@ input, textarea { font-weight: 600; } } + + +.chart-time-series.hide{ + display: none !important; +} \ No newline at end of file diff --git a/nezha-fronted/src/assets/css/common/tableCommon.scss b/nezha-fronted/src/assets/css/common/tableCommon.scss index 8292e7580..8f21fad11 100644 --- a/nezha-fronted/src/assets/css/common/tableCommon.scss +++ b/nezha-fronted/src/assets/css/common/tableCommon.scss @@ -88,12 +88,15 @@ background-color: $--background-color-empty; transition:all .2s; color: $--button-icon-color; - i { font-size: 14px; color: $--button-icon-color; } } + .top-tool-btn.active{ + background-color: $--button-icon-active-background-color; + border: 1px solid $--button-icon-active-border-color !important; + } .top-tool-btn.top-tool-btn--text { padding: 0 8px; width: unset; diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index 54fb548a5..2f7339be4 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -26,7 +26,7 @@ import { formatScientificNotation } from '@/components/common/js/tools' import chartDataFormat from '@/components/chart/chartDataFormat' import { randomcolor } from '@/components/common/js/radomcolor/randomcolor' import { chartLegendPlacement } from '@/components/common/js/constants' -import { getChart, setChart } from '@/components/common/js/common' +import { getChart, setChart, chartCache } from '@/components/common/js/common' import { initColor } from '@/components/chart/chart/tools' import lodash from 'lodash' @@ -69,6 +69,36 @@ export default { } } }, + watch: { + // 监听当前鼠标所在的图表id变化 + '$store.state.panel.currentMousemove': { + handler (n) { + // 判断是否是当前鼠标所在的图表 + if (n === this.chartId) { + let option = {} + for (const key in chartCache) { + if (!chartCache[key] || chartCache[key].group !== 'timeSeriesGroup') { + continue + } + if (chartCache[key] === getChart(this.chartId)) { + option = { + tooltip: { + className: 'chart-time-series' + } + } + } else { + option = { + tooltip: { + className: 'chart-time-series hide' + } + } + } + chartCache[key].setOption(option) + } + } + } + } + }, methods: { initChart (chartOptions = this.chartOption) { try { @@ -120,13 +150,21 @@ export default { if (!myChart) { return } + if (this.isInit) { + this.$store.commit('setCurrentMousemove', 0) + } myChart.setOption(chartOption) this.isInit && setChart(this.chartId, myChart) // 缓存;不使用vue的data是为避免整个chart被监听导致卡顿 this.isInit = false // timeSeries类型图表设置group 用于多表联动 myChart.group = 'timeSeriesGroup' - getChart(this.chartId).on('dataZoom', function (params) { - console.log(params) + myChart.getZr().on('mousemove', params => { + if (this.$store.state.panel.isconnect !== 1) { + return false + } + if (this.$store.state.panel.currentMousemove !== this.chartId) { + this.$store.commit('setCurrentMousemove', this.chartId) + } }) }, 200) }, diff --git a/nezha-fronted/src/components/chart/chart/legend.vue b/nezha-fronted/src/components/chart/chart/legend.vue index 39aecf264..e53c55bf6 100644 --- a/nezha-fronted/src/components/chart/chart/legend.vue +++ b/nezha-fronted/src/components/chart/chart/legend.vue @@ -44,6 +44,8 @@ import lodash from 'lodash' import { getChart } from '@/components/common/js/common' import chartDataFormat from '@/components/chart/chartDataFormat' import { statisticsList } from '@/components/common/js/constants' +import * as chart from 'echarts' +import { isTimeSeries } from './tools' export default { name: 'chartLegend', props: { @@ -65,6 +67,10 @@ export default { computed: { isStatistics () { return !lodash.isEmpty(this.chartInfo.param.legend.values) + }, + // timeSeries类型图表联动 + isconnect () { + return this.$store.state.panel.isconnect } }, methods: { @@ -94,6 +100,10 @@ export default { } if (echarts) { + // 判断timeSeries类型图表 先取消多表联动 + if (isTimeSeries(this.chartInfo.type) && this.isconnect) { + chart.disconnect('timeSeriesGroup') + } if (!hasGrey) { // 1.除当前legend外全置灰 echarts.dispatchAction({ type: 'legendInverseSelect' @@ -116,6 +126,10 @@ export default { }) this.$set(this.isGrey, index, !this.isGrey[index]) } + // 判断timeSeries类型图表 建立多表联动 + if (isTimeSeries(this.chartInfo.type) && this.isconnect) { + chart.connect('timeSeriesGroup') + } if (this.chartInfo.type !== 'pie' && this.chartInfo.type !== 'bar' && this.chartInfo.type !== 'treemap') { // 处理点击后的 Y轴 const chartInfo = this.chartInfo diff --git a/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js b/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js index 8393a5d32..3fcf01ce5 100644 --- a/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js +++ b/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js @@ -32,6 +32,7 @@ export const chartTimeSeriesLineOption = { } }, tooltip: { + show: true, trigger: 'axis', confine: false, extraCssText: 'z-index:99999999;', @@ -45,7 +46,6 @@ export const chartTimeSeriesLineOption = { show: false } } - // formatter: 动态生成 }, color: initColor(), grid: { diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 649792f33..e02e54f5d 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -41,11 +41,15 @@ --> - - + + @@ -153,6 +157,7 @@