修复PieChart边框大小不一致的问题

This commit is contained in:
monitor1394
2020-09-22 07:25:05 +08:00
parent 51f8372f32
commit 9a866c0352
3 changed files with 5 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
# 更新日志 # 更新日志
* (2020.09.22) Fixed `PieChart` inconsistent border size
* (2020.09.18) Added `Remove All Chart Object` to Remove All child nodes under the Chart (automatically reinitialized) * (2020.09.18) Added `Remove All Chart Object` to Remove All child nodes under the Chart (automatically reinitialized)
* (2020.09.18) Fixed `SerieLabel` also displayed after hided `Serie` by clicked the legend #94 * (2020.09.18) Fixed `SerieLabel` also displayed after hided `Serie` by clicked the legend #94
* (2020.09.18) Optimize coordinate axis calibration and text display #93 * (2020.09.18) Optimize coordinate axis calibration and text display #93

View File

@@ -1,6 +1,7 @@
# 更新日志 # 更新日志
* (2020.09.22) 修复`PieChart`边框大小不一致的问题
* (2020.09.19) 发布`v1.6.1`版本 * (2020.09.19) 发布`v1.6.1`版本
* (2020.09.19) 增加`Remove All Chart Object`移除图表下的所有子节点(会自动重新初始化) * (2020.09.19) 增加`Remove All Chart Object`移除图表下的所有子节点(会自动重新初始化)
* (2020.09.18) 修复`SerieLabel`在点击图例隐藏`Serie`后还显示的问题#94 * (2020.09.18) 修复`SerieLabel`在点击图例隐藏`Serie`后还显示的问题#94

View File

@@ -865,6 +865,7 @@ namespace XCharts
var lastColor = color; var lastColor = color;
var needBorder = borderWidth != 0; var needBorder = borderWidth != 0;
var needSpace = space != 0; var needSpace = space != 0;
var borderLineWidth = needSpace ? borderWidth : borderWidth / 2;
var lastPos = Vector3.zero; var lastPos = Vector3.zero;
var middleDire = ChartHelper.GetDire(startAngle + halfAngle); var middleDire = ChartHelper.GetDire(startAngle + halfAngle);
if (needBorder || needSpace) if (needBorder || needSpace)
@@ -884,9 +885,9 @@ namespace XCharts
} }
if (needBorder) if (needBorder)
{ {
borderDiff = borderWidth / Mathf.Sin(halfAngle); borderDiff = borderLineWidth / Mathf.Sin(halfAngle);
realCenter += borderDiff * middleDire; realCenter += borderDiff * middleDire;
borderAngle = 2 * Mathf.Asin(borderWidth / (2 * radius)); borderAngle = 2 * Mathf.Asin(borderLineWidth / (2 * radius));
realStartAngle = realStartAngle + borderAngle; realStartAngle = realStartAngle + borderAngle;
realToAngle = realToAngle - borderAngle; realToAngle = realToAngle - borderAngle;
if (realToAngle < realStartAngle) if (realToAngle < realStartAngle)
@@ -963,8 +964,6 @@ namespace XCharts
} }
} }
public static void DrawRoundCap(VertexHelper vh, Vector3 center, float width, float radius, float angle, public static void DrawRoundCap(VertexHelper vh, Vector3 center, float width, float radius, float angle,
bool clockwise, Color32 color, bool end) bool clockwise, Color32 color, bool end)
{ {