优化DataZoomMarquee框选功能

This commit is contained in:
monitor1394
2026-05-25 22:19:22 +08:00
parent b14a574ad6
commit 584ef9a834
2 changed files with 7 additions and 12 deletions

View File

@@ -122,10 +122,7 @@ namespace XCharts
{
if (axis is YAxis)
{
var yRate = axis.context.minMaxRange / grid.context.height;
var yValue = yRate * (chart.pointerPos.y - grid.context.y - axis.context.offset);
if (axis.context.minValue > 0)
yValue += axis.context.minValue;
var yValue = axis.context.minValue + (chart.pointerPos.y - grid.context.y) / grid.context.height * axis.context.minMaxRange;
if (axis.inverse)
yValue = -yValue;
@@ -152,10 +149,7 @@ namespace XCharts
}
else
{
var xRate = axis.context.minMaxRange / grid.context.width;
xValue = xRate * (chart.pointerPos.x - grid.context.x - axis.context.offset);
if (axis.context.minValue > 0)
xValue += axis.context.minValue;
xValue = axis.context.minValue + (chart.pointerPos.x - grid.context.x) / grid.context.width * axis.context.minMaxRange;
if (axis.inverse)
xValue = -xValue;
}

View File

@@ -117,7 +117,7 @@ namespace XCharts.Runtime
dataZoom.context.isCoordinateDrag = true;
}
}
if (dataZoom.supportMarquee)
if (dataZoom.supportMarquee && grid.Contains(pos))
{
dataZoom.context.isMarqueeDrag = true;
dataZoom.context.marqueeStartPos = pos;
@@ -167,7 +167,7 @@ namespace XCharts.Runtime
var dataZoom = component;
var grid = chart.GetGridOfDataZoom(dataZoom);
if (dataZoom.supportMarquee)
if (dataZoom.supportMarquee && dataZoom.context.isMarqueeDrag)
{
Vector2 pos;
if (!chart.ScreenPointToChartPoint(eventData.position, out pos))
@@ -211,7 +211,7 @@ namespace XCharts.Runtime
var dataZoom = component;
if (dataZoom.supportMarquee)
if (dataZoom.supportMarquee && dataZoom.context.isMarqueeDrag)
{
dataZoom.context.isMarqueeDrag = false;
if (dataZoom.marqueeStyle.apply)
@@ -264,7 +264,8 @@ namespace XCharts.Runtime
var dataZoom = component;
var grid = chart.GetGridOfDataZoom(dataZoom);
if (dataZoom.IsInStartZoom(localPos) ||
dataZoom.IsInEndZoom(localPos))
dataZoom.IsInEndZoom(localPos) ||
dataZoom.IsInSelectedZoom(localPos))
{
return;
}