diff --git a/nezha-fronted/src/assets/css/components/chart/chart.scss b/nezha-fronted/src/assets/css/components/chart/chart.scss index e3094f8fd..3ab8caae0 100644 --- a/nezha-fronted/src/assets/css/components/chart/chart.scss +++ b/nezha-fronted/src/assets/css/components/chart/chart.scss @@ -507,6 +507,7 @@ font-weight: bold; } } + .endpoint-query-metrics.chart-fullscreen.nz-dialog,.recordRules-query-metrics.chart-fullscreen.nz-dialog { .chart-screen-header .chart-header__tools #browser-go { margin-left: 5px; @@ -683,8 +684,8 @@ } .chart-dataLink-tooltip{ - position: absolute; - padding-bottom: 2px; + position: absolute !important; + padding-bottom: 2px !important; z-index: 999999999; pointer-events: auto; .chart-dataLink-list{ @@ -717,6 +718,22 @@ } } +.chart-expolre-tooltip{ + display: block; + border-style: solid; + white-space: nowrap; + will-change: transform; + box-shadow: rgba(0, 0, 0, 0.2) 1px 2px 10px; + transition: opacity 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, transform 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s; + background-color: $--background-color-empty; + border-width: 1px; + border-radius: 4px; + color: rgb(0, 0, 0); + font: 14px / 21px "Microsoft YaHei"; + padding: 10px; + border-color: rgb(221, 228, 237); +} + .graph-icon-info-box{ position: absolute; top: 50%; @@ -854,4 +871,4 @@ .chart-canvas-tooltip{ height: auto !important; } -} \ No newline at end of file +} diff --git a/nezha-fronted/src/assets/css/components/page/dashboard/explore/explore.scss b/nezha-fronted/src/assets/css/components/page/dashboard/explore/explore.scss index 556aa7f1c..b61d18f2b 100644 --- a/nezha-fronted/src/assets/css/components/page/dashboard/explore/explore.scss +++ b/nezha-fronted/src/assets/css/components/page/dashboard/explore/explore.scss @@ -243,6 +243,7 @@ .chart-room { width: 100%; height: 300px; + position: relative; } .introduce-view { .info-room { diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index 3069bb63a..c7282202a 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -174,6 +174,18 @@ export default { this.legends = [] this.series = chartOption.series = this.handleTimeSeries(this.chartInfo, chartOption.series[0], this.chartData) // 生成series和legends + const styleOption = this.$lodash.get(this.chartInfo, 'param.option') + if (styleOption) { + chartOption.series.forEach(item => { + if (item.lineStyle && styleOption.lineWidth != undefined) { + item.lineStyle.width = styleOption.lineWidth + } + if (styleOption.pointSize != undefined) { + item.symbolSize = styleOption.pointSize + } + }) + } + this.isGrey = this.legends.map(() => false) chartOption.color = this.colorList if (!this.series.length) { @@ -260,12 +272,11 @@ export default { if (this.tooltip.activeIndex != params.seriesIndex) { const option = myChart.getOption() option.series[params.seriesIndex].symbol = 'circle' - option.series[params.seriesIndex].emphasis.itemStyle = { - opacity: 1, + option.series[params.seriesIndex].itemStyle = { borderColor: this.hexToRgb(params.color, 0.4), - borderWidth: 6 + borderWidth: 5 } - myChart.setOption(option, true) + myChart.setOption(option) } } this.tooltip.activeIndex = params.seriesIndex @@ -275,11 +286,8 @@ export default { const option = myChart.getOption() option.series.forEach(item => { item.symbol = 'emptyCircle' - item.emphasis.itemStyle = { - opacity: 1 - } }) - myChart.setOption(option, true) + myChart.setOption(option) } this.tooltip.activeIndex = undefined }) diff --git a/nezha-fronted/src/components/chart/chart/legend.vue b/nezha-fronted/src/components/chart/chart/legend.vue index 0c9ffcea4..6968fee1c 100644 --- a/nezha-fronted/src/components/chart/chart/legend.vue +++ b/nezha-fronted/src/components/chart/chart/legend.vue @@ -129,11 +129,6 @@ export default { } }, methods: { - onCopy (txt) { - this.$copyText(txt).then(() => { - this.$message.success({ message: this.$t('overall.copySuccess') }) - }) - }, clickLegend (legendName, index) { /* 点击legend * 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮 diff --git a/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js b/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js index c10ebc33b..65b859d54 100644 --- a/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js +++ b/nezha-fronted/src/components/chart/chart/options/chartTimeSeries.js @@ -152,26 +152,23 @@ export const chartTimeSeriesLineOption = { type: 'line', symbol: 'emptyCircle', // 去掉点 connectNulls: true, - symbolSize: [6, 6], + symbolSize: 6, smooth: 0.2, // 曲线变平滑 - // showSymbol: false, - itemStyle: { - opacity: 0.001 - }, + showSymbol: false, data: [], lineStyle: { width: 1, opacity: 0.9 }, emphasis: { - focus: 'series', - itemStyle: { - opacity: 1 - } + focus: 'series' }, blur: { lineStyle: { opacity: 0.3 + }, + itemStyle: { + opacity: 1 } } }], diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue index 1dd8abbcd..8402ae91d 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue @@ -250,7 +250,11 @@ export default { min: undefined, max: undefined }, - dataLink: [] + dataLink: [], + option: { + lineWidth: 1, + pointSize: 6 + } }, elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1, orderNum: 0 }], panel: '', @@ -433,14 +437,22 @@ export default { if (this.chart.type === 'group' && !this.chart.param.collapse == undefined) { this.chart.param.collapse = false } - if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point') && !this.chart.param.rightYAxis) { - this.chart.param.rightYAxis = { - elementNames: [], - style: 'line', - unit: 2, - label: '', - min: undefined, - max: undefined + if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point')) { + if (!this.chart.param.rightYAxis) { + this.chart.param.rightYAxis = { + elementNames: [], + style: 'line', + unit: 2, + label: '', + min: undefined, + max: undefined + } + } + if (!this.chart.param.option) { + this.chart.param.option = { + lineWidth: 1, + pointSize: 6 + } } } if (this.chart.type === 'stat') { @@ -480,14 +492,22 @@ export default { if (this.chart.type === 'group' && !this.chart.param.collapse == undefined) { this.chart.param.collapse = false } - if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point') && !this.chart.param.rightYAxis) { - this.chart.param.rightYAxis = { - elementNames: [], - style: 'line', - unit: 2, - label: '', - min: undefined, - max: undefined + if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point')) { + if (!this.chart.param.rightYAxis) { + this.chart.param.rightYAxis = { + elementNames: [], + style: 'line', + unit: 2, + label: '', + min: undefined, + max: undefined + } + } + if (!this.chart.param.option) { + this.chart.param.option = { + lineWidth: 1, + pointSize: 6 + } } } if (this.chart.type === 'stat') { diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue index e968db0ab..f8831f022 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartConfig.vue @@ -447,8 +447,46 @@ + +
+
+ {{$t('dashboard.dashboard.chartForm.option')}} +
+
+ + + + + + + + +
+
+ -
+
{{$t('dashboard.dashboard.chartForm.rightYAxis')}} { this.chartConfig.param.thresholds.push({ value: undefined, color: randomcolor() }) diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue index 1d09fe442..fe46069ce 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue @@ -408,7 +408,11 @@ export default { min: undefined, max: undefined }, - dataLink: [] + dataLink: [], + option: { + lineWidth: 1, + pointSize: 6 + } } } } diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js index 1311170bd..e778e62e8 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js +++ b/nezha-fronted/src/components/common/rightBox/chart/chartTypeShow.js @@ -239,7 +239,7 @@ export default { default: return false } }, - isShowRightYAxis (type) { + isTimeSeries (type) { switch (type) { case 'line': case 'area': diff --git a/nezha-fronted/src/components/page/dashboard/dashboard.vue b/nezha-fronted/src/components/page/dashboard/dashboard.vue index f6105eb8c..8ea5d6347 100644 --- a/nezha-fronted/src/components/page/dashboard/dashboard.vue +++ b/nezha-fronted/src/components/page/dashboard/dashboard.vue @@ -266,7 +266,11 @@ export default { min: undefined, max: undefined }, - dataLink: [] + dataLink: [], + option: { + lineWidth: 1, + pointSize: 6 + } }, elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1, orderNum: 0 }], panel: '', @@ -607,14 +611,22 @@ export default { if (this.chart.type === 'group' && !this.chart.param.collapse == undefined) { this.chart.param.collapse = false } - if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point') && !this.chart.param.rightYAxis) { - this.chart.param.rightYAxis = { - elementNames: [], - style: 'line', - unit: 2, - label: '', - min: undefined, - max: undefined + if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point')) { + if (!this.chart.param.rightYAxis) { + this.chart.param.rightYAxis = { + elementNames: [], + style: 'line', + unit: 2, + label: '', + min: undefined, + max: undefined + } + } + if (!this.chart.param.option) { + this.chart.param.option = { + lineWidth: 1, + pointSize: 6 + } } } if (this.chart.type === 'stat') { @@ -654,14 +666,22 @@ export default { if (this.chart.type === 'group' && !this.chart.param.collapse == undefined) { this.chart.param.collapse = false } - if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point') && !this.chart.param.rightYAxis) { - this.chart.param.rightYAxis = { - elementNames: [], - style: 'line', - unit: 2, - label: '', - min: undefined, - max: undefined + if ((this.chart.type === 'line' || this.chart.type === 'area' || this.chart.type === 'point')) { + if (!this.chart.param.rightYAxis) { + this.chart.param.rightYAxis = { + elementNames: [], + style: 'line', + unit: 2, + label: '', + min: undefined, + max: undefined + } + } + if (!this.chart.param.option) { + this.chart.param.option = { + lineWidth: 1, + pointSize: 6 + } } } if (this.chart.type === 'stat') { diff --git a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue index 7140e3233..84b57da49 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue @@ -3850,9 +3850,10 @@ export default { } data.forEach((result, i) => { const seriesItem = { + type: 'line', name: '', symbol: 'emptyCircle', // 去掉点 - symbolSize: [2, 2], + symbolSize: [6, 6], showSymbol: false, smooth: 0.2, // 曲线变平滑 data: [], @@ -3860,7 +3861,17 @@ export default { width: 1, opacity: 0.9 }, - type: 'line' + emphasis: { + focus: 'series' + }, + blur: { + lineStyle: { + opacity: 0.3 + }, + itemStyle: { + opacity: 1 + } + } } let legendName = '' seriesItem.data = result.values.map((item) => { @@ -3932,9 +3943,10 @@ export default { } data.forEach((result, i) => { const seriesItem = { + type: 'line', name: '', symbol: 'emptyCircle', // 去掉点 - symbolSize: [2, 2], + symbolSize: [6, 6], showSymbol: false, smooth: 0.2, // 曲线变平滑 data: [], @@ -3942,7 +3954,17 @@ export default { width: 1, opacity: 0.9 }, - type: 'line' + emphasis: { + focus: 'series' + }, + blur: { + lineStyle: { + opacity: 0.3 + }, + itemStyle: { + opacity: 1 + } + } } let legendName = '' seriesItem.data = result.values.map((item) => { diff --git a/nezha-fronted/src/components/page/dashboard/explore/exploreItemHtml.vue b/nezha-fronted/src/components/page/dashboard/explore/exploreItemHtml.vue index edecf1d52..f966d3cd9 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/exploreItemHtml.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/exploreItemHtml.vue @@ -408,9 +408,10 @@ export default { } data.forEach((result, i) => { const seriesItem = { + type: 'line', name: '', symbol: 'emptyCircle', // 去掉点 - symbolSize: [2, 2], + symbolSize: [6, 6], showSymbol: false, smooth: 0.2, // 曲线变平滑 data: [], @@ -418,7 +419,17 @@ export default { width: 1, opacity: 0.9 }, - type: 'line' + emphasis: { + focus: 'series' + }, + blur: { + lineStyle: { + opacity: 0.3 + }, + itemStyle: { + opacity: 1 + } + } } let legendName = '' seriesItem.data = result.values.map((item) => { @@ -612,9 +623,10 @@ export default { } data.forEach((result, i) => { const seriesItem = { + type: 'line', name: '', symbol: 'emptyCircle', // 去掉点 - symbolSize: [2, 2], + symbolSize: [6, 6], showSymbol: false, smooth: 0.2, // 曲线变平滑 data: [], @@ -622,7 +634,17 @@ export default { width: 1, opacity: 0.9 }, - type: 'line' + emphasis: { + focus: 'series' + }, + blur: { + lineStyle: { + opacity: 0.3 + }, + itemStyle: { + opacity: 1 + } + } } let legendName = '' seriesItem.data = result.values.map((item) => { diff --git a/nezha-fronted/src/components/page/dashboard/overview/chart.vue b/nezha-fronted/src/components/page/dashboard/overview/chart.vue index 1a4fc1704..f24963753 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chart.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chart.vue @@ -4,15 +4,40 @@
{{$t("dashboard.dashboard.moreTitle")}} {{$t("dashboard.dashboard.showAll")+legendAll.length}}
{{chartTitle}}
-
+
No Data
-
- {{item.alias?item.alias:item.name}} +
+ + {{item.alias?item.alias:item.name}} +
+
+
+ +
@@ -56,7 +81,21 @@ export default { noData: false, dataSize: 20, chartDot: 2, - theme: localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light' + theme: localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light', + cursorDefault: false, + tooltip: { + x: 0, + y: 0, + title: 0, + value: 0, + mapping: {}, + show: false, + dataLinkShow: '', + metric: {}, + activeIndex: undefined, + clickIndex: undefined + }, + isInit: true } }, created () { @@ -174,6 +213,11 @@ export default { } else { this.option.yAxis.axisLabel.formatter = this.defaultYAxisFormatter } + if (this.series.length == 1) { + this.series.forEach(item => { + item.cursor = 'default' + }) + } } if (this.series && this.series.length) { this.$set(this.option, 'series', this.series) @@ -207,6 +251,60 @@ export default { } }) } + + if (this.isInit) { + // 未设置dataLink的图表 鼠标样式为default + this.chart.getZr().on('mousemove', (params) => { + // 获取鼠标在图表中的坐标 + const pointInPixel = [params.offsetX, params.offsetY] + const option = this.chart.getOption() + const zoomState = this.$lodash.get(option, 'toolbox[0].feature.dataZoom.iconStatus.zoom', 'normal') + // 判断鼠标在坐标轴中且zoom未被激活 + if (this.chart.containPixel('grid', pointInPixel) && zoomState === 'normal') { + this.cursorDefault = true + } else { + this.cursorDefault = false + } + }) + + if (this.series.length > 1) { + this.chart.on('mousemove', () => { + this.cursorDefault = false + }) + this.chart.on('click', this.chartClick) + this.chart.on('mousedown', (params) => { + if (this.tooltip.dataLinkShow) { + const e = params.event.event + e.stopPropagation() + } + }) + } + + this.chart.on('mouseover', (params) => { + if (this.tooltip.activeIndex != params.seriesIndex) { + const option = this.chart.getOption() + option.series[params.seriesIndex].symbol = 'circle' + option.series[params.seriesIndex].itemStyle = { + borderColor: this.hexToRgb(params.color, 0.4), + borderWidth: 5 + } + this.chart.setOption(option) + } + this.tooltip.activeIndex = params.seriesIndex + }) + + this.chart.on('mouseout', (params) => { + const option = this.chart.getOption() + option.series.forEach(item => { + item.symbol = 'emptyCircle' + }) + this.chart.setOption(option) + this.tooltip.activeIndex = undefined + }) + } + + this.isInit = false + this.resize() }, chartRoomMouseMove (event, tooltipDom) { @@ -252,6 +350,17 @@ export default { const color = this.colors[index] return color }, + hoverLegend (legendName, index, type) { + // legend 已经取消显示,鼠标悬浮,不开启 高亮效果 + if (this.legend[index].isGray) { + return false + } + this.chart && this.chart.dispatchAction({ + type: type, + seriesIndex: index, + name: legendName + }) + }, clickLegend (legendName, index) { /* 点击legend * 1.当前如果是全高亮状态,则全部置灰,只留被点击的legend高亮 @@ -350,35 +459,17 @@ export default { // 当前鼠标位置 const pointX = point[0] const pointY = point[1] - // 外层div大小 - /* const viewWidth = size.viewSize[0] - const viewHeight = size.viewSize[1] */ // 提示框大小 const boxWidth = size.contentSize[0] - // const boxHeight = size.contentSize[1] const chartDom = document.getElementById(this.chartId) if (chartDom) { - // const parTop = chartDom.offsetTop - const parLeft = chartDom.offsetLeft - const parent = chartDom.parentElement - // const parClientHeight = parent.clientHeight// 可视高度 const parClientWidth = parent.clientWidth// 可视宽度 - // const parScrollTop = parent.scrollTop - if ((parClientWidth - pointX - parLeft - 20) >= boxWidth) { // 说明鼠标在左边放不下提示框 + if ((parClientWidth - pointX - 20) >= boxWidth) { // 说明鼠标在左边放不下提示框 x = pointX + 10 } else { x = pointX - boxWidth } - // if((parClientHeight-pointY-(parTop-parScrollTop)-20)>=boxHeight){//说明鼠标上面放不下提示框 - // y = pointY+10; - // }else { - // y = pointY-boxHeight; - // } - y = pointY + 10 - return [x, y] - } else { - x = pointX - boxWidth y = pointY + 10 return [x, y] } @@ -422,13 +513,15 @@ export default { defaultTooltipFormatter: function (params) { let showFlag = false let minusFlag = true - let str = '
' + let str = '
' params instanceof Array || (params = [params]) params.forEach((item, i) => { const alias = this.queryAlias(item.seriesIndex) if (i === 0 && alias.indexOf('Previous ') === -1) { const value = item.data[0] + str += '
' str += bus.timeFormate(bus.computeTimezone(value)) + str += '
' } if (alias.indexOf('Previous ') !== -1 && minusFlag) { if (i !== 0) { @@ -441,9 +534,12 @@ export default { showFlag = showFlag || item.data[1] if (!isNaN(item.data[1] + '')) { const val = Number(item.data[1]) - str += '
' - str += `
${alias || item.seriesName}:
` - str += '
' + str += `
` + str += `
+ + ${alias || item.seriesName} +
` + str += '
' let dot = bus.countDecimals(val) if (dot < this.chartDot) { dot = this.chartDot @@ -611,6 +707,134 @@ export default { unit, oldDot } + }, + datalinkPosition (e) { + this.$nextTick(() => { + const box = document.getElementById(`chart-canvas-tooltip-${this.chartId}`) + const left = e.pageX - this.$refs.chartRoom.getBoundingClientRect().left + const top = e.pageY - this.$refs.chartRoom.getBoundingClientRect().top + if (box) { + const boxWidth = box.offsetWidth + const chartDom = document.getElementById(this.chartId) + const parent = chartDom.parentElement + const parClientWidth = parent.clientWidth// 可视宽度 + if ((parClientWidth - left - 20) >= boxWidth) { // 说明鼠标在左边放不下提示框 + this.tooltip.x = left + 10 + } else { + this.tooltip.x = left - boxWidth + } + this.tooltip.y = top + 10 + } + }) + }, + chartClick (params) { + const option = { + tooltip: { + extraCssText: 'z-index:1000;visibility:hidden;transition:none;', + hideDelay: 0 + } + } + this.chart.setOption(option) + this.chart.dispatchAction({ + type: 'hideTip' + }) + const nameArr = params.seriesName.split('-') + if (nameArr.length > 1) { + nameArr.splice(nameArr.length - 1, 1) + } + const seriesName = nameArr.join('-') + // title + const value = bus.computeTimezone(params.data[0]) + const tData = new Date(value) + // value + let paramsDot = bus.countDecimals(params.data[1]) + if (paramsDot < this.chartDot) { + paramsDot = this.chartDot + } else if (paramsDot > 6) { + paramsDot = 6 + } + const val = formatScientificNotation(params.data[1], paramsDot) + const color = this.colors[params.seriesIndex] + this.tooltip.tooltipHtml = ` +
+
${bus.timeFormate(tData)}
+
+
+ + ${seriesName} +
+
+ ${chartDataFormat.getUnit(this.unit).compute(val, null, -1, paramsDot)} +
+
+
+ ` + this.tooltip.show = true + this.tooltip.dataLinkShow = true + this.tooltip.clickIndex = params.seriesIndex + const e = params.event.event + this.datalinkPosition(e) + }, + clickout () { + if (this.series.length > 1) { + this.tooltip.show = false + this.tooltip.dataLinkShow = false + const option = { + tooltip: { + extraCssText: 'z-index:1000;visibility:visible;' + } + } + this.chart.setOption(option) + } + }, + showSelectedSeries () { + this.legend.forEach((item, index) => { + if (index == this.tooltip.clickIndex) { + this.chart.dispatchAction({ + type: 'legendSelect', + name: item.name + }) + } else { + this.chart.dispatchAction({ + type: 'legendUnSelect', + name: item.name + }) + } + }) + + this.legend = this.legend.map((item, index) => { + return { + ...item, + isGray: index !== this.tooltip.clickIndex + } + }) + this.clickout() + }, + showAllSeries () { + this.chart.dispatchAction({ + type: 'legendAllSelect' + }) + this.legend = this.legend.map((item, index) => { + return { + ...item, + isGray: false + } + }) + this.clickout() + }, + // 十六进制转为rgba + hexToRgb (hex, a = 1) { + /* + hex: {String}, "#333", "#AF0382" + */ + hex = hex.slice(1) + if (hex.length == 3) { + hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + } + const r = parseInt(hex.slice(0, 2), 16) + const g = parseInt(hex.slice(2, 4), 16) + const b = parseInt(hex.slice(4, 6), 16) + return `rgba(${r}, ${g}, ${b}, ${a})` } }, mounted () { @@ -623,7 +847,7 @@ export default { beforeDestroy () { this.$refs.chartRoom.removeEventListener('mousemove', this.chartRoomMouseMove) if (this.chart) { - this.chart.clear() + this.chart.dispose() } } }