fix: 移动ROI方框时容易误操作的问题,及ROI ITEM刷选时鼠标悬浮的异常
This commit is contained in:
parent
7f3f3b95d1
commit
684ccf165a
|
@ -30,7 +30,7 @@
|
||||||
<!-- 2D图表结束 -->
|
<!-- 2D图表结束 -->
|
||||||
<!-- 图表上面的四边形 -->
|
<!-- 图表上面的四边形 -->
|
||||||
<div
|
<div
|
||||||
class="boundary-list"
|
:class="['boundary-list', currBoundaryItem ? 'is-moving' : '']"
|
||||||
:style="{
|
:style="{
|
||||||
left: boundaryContainerPosition.left + 'px',
|
left: boundaryContainerPosition.left + 'px',
|
||||||
top: boundaryContainerPosition.top + 'px',
|
top: boundaryContainerPosition.top + 'px',
|
||||||
|
@ -51,8 +51,8 @@
|
||||||
borderColor: boundaryItem.borderColor,
|
borderColor: boundaryItem.borderColor,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div class="boundary-item-left" @mousedown="handleBorderMouseDown(boundaryItem, 'left', index)"></div>
|
<div :class="['boundary-item-left']" @mousedown="handleBorderMouseDown(boundaryItem, 'left', index)"></div>
|
||||||
<div class="boundary-item-right" @mousedown="handleBorderMouseDown(boundaryItem, 'right', index)"></div>
|
<div :class="['boundary-item-right']" @mousedown="handleBorderMouseDown(boundaryItem, 'right', index)"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 图表上面的四边形结束 -->
|
<!-- 图表上面的四边形结束 -->
|
||||||
|
@ -149,7 +149,7 @@ const twoDOption = {
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 4096,
|
max: 2300,
|
||||||
interval: 512,
|
interval: 512,
|
||||||
},
|
},
|
||||||
series: {
|
series: {
|
||||||
|
@ -262,6 +262,7 @@ export default {
|
||||||
boundaryList: [], // 最终生成的框
|
boundaryList: [], // 最终生成的框
|
||||||
boundaryContainerPosition: {},
|
boundaryContainerPosition: {},
|
||||||
isLog: true, // 当前右侧的图表是否是log
|
isLog: true, // 当前右侧的图表是否是log
|
||||||
|
currBoundaryItem: null, // 当前正在操作的方框
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -287,7 +288,7 @@ export default {
|
||||||
} = this.twoDOption
|
} = this.twoDOption
|
||||||
|
|
||||||
//点大小
|
//点大小
|
||||||
this.twoDOption.series.symbolSize = 5
|
this.twoDOption.series.symbolSize = 2
|
||||||
this.twoDOption.series.data = this.histogramDataList
|
this.twoDOption.series.data = this.histogramDataList
|
||||||
.filter(({ b, g, c }) => c && b >= minX && b <= maxX && g >= minY && g <= maxY)
|
.filter(({ b, g, c }) => c && b >= minX && b <= maxX && g >= minY && g <= maxY)
|
||||||
.map(({ b, g, c }) => this.buildScatterItem(b, g, c))
|
.map(({ b, g, c }) => this.buildScatterItem(b, g, c))
|
||||||
|
@ -301,9 +302,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
setVisialMapParams() {
|
setVisialMapParams() {
|
||||||
const counts = this.histogramDataList.map(({ c }) => c)
|
const counts = this.histogramDataList.filter(({ c }) => c).map(({ c }) => c)
|
||||||
if (counts.length) {
|
if (counts.length) {
|
||||||
this.twoDOption.visualMap.max = Math.max(...counts)
|
this.twoDOption.visualMap.max = counts.sort((a, b) => b - a)[0]
|
||||||
} else {
|
} else {
|
||||||
this.twoDOption.visualMap.max = 0
|
this.twoDOption.visualMap.max = 0
|
||||||
}
|
}
|
||||||
|
@ -350,7 +351,7 @@ export default {
|
||||||
|
|
||||||
setVisualMapHeight() {
|
setVisualMapHeight() {
|
||||||
const chartContainerRef = this.$refs.chartContainerRef
|
const chartContainerRef = this.$refs.chartContainerRef
|
||||||
this.twoDOption.visualMap.itemHeight = chartContainerRef.offsetHeight - 75
|
this.twoDOption.visualMap.itemHeight = chartContainerRef.offsetHeight - 40
|
||||||
},
|
},
|
||||||
|
|
||||||
handleChartResize() {
|
handleChartResize() {
|
||||||
|
@ -397,7 +398,7 @@ export default {
|
||||||
|
|
||||||
// 鼠标按下时开启可刷选状态
|
// 鼠标按下时开启可刷选状态
|
||||||
handleMouseDown() {
|
handleMouseDown() {
|
||||||
if (this.boundaryItem) {
|
if (this.currBoundaryItem) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,56 +473,56 @@ export default {
|
||||||
// 矩形周边点击
|
// 矩形周边点击
|
||||||
handleBorderMouseDown(boundaryItem, direction, index) {
|
handleBorderMouseDown(boundaryItem, direction, index) {
|
||||||
this.boundaryRight = boundaryItem.left + boundaryItem.width
|
this.boundaryRight = boundaryItem.left + boundaryItem.width
|
||||||
this.boundaryItem = boundaryItem
|
this.currBoundaryItem = boundaryItem
|
||||||
this.boundaryIndex = index
|
this.boundaryIndex = index
|
||||||
this.direction = direction
|
this.direction = direction
|
||||||
},
|
},
|
||||||
|
|
||||||
// 矩形周边移动
|
// 矩形周边移动
|
||||||
handleBorderMouseMove({ movementX }) {
|
handleBorderMouseMove({ movementX }) {
|
||||||
if (!this.boundaryItem) {
|
if (!this.currBoundaryItem) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevLeft = this.boundaryItem.left
|
const prevLeft = this.currBoundaryItem.left
|
||||||
// 移动的形式是在左侧移动,则改变left定位
|
// 移动的形式是在左侧移动,则改变left定位
|
||||||
if (this.direction == 'left') {
|
if (this.direction == 'left') {
|
||||||
const nextLeft = prevLeft + movementX
|
const nextLeft = prevLeft + movementX
|
||||||
const nextWidth = this.boundaryItem.width - movementX
|
const nextWidth = this.currBoundaryItem.width - movementX
|
||||||
// 如果移动到的位置将要超过右边线
|
// 如果移动到的位置将要超过右边线
|
||||||
if (nextLeft >= this.boundaryRight) {
|
if (nextLeft >= this.boundaryRight) {
|
||||||
this.boundaryItem.left = this.boundaryRight
|
this.currBoundaryItem.left = this.boundaryRight
|
||||||
this.boundaryItem.width = nextLeft - this.boundaryRight
|
this.currBoundaryItem.width = nextLeft - this.boundaryRight
|
||||||
this.direction = 'right'
|
this.direction = 'right'
|
||||||
} else {
|
} else {
|
||||||
this.boundaryItem.left = nextLeft
|
this.currBoundaryItem.left = nextLeft
|
||||||
this.boundaryItem.width = nextWidth
|
this.currBoundaryItem.width = nextWidth
|
||||||
this.direction = 'left'
|
this.direction = 'left'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 移动的形式是在右侧移动,则改变宽度
|
// 移动的形式是在右侧移动,则改变宽度
|
||||||
else {
|
else {
|
||||||
const nextWidth = this.boundaryItem.width + movementX
|
const nextWidth = this.currBoundaryItem.width + movementX
|
||||||
// 如果移动到的位置将要超过左边线
|
// 如果移动到的位置将要超过左边线
|
||||||
if (nextWidth <= 0) {
|
if (nextWidth <= 0) {
|
||||||
this.direction = 'left'
|
this.direction = 'left'
|
||||||
this.boundaryItem.left = prevLeft + nextWidth
|
this.currBoundaryItem.left = prevLeft + nextWidth
|
||||||
this.boundaryItem.width = -nextWidth
|
this.currBoundaryItem.width = -nextWidth
|
||||||
} else {
|
} else {
|
||||||
this.boundaryItem.width = nextWidth
|
this.currBoundaryItem.width = nextWidth
|
||||||
this.direction = 'right'
|
this.direction = 'right'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.boundaryRight = this.boundaryItem.left + this.boundaryItem.width
|
this.boundaryRight = this.currBoundaryItem.left + this.currBoundaryItem.width
|
||||||
},
|
},
|
||||||
|
|
||||||
// 鼠标离开图表
|
// 鼠标离开图表
|
||||||
handleBorderMouseLeave() {
|
handleBorderMouseLeave() {
|
||||||
// 如果是改变矩形范围的情况
|
// 如果是改变矩形范围的情况
|
||||||
if (this.boundaryItem) {
|
if (this.currBoundaryItem) {
|
||||||
// 物理坐标转换回坐标系坐标
|
// 物理坐标转换回坐标系坐标
|
||||||
const { left, width } = this.boundaryItem
|
const { left, width } = this.currBoundaryItem
|
||||||
const realLeft = left + this.boundaryContainerPosition.left
|
const realLeft = left + this.boundaryContainerPosition.left
|
||||||
|
|
||||||
const chart = this.$refs.chartTwoDRef.getChartInstance()
|
const chart = this.$refs.chartTwoDRef.getChartInstance()
|
||||||
|
@ -534,7 +535,7 @@ export default {
|
||||||
start: parseInt(start.toFixed()),
|
start: parseInt(start.toFixed()),
|
||||||
end: parseInt(end.toFixed()),
|
end: parseInt(end.toFixed()),
|
||||||
})
|
})
|
||||||
this.boundaryItem = null
|
this.currBoundaryItem = null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -587,6 +588,12 @@ export default {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
&.is-moving {
|
||||||
|
pointer-events: all;
|
||||||
|
cursor: w-resize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.boundary-item {
|
.boundary-item {
|
||||||
|
|
|
@ -42,10 +42,9 @@ import { buildLineSeries, findSeriesByName, getAxisMax, rangeNumber } from '@/ut
|
||||||
const option = {
|
const option = {
|
||||||
grid: {
|
grid: {
|
||||||
top: 10,
|
top: 10,
|
||||||
left: 20,
|
left: 60,
|
||||||
right: 20,
|
right: 20,
|
||||||
bottom: 25,
|
bottom: 25,
|
||||||
containLabel: true,
|
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -194,7 +193,7 @@ export default {
|
||||||
this.axisInfo = {
|
this.axisInfo = {
|
||||||
channel: Math.round(xAxis),
|
channel: Math.round(xAxis),
|
||||||
count: this.channelData.all ? this.channelData.all.pointlist[channel].y : count,
|
count: this.channelData.all ? this.channelData.all.pointlist[channel].y : count,
|
||||||
energy: this.energys[channel].toFixed(3),
|
energy: (this.energys[channel] || 0).toFixed(3),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user