mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 02:40:13 +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;
|
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);
|
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 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 || smoothDownPoints.Count <= 3)
|
||||||
if (cross == Vector3.zero || isZeroValue)
|
|
||||||
{
|
{
|
||||||
Vector3 sp = points[0];
|
Vector3 sp = points[0];
|
||||||
Vector3 ep;
|
Vector3 ep;
|
||||||
for (int i = 1; i < points.Count; i++)
|
for (int i = 1; i < points.Count; i++)
|
||||||
{
|
{
|
||||||
ep = points[i];
|
ep = points[i];
|
||||||
if(isZeroValue && i == 1){
|
|
||||||
sp = ep;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (serie.animation.CheckDetailBreak(ep, isYAxis)) break;
|
if (serie.animation.CheckDetailBreak(ep, isYAxis)) break;
|
||||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||||
sp = ep;
|
sp = ep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (smoothDownPoints.Count > 3)
|
else
|
||||||
{
|
{
|
||||||
var sp1 = smoothDownPoints[1];
|
var sp1 = smoothDownPoints[1];
|
||||||
var ep1 = smoothDownPoints[smoothDownPoints.Count - 2];
|
var ep1 = smoothDownPoints[smoothDownPoints.Count - 2];
|
||||||
@@ -554,9 +549,23 @@ namespace XCharts
|
|||||||
var ldPos = ChartHelper.GetIntersection(sp1, ep1, axisDownStart, axisDownEnd);
|
var ldPos = ChartHelper.GetIntersection(sp1, ep1, axisDownStart, axisDownEnd);
|
||||||
sp1 = smoothPoints[1];
|
sp1 = smoothPoints[1];
|
||||||
ep1 = smoothPoints[smoothPoints.Count - 2];
|
ep1 = smoothPoints[smoothPoints.Count - 2];
|
||||||
|
|
||||||
var ruPos = ChartHelper.GetIntersection(sp1, ep1, axisUpStart, axisUpEnd);
|
var ruPos = ChartHelper.GetIntersection(sp1, ep1, axisUpStart, axisUpEnd);
|
||||||
var rdPos = ChartHelper.GetIntersection(sp1, ep1, axisDownStart, axisDownEnd);
|
var rdPos = ChartHelper.GetIntersection(sp1, ep1, axisDownStart, axisDownEnd);
|
||||||
Vector3 sp, ep;
|
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))
|
if ((isYAxis && lp.x >= zeroPos.x) || (!isYAxis && lp.y >= zeroPos.y))
|
||||||
{
|
{
|
||||||
sp = smoothDownPoints[0];
|
sp = smoothDownPoints[0];
|
||||||
@@ -652,6 +661,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
stPos1 = isDown ? upPos2 : dnPos;
|
stPos1 = isDown ? upPos2 : dnPos;
|
||||||
stPos2 = isDown ? dnPos : upPos2;
|
stPos2 = isDown ? dnPos : upPos2;
|
||||||
lastDnPos = dnPos;
|
lastDnPos = dnPos;
|
||||||
|
|||||||
Reference in New Issue
Block a user