feat: 对接ColorConfig功能,完成Interactive Tools中的Fit功能,及切换回BaseLine的部分处理

This commit is contained in:
Xu Zhimeng 2023-09-13 19:42:28 +08:00
parent 5ae9115577
commit 1c16157a27
14 changed files with 262843 additions and 189 deletions

View File

@ -55,7 +55,7 @@ export function putAction(url,parameter) {
} }
//get //get
export function getAction(url,parameter) { export function getAction(url,parameter, cancelToken) {
let sign = signMd5Utils.getSign(url, parameter); let sign = signMd5Utils.getSign(url, parameter);
//将签名和时间戳,添加在请求接口 Header //将签名和时间戳,添加在请求接口 Header
// update-begin--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯 // update-begin--author:taoyan---date:20220421--for: VUEN-410【签名改造】 X-TIMESTAMP牵扯
@ -66,7 +66,8 @@ export function getAction(url,parameter) {
url: url, url: url,
method: 'get', method: 'get',
params: parameter, params: parameter,
headers: signHeader headers: signHeader,
cancelToken
}) })
} }

View File

@ -17,7 +17,7 @@ export default {
props: { props: {
value: { value: {
type: Object, type: Object,
default: () => ({ rgba: { r: 255, g: 255, b: 255 } }) required: true
} }
}, },
components: { components: {

View File

@ -1,88 +0,0 @@
<template>
<div class="custom-chart" ref="containerRef" :style="{ height: height + 'px' }"></div>
</template>
<script>
import * as echarts from 'echarts'
import 'echarts-gl'
const events = ['click', 'brushEnd']
const zrEvents = ['mousemove', 'mousedown', 'mouseup', 'click']
export default {
props: {
option: {
type: Object,
default: () => ({})
},
opts: {
type: Object,
default: () => {}
},
height: {
type: Number,
default: 0
}
},
data() {
return {}
},
mounted() {
this._chart = echarts.init(this.$refs.containerRef)
this._chart.setOption(this.option, this.opts)
this.initEventListener()
},
destroyed() {
if(this._chart) {
this._chart.dispose()
}
},
methods: {
initEventListener() {
events.forEach(eventName => {
this._chart.on(eventName, params => {
this.$emit(eventName, params)
})
})
const zr = this.getZRender()
zrEvents.forEach(eventName => {
zr.on(eventName, params => {
this.$emit(`zr:${eventName}`, params)
})
})
},
resize() {
this._chart && this._chart.resize()
},
// echart
getChartInstance() {
return this._chart
},
getZRender() {
return this._chart.getZr()
}
},
watch: {
option: {
handler() {
if (this._chart) {
this._chart.setOption(this.option, this.opts)
}
},
deep: true
},
height() {
this.$nextTick(() => {
this._chart && this._chart.resize()
})
}
}
}
</script>
<style lang="less" scoped>
.custom-chart {
height: 100% !important;
}
</style>

View File

@ -3,10 +3,10 @@
</template> </template>
<script> <script>
import * as echarts from 'echarts' import * as echarts from 'echarts'
import 'echarts-gl'
const events = ['brushEnd'] const events = ['click', 'brushEnd']
const zrEvents = ['mousemove', 'mousedown', 'mouseup', 'click'] const zrEvents = ['mousemove', 'mousedown', 'mouseup', 'click']
export default { export default {
props: { props: {
option: { option: {

View File

@ -15,7 +15,7 @@
<div class="beta-gamma-spectrum-chart-main"> <div class="beta-gamma-spectrum-chart-main">
<!-- 2D 图表为了相应Unzoom采用的v-show --> <!-- 2D 图表为了相应Unzoom采用的v-show -->
<div class="_2d-chart" v-show="active == 0"> <div class="_2d-chart" v-show="active == 0">
<Custom3DChart <CustomChart
ref="chartRef" ref="chartRef"
:option="twoDOption" :option="twoDOption"
@zr:mousemove="handleMouseMove" @zr:mousemove="handleMouseMove"
@ -33,17 +33,17 @@
<!-- 2D图表结束 --> <!-- 2D图表结束 -->
<!-- 3D Surface开始 --> <!-- 3D Surface开始 -->
<Custom3DChart v-if="active == 1" key="1" ref="_3dSurfaceRef" :option="threeDSurfaceOption" /> <CustomChart v-if="active == 1" key="1" ref="_3dSurfaceRef" :option="threeDSurfaceOption" />
<!-- 3D Surface结束 --> <!-- 3D Surface结束 -->
<!-- 3D Scatter --> <!-- 3D Scatter -->
<Custom3DChart v-if="active == 2" key="2" ref="_3dScannerRef" :option="threeDScatterOption" /> <CustomChart v-if="active == 2" key="2" ref="_3dScannerRef" :option="threeDScatterOption" />
<!-- 3D Scatter结束 --> <!-- 3D Scatter结束 -->
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import Custom3DChart from '@/components/Custom3DChart/index.vue' import CustomChart from '@/components/CustomChart/index.vue'
import ColorPalette from './ColorPalette.vue' import ColorPalette from './ColorPalette.vue'
import { getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper.js' import { getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper.js'
@ -314,7 +314,7 @@ export default {
} }
}, },
components: { components: {
Custom3DChart, CustomChart,
ColorPalette ColorPalette
}, },
data() { data() {

View File

@ -86,7 +86,7 @@ export default {
type: 'line', type: 'line',
data: pointlist.map(({ x, y }) => [x, y]), data: pointlist.map(({ x, y }) => [x, y]),
itemStyle: { itemStyle: {
color: `rgb(${color})` color
}, },
symbol: 'none', symbol: 'none',
animation: false animation: false

View File

@ -60,7 +60,7 @@
<a-button type="primary" @click="handleDel">Delete</a-button> <a-button type="primary" @click="handleDel">Delete</a-button>
</div> </div>
<div class="peak-box-item"> <div class="peak-box-item">
<a-button type="primary" @click="handleFit">Fit</a-button> <a-button type="primary" :class="{ 'is-fitting': isFitting }" @click="handleFit">Fit</a-button>
</div> </div>
<div class="peak-box-item symbol" :key="4"> <div class="peak-box-item symbol" :key="4">
@ -96,7 +96,7 @@
<a-button type="primary" :disabled="isOperationStackEmpty" @click="handleUndo">Undo</a-button> <a-button type="primary" :disabled="isOperationStackEmpty" @click="handleUndo">Undo</a-button>
</div> </div>
<div class="peak-box-item"> <div class="peak-box-item">
<a-button type="primary">Replot</a-button> <a-button type="primary" @click="handleReplot">Replot</a-button>
</div> </div>
<div class="peak-box-item"> <div class="peak-box-item">
<a-button type="primary" @click="handleAccept">Accept</a-button> <a-button type="primary" @click="handleAccept">Accept</a-button>
@ -205,6 +205,7 @@ import { buildLineSeries, findSeriesByName, getXAxisAndYAxisByPosition, rangeNum
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin' import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
import GeneralCommentModal from './components/GeneralCommentModal.vue' import GeneralCommentModal from './components/GeneralCommentModal.vue'
import EditSlopeModal from './components/EditSlopeModal.vue' import EditSlopeModal from './components/EditSlopeModal.vue'
import Response from './Response.json'
// //
const initialOption = { const initialOption = {
@ -452,6 +453,8 @@ export default {
selectedTableItem: undefined, // selectedTableItem: undefined, //
isModifying: false, // isModifying: false, //
isFitting: false, // Fit
firstFittingChannel: null, // Fitchannel
operationStack: [] // operationStack: [] //
} }
@ -475,6 +478,8 @@ export default {
fileName: this.fileName fileName: this.fileName
}) })
// const { success, result, message } = Response
if (success) { if (success) {
this.isLoading = false this.isLoading = false
const { const {
@ -504,7 +509,7 @@ export default {
buildLineSeries( buildLineSeries(
'BaseLine', 'BaseLine',
channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]), channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${channelBaseLineChart.color})`, channelBaseLineChart.color,
{ {
markLine: { markLine: {
silent: true, silent: true,
@ -528,7 +533,7 @@ export default {
buildLineSeries( buildLineSeries(
'CountChart', 'CountChart',
channelCountChart.pointlist.map(({ x, y }) => [x, y]), channelCountChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${channelCountChart.color})` channelCountChart.color
) )
) )
@ -539,7 +544,7 @@ export default {
buildLineSeries( buildLineSeries(
'Peak_' + (index + 1), 'Peak_' + (index + 1),
item.pointlist.map(({ x, y }) => [x, y]), item.pointlist.map(({ x, y }) => [x, y]),
`rgb(${item.color})` item.color
) )
) )
}) })
@ -584,25 +589,30 @@ export default {
} }
}, },
beforeModalOpen() { reset() {
const { sampleId, inputFileName } = this.sampleData
this.sampleId = sampleId
this.fileName = inputFileName
this.currChannel = undefined this.currChannel = undefined
this.btnGroupType = 1 this.btnGroupType = 1
this.getInfo()
this.opts.notMerge = false this.opts.notMerge = false
this.option.graphic = [] this.option.graphic = []
this.isFitting = false
this.$nextTick(() => { this.$nextTick(() => {
this.option.brush = { toolbox: [] } this.option.brush = { toolbox: [] }
this.selectedKeys = [] this.selectedKeys = []
}) })
}, },
beforeModalOpen() {
const { sampleId, inputFileName } = this.sampleData
this.sampleId = sampleId
this.fileName = inputFileName
this.getInfo()
this.reset()
},
// 线 // 线
handleChartClick(param) { handleChartClick(param) {
const { offsetX, offsetY } = param const { offsetX, offsetY } = param
@ -642,6 +652,43 @@ export default {
this.getSelPosNuclide(selectedRow) this.getSelPosNuclide(selectedRow)
this.selectedTableItem = selectedRow this.selectedTableItem = selectedRow
// Fit
if (this.isFitting) {
this.handleFittingChannel(xAxis)
}
}
},
// Fitchannel
handleFittingChannel(channel) {
// channel
if (this.firstFittingChannel !== null) {
// channelPeak
let left = this.firstFittingChannel
let right = channel
if (left > right) {
right = left
left = channel
}
const peaksBetweenChannel = this.list.filter(peak => {
const centroidId = peak.peakCentroid
return centroidId >= left && centroidId <= right
})
if (!peaksBetweenChannel.length) {
this.$message.warn(`There are 0 peak between channel ${left} and ${right}`)
return
}
this.fitPeaksAndBaselineModalVisible = true
this.isFitting = false
this.firstFittingChannel = null
} else {
this.firstFittingChannel = channel
} }
}, },
@ -730,6 +777,8 @@ export default {
// Insert // Insert
handleInsert() { handleInsert() {
this.isFitting = false
const xAxises = this.channelBaseCPChart.map(({ point: { x } }) => x) const xAxises = this.channelBaseCPChart.map(({ point: { x } }) => x)
const min = xAxises[0] const min = xAxises[0]
const max = xAxises[xAxises.length - 1] const max = xAxises[xAxises.length - 1]
@ -774,7 +823,7 @@ export default {
buildLineSeries( buildLineSeries(
'BaseLine', 'BaseLine',
channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]), channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${channelBaseLineChart.color})`, channelBaseLineChart.color,
{ {
markLine: { markLine: {
silent: true, silent: true,
@ -798,7 +847,7 @@ export default {
buildLineSeries( buildLineSeries(
'CountChart', 'CountChart',
this.channelCountChart.pointlist.map(({ x, y }) => [x, y]), this.channelCountChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${this.channelCountChart.color})` this.channelCountChart.color
) )
) )
@ -809,7 +858,7 @@ export default {
buildLineSeries( buildLineSeries(
'Peak_' + (index + 1), 'Peak_' + (index + 1),
item.pointlist.map(({ x, y }) => [x, y]), item.pointlist.map(({ x, y }) => [x, y]),
`rgb(${item.color})` item.color
) )
) )
}) })
@ -859,7 +908,7 @@ export default {
buildLineSeries( buildLineSeries(
'BaseLine', 'BaseLine',
this.channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]), this.channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${this.channelBaseLineChart.color})`, this.channelBaseLineChart.color,
{ {
markLine: { markLine: {
silent: true, silent: true,
@ -883,7 +932,7 @@ export default {
buildLineSeries( buildLineSeries(
'CountChart', 'CountChart',
this.channelCountChart.pointlist.map(({ x, y }) => [x, y]), this.channelCountChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${this.channelCountChart.color})` this.channelCountChart.color
) )
) )
@ -894,7 +943,7 @@ export default {
buildLineSeries( buildLineSeries(
'Peak_' + (index + 1), 'Peak_' + (index + 1),
item.pointlist.map(({ x, y }) => [x, y]), item.pointlist.map(({ x, y }) => [x, y]),
`rgb(${item.color})` item.color
) )
) )
}) })
@ -926,14 +975,21 @@ export default {
// //
handleDel() { handleDel() {
this.isFitting = false
if (!this.selectedKeys.length) { if (!this.selectedKeys.length) {
this.$message.warn('No peak to delete.') this.$message.warn('No peak to delete.')
return return
} }
this.$warning({ this.$confirm({
title: 'Warning', title: 'Warning',
content: 'Are you sure to delete this peak?', content: 'Are you sure to delete this peak?',
cancelButtonProps: {
props: {
type: 'warn'
}
},
onOk: async () => { onOk: async () => {
// this.list.splice(findIndex, 1) // this.list.splice(findIndex, 1)
// this.selectedKeys = [] // this.selectedKeys = []
@ -956,7 +1012,6 @@ export default {
curRow: this.curRow curRow: this.curRow
}) })
if (success) { if (success) {
console.log('%c [ ]-935', 'font-size:13px; background:pink; color:#bf2c9f;', result)
const { const {
allData, allData,
channelPeakChart, channelPeakChart,
@ -983,7 +1038,7 @@ export default {
buildLineSeries( buildLineSeries(
'BaseLine', 'BaseLine',
this.channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]), this.channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${this.channelBaseLineChart.color})`, this.channelBaseLineChart.color,
{ {
markLine: { markLine: {
silent: true, silent: true,
@ -1007,7 +1062,7 @@ export default {
buildLineSeries( buildLineSeries(
'CountChart', 'CountChart',
this.channelCountChart.pointlist.map(({ x, y }) => [x, y]), this.channelCountChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${this.channelCountChart.color})` this.channelCountChart.color
) )
) )
@ -1018,7 +1073,7 @@ export default {
buildLineSeries( buildLineSeries(
'Peak_' + (index + 1), 'Peak_' + (index + 1),
item.pointlist.map(({ x, y }) => [x, y]), item.pointlist.map(({ x, y }) => [x, y]),
`rgb(${item.color})` item.color
) )
) )
}) })
@ -1046,6 +1101,8 @@ export default {
this.list = table this.list = table
this.option.series = series this.option.series = series
this.selectedKeys = []
} else { } else {
this.$message.error(message) this.$message.error(message)
} }
@ -1064,10 +1121,13 @@ export default {
// //
handleFit() { handleFit() {
if (!this.list.length) { if (!this.channelPeakChart || !this.channelPeakChart.length) {
this.$message.warn('No peak to fit.') this.$message.warn('No peak to fit.')
return return
} }
this.isFitting = true
this.firstFittingChannel = null
}, },
// //
@ -1210,14 +1270,19 @@ export default {
else { else {
this.btnGroupType = 1 this.btnGroupType = 1
this.opts.notMerge = true this.opts.notMerge = true
this.option.series.splice(this.option.series.length - 1, 1) this.option.series.splice(this.option.series.length - 1, 1) // 线
this.option.graphic = [] this.option.graphic = [] //
const baseLineEditSeries = findSeriesByName(this.option.series, 'BaseLine')
baseLineEditSeries.data = this.channelBaseLineChart.pointlist.map(({ x, y }) => [x, y]) // 线
this.$nextTick(() => { this.$nextTick(() => {
this.resetChartOpts() this.resetChartOpts()
}) })
} }
this.isModifying = false this.isModifying = false
this.isFitting = false
this.clearOperationStack() this.clearOperationStack()
}, },
@ -1407,10 +1472,12 @@ export default {
// //
handleUndo() { handleUndo() {
this.setGraphicDraggable(false) this.setGraphicDraggable(false)
this.popOperationStack() this.popOperationStack()
}, },
// 线
handleReplot() {},
// Baseline Control Points // Baseline Control Points
handleAccept() {}, handleAccept() {},
@ -1704,7 +1771,8 @@ export default {
} }
} }
.is-modify { .is-modify,
.is-fitting {
color: #f00; color: #f00;
} }
</style> </style>

