From 9d0e6e04b6d6bef5afb5b55f88743e8ee71adcdd Mon Sep 17 00:00:00 2001 From: renpy Date: Wed, 2 Aug 2023 10:44:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86echarts=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9=E6=95=B0=E8=BD=B4=E6=95=B0=E6=8D=AE=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/statistics/detail.vue | 48 ++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/views/statistics/detail.vue b/src/views/statistics/detail.vue index c696227..7fa893f 100644 --- a/src/views/statistics/detail.vue +++ b/src/views/statistics/detail.vue @@ -564,7 +564,7 @@ export default { this.dataSourceSpectrumX_B = this.allData.bspectrumBlock&&this.allData.bspectrumBlock.bspectrumSubBlock.map((item, index) => { return index }) - this.allData.histogramBlock.histogramSubBlock.forEach(item => { + this.allData.histogramBlock&&this.allData.histogramBlock.histogramSubBlock.forEach(item => { if (item.c === 1) { this.dataSourceHistogray.level_1.push(item) } else if (item.c <= 5 && item.c > 1) { @@ -647,9 +647,26 @@ export default { getUid() { return (Math.random()+new Date().getTime()).toString(32).slice(0,8) }, + changeData(data) { + let arr = data.map(item => { + if (item==0) { + return 1 + } else { + return item + } + }) + return arr + }, yLogChange(e,str) { let yAxisType = e.target.checked ? "log" : "value" - str==="G"?this.yAxisType_g = yAxisType:this.yAxisType_b = yAxisType + str === "G" ? this.yAxisType_g = yAxisType : this.yAxisType_b = yAxisType + let dataArr =[] + if (e.target.checked) { + + dataArr = this.changeData(str === "G"?this.dataSourceSpectrum_G:this.dataSourceSpectrum_B) + } else { + dataArr = str === "G"?this.dataSourceSpectrum_G:this.dataSourceSpectrum_B + } let options = { yAxis: { type: str==="G"?this.yAxisType_g:this.yAxisType_b, @@ -658,8 +675,25 @@ export default { lineStyle: { color: "rgbA(64, 105, 121, 0.2)" } - } + }, + axisLabel: { + formatter: function (value) { + if (e.target.checked) { + return value == 1 ? 0 : value + } else { + return value + } + } + }, + scale: false }, + series: [ + { + type: 'line', + itemStyle: { normal: { color: '#0656ff' } }, + data: dataArr + } + ] } if (str === "G") { this.spectrumChart_G.setOption(options) @@ -743,7 +777,7 @@ export default { dataZoom: [ { start: 0, - end: 255 + end: 100 } ], series: [ @@ -759,14 +793,14 @@ export default { this.spectrumChart_G = echarts.init(document.getElementById("spectrumChartRef_G")) this.spectrumChart_G.setOption(this.getOptions("G")) window.addEventListener("resize", function () { - spectrumChart_G.resize(); + this,spectrumChart_G.resize(); }); }, drawSpectrumChart_B() { this.spectrumChart_B = echarts.init(document.getElementById("spectrumChartRef_B")) this.spectrumChart_B.setOption(this.getOptions("B")) window.addEventListener("resize", function () { - spectrumChart_B.resize(); + this.spectrumChart_B.resize(); }); }, drawHistogramChart() { @@ -832,7 +866,7 @@ export default { series }) window.addEventListener("resize", function () { - histogramChart.resize(); + this.histogramChart.resize(); }); } }