Form file选择能谱文件之后,曲线图没渲染数据

This commit is contained in:
renpy 2023-09-11 15:58:58 +08:00
parent 60c2ed556e
commit 1b80817da3

View File

@ -263,238 +263,7 @@ export default {
})
console.log('%c [ result ]-243', 'font-size:13px; background:pink; color:#bf2c9f;', result)
if (success) {
this.isLoading = false
const {
dead_time,
live_time,
real_time,
start_time,
DetailedInformation,
QCFlag,
allData,
shadowChannelChart,
shadowEnergyChart,
shapeChannelData,
shapeEnergyData
} = result
this.detailedInfomation = DetailedInformation
this.qcFlags = QCFlag
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')
this.allEnergy = allData.find(item => item.name == 'Energy' && item.group == 'energy')
this.allChannel = allData.find(item => item.name == 'Count' && item.group == 'channel')
// Peak Line
this.channelPeakGroup = channelPeakGroup
this.energyPeakGroup = energyPeakGroup
// Spectrum Line
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)
this.thumbnailOption.yAxis.max = Math.ceil(
Math.max(...shadowChannelChart.pointlist.map(item => item.y)) * 1.1
)
const series = []
// Spectrum Line
series.push({
name: 'Spectrum',
type: 'line',
data: shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${shadowChannelChart.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
symbolSize: 1,
emphasis: {
disabled: true
},
markLine: {
silent: true,
symbol: 'none',
label: {
show: false
},
lineStyle: {
color: 'red',
width: 1
},
data: [{ xAxis: -1 }]
},
animation: false
})
// Spectrum Line
this.thumbnailOption.series.push({
name: 'Spectrum',
type: 'line',
data: shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${shadowChannelChart.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
symbolSize: 1,
emphasis: {
disabled: true
},
silent: true,
markLine: {
silent: true,
symbol: 'none',
label: {
show: false
},
lineStyle: {
type: 'solid',
color: '#1397a3',
width: 1
},
data: []
}
})
// BaseLine
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
},
animation: false,
zlevel: 2
})
// LcLine线
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
},
animation: false,
zlevel: 3
})
// Scac线
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
},
animation: false,
zlevel: 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,
zlevel: 5
})
// Peak Line
const peakLines = []
channelPeakGroup.forEach((item, index) => {
peakLines.push({
name: `Peak_${index}`,
type: 'line',
data: item.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${item.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
animation: false,
zlevel: 6
})
})
series.push(...peakLines)
this.option.series = series
this.option.tooltip.formatter = this.tooltipFormatter
this.dataProsess(result)
} else {
this.$message.error(message)
}
@ -502,6 +271,7 @@ export default {
console.error(error)
}
},
async getSampleDetail_file() {
const { inputFileName: fileName } = this.sample
try {
@ -514,238 +284,7 @@ export default {
})
console.log('%c [ result ]-243', 'font-size:13px; background:pink; color:#bf2c9f;', result)
if (success) {
this.isLoading = false
const {
dead_time,
live_time,
real_time,
start_time,
DetailedInformation,
QCFlag,
allData,
shadowChannelChart,
shadowEnergyChart,
shapeChannelData,
shapeEnergyData
} = result
this.detailedInfomation = DetailedInformation
this.qcFlags = QCFlag
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')
this.allEnergy = allData.find(item => item.name == 'Energy' && item.group == 'energy')
this.allChannel = allData.find(item => item.name == 'Count' && item.group == 'channel')
// Peak Line
this.channelPeakGroup = channelPeakGroup
this.energyPeakGroup = energyPeakGroup
// Spectrum Line
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)
this.thumbnailOption.yAxis.max = Math.ceil(
Math.max(...shadowChannelChart.pointlist.map(item => item.y)) * 1.1
)
const series = []
// Spectrum Line
series.push({
name: 'Spectrum',
type: 'line',
data: shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${shadowChannelChart.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
symbolSize: 1,
emphasis: {
disabled: true
},
markLine: {
silent: true,
symbol: 'none',
label: {
show: false
},
lineStyle: {
color: 'red',
width: 1
},
data: [{ xAxis: -1 }]
},
animation: false
})
// Spectrum Line
this.thumbnailOption.series.push({
name: 'Spectrum',
type: 'line',
data: shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${shadowChannelChart.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
symbolSize: 1,
emphasis: {
disabled: true
},
silent: true,
markLine: {
silent: true,
symbol: 'none',
label: {
show: false
},
lineStyle: {
type: 'solid',
color: '#1397a3',
width: 1
},
data: []
}
})
// BaseLine
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
},
animation: false,
zlevel: 2
})
// LcLine线
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
},
animation: false,
zlevel: 3
})
// Scac线
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
},
animation: false,
zlevel: 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,
zlevel: 5
})
// Peak Line
const peakLines = []
channelPeakGroup.forEach((item, index) => {
peakLines.push({
name: `Peak_${index}`,
type: 'line',
data: item.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${item.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
animation: false,
zlevel: 6
})
})
series.push(...peakLines)
this.option.series = series
this.option.tooltip.formatter = this.tooltipFormatter
this.dataProsess(result)
} else {
this.$message.error(message)
}
@ -754,6 +293,240 @@ export default {
}
},
dataProsess(result) {
this.isLoading = false
const {
dead_time,
live_time,
real_time,
start_time,
DetailedInformation,
QCFlag,
allData,
shadowChannelChart,
shadowEnergyChart,
shapeChannelData,
shapeEnergyData
} = result
this.detailedInfomation = DetailedInformation
this.qcFlags = QCFlag
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')
this.allEnergy = allData.find(item => item.name == 'Energy' && item.group == 'energy')||{}
this.allChannel = allData.find(item => item.name == 'Count' && item.group == 'channel')
// Peak Line
this.channelPeakGroup = channelPeakGroup
this.energyPeakGroup = energyPeakGroup
// Spectrum Line
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 = shadowChannelChart.pointlist&&Math.ceil(Math.max(...shadowChannelChart.pointlist.map(item => item.y)) * 1.1)
this.thumbnailOption.yAxis.max = shadowChannelChart.pointlist&&Math.ceil(
Math.max(...shadowChannelChart.pointlist.map(item => item.y)) * 1.1
)
const series = []
// Spectrum Line
series.push({
name: 'Spectrum',
type: 'line',
data: shadowChannelChart.pointlist&&shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${shadowChannelChart.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
symbolSize: 1,
emphasis: {
disabled: true
},
markLine: {
silent: true,
symbol: 'none',
label: {
show: false
},
lineStyle: {
color: 'red',
width: 1
},
data: [{ xAxis: -1 }]
},
animation: false
})
// Spectrum Line
this.thumbnailOption.series.push({
name: 'Spectrum',
type: 'line',
data: shadowChannelChart.pointlist&&shadowChannelChart.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${shadowChannelChart.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
symbolSize: 1,
emphasis: {
disabled: true
},
silent: true,
markLine: {
silent: true,
symbol: 'none',
label: {
show: false
},
lineStyle: {
type: 'solid',
color: '#1397a3',
width: 1
},
data: []
}
})
// BaseLine
series.push({
name: 'BaseLine',
type: 'line',
data: channelBaseLine.pointlist&&channelBaseLine.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${channelBaseLine.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
emphasis: {
disabled: true
},
animation: false,
zlevel: 2
})
// LcLine线
series.push({
name: 'LcLine',
type: 'line',
data: channelLcLine.pointlist&&channelLcLine.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${channelLcLine.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
emphasis: {
disabled: true
},
animation: false,
zlevel: 3
})
// Scac线
series.push({
name: 'ScacLine',
type: 'line',
data: channelScacLine.pointlist&&channelScacLine.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${channelScacLine.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
emphasis: {
disabled: true
},
animation: false,
zlevel: 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,
zlevel: 5
})
// Peak Line
const peakLines = []
channelPeakGroup.forEach((item, index) => {
peakLines.push({
name: `Peak_${index}`,
type: 'line',
data: item.pointlist.map(({ x, y }) => [x, y]),
itemStyle: {
color: `rgb(${item.color})`
},
lineStyle: {
width: 1
},
symbol: 'none',
animation: false,
zlevel: 6
})
})
series.push(...peakLines)
this.option.series = series
this.option.tooltip.formatter = this.tooltipFormatter
},
tooltipFormatter(params) {
if (this.isEnergy()) {
const energy = params[0].value[0]
@ -763,7 +536,7 @@ export default {
<div class="energy">Energy: ${energy.toFixed(2)}</div>`
} else {
const channel = parseInt(params[0].value[0].toFixed())
const energy = this.allEnergy.pointlist[channel - 1]
const energy = this.allEnergy.pointlist&&this.allEnergy.pointlist[channel - 1]
return energy
? `<div class="channel">Channel: ${channel}</div>
<div class="energy">Energy: ${energy.x.toFixed(2)}</div>`
@ -925,7 +698,7 @@ export default {
this.option.series[0].markLine.data[0].xAxis = xAxis
const channel = this.isEnergy() ? this.getChannelByEnergy(xAxis) : parseInt(xAxis.toFixed())
const energy = this.isEnergy() ? xAxis.toFixed(2) : this.allEnergy.pointlist[channel - 1].x.toFixed(2)
const energy = this.isEnergy() ? xAxis.toFixed(2) : this.allEnergy.pointlist&&this.allEnergy.pointlist[channel - 1].x.toFixed(2)
const counts = this.isEnergy() ? this.allEnergy.pointlist[channel - 1] : this.allChannel.pointlist[channel - 1]
this.option.title.text = `{a|Channel:${channel}} {a|Energy:${energy}} {a|Counts:${counts.y}} {a|Detectability:0}`
}