修复PieChart选中扇区后鼠标区域指示不准确的问题

This commit is contained in:
monitor1394
2021-07-04 21:16:30 +08:00
parent 1fccc25873
commit 32a8fed625
3 changed files with 10 additions and 2 deletions

View File

@@ -38,6 +38,8 @@
## master
* (2021.07.04) Fixed incorrect mouse area indication after `PieChart` selected sector
* (2021.07.04) Optimize when the `Label` of `PieChart` is `Inside`, the offset can be adjusted by the parameter `Margin`
* (2021.07.01) Added `DataZoom` arguments to `supportInsideScroll` and `supportInsideDrag` to set whether scrolling and dragging are supported in the coordinate system
* (2021.06.27) Add `showStartLabel` and `showEndLabel` arguments to `AxisLabel` to set whether the `Label` should be displayed at the beginning and end of the `AxisLabel`
* (2021.06.27) Added `formatter` delegate method to `AxisLabel` and `SerieLabel` (#145)

View File

@@ -38,6 +38,8 @@
## master
* (2021.07.04) 修复`PieChart`选中扇区后鼠标区域指示不准确的问题
* (2021.07.04) 优化`PieChart``Label``Inside`时可通过参数`Margin`调节偏移
* (2021.07.01) 增加`DataZoom``supportInsideScroll``supportInsideDrag`参数设置坐标系内是否支持滚动和拖拽
* (2021.06.27) 增加`AxisLabel``showStartLabel``showEndLabel`参数设置首尾的`Label`是否显示
* (2021.06.27) 增加`AxisLabel``SerieLabel``formatter`委托方法 (#145)

View File

@@ -566,7 +566,6 @@ namespace XCharts
{
if (serie.type != SerieType.Pie) return -1;
var dist = Vector2.Distance(local, serie.runtimeCenterPos);
if (dist < serie.runtimeInsideRadius || dist > serie.runtimeOutsideRadius) return -1;
Vector2 dir = local - new Vector2(serie.runtimeCenterPos.x, serie.runtimeCenterPos.y);
float angle = ChartHelper.GetAngle360(Vector2.up, dir);
for (int i = 0; i < serie.data.Count; i++)
@@ -574,7 +573,12 @@ namespace XCharts
var serieData = serie.data[i];
if (angle >= serieData.runtimePieStartAngle && angle <= serieData.runtimePieToAngle)
{
return i;
var ndist = !serieData.selected ? dist :
Vector2.Distance(local, serieData.runtiemPieOffsetCenter);
if (ndist >= serieData.runtimePieInsideRadius && ndist <= serieData.runtimePieOutsideRadius)
{
return i;
}
}
}
return -1;