feat: 完成BaseLine、Lc Line、Scac Line绘制,完成刷选及点击右上角小图表的交互,对接Configure接口

This commit is contained in:
Xu Zhimeng 2023-08-16 18:20:19 +08:00
parent f1d02d2dc0
commit 651c72320e
4 changed files with 688224 additions and 45 deletions

View File

@ -13,42 +13,42 @@
<a-form-model :colon="false" :labelCol="{ style: { width: '160px' } }">
<a-form-model-item label="ECutAnalysis_Low">
<div class="input-with-unit">
<a-input></a-input>
<a-input-number v-model="model.edit_ps_low"></a-input-number>
KeV
</div>
</a-form-model-item>
<a-form-model-item label="ECutAnalysis_High">
<div class="input-with-unit">
<a-input></a-input>
<a-input-number v-model="model.edit_ps_high"></a-input-number>
KeV
</div>
</a-form-model-item>
<a-form-model-item label="EnergyTolerance">
<div class="input-with-unit">
<a-input></a-input>
<a-input-number v-model="model.edit_energy"></a-input-number>
KeV
</div>
</a-form-model-item>
<a-form-model-item label="PSS_low">
<a-input></a-input>
<a-input-number v-model="model.edit_pss_low"></a-input-number>
</a-form-model-item>
</a-form-model>
</title-over-border>
<title-over-border title="Calibration Peak Searching">
<a-form-model :colon="false" :labelCol="{ style: { width: '170px' } }">
<a-form-model-item label="CalibrationPSS_low">
<a-input></a-input>
<a-input-number v-model="model.edit_cal_low" disabled></a-input-number>
</a-form-model-item>
<a-form-model-item label="CalibrationPSS_high">
<a-input></a-input>
<a-input-number v-model="model.edit_cal_high" disabled></a-input-number>
</a-form-model-item>
<a-form-model-item>
<a-checkbox>
<a-checkbox v-model="model.checkBox_updateCal" disabled>
Update Calibration
</a-checkbox>
</a-form-model-item>
<a-form-model-item>
<a-checkbox>
<a-checkbox v-model="model.checkBox_keepPeak" disabled>
Keep Calibration Peak Search Peaks
</a-checkbox>
</a-form-model-item>
@ -61,13 +61,13 @@
<title-over-border title="Baseline Param">
<a-form-model :colon="false" :labelCol="{ style: { width: '90px' } }">
<a-form-model-item label="k_back">
<a-input></a-input>
<a-input-number v-model="model.edit_k_back"></a-input-number>
</a-form-model-item>
<a-form-model-item label="k_alpha">
<a-input></a-input>
<a-input-number v-model="model.edit_k_alpha"></a-input-number>
</a-form-model-item>
<a-form-model-item label="k_beta">
<a-input></a-input>
<a-input-number v-model="model.edit_k_beta"></a-input-number>
</a-form-model-item>
</a-form-model>
</title-over-border>
@ -75,12 +75,12 @@
<a-form-model :colon="false" :labelCol="{ style: { width: '150px' } }">
<title-over-border title="BaseImprove">
<a-form-model-item label="BaseImprovePSS">
<a-input></a-input>
<a-input-number v-model="model.edit_bi_pss"></a-input-number>
</a-form-model-item>
</title-over-border>
<title-over-border title="LC Computing" style="margin-top: 20px">
<a-form-model-item label="RiskLevelK">
<a-input></a-input>
<a-input-number v-model="model.edit_riskLevelK"></a-input-number>
</a-form-model-item>
</title-over-border>
</a-form-model>
@ -90,12 +90,17 @@
<!-- 第三行 -->
<div class="analysis-settings-item">
<title-over-border title="Activity Reference Time">
<custom-date-picker show-time v-model="formModel.activityReferenceTime"></custom-date-picker>
<custom-date-picker show-time v-model="model.dateTime_Act"></custom-date-picker>
</title-over-border>
<title-over-border title="Concentration Reference Time">
<custom-date-picker show-time v-model="formModel.concentrationReferenceTime"></custom-date-picker>
<custom-date-picker show-time v-model="model.dateTime_Conc"></custom-date-picker>
</title-over-border>
</div>
<!-- 第四行 -->
<div class="analysis-settings-item">
<a-checkbox v-model="model.group_calPS">Apply to All Spectrums</a-checkbox>
</div>
</a-spin>
</custom-modal>
</template>
@ -117,21 +122,24 @@ export default {
data() {
return {
isLoading: false,
formModel: {
activityReferenceTime: undefined,
concentrationReferenceTime: undefined
}
model: {}
}
},
methods: {
async getInfo() {
try {
this.isLoading = true
const res = await getAction('/gamma/configure', {
const { success, result, message } = await getAction('/gamma/configure', {
sampleId: this.sampleId
})
this.isLoading = false
console.log('%c [ ]-128', 'font-size:13px; background:pink; color:#bf2c9f;', res)
if (success) {
this.model = result
console.log('%c [ ]-137', 'font-size:13px; background:pink; color:#bf2c9f;', result)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
@ -188,15 +196,11 @@ export default {
}
}
.ant-input {
height: 26px;
}
.input-with-unit {
display: flex;
align-items: center;
.ant-input {
.ant-input-number {
margin-right: 10px;
}
}

View File

@ -50,7 +50,7 @@ const items = [
},
{
label: ['SCAC'],
checked: false
checked: true
}
]
export default {
@ -81,7 +81,9 @@ export default {
})
},
handleReset() {}
handleReset() {
this.$emit('reset')
}
}
}
</script>

View File

@ -13,7 +13,7 @@
</pop-over-with-icon>
<pop-over-with-icon>
Graph Assistance
<graph-assistance slot="content" @change="handleGraphAssistanceChange" />
<graph-assistance slot="content" @change="handleGraphAssistanceChange" @reset="handleReset" />
</pop-over-with-icon>
<pop-over-with-icon>
Nuclide Library
@ -29,10 +29,23 @@
<!-- 主体部分 -->
<div class="gamma-analysis-main">
<div class="gamma-analysis-chart">
<custom-chart ref="chartRef" :option="option" @zr:click="handleChartClick" style="height: 100%" />
<custom-chart
ref="chartRef"
:option="option"
@zr:click="handleChartClick"
@zr:mousedown="handleMouseDown"
@zr:mouseup="handleMouseUp"
@brushEnd="handleBrushEnd"
style="height: 100%"
/>
<div class="gamma-analysis-thumbnail">
<custom-chart ref="thumbnailChartRef" :option="thumbnailOption" style="height: 100%" />
<custom-chart
ref="thumbnailChartRef"
:option="thumbnailOption"
@zr:click="handleThumbnailChartClick"
style="height: 100%"
/>
</div>
</div>
</div>
@ -112,7 +125,9 @@ const initialOption = {
color: '#ade6ee'
}
},
boundaryGap: false
min: 0,
max: 'dataMax',
animation: false
},
yAxis: {
name: 'Counts',
@ -136,9 +151,13 @@ const initialOption = {
textStyle: {
color: '#ade6ee'
}
}
},
min: 0,
max: 'dataMax',
animation: false
},
series: []
series: [],
brush: {}
}
//
@ -159,7 +178,9 @@ const thumbnailOption = {
},
axisLabel: {
show: false
}
},
min: 0,
max: 'dataMax'
},
yAxis: {
axisLine: {
@ -240,7 +261,6 @@ export default {
shapeEnergyData
} = result
console.log('%c [ ]-258', 'font-size:13px; background:pink; color:#bf2c9f;', result)
this.detailedInfomation = DetailedInformation
this.qcFlags = QCFlag
@ -248,6 +268,15 @@ export default {
const channelPeakGroup = allData.filter(item => item.name == 'Peak' && item.group == 'channel')
const energyPeakGroup = allData.filter(item => item.name == 'Peak' && item.group == 'energy')
const channelBaseLine = allData.find(item => item.name == 'BaseLine' && item.group == 'channel')
const energyBaseLine = allData.find(item => item.name == 'BaseLine' && item.group == 'energy')
const channelLcLine = allData.find(item => item.name == 'Lc' && item.group == 'channel')
const energyLcLine = allData.find(item => item.name == 'Lc' && item.group == 'energy')
const channelScacLine = allData.find(item => item.name == 'Scac' && item.group == 'channel')
const energyScacLine = allData.find(item => item.name == 'Scac' && item.group == 'energy')
// Peak Line
this.channelPeakGroup = channelPeakGroup
this.energyPeakGroup = energyPeakGroup
@ -256,10 +285,24 @@ export default {
this.shadowChannelChart = shadowChannelChart
this.shadowEnergyChart = shadowEnergyChart
// 线
this.channelBaseLine = channelBaseLine
this.energyBaseLine = energyBaseLine
// Lc
this.channelLcLine = channelLcLine
this.energyLcLine = energyLcLine
// Scac
this.channelScacLine = channelScacLine
this.energyScacLine = energyScacLine
// 线
this.shapeChannelData = shapeChannelData
this.shapeEnergyData = shapeEnergyData
this.option.yAxis.max = Math.ceil(Math.max(...shadowChannelChart.pointlist.map(item => item.y)) * 1.1)
// Spectrum Line
this.option.series.push({
name: 'Spectrum',
@ -291,6 +334,7 @@ export default {
zlevel: 0
})
// Spectrum Line
this.thumbnailOption.series.push({
name: 'Spectrum',
type: 'line',
@ -306,6 +350,7 @@ export default {
emphasis: {
disabled: true
},
silent: true,
markLine: {
silent: true,
symbol: 'none',
@ -313,10 +358,11 @@ export default {
show: false
},
lineStyle: {
color: 'red',
type: 'solid',
color: '#1397a3',
width: 2
},
data: [{ xAxis: -1 }]
data: []
},
zlevel: 0
})
@ -338,6 +384,57 @@ export default {
}
})
// 线
this.option.series.push({
name: 'BaseLine',
type: 'line',
data: channelBaseLine.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${channelBaseLine.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
emphasis: {
disabled: true
}
})
// LC线
this.option.series.push({
name: 'LcLine',
type: 'line',
data: channelLcLine.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${channelLcLine.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
emphasis: {
disabled: true
}
})
// Scac线
this.option.series.push({
name: 'ScacLine',
type: 'line',
data: channelScacLine.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${channelScacLine.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
emphasis: {
disabled: true
}
})
// 线
this.option.series.push({
name: 'BaseLine_Ctrl_Point',
@ -355,7 +452,8 @@ export default {
emphasis: {
disabled: true
},
z: 3
z: 3,
animation: false
})
// Peak Line
@ -370,7 +468,8 @@ export default {
lineStyle: {
width: 1
},
symbol: 'none'
symbol: 'none',
animation: false
})
})
} else {
@ -391,10 +490,9 @@ export default {
case 'Log10':
break
case 'Channel':
this.option.xAxis.name = label
break
case 'Energy':
this.option.xAxis.name = label
this.graphAssistance.type = type
break
case 'Lines':
this.option.series[0].type = 'line'
@ -408,7 +506,6 @@ export default {
}
//
else if (type == 'valueChange') {
console.log('%c [ ]-315', 'font-size:13px; background:pink; color:#bf2c9f;', label, value)
this.graphAssistance[label] = value
switch (label) {
@ -420,6 +517,42 @@ export default {
this.option.series[0].markLine.lineStyle.width = 0
}
break
case 'Baseline':
const baseLineSeries = this.findSeriesByName('BaseLine')
if (value) {
if (this.graphAssistance.type == 'Energy') {
baseLineSeries.data = this.energyBaseLine.pointlist.map(({ x, y }) => [x, y])
} else {
baseLineSeries.data = this.channelBaseLine.pointlist.map(({ x, y }) => [x, y])
}
} else {
baseLineSeries.data = []
}
break
case 'Lc':
const lcLineSeries = this.findSeriesByName('LcLine')
if (value) {
if (this.graphAssistance.type == 'Energy') {
lcLineSeries.data = this.energyLcLine.pointlist.map(({ x, y }) => [x, y])
} else {
lcLineSeries.data = this.channelLcLine.pointlist.map(({ x, y }) => [x, y])
}
} else {
lcLineSeries.data = []
}
break
case 'SCAC':
const scacLineSeries = this.findSeriesByName('ScacLine')
if (value) {
if (this.graphAssistance.type == 'Energy') {
scacLineSeries.data = this.energyScacLine.pointlist.map(({ x, y }) => [x, y])
} else {
scacLineSeries.data = this.channelScacLine.pointlist.map(({ x, y }) => [x, y])
}
} else {
scacLineSeries.data = []
}
break
}
}
},
@ -470,7 +603,183 @@ export default {
this.option.series[0].markLine.data[0].xAxis = find
}
}
}
},
//
handleMouseDown() {
const chart = this.$refs.chartRef.getChartInstance()
chart.dispatchAction({
type: 'takeGlobalCursor',
//
key: 'brush',
brushOption: {
// brush brushType false
brushType: 'rect'
}
})
},
handleMouseUp() {
setTimeout(() => {
const chart = this.$refs.chartRef.getChartInstance()
this.clearBrush(chart)
}, 0)
},
clearBrush(chart) {
//
chart.dispatchAction({
type: 'brush',
areas: []
})
//
chart.dispatchAction({
type: 'takeGlobalCursor'
})
},
//
handleBrushEnd(param) {
const chart = this.$refs.chartRef.getChartInstance()
const areas = param.areas[0]
if (areas) {
const range = areas.range
const [[minX, maxX], [minY, maxY]] = range
const point1 = chart.convertFromPixel({ seriesIndex: 0 }, [minX, minY]).map(num => parseInt(num.toFixed()))
const point2 = chart.convertFromPixel({ seriesIndex: 0 }, [maxX, maxY]).map(num => parseInt(num.toFixed()))
const xAxisMax = chart.getModel().getComponent('xAxis').axis.scale._extent[1]
const yAxisMax = chart.getModel().getComponent('yAxis').axis.scale._extent[1]
let [x1, y2, x2, y1] = [...point1, ...point2] //
const xAxisLimit = this.rangeNumber(0, xAxisMax)
const yAxisLimit = this.rangeNumber(0, yAxisMax)
x1 = xAxisLimit(x1)
x2 = xAxisLimit(x2)
y1 = yAxisLimit(y1)
y2 = yAxisLimit(y2)
this.option.xAxis.min = x1
this.option.xAxis.max = x2
this.option.yAxis.min = y1
this.option.yAxis.max = y2
this.setThumbnailChartRect(x1, y2, x2, y1)
}
this.clearBrush(chart)
},
//
setThumbnailChartRect(x1, y2, x2, y1) {
this.thumbnailChartRect = [x1, y2, x2, y1]
const { markLine } = this.thumbnailOption.series[0]
const pointList = [
[
[x1, y1],
[x2, y1]
],
[
[x2, y1],
[x2, y2]
],
[
[x2, y2],
[x1, y2]
],
[
[x1, y2],
[x1, y1]
]
]
const lines = pointList.map(point => {
return this.generateLineDataByTwoPoints(point[0], point[1])
})
markLine.data = lines
},
//
handleThumbnailChartClick(param) {
const { offsetX, offsetY } = param
const thumbnailChart = this.$refs.thumbnailChartRef.getChartInstance()
const point = getXAxisAndYAxisByPosition(thumbnailChart, offsetX, offsetY)
if (point && this.thumbnailChartRect && this.thumbnailChartRect.length) {
const [x1, y2, x2, y1] = this.thumbnailChartRect
const halfWidth = Math.ceil((x2 - x1) / 2)
const halfHeight = Math.ceil((y2 - y1) / 2)
let [xAxis, yAxis] = point
xAxis = parseInt(xAxis)
yAxis = parseInt(yAxis)
const xAxisMax = thumbnailChart.getModel().getComponent('xAxis').axis.scale._extent[1]
const yAxisMax = thumbnailChart.getModel().getComponent('yAxis').axis.scale._extent[1]
const xAxisLimit = this.rangeNumber(halfWidth, xAxisMax - halfWidth)
const yAxisLimit = this.rangeNumber(halfHeight, yAxisMax - halfHeight)
xAxis = xAxisLimit(xAxis)
yAxis = yAxisLimit(yAxis)
this.setThumbnailChartRect(xAxis - halfWidth, yAxis + halfHeight, xAxis + halfWidth, yAxis - halfHeight)
this.option.xAxis.min = xAxis - halfWidth
this.option.xAxis.max = xAxis + halfWidth
this.option.yAxis.min = yAxis - halfHeight
this.option.yAxis.max = yAxis + halfHeight
}
},
//
handleReset() {
this.option.xAxis.min = 0
this.option.xAxis.max = 'dataMax'
this.option.yAxis.min = 0
this.option.yAxis.max = Math.ceil(Math.max(...this.shadowChannelChart.pointlist.map(item => item.y)) * 1.1)
this.thumbnailOption.series[0].markLine.data = []
this.thumbnailChartRect = []
},
// nameseries
findSeriesByName(seriesName) {
return this.option.series.find(item => item.name == seriesName)
},
/**
* 根据两个点生成一个markLine直线
*/
generateLineDataByTwoPoints(point1, point2) {
return [
{
xAxis: point1[0],
yAxis: point1[1]
},
{
xAxis: point2[0],
yAxis: point2[1]
}
]
},
/**
* 限定数字在一定范围
* @param {Number} min
* @param {Number} max
*/
rangeNumber(min, max) {
return num => {
return num > max ? max : num < min ? min : num
}
},
},
watch: {
sample: {

File diff suppressed because one or more lines are too long