diff --git a/Runtime/Component/Animation/AnimationStyleHelper.cs b/Runtime/Component/Animation/AnimationStyleHelper.cs index 9ae4eb01..fe0c5955 100644 --- a/Runtime/Component/Animation/AnimationStyleHelper.cs +++ b/Runtime/Component/Animation/AnimationStyleHelper.cs @@ -35,7 +35,6 @@ namespace XCharts.Runtime animationType = serieType.GetAttribute().type; } UpdateAnimationType(serie.animation, animationType); - serie.animation.context.isAllItemAnimationEnd = true; } public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType) diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index 0a8a4ee8..f80899e4 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -767,7 +767,6 @@ namespace XCharts var current = orient == Orient.Horizonal ? startX : startY; - for (int i = 0; i < size; i++) { var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom); @@ -803,17 +802,17 @@ namespace XCharts { if (orient == Orient.Horizonal) { - if (relativedAxis == null || MathUtil.Approximately(current, relativedAxis.context.x)) - ChartDrawer.DrawLineStyle(vh, - lineType, - lineWidth, - new Vector3(current, startY), - new Vector3(current, startY + splitLength), - lineColor); + if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.x)) + ChartDrawer.DrawLineStyle(vh, + lineType, + lineWidth, + new Vector3(current, startY), + new Vector3(current, startY + splitLength), + lineColor); } else { - if (relativedAxis == null || MathUtil.Approximately(current, relativedAxis.context.y)) + if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.y)) ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, diff --git a/Runtime/Internal/BaseChart.Serie.cs b/Runtime/Internal/BaseChart.Serie.cs index a3f66e52..5773d8aa 100644 --- a/Runtime/Internal/BaseChart.Serie.cs +++ b/Runtime/Internal/BaseChart.Serie.cs @@ -26,6 +26,7 @@ namespace XCharts.Runtime public void InsertSerie(Serie serie, int index = -1, bool addToHead = false) { serie.AnimationRestart(); + AnimationStyleHelper.UpdateSerieAnimation(serie); if (addToHead) m_Series.Insert(0, serie); else if (index >= 0) m_Series.Insert(index, serie); else m_Series.Add(serie); @@ -180,7 +181,7 @@ namespace XCharts.Runtime var index = m_Series.IndexOf(oldSerie); if (index < 0) return false; - + AnimationStyleHelper.UpdateSerieAnimation(newSerie); oldSerie.OnRemove(); m_Series.RemoveAt(index); m_Series.Insert(index, newSerie); diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index afb7eb51..75c3056d 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -220,7 +220,7 @@ namespace XCharts.Runtime { m_Theme.sharedTheme = XCThemeMgr.GetTheme(ThemeType.Default); } - if (m_CheckTheme != m_Theme.themeType) + if (m_Theme.sharedTheme != null && m_CheckTheme != m_Theme.themeType) { m_CheckTheme = m_Theme.themeType; m_Theme.sharedTheme.CopyTheme(m_CheckTheme); @@ -536,7 +536,8 @@ namespace XCharts.Runtime serie.context.colorIndex = GetLegendRealShowNameIndex(serie.legendName); serie.context.dataPoints.Clear(); serie.context.dataIgnores.Clear(); - AnimationStyleHelper.UpdateSerieAnimation(serie); + serie.animation.context.isAllItemAnimationEnd = true; + if (m_OnDrawSerieBefore != null) { m_OnDrawSerieBefore.Invoke(vh, serie); diff --git a/Runtime/XUGL/UGL.cs b/Runtime/XUGL/UGL.cs index bac8fef2..19ad77dd 100644 --- a/Runtime/XUGL/UGL.cs +++ b/Runtime/XUGL/UGL.cs @@ -120,7 +120,7 @@ namespace XUGL } } - public static void DrawLine(VertexHelper vh, List points, float width, Color32 color, bool smooth) + public static void DrawLine(VertexHelper vh, List points, float width, Color32 color, bool smooth, bool closepath = false) { for (int i = points.Count - 1; i >= 1; i--) { @@ -146,6 +146,10 @@ namespace XUGL var ibp = Vector3.zero; var ctp = Vector3.zero; var cbp = Vector3.zero; + if (closepath && !UGLHelper.IsValueEqualsVector3(points[points.Count - 1], points[0])) + { + points.Add(points[0]); + } for (int i = 1; i < points.Count - 1; i++) { bool bitp = true, bibp = true; @@ -1806,5 +1810,71 @@ namespace XUGL { SVG.DrawPath(vh, path); } + + public static void DrawEllipse(VertexHelper vh, Vector3 center, float w, float h, Color32 color, float smoothness = 1) + { + DrawEllipse(vh, center, w, h, color, smoothness, 0, s_ClearColor32, 0, 360); + } + + public static void DrawEllipse(VertexHelper vh, Vector3 center, float w, float h, Color32 color, float smoothness, + float borderWidth, Color32 borderColor, + float startAngle, float endAngle) + { + startAngle = (startAngle + 360) % 360; + endAngle = (endAngle + 360) % 360; + if (endAngle < startAngle) + endAngle += 360; + if (endAngle <= startAngle) + return; + + var angle = startAngle; + var lp = Vector2.zero; + var fill = color.a != 0; + var border = borderWidth != 0 && borderColor.a != 0; + if (!fill && !border) + return; + + var startTriangleIndex = vh.currentVertCount; + if (fill) + { + vh.AddVert(center, color, Vector2.zero); + } + if (smoothness < 0.5f) + smoothness = 0.5f; + + var i = 0; + while (angle <= endAngle) + { + var rad = angle * Mathf.Deg2Rad; + var x = center.x + w * Mathf.Cos(rad); + var y = center.y + h * Mathf.Sin(rad); + var p1 = new Vector3(x, y); + vh.AddVert(p1, color, Vector2.zero); + if (border) + { + var dire = (p1 - center).normalized; + var diff = dire * borderWidth; + var p2 = p1 + diff; + vh.AddVert(p1, borderColor, Vector2.zero); + vh.AddVert(p2, borderColor, Vector2.zero); + + if (i > 0) + { + var index = startTriangleIndex + i * 3 + 2; + vh.AddTriangle(index - 3, index + 1, index - 2); + vh.AddTriangle(index - 3, index, index + 1); + if (fill) + vh.AddTriangle(startTriangleIndex, index - 1, index - 4); + } + } + else if (i > 0 && fill) + { + var index = startTriangleIndex + i; + vh.AddTriangle(startTriangleIndex, index + 1, index); + } + i++; + angle += smoothness; + } + } } }