mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 18:00:26 +00:00
优化Line3D绘制
This commit is contained in:
@@ -401,7 +401,7 @@ the animation of serie. support animation type: fadeIn, fadeOut, change, additio
|
|||||||
|public method|since|description|
|
|public method|since|description|
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|CheckDataAnimation()||public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0)|
|
|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)|
|
|UpdateAnimationType()||public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)|
|
||||||
|UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)|
|
|UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)|
|
||||||
|
|
||||||
|
|||||||
@@ -401,7 +401,7 @@ slug: /api
|
|||||||
|API|版本|描述|
|
|API|版本|描述|
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|CheckDataAnimation()||public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0)|
|
|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)|
|
|UpdateAnimationType()||public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)|
|
||||||
|UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)|
|
|UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)|
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace XCharts.Runtime
|
|||||||
animationType = attribute.type;
|
animationType = attribute.type;
|
||||||
enableSerieDataAnimation = attribute.enableSerieDataAddedAnimation;
|
enableSerieDataAnimation = attribute.enableSerieDataAddedAnimation;
|
||||||
}
|
}
|
||||||
UpdateAnimationType(serie.animation, animationType,enableSerieDataAnimation);
|
UpdateAnimationType(serie.animation, animationType, enableSerieDataAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)
|
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)
|
||||||
@@ -48,12 +48,12 @@ namespace XCharts.Runtime
|
|||||||
animation.context.enableSerieDataAddedAnimation = enableSerieDataAnimation;
|
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)
|
if (animation.context.type == AnimationType.AlongPath)
|
||||||
{
|
{
|
||||||
var dist = Vector3.Distance(lp, cp);
|
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);
|
ip = Vector3.Lerp(lp, cp, rate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,15 @@ namespace XCharts.Runtime
|
|||||||
var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
|
var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
|
||||||
var endPos = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,11 +302,12 @@ namespace XCharts.Runtime
|
|||||||
isBreak = true;
|
isBreak = true;
|
||||||
var ip = Vector3.zero;
|
var ip = Vector3.zero;
|
||||||
var progress = serie.animation.GetCurrDetail();
|
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;
|
cp = np = ip;
|
||||||
}
|
}
|
||||||
serie.context.lineEndPostion = cp;
|
serie.context.lineEndPostion = cp;
|
||||||
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
|
serie.context.lineEndValueY = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
|
||||||
var handled = false;
|
var handled = false;
|
||||||
var isClip = false;
|
var isClip = false;
|
||||||
if (serie.clip)
|
if (serie.clip)
|
||||||
@@ -382,7 +383,7 @@ namespace XCharts.Runtime
|
|||||||
AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
|
||||||
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
|
||||||
serie.context.lineEndPostion = cp;
|
serie.context.lineEndPostion = cp;
|
||||||
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
|
serie.context.lineEndValueY = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ namespace XCharts.Runtime
|
|||||||
/// 线段终点
|
/// 线段终点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 lineEndPostion;
|
public Vector3 lineEndPostion;
|
||||||
public double lineEndValue;
|
public double lineEndValueX;
|
||||||
|
public double lineEndValueY;
|
||||||
|
public double lineEndValueZ;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内半径
|
/// 内半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ namespace XCharts.Runtime
|
|||||||
m_EndLabel.SetActive(active);
|
m_EndLabel.SetActive(active);
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
var value = serie.context.lineEndValue;
|
var value = serie.context.lineEndValueY;
|
||||||
var content = SerieLabelHelper.GetFormatterContent(serie, null, value, 0,
|
var content = SerieLabelHelper.GetFormatterContent(serie, null, value, 0,
|
||||||
endLabelStyle, Color.clear);
|
endLabelStyle, Color.clear);
|
||||||
m_EndLabel.SetText(content);
|
m_EndLabel.SetText(content);
|
||||||
|
|||||||
Reference in New Issue
Block a user