优化Line3D绘制

This commit is contained in:
monitor1394
2024-05-15 13:19:34 +08:00
parent 4e3182edfc
commit 3e8bf7caee
6 changed files with 22 additions and 11 deletions

View File

@@ -401,7 +401,7 @@ the animation of serie. support animation type: fadeIn, fadeOut, change, additio
|public method|since|description|
|--|--|--|
|CheckDataAnimation()||public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0)|
|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)|
|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip, ref float rate)|
|UpdateAnimationType()||public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)|
|UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)|

View File

@@ -401,7 +401,7 @@ slug: /api
|API|版本|描述|
|--|--|--|
|CheckDataAnimation()||public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0)|
|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)|
|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip, ref float rate)|
|UpdateAnimationType()||public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)|
|UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)|

View File

@@ -37,7 +37,7 @@ namespace XCharts.Runtime
animationType = attribute.type;
enableSerieDataAnimation = attribute.enableSerieDataAddedAnimation;
}
UpdateAnimationType(serie.animation, animationType,enableSerieDataAnimation);
UpdateAnimationType(serie.animation, animationType, enableSerieDataAnimation);
}
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)
@@ -48,12 +48,12 @@ namespace XCharts.Runtime
animation.context.enableSerieDataAddedAnimation = enableSerieDataAnimation;
}
public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)
public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip, ref float rate)
{
if (animation.context.type == AnimationType.AlongPath)
{
var dist = Vector3.Distance(lp, cp);
var rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist;
rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist;
ip = Vector3.Lerp(lp, cp, rate);
return true;
}
@@ -62,7 +62,15 @@ namespace XCharts.Runtime
var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
var endPos = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000);
return UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip);
if (UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip))
{
rate = Vector3.Distance(lp, ip) / Vector3.Distance(lp, cp);
return true;
}
else
{
return false;
}
}
}
}

View File

@@ -302,11 +302,12 @@ namespace XCharts.Runtime
isBreak = true;
var ip = Vector3.zero;
var progress = serie.animation.GetCurrDetail();
if (AnimationStyleHelper.GetAnimationPosition(serie.animation, isY, lp, cp, progress, ref ip))
var rate = 0f;
if (AnimationStyleHelper.GetAnimationPosition(serie.animation, isY, lp, cp, progress, ref ip, ref rate))
cp = np = ip;
}
serie.context.lineEndPostion = cp;
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
serie.context.lineEndValueY = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
var handled = false;
var isClip = false;
if (serie.clip)
@@ -382,7 +383,7 @@ namespace XCharts.Runtime
AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
serie.context.lineEndPostion = cp;
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
serie.context.lineEndValueY = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
break;
}
}

View File

@@ -57,7 +57,9 @@ namespace XCharts.Runtime
/// 线段终点
/// </summary>
public Vector3 lineEndPostion;
public double lineEndValue;
public double lineEndValueX;
public double lineEndValueY;
public double lineEndValueZ;
/// <summary>
/// 内半径
/// </summary>

View File

@@ -557,7 +557,7 @@ namespace XCharts.Runtime
m_EndLabel.SetActive(active);
if (active)
{
var value = serie.context.lineEndValue;
var value = serie.context.lineEndValueY;
var content = SerieLabelHelper.GetFormatterContent(serie, null, value, 0,
endLabelStyle, Color.clear);
m_EndLabel.SetText(content);