View File

@ -1,66 +1,69 @@
<template> <template>
<custom-modal v-model="visible" :width="700" title="Color Config"> <custom-modal v-model="visible" :width="700" title="Color Config" :okHandler="handleApply">
<div class="color-config"> <a-spin :spinning="isLoading">
<div class="color-config-item" v-for="(item, index) in configList" :key="index"> <div class="color-config">
<div class="title">{{ item.title }}</div> <div class="color-config-item" v-for="(item, index) in configList" :key="index">
<color-picker v-model="config[item.key]"> <div class="title">{{ item.title }}</div>
<div class="color-picker-picker" :style="{ background: combineRGBA(config[item.key]) }"></div> <color-picker v-model="config[item.key]">
</color-picker> <div class="color-picker-picker" :style="{ background: combineRGBA(config[item.key]) }"></div>
</color-picker>
<div class="desc">{{ item.desc }}</div> <div class="desc">{{ item.desc }}</div>
</div>
</div> </div>
</div> </a-spin>
</custom-modal> </custom-modal>
</template> </template>
<script> <script>
import ModalMixin from '@/mixins/ModalMixin' import ModalMixin from '@/mixins/ModalMixin'
import ColorPicker from '@/components/ColorPicker/index.vue' import ColorPicker from '@/components/ColorPicker/index.vue'
import { getAction, putAction } from '@/api/manage'
const configList = [ const configList = [
{ {
title: 'Spectrum Line', title: 'Spectrum Line',
key: 'spectrumLine', key: 'Color_Spec',
desc: 'Color of the original spectrum line' desc: 'Color of the original spectrum line'
}, },
{ {
title: 'Baseline', title: 'Baseline',
key: 'baseline', key: 'Color_Base',
desc: 'Color of baseline' desc: 'Color of baseline'
}, },
{ {
title: 'Lc Line', title: 'Lc Line',
key: 'lcLine', key: 'Color_Lc',
desc: 'Color of lc line' desc: 'Color of lc line'
}, },
{ {
title: 'Scac Line', title: 'Scac Line',
key: 'scacLine', key: 'Color_Scac',
desc: 'Color of scac line' desc: 'Color of scac line'
}, },
{ {
title: 'Peak Line', title: 'Peak Line',
key: 'peakLine', key: 'Color_Peak',
desc: "Color of all peaks' curve" desc: "Color of all peaks' curve"
}, },
{ {
title: 'Compare Line', title: 'Compare Line',
key: 'compareLine', key: 'Color_Compare',
desc: 'Color of another spectrum line which is used to compare with current spectrum' desc: 'Color of another spectrum line which is used to compare with current spectrum'
}, },
{ {
title: 'Spect Sum Line', title: 'Spec Sum Line',
key: 'spectSumLine', key: 'Color_Strip',
desc: 'Color of the line which is the sum of current spectrum and other spectrum Multiplied by a ratio' desc: 'Color of the line which is the sum of current spectrum and other spectrum Multiplied by a ratio'
}, },
{ {
title: 'Spect Cut Line', title: 'Spec Cut Line',
key: 'spectCutLine', key: 'spectCutLine',
desc: 'Color of the line which is the difference of current spectrum and other spectrum Multiplied by a ratio' desc: 'Color of the line which is the difference of current spectrum and other spectrum Multiplied by a ratio'
}, },
{ {
title: 'FitBase Line', title: 'FitBase Line',
key: 'fitBaseLine', key: 'Color_Fitbase',
desc: 'Color of the base line in edit state' desc: 'Color of the base line in edit state'
} }
] ]
@ -73,21 +76,79 @@ export default {
this.configList = configList this.configList = configList
return { return {
config: { config: {
spectrumLine: { rgba: { r: 255, g: 255, b: 0 } }, Color_Spec: { hex: 'yellow' }, // Spectrum
baseline: { rgba: { r: 0, g: 246, b: 255 } }, Color_Base: { hex: 'rgb(0, 246, 255)' }, // 线
lcLine: { rgba: { r: 255, g: 0, b: 0 } }, Color_Lc: { hex: 'red' }, // LC
scacLine: { rgba: { r: 244, g: 112, b: 247 } }, Color_Scac: { hex: 'rgb(244, 112, 247)' }, // Scac
peakLine: { rgba: { r: 255, g: 127, b: 39 } }, Color_Peak: { hex: 'rgb(255, 127, 39)' }, // Peak
compareLine: { rgba: { r: 0, g: 255, b: 0 } }, Color_Compare: { hex: 'green' }, // Sample -> Compare
spectSumLine: { rgba: { r: 0, g: 0, b: 255 } }, Color_Strip: { hex: 'rgb(0, 0, 255)' }, // Sample -> Compare
spectCutLine: { rgba: { r: 34, g: 90, b: 106 } }, spectCutLine: { hex: 'rgb(33, 90, 104)' }, //
fitBaseLine: { rgba: { r: 255, g: 255, b: 255 } } Color_Fitbase: { hex: 'white' } // Interactive Tool BaseLine线
} }
} }
}, },
methods: { methods: {
combineRGBA({ rgba: { r, g, b} }) { combineRGBA({ hex }) {
return `rgb(${r}, ${g}, ${b})` return hex
},
async getData() {
try {
this.isLoading = true
const { success, result, message } = await getAction('/gamma/viewColorConfig')
if (success) {
Object.entries(result).forEach(([k, v]) => {
this.config[k].hex = v
})
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
} finally {
this.isLoading = false
}
},
beforeModalOpen() {
this.getData()
},
//
async handleApply() {
const {
Color_Spec,
Color_Peak,
Color_Lc,
Color_Base,
Color_Scac,
Color_Compare,
Color_Strip,
Color_Fitbase
} = this.config
const { success, message } = await putAction('/gamma/updateColorConfig', {
colorSpec: Color_Spec.hex,
colorPeak: Color_Peak.hex,
colorLc: Color_Lc.hex,
colorBase: Color_Base.hex,
colorScac: Color_Scac.hex,
colorCompare: Color_Compare.hex,
colorFitbase: Color_Fitbase.hex,
colorStrip: Color_Strip.hex
})
if (success) {
this.$bus.$emit(
'colorChange',
Object.entries(this.config).reduce((prev, [key, value]) => {
prev[key] = value.hex
return prev
}, {})
)
} else {
this.$message.error(message)
throw new Error(message)
}
} }
} }
} }
@ -119,4 +180,9 @@ export default {
} }
} }
} }
.footer {
display: flex;
justify-content: space-between;
}
</style> </style>

View File

@ -305,7 +305,7 @@ export default {
buildLineSeries( buildLineSeries(
'LineSeries', 'LineSeries',
linePoint.pointlist.map(({ x, y }) => [x, y]), linePoint.pointlist.map(({ x, y }) => [x, y]),
`rgb(${linePoint.color})` linePoint.color
) )
) )
series.push({ series.push({

View File

@ -266,7 +266,7 @@ export default {
buildLineSeries( buildLineSeries(
'LineSeries', 'LineSeries',
linePoint.pointlist.map(({ x, y }) => [x, y]), linePoint.pointlist.map(({ x, y }) => [x, y]),
`rgb(${linePoint.color})` linePoint.color
) )
) )
series.push({ series.push({

View File

@ -266,7 +266,7 @@ export default {
buildLineSeries( buildLineSeries(
'LineSeries', 'LineSeries',
linePoint.pointlist.map(({ x, y }) => [x, y]), linePoint.pointlist.map(({ x, y }) => [x, y]),
`rgb(${linePoint.color})` linePoint.color
) )
) )
series.push({ series.push({

View File

@ -20,6 +20,8 @@
</template> </template>
<script> <script>
import { cloneDeep } from 'lodash'
const items = [ const items = [
{ {
label: ['Linear', 'Log10'], label: ['Linear', 'Log10'],
@ -56,7 +58,7 @@ const items = [
export default { export default {
data() { data() {
return { return {
items items: cloneDeep(items)
} }
}, },
methods: { methods: {

View File

@ -32,9 +32,10 @@
<!-- 主体部分 --> <!-- 主体部分 -->
<div class="gamma-analysis-main"> <div class="gamma-analysis-main">
<div class="gamma-analysis-chart"> <div class="gamma-analysis-chart">
<custom-3d-chart <CustomChart
ref="chartRef" ref="chartRef"
:option="option" :option="option"
:opts="opts"
@zr:click="handleChartClick" @zr:click="handleChartClick"
@zr:mousedown="handleMouseDown" @zr:mousedown="handleMouseDown"
@zr:mouseup="handleMouseUp" @zr:mouseup="handleMouseUp"
@ -43,7 +44,7 @@
/> />
<!-- 右上角缩略图 --> <!-- 右上角缩略图 -->
<div class="gamma-analysis-thumbnail"> <div class="gamma-analysis-thumbnail">
<custom-3d-chart <CustomChart
ref="thumbnailChartRef" ref="thumbnailChartRef"
:option="thumbnailOption" :option="thumbnailOption"
@zr:click="handleThumbnailChartClick" @zr:click="handleThumbnailChartClick"
@ -72,7 +73,7 @@
</template> </template>
<script> <script>
import Custom3dChart from '@/components/Custom3DChart/index.vue' import CustomChart from '@/components/CustomChart/index.vue'
import PopOverWithIcon from './components/SubOperators/PopOverWithIcon.vue' import PopOverWithIcon from './components/SubOperators/PopOverWithIcon.vue'
import DetailedInfomation from './components/SubOperators/DetailedInfomation.vue' import DetailedInfomation from './components/SubOperators/DetailedInfomation.vue'
import QcFlags from './components/SubOperators/QcFlags.vue' import QcFlags from './components/SubOperators/QcFlags.vue'
@ -81,8 +82,9 @@ import NuclearLibrary from './components/SubOperators/NuclearLibrary.vue'
import ButtonWithSwitchIcon from './components/SubOperators/ButtonWithSwitchIcon.vue' import ButtonWithSwitchIcon from './components/SubOperators/ButtonWithSwitchIcon.vue'
import { getAction } from '@/api/manage' import { getAction } from '@/api/manage'
import Response from './response.json' import Response from './response.json'
import { buildLineSeries, getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper' import { buildLineSeries, findSeriesByName, getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import axios from 'axios'
// //
const initialOption = { const initialOption = {
@ -225,6 +227,13 @@ const thumbnailOption = {
series: [] series: []
} }
const graphAssistance = {
axisType: 'Channel',
Baseline: true,
SCAC: true,
Lc: true
}
export default { export default {
props: { props: {
sample: { sample: {
@ -232,7 +241,7 @@ export default {
} }
}, },
components: { components: {
Custom3dChart, CustomChart,
PopOverWithIcon, PopOverWithIcon,
DetailedInfomation, DetailedInfomation,
QcFlags, QcFlags,
@ -244,11 +253,14 @@ export default {
return { return {
isLoading: false, isLoading: false,
option: cloneDeep(initialOption), option: cloneDeep(initialOption),
opts: {
notMerge: false
},
thumbnailOption: cloneDeep(thumbnailOption), thumbnailOption: cloneDeep(thumbnailOption),
detailedInfomation: [], detailedInfomation: [],
qcFlags: [], qcFlags: [],
graphAssistance: {}, graphAssistance: cloneDeep(graphAssistance),
channelPeakGroup: [], channelPeakGroup: [],
energyPeakGroup: [], energyPeakGroup: [],
@ -265,6 +277,16 @@ export default {
}, },
created() { created() {
this.option.title.text = '{a|Channel:0} {a|Energy:0} {a|Counts:0} {a|Detectability:0}' this.option.title.text = '{a|Channel:0} {a|Energy:0} {a|Counts:0} {a|Detectability:0}'
this.$bus.$on('colorChange', colorConfig => {
//
if (this.isLoading) {
this.getSampleDetail()
}
//
else {
this.changeColor(colorConfig)
}
})
}, },
mounted() { mounted() {
this.option.brush = { toolbox: [] } this.option.brush = { toolbox: [] }
@ -274,13 +296,27 @@ export default {
const { dbName, sampleId } = this.sample const { dbName, sampleId } = this.sample
try { try {
this.isLoading = true this.isLoading = true
this.option.series = []
this.thumbnailOption.series = [] this.reset()
// const { success, result, message } = Response // const { success, result, message } = Response
const { success, result, message } = await getAction('/gamma/gammaByDB', {
dbName, if (this._cancelToken && typeof this._cancelToken == 'function') {
sampleId this._cancelToken()
}
const cancelToken = new axios.CancelToken(c => {
this._cancelToken = c
}) })
const { success, result, message } = await getAction(
'/gamma/gammaByDB',
{
dbName,
sampleId
},
cancelToken
)
console.log('%c [ result ]-243', 'font-size:13px; background:pink; color:#bf2c9f;', result) console.log('%c [ result ]-243', 'font-size:13px; background:pink; color:#bf2c9f;', result)
if (success) { if (success) {
this.isLoading = false this.isLoading = false
@ -357,7 +393,7 @@ export default {
buildLineSeries( buildLineSeries(
'Spectrum', 'Spectrum',
shadowChannelChart.pointlist.map(({ x, y }) => [x, y]), shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${shadowChannelChart.color})`, shadowChannelChart.color,
{ {
markLine: { markLine: {
silent: true, silent: true,
@ -380,7 +416,7 @@ export default {
buildLineSeries( buildLineSeries(
'Spectrum', 'Spectrum',
shadowChannelChart.pointlist.map(({ x, y }) => [x, y]), shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
`rgb(${shadowChannelChart.color})`, shadowChannelChart.color,
{ {
silent: true, silent: true,
markLine: { markLine: {
@ -405,7 +441,7 @@ export default {
buildLineSeries( buildLineSeries(
'BaseLine', 'BaseLine',
channelBaseLine.pointlist.map(({ x, y }) => [x, y]), channelBaseLine.pointlist.map(({ x, y }) => [x, y]),
`rgb(${channelBaseLine.color})`, channelBaseLine.color,
{ {
zlevel: 2 zlevel: 2
} }
@ -417,7 +453,7 @@ export default {
buildLineSeries( buildLineSeries(
'LcLine', 'LcLine',
channelLcLine.pointlist.map(({ x, y }) => [x, y]), channelLcLine.pointlist.map(({ x, y }) => [x, y]),
`rgb(${channelLcLine.color})`, channelLcLine.color,
{ {
zlevel: 3 zlevel: 3
} }
@ -429,7 +465,7 @@ export default {
buildLineSeries( buildLineSeries(
'ScacLine', 'ScacLine',
channelScacLine.pointlist.map(({ x, y }) => [x, y]), channelScacLine.pointlist.map(({ x, y }) => [x, y]),
`rgb(${channelScacLine.color})`, channelScacLine.color,
{ {
zlevel: 4 zlevel: 4
} }
@ -464,7 +500,7 @@ export default {
buildLineSeries( buildLineSeries(
`Peak_${index}`, `Peak_${index}`,
item.pointlist.map(({ x, y }) => [x, y]), item.pointlist.map(({ x, y }) => [x, y]),
`rgb(${item.color})`, item.color,
{ {
zlevel: 6 zlevel: 6
} }
@ -586,7 +622,7 @@ export default {
// seriesName线 // seriesName线
redrawLineBySeriesName(seriesName, energyData, channelData, isShow = true) { redrawLineBySeriesName(seriesName, energyData, channelData, isShow = true) {
const series = this.findSeriesByName(seriesName) const series = findSeriesByName(this.option.series, seriesName)
if (isShow) { if (isShow) {
const data = this.isEnergy() ? energyData : channelData const data = this.isEnergy() ? energyData : channelData
series.data = data.pointlist.map(({ x, y }) => [x, y]) series.data = data.pointlist.map(({ x, y }) => [x, y])
@ -597,7 +633,7 @@ export default {
// //
redrawCtrlPointBySeriesName() { redrawCtrlPointBySeriesName() {
const series = this.findSeriesByName('BaseLine_Ctrl_Point') const series = findSeriesByName(this.option.series, 'BaseLine_Ctrl_Point')
const data = this.isEnergy() ? this.shapeEnergyData : this.shapeChannelData const data = this.isEnergy() ? this.shapeEnergyData : this.shapeChannelData
series.data = data.map(({ size, color, point: { x, y } }) => { series.data = data.map(({ size, color, point: { x, y } }) => {
return { return {
@ -614,7 +650,7 @@ export default {
// Peak Line // Peak Line
redrawPeakLine() { redrawPeakLine() {
this.option.series = this.option.series.filter(item => { this.option.series = this.option.series.filter(item => {
return -1 == item.name.indexOf('Peak_') return -1 == item.name.includes('Peak_')
}) })
const data = this.isEnergy() ? this.energyPeakGroup : this.channelPeakGroup const data = this.isEnergy() ? this.energyPeakGroup : this.channelPeakGroup
@ -624,7 +660,7 @@ export default {
buildLineSeries( buildLineSeries(
`Peak_${index}`, `Peak_${index}`,
item.pointlist.map(({ x, y }) => [x, y]), item.pointlist.map(({ x, y }) => [x, y]),
`rgb(${item.color})`, item.color,
{ {
zlevel: 6 zlevel: 6
} }
@ -705,7 +741,6 @@ export default {
const min = Math.min(...allX) const min = Math.min(...allX)
return channel >= min && channel <= max return channel >= min && channel <= max
}) })
console.log('%c [ index ]-732', 'font-size:13px; background:pink; color:#bf2c9f;', index)
if (-1 !== index) { if (-1 !== index) {
this.getPeakInfo(index) this.getPeakInfo(index)
} else { } else {
@ -731,7 +766,6 @@ export default {
const chart = this.$refs.chartRef.getChartInstance() const chart = this.$refs.chartRef.getChartInstance()
const [xPix, yPix] = chart.convertToPixel({ seriesIndex: 0 }, [x, y]) const [xPix, yPix] = chart.convertToPixel({ seriesIndex: 0 }, [x, y])
console.log('%c [ xPix, yPix ]-731', 'font-size:13px; background:pink; color:#bf2c9f;', xPix, yPix)
this.peakInfomationTooltip.content = html this.peakInfomationTooltip.content = html
this.peakInfomationTooltip.visible = true this.peakInfomationTooltip.visible = true
this.peakInfomationTooltip.left = xPix this.peakInfomationTooltip.left = xPix
@ -952,7 +986,6 @@ export default {
// //
refresh(data) { refresh(data) {
console.log('%c [ data ]-892', 'font-size:13px; background:pink; color:#bf2c9f;', data)
const { allData, shadowChannelChart, shadowEnergyChart, shapeChannelData, shapeEnergyData } = data const { allData, shadowChannelChart, shadowEnergyChart, shapeChannelData, shapeEnergyData } = data
const channelPeakGroup = allData.filter(item => item.name == 'Peak' && item.group == 'channel') const channelPeakGroup = allData.filter(item => item.name == 'Peak' && item.group == 'channel')
@ -994,6 +1027,7 @@ export default {
this.shapeChannelData = shapeChannelData this.shapeChannelData = shapeChannelData
this.shapeEnergyData = shapeEnergyData this.shapeEnergyData = shapeEnergyData
this.opts.notMerge = true
this.redrawPeakLine() this.redrawPeakLine()
this.redrawCtrlPointBySeriesName() this.redrawCtrlPointBySeriesName()
@ -1003,11 +1037,15 @@ export default {
this.redrawLineBySeriesName('Spectrum', this.shadowEnergyChart, this.shadowChannelChart) this.redrawLineBySeriesName('Spectrum', this.shadowEnergyChart, this.shadowChannelChart)
this.redrawThumbnailChart() this.redrawThumbnailChart()
this.$nextTick(() => {
this.resetChartOpts()
})
}, },
// nameseries //
findSeriesByName(seriesName) { resetChartOpts() {
return this.option.series.find(item => item.name == seriesName) this.opts.notMerge = false
this.option.brush = { toolbox: [] }
}, },
/** /**
@ -1048,6 +1086,77 @@ export default {
this.selectedChannel = -1 this.selectedChannel = -1
this.nuclideLibraryList = [] this.nuclideLibraryList = []
this.closePeakInfomationTooltip() this.closePeakInfomationTooltip()
this.option.series = []
this.thumbnailOption.series = []
this.option.xAxis.name = 'Channel'
this.option.yAxis.type = 'value'
if (this.option.series.length) {
this.option.series[0].type = 'line'
this.option.series[0].symbol = 'none'
this.option.series[0].markLine.lineStyle.width = 2
}
if (this.thumbnailOption.series.length) {
this.thumbnailOption.series[0].type = 'line'
this.thumbnailOption.series[0].symbol = 'none'
}
this.graphAssistance = cloneDeep(graphAssistance)
},
//
changeColor(colorConfig) {
const {
Color_Spec,
Color_Peak,
Color_Lc,
Color_Base,
Color_Scac,
Color_Compare,
Color_Strip,
Color_Fitbase
} = colorConfig
this.shadowChannelChart.color = Color_Spec
this.shadowEnergyChart.color = Color_Spec
for (let i = 0; i < this.channelPeakGroup.length; i++) {
this.channelPeakGroup[i].color = Color_Peak
this.energyPeakGroup[i].color = Color_Peak
}
this.channelLcLine.color = Color_Lc
this.energyLcLine.color = Color_Lc
this.channelBaseLine.color = Color_Base
this.energyBaseLine.color = Color_Base
this.channelScacLine.color = Color_Scac
this.energyScacLine.color = Color_Scac
this.changeColorBySeriesName('Spectrum', Color_Spec)
this.changePeakLineColor(Color_Peak)
this.changeColorBySeriesName('LcLine', Color_Lc)
this.changeColorBySeriesName('BaseLine', Color_Base)
this.changeColorBySeriesName('ScacLine', Color_Scac)
const thumbnailChartSeries = findSeriesByName(this.thumbnailOption.series, 'Spectrum')
thumbnailChartSeries.itemStyle.color = Color_Spec
},
// series
changeColorBySeriesName(seriesName, color) {
const series = findSeriesByName(this.option.series, seriesName)
series.itemStyle.color = color
},
// Peak
changePeakLineColor(color) {
this.option.series
.filter(item => item.name.includes('Peak_'))
.forEach(item => {
item.itemStyle.color = color
})
}, },
isEnergy() { isEnergy() {
@ -1057,7 +1166,6 @@ export default {
watch: { watch: {
sample: { sample: {
handler() { handler() {
this.reset()
this.getSampleDetail() this.getSampleDetail()
}, },
immediate: true immediate: true