From 46c4dcd9278ec24e825220efa9f1b3bb5614181a Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Wed, 25 Oct 2023 14:39:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96gamma=E9=A1=B5?= =?UTF-8?q?=E5=90=84=E5=9B=BE=E5=BD=A2=E6=9E=84=E5=BB=BA=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8Dlog10=E5=88=B7=E9=80=89=E5=90=8Escat?= =?UTF-8?q?ter=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96GraphAssistance=E7=BB=84=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=80=89=E4=B8=ADlog10=EF=BC=8Cfrom=20db?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=80=89=E6=8B=A9full?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.js | 2 + src/store/modules/sample.js | 30 ++ src/utils/chartHelper.js | 2 +- .../components/Modals/LoadFromDBModal.vue | 3 +- .../{ => GraphAssistance}/GraphAssistance.vue | 64 ++-- .../GraphAssistance/TwoLabelSwitch.vue | 54 +++ src/views/spectrumAnalysis/gamma-analysis.vue | 336 ++++++++---------- src/views/spectrumAnalysis/seriesBuilder.js | 46 +++ src/views/spectrumAnalysis/settings.js | 11 +- 9 files changed, 307 insertions(+), 241 deletions(-) create mode 100644 src/store/modules/sample.js rename src/views/spectrumAnalysis/components/SubOperators/{ => GraphAssistance}/GraphAssistance.vue (60%) create mode 100644 src/views/spectrumAnalysis/components/SubOperators/GraphAssistance/TwoLabelSwitch.vue create mode 100644 src/views/spectrumAnalysis/seriesBuilder.js diff --git a/src/store/index.js b/src/store/index.js index 5936c50..b77f9bd 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,6 +6,7 @@ import user from './modules/user' import permission from './modules/permission' import enhance from './modules/enhance' import online from './modules/online' +import sample from './modules/sample' import getters from './getters' Vue.use(Vuex) @@ -17,6 +18,7 @@ export default new Vuex.Store({ permission, enhance, online, + sample }, state: { diff --git a/src/store/modules/sample.js b/src/store/modules/sample.js new file mode 100644 index 0000000..0630a0c --- /dev/null +++ b/src/store/modules/sample.js @@ -0,0 +1,30 @@ +const sample = { + state: { + sampleList: [] + }, + mutations: { + SET_SAMPLE_LIST: (state, sampleList) => { + state.sampleList = sampleList + }, + + ADD_SAMPLE_DATA: (state, sampleData) => { + state.sampleList.push(sampleData) + }, + + GET_SAMPLE_DATA: (state, inputFileName) => { + const find = state.sampleList.find(item => item.inputFileName == inputFileName) + return find + }, + + REMOVE_SAMPLE_DATA: (state, inputFileName) => { + const findIndex = state.sampleList.findIndex(item => item.inputFileName == inputFileName) + state.sampleList.splice(findIndex, 1) + }, + + CLEAR_SAMPLE_DATA: () => { + state.sampleList = [] + } + } +} + +export default sample diff --git a/src/utils/chartHelper.js b/src/utils/chartHelper.js index 86c1e8f..affe08c 100644 --- a/src/utils/chartHelper.js +++ b/src/utils/chartHelper.js @@ -114,5 +114,5 @@ export function rangeNumber(min, max) { * @returns */ export function getAxisMax(chartInstance, axis) { - return chartInstance.getModel().getComponent(axis).axis.scale._extent[1] + return chartInstance.getModel().getComponent(axis).axis.scale.rawExtentInfo._dataMax } \ No newline at end of file diff --git a/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue b/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue index 8465ffd..c3c0723 100644 --- a/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/LoadFromDBModal.vue @@ -117,7 +117,8 @@ export default { .add(-7, 'd') .format('YYYY-MM-DD'), endDate: moment().format('YYYY-MM-DD'), - dbName: 'auto' + dbName: 'auto', + spectralQualifie: 'FULL' }, selectedRowKeys: [], selectionRows: [], diff --git a/src/views/spectrumAnalysis/components/SubOperators/GraphAssistance.vue b/src/views/spectrumAnalysis/components/SubOperators/GraphAssistance/GraphAssistance.vue similarity index 60% rename from src/views/spectrumAnalysis/components/SubOperators/GraphAssistance.vue rename to src/views/spectrumAnalysis/components/SubOperators/GraphAssistance/GraphAssistance.vue index a388db6..1fb81bd 100644 --- a/src/views/spectrumAnalysis/components/SubOperators/GraphAssistance.vue +++ b/src/views/spectrumAnalysis/components/SubOperators/GraphAssistance/GraphAssistance.vue @@ -4,14 +4,14 @@
@@ -21,72 +21,60 @@ @@ -122,10 +110,6 @@ export default { } } -.no-change { - background-color: @primary-color; -} - .ant-switch { &::after { background-color: #fff; diff --git a/src/views/spectrumAnalysis/components/SubOperators/GraphAssistance/TwoLabelSwitch.vue b/src/views/spectrumAnalysis/components/SubOperators/GraphAssistance/TwoLabelSwitch.vue new file mode 100644 index 0000000..23e8136 --- /dev/null +++ b/src/views/spectrumAnalysis/components/SubOperators/GraphAssistance/TwoLabelSwitch.vue @@ -0,0 +1,54 @@ + + + + + \ No newline at end of file diff --git a/src/views/spectrumAnalysis/gamma-analysis.vue b/src/views/spectrumAnalysis/gamma-analysis.vue index d2b833e..d7b0d48 100644 --- a/src/views/spectrumAnalysis/gamma-analysis.vue +++ b/src/views/spectrumAnalysis/gamma-analysis.vue @@ -14,8 +14,8 @@ Graph Assistance @@ -114,7 +114,7 @@ import CustomChart from '@/components/CustomChart/index.vue' import PopOverWithIcon from './components/SubOperators/PopOverWithIcon.vue' import DetailedInfomation from './components/SubOperators/DetailedInfomation.vue' import QcFlags from './components/SubOperators/QcFlags.vue' -import GraphAssistance from './components/SubOperators/GraphAssistance.vue' +import GraphAssistance from './components/SubOperators/GraphAssistance/GraphAssistance.vue' import NuclideLibrary from './components/SubOperators/NuclideLibrary.vue' import ButtonWithSwitchIcon from './components/SubOperators/ButtonWithSwitchIcon.vue' import { getAction, postAction } from '@/api/manage' @@ -140,6 +140,7 @@ import { ACCESS_TOKEN } from '@/store/mutation-types' import StripModal from './components/Modals/StripModal.vue' import { FilePicker } from '@/utils/FilePicker' import { zipFile } from '@/utils/file' +import { mapMutations } from 'vuex' export default { props: { @@ -298,9 +299,6 @@ export default { const { dbName, sampleId } = this.sample try { this.isLoading = true - - this.handleResetState() - // const { success, result, message } = Response this.cancelLastRequest() const cancelToken = this.createCancelToken() @@ -330,7 +328,6 @@ export default { const { inputFileName: fileName } = this.sample try { this.isLoading = true - this.handleResetState() // const { success, result, message } = Response this.cancelLastRequest() @@ -435,107 +432,47 @@ export default { } this.resetThumbnailChartDataMax() - const series = [] - // 推入Spectrum Line - series.push( - buildLineSeries( - 'Spectrum', - this.transformPointListData(shadowChannelChart.pointlist), - shadowChannelChart.color, - { - symbolSize: 2, - markLine: { - silent: true, - symbol: 'none', - label: { - show: false, - }, - lineStyle: { - color: 'red', - width: 1, - }, - data: [{ xAxis: -1 }], - }, - } - ) + // 设置 Spectrum Line + this.redrawLineBySeriesName('Spectrum', shadowEnergyChart, shadowChannelChart, true, shadowChannelChart.color) + + // 设置 BaseLine + this.setSeriesData( + this.option.series, + 'BaseLine', + this.transformPointListData(channelBaseLine.pointlist), + channelBaseLine.color ) - // 右上角缩略图设置Spectrum Line 数据 + // 设置 LcLine + this.setSeriesData( + this.option.series, + 'LcLine', + this.transformPointListData(channelLcLine.pointlist), + channelLcLine.color + ) + + // 设置 ScacLine + this.setSeriesData( + this.option.series, + 'ScacLine', + this.transformPointListData(channelScacLine.pointlist), + channelScacLine.color + ) + + // 设置 基线控制点 + this.redrawCtrlPointBySeriesName() + + // 设置 Peak Line + this.redrawPeakLine() + + // 设置右上角缩略图 Spectrum Line 数据 this.setSeriesData( this.thumbnailOption.series, 'Spectrum', this.transformPointListData(shadowChannelChart.pointlist), shadowChannelChart.color ) - - // 推入BaseLine - series.push( - buildLineSeries('BaseLine', this.transformPointListData(channelBaseLine.pointlist), channelBaseLine.color, { - z: 2, - }) - ) - - // 推入LcLine线 - series.push( - buildLineSeries('LcLine', this.transformPointListData(channelLcLine.pointlist), channelLcLine.color, { - z: 3, - }) - ) - - // 推入Scac线 - series.push( - buildLineSeries('ScacLine', this.transformPointListData(channelScacLine.pointlist), channelScacLine.color, { - z: 4, - }) - ) - - // 推入基线控制点 - series.push({ - name: 'BaseLine_Ctrl_Point', - type: 'scatter', - data: shapeChannelData.map(({ size, color, point: { x, y } }) => { - return { - value: [x, y], - itemStyle: { - color: 'transparent', - borderColor: color, - borderWidth: size / 2, - }, - } - }), - emphasis: { - disabled: true, - }, - animation: false, - z: 5, - }) - - // 推入Peak Line - const peakLines = [] - channelPeakGroup.forEach((item, index) => { - peakLines.push( - buildLineSeries(`Peak_${index}`, this.transformPointListData(item.pointlist), item.color, { - z: 6, - }) - ) - }) - series.push(...peakLines) - - // 推入Compare Line - series.push( - buildLineSeries('Compare', [], '#fff', { - symbolSize: 2, - z: 7, - }) - ) - - this.opts.notMerge = true - this.option.series = series - - this.$nextTick(() => { - this.resetChartOpts() - }) }, // chart 的 tooltip @@ -559,68 +496,93 @@ export default { }, // Graph Assistance 操作 - handleGraphAssistanceChange({ type, label, value }) { + handleGraphAssistanceChange(key) { + const value = this.graphAssistance[key] const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') const compareLineSeries = findSeriesByName(this.option.series, 'Compare') - // 类型变化 - if (type == 'labelChange') { - switch (label) { - case 'Linear': + switch (key) { + // 折线y轴类型变化 + case 'chartYAxisType': + if (value == 'Linear') { this.option.yAxis.type = 'value' this.thumbnailOption.yAxis.type = 'value' - this.handleResetChart() - break - case 'Log10': + } else { this.option.yAxis.type = 'log' this.thumbnailOption.yAxis.type = 'log' - this.handleResetChart() - break - case 'Channel': - case 'Energy': - // 如果Energy没有值,则不进行切换 - if (!this.energyData.all.pointlist) { - return + } + this.handleResetChart() + break + + // 红色竖线是否显示 + case 'Cursor': + if (value) { + spectrumLineSeries.markLine.lineStyle.width = 2 + } else { + spectrumLineSeries.markLine.lineStyle.width = 0 + } + break + + // 基线是否显示 + case 'Baseline': + this.redrawLineBySeriesName('BaseLine', this.energyData.baseLine, this.channelData.baseLine, value) + break + + // Lc 线是否显示 + case 'Lc': + this.redrawLineBySeriesName('LcLine', this.energyData.lcLine, this.channelData.lcLine, value) + break + + // Channel和Energy的切换 + case 'axisType': + // 如果Energy没有值,则不进行切换 + if (!this.energyData.all.pointlist) { + if (value == 'Energy') { + this.graphAssistance[key] = 'Channel' } + this.$message.warn('Has No Energy Yet') + return + } - this.graphAssistance.axisType = label - this.option.xAxis.name = label + this.option.xAxis.name = value - this.handleResetChart() + this.handleResetChart() - this.redrawLineBySeriesName( - 'BaseLine', - this.energyData.baseLine, - this.channelData.baseLine, - this.graphAssistance.Baseline - ) - this.redrawLineBySeriesName( - 'LcLine', - this.energyData.lcLine, - this.channelData.lcLine, - this.graphAssistance.Lc - ) - this.redrawLineBySeriesName( - 'ScacLine', - this.energyData.scacLine, - this.channelData.scacLine, - this.graphAssistance.SCAC - ) + this.redrawLineBySeriesName( + 'BaseLine', + this.energyData.baseLine, + this.channelData.baseLine, + this.graphAssistance.Baseline + ) + this.redrawLineBySeriesName( + 'LcLine', + this.energyData.lcLine, + this.channelData.lcLine, + this.graphAssistance.Lc + ) + this.redrawLineBySeriesName( + 'ScacLine', + this.energyData.scacLine, + this.channelData.scacLine, + this.graphAssistance.SCAC + ) - this.redrawLineBySeriesName('Spectrum', this.energyData.spectrumLine, this.channelData.spectrumLine) - this.redrawCtrlPointBySeriesName() - this.redrawPeakLine() + this.redrawLineBySeriesName('Spectrum', this.energyData.spectrumLine, this.channelData.spectrumLine) + this.redrawCtrlPointBySeriesName() + this.redrawPeakLine() - this.redrawThumbnailChart() + this.redrawThumbnailChart() - if (this.channelCompareLine) { - this.redrawLineBySeriesName('Compare', this.energyCompareLine, this.channelCompareLine) - } - break - case 'Lines': - this.graphAssistance.spectrumType = 'Lines' + if (this.channelCompareLine) { + this.redrawLineBySeriesName('Compare', this.energyCompareLine, this.channelCompareLine) + } + break + + // Lines 和 Scatter 的切换 + case 'spectrumType': + if (value == 'Lines') { spectrumLineSeries.type = 'line' spectrumLineSeries.symbol = 'none' @@ -635,10 +597,7 @@ export default { if (this.channelCompareLine) { this.redrawLineBySeriesName('Compare', this.energyCompareLine, this.channelCompareLine) } - break - case 'Scatter': - this.graphAssistance.spectrumType = 'Scatter' - + } else { spectrumLineSeries.type = 'scatterGL' spectrumLineSeries.symbol = 'circle' @@ -651,35 +610,18 @@ export default { this.$nextTick(() => { this.rangeScatter() }) - break - } - } - // 值变化 - else if (type == 'valueChange') { - this.graphAssistance[label] = value + } + break - switch (label) { - case 'Cursor': - // 显示红色竖线 - if (value) { - spectrumLineSeries.markLine.lineStyle.width = 2 - } else { - spectrumLineSeries.markLine.lineStyle.width = 0 - } - break - case 'Baseline': - this.redrawLineBySeriesName('BaseLine', this.energyData.baseLine, this.channelData.baseLine, value) - break - case 'Lc': - this.redrawLineBySeriesName('LcLine', this.energyData.lcLine, this.channelData.lcLine, value) - break - case 'SCAC': - this.redrawLineBySeriesName('ScacLine', this.energyData.scacLine, this.channelData.scacLine, value) - break - } + // SCAC 线是否显示 + case 'SCAC': + this.redrawLineBySeriesName('ScacLine', this.energyData.scacLine, this.channelData.scacLine, value) + break } }, + changeSeriesType() {}, + handleChangeNuclideVisible() { this.nuclideLibraryVisible = !this.nuclideLibraryVisible }, @@ -710,11 +652,17 @@ export default { }) }, + clearPeakLine() { + this.opts.notMerge = true + this.option.series.splice(6) + this.$nextTick(() => { + this.resetChartOpts() + }) + }, + // 重绘Peak Line redrawPeakLine() { - this.option.series = this.option.series.filter((item) => { - return !item.name.includes('Peak_') - }) + this.clearPeakLine() const data = this.isEnergy() ? this.energyData.peakGroup : this.channelData.peakGroup const peakLines = [] @@ -1179,9 +1127,9 @@ export default { // 从分析工具刷新部分数据 handleRefresh(data) { - this.handleResetState() data.DetailedInformation = this.detailedInfomation this.clearCompareLine() + this.redrawPeakLine() this.dataProcess(data) }, @@ -1416,23 +1364,10 @@ export default { this.selectedChannel = -1 this.nuclideLibraryList = [] this.closePeakInfomationTooltip() - this.option.series = [] + this.clearPeakLine() this.option.xAxis.name = 'Channel' - this.option.yAxis.type = 'value' - this.thumbnailOption.yAxis.type = 'value' - - if (this.option.series.length) { - const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum') - spectrumLineSeries.type = 'line' - spectrumLineSeries.symbol = 'none' - spectrumLineSeries.markLine.lineStyle.width = 2 - } - - const thumbnailSpectrumLineSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum') - thumbnailSpectrumLineSeries.type = 'line' - thumbnailSpectrumLineSeries.symbol = 'none' - - this.graphAssistance = cloneDeep(graphAssistance) + this.option.yAxis.type = 'log' + this.thumbnailOption.yAxis.type = 'log' }, /** @@ -1554,6 +1489,8 @@ export default { const arrFunc = isList ? Array.prototype.filter : Array.prototype.find return arrFunc.call(allData, (item) => item.name == name && item.group == group) || {} }, + + ...mapMutations(['ADD_SAMPLE_DATA', 'GET_SAMPLE_DATA']), }, watch: { currStep: { @@ -1568,10 +1505,17 @@ export default { sample: { handler(newVal, oldVal) { console.log('newValnewVal', newVal) - if (newVal.sampleId) { - this.getSampleDetail() + this.graphAssistance.axisType = 'Channel' + this.handleResetState() + const sampleData = this.GET_SAMPLE_DATA(newVal.inputFileName) + if (sampleData) { + console.log('%c [ ]-1521', 'font-size:13px; background:pink; color:#bf2c9f;', sampleData) } else { - this.getSampleDetail_file() + if (newVal.sampleId) { + this.getSampleDetail() + } else { + this.getSampleDetail_file() + } } }, immediate: true, diff --git a/src/views/spectrumAnalysis/seriesBuilder.js b/src/views/spectrumAnalysis/seriesBuilder.js new file mode 100644 index 0000000..e011769 --- /dev/null +++ b/src/views/spectrumAnalysis/seriesBuilder.js @@ -0,0 +1,46 @@ +import { buildLineSeries } from '@/utils/chartHelper' + +export const spectrumSeries = buildLineSeries('Spectrum', [], '#fff', { + symbolSize: 2, + markLine: { + silent: true, + symbol: 'none', + label: { + show: false + }, + lineStyle: { + color: 'red', + width: 1 + }, + data: [{ xAxis: -1 }] + }, + z: 1 +}) + +export const baseLineSeries = buildLineSeries('BaseLine', [], '#fff', { + z: 2 +}) + +export const lcLineSeries = buildLineSeries('LcLine', [], '#fff', { + z: 3 +}) + +export const scacLineSeries = buildLineSeries('ScacLine', [], '#fff', { + z: 4 +}) + +export const baseLineCtrlPoint = { + name: 'BaseLine_Ctrl_Point', + type: 'scatter', + data: [], + emphasis: { + disabled: true + }, + animation: false, + z: 5 +} + +export const compareLineSeries = buildLineSeries('Compare', [], '#fff', { + symbolSize: 2, + z: 7 +}) diff --git a/src/views/spectrumAnalysis/settings.js b/src/views/spectrumAnalysis/settings.js index 3a89271..b039cf6 100644 --- a/src/views/spectrumAnalysis/settings.js +++ b/src/views/spectrumAnalysis/settings.js @@ -1,4 +1,5 @@ import { buildLineSeries } from "@/utils/chartHelper" +import { baseLineCtrlPoint, baseLineSeries, compareLineSeries, lcLineSeries, scacLineSeries, spectrumSeries } from "./seriesBuilder" export const GammaOptions = { option: { @@ -98,7 +99,7 @@ export const GammaOptions = { } } }, - series: [], + series: [spectrumSeries, baseLineSeries, lcLineSeries, scacLineSeries, baseLineCtrlPoint, compareLineSeries], brush: {} }, // 缩略图配置 @@ -158,10 +159,14 @@ export const GammaOptions = { } } +console.log('%c [ ]-162', 'font-size:13px; background:pink; color:#bf2c9f;', GammaOptions.option) + export const graphAssistance = { + chartYAxisType: 'Log10', + Cursor: true, + Baseline: true, + Lc: true, axisType: 'Channel', spectrumType: 'Lines', - Baseline: true, SCAC: true, - Lc: true, } \ No newline at end of file