mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 12:08:46 +00:00
修复LineChart有数据为0时区域图绘制可能异常的问题
This commit is contained in:
@@ -525,24 +525,19 @@ namespace XCharts
|
||||
var points = ((isYAxis && lp.x < zeroPos.x) || (!isYAxis && lp.y < zeroPos.y)) ? smoothPoints : smoothDownPoints;
|
||||
Vector3 aep = isYAxis ? new Vector3(zeroPos.x, zeroPos.y + coordinateHig) : new Vector3(zeroPos.x + coordinateWid, zeroPos.y);
|
||||
var cross = ChartHelper.GetIntersection(points[0], points[points.Count - 1], zeroPos, aep);
|
||||
var isZeroValue = (isYAxis && cross.x == zeroPos.x) || (!isYAxis && cross.y == zeroPos.y);
|
||||
if (cross == Vector3.zero || isZeroValue)
|
||||
if (cross == Vector3.zero || smoothDownPoints.Count <= 3)
|
||||
{
|
||||
Vector3 sp = points[0];
|
||||
Vector3 ep;
|
||||
for (int i = 1; i < points.Count; i++)
|
||||
{
|
||||
ep = points[i];
|
||||
if(isZeroValue && i == 1){
|
||||
sp = ep;
|
||||
continue;
|
||||
}
|
||||
if (serie.animation.CheckDetailBreak(ep, isYAxis)) break;
|
||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||
sp = ep;
|
||||
}
|
||||
}
|
||||
else if (smoothDownPoints.Count > 3)
|
||||
else
|
||||
{
|
||||
var sp1 = smoothDownPoints[1];
|
||||
var ep1 = smoothDownPoints[smoothDownPoints.Count - 2];
|
||||
@@ -554,9 +549,23 @@ namespace XCharts
|
||||
var ldPos = ChartHelper.GetIntersection(sp1, ep1, axisDownStart, axisDownEnd);
|
||||
sp1 = smoothPoints[1];
|
||||
ep1 = smoothPoints[smoothPoints.Count - 2];
|
||||
|
||||
var ruPos = ChartHelper.GetIntersection(sp1, ep1, axisUpStart, axisUpEnd);
|
||||
var rdPos = ChartHelper.GetIntersection(sp1, ep1, axisDownStart, axisDownEnd);
|
||||
Vector3 sp, ep;
|
||||
if (luPos == Vector3.zero || ldPos == Vector3.zero || ruPos == Vector3.zero || rdPos == Vector3.zero)
|
||||
{
|
||||
sp = points[0];
|
||||
for (int i = 1; i < points.Count; i++)
|
||||
{
|
||||
ep = points[i];
|
||||
if (serie.animation.CheckDetailBreak(ep, isYAxis)) break;
|
||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||
sp = ep;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((isYAxis && lp.x >= zeroPos.x) || (!isYAxis && lp.y >= zeroPos.y))
|
||||
{
|
||||
sp = smoothDownPoints[0];
|
||||
@@ -652,6 +661,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stPos1 = isDown ? upPos2 : dnPos;
|
||||
stPos2 = isDown ? dnPos : upPos2;
|
||||
lastDnPos = dnPos;
|
||||
|
||||
Reference in New Issue
Block a user