mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 09:50:15 +00:00
增加RadarChart、ScatterChart和HeatmapChart的起始动画效果
This commit is contained in:
@@ -208,6 +208,24 @@ namespace XCharts
|
|||||||
return m_CurrDetailProgress;
|
return m_CurrDetailProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetCurrRate()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Application.isPlaying) return 1;
|
||||||
|
#endif
|
||||||
|
if (!enable || m_IsEnd) return 1;
|
||||||
|
return m_CurrDetailProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetCurrIndex()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Application.isPlaying) return -1;
|
||||||
|
#endif
|
||||||
|
if (!enable || m_IsEnd) return -1;
|
||||||
|
return (int)m_CurrDetailProgress;
|
||||||
|
}
|
||||||
|
|
||||||
public float GetCurrData()
|
public float GetCurrData()
|
||||||
{
|
{
|
||||||
return m_CurrDataProgress;
|
return m_CurrDataProgress;
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ namespace XCharts
|
|||||||
var borderColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderColor : Color.clear;
|
var borderColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderColor : Color.clear;
|
||||||
borderColor.a *= serie.itemStyle.opacity;
|
borderColor.a *= serie.itemStyle.opacity;
|
||||||
serie.dataPoints.Clear();
|
serie.dataPoints.Clear();
|
||||||
|
serie.animation.InitProgress(1, 0, xCount);
|
||||||
|
var animationIndex = serie.animation.GetCurrIndex();
|
||||||
for (int i = 0; i < xCount; i++)
|
for (int i = 0; i < xCount; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < yCount; j++)
|
for (int j = 0; j < yCount; j++)
|
||||||
@@ -157,6 +159,7 @@ namespace XCharts
|
|||||||
if (!m_VisualMap.IsInSelectedValue(value)) continue;
|
if (!m_VisualMap.IsInSelectedValue(value)) continue;
|
||||||
color = m_VisualMap.GetColor(value);
|
color = m_VisualMap.GetColor(value);
|
||||||
}
|
}
|
||||||
|
if(animationIndex>= 0 && i> animationIndex) continue;
|
||||||
serieData.canShowLabel = true;
|
serieData.canShowLabel = true;
|
||||||
var emphasis = (m_Tooltip.show && i == (int)m_Tooltip.xValues[0] && j == (int)m_Tooltip.yValues[0])
|
var emphasis = (m_Tooltip.show && i == (int)m_Tooltip.xValues[0] && j == (int)m_Tooltip.yValues[0])
|
||||||
|| m_VisualMap.rtSelectedIndex > 0;
|
|| m_VisualMap.rtSelectedIndex > 0;
|
||||||
@@ -175,6 +178,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!serie.animation.IsFinish())
|
||||||
|
{
|
||||||
|
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
||||||
|
float speed = xCount / duration;
|
||||||
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void DrawVisualMap(VertexHelper vh)
|
protected void DrawVisualMap(VertexHelper vh)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
public partial class CoordinateChart
|
public partial class CoordinateChart
|
||||||
{
|
{
|
||||||
protected void DrawScatterSerie(VertexHelper vh,int colorIndex, Serie serie)
|
protected void DrawScatterSerie(VertexHelper vh, int colorIndex, Serie serie)
|
||||||
{
|
{
|
||||||
var yAxis = m_YAxises[serie.axisIndex];
|
var yAxis = m_YAxises[serie.axisIndex];
|
||||||
var xAxis = m_XAxises[serie.axisIndex];
|
var xAxis = m_XAxises[serie.axisIndex];
|
||||||
@@ -16,6 +16,8 @@ namespace XCharts
|
|||||||
int maxCount = serie.maxShow > 0 ?
|
int maxCount = serie.maxShow > 0 ?
|
||||||
(serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
|
(serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
|
||||||
: serie.dataCount;
|
: serie.dataCount;
|
||||||
|
serie.animation.InitProgress(1, 0, 1);
|
||||||
|
var rate = serie.animation.GetCurrRate();
|
||||||
for (int n = serie.minShow; n < maxCount; n++)
|
for (int n = serie.minShow; n < maxCount; n++)
|
||||||
{
|
{
|
||||||
var serieData = serie.GetDataList(m_DataZoom)[n];
|
var serieData = serie.GetDataList(m_DataZoom)[n];
|
||||||
@@ -37,6 +39,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
symbolSize = serie.symbol.GetSize(datas);
|
symbolSize = serie.symbol.GetSize(datas);
|
||||||
}
|
}
|
||||||
|
symbolSize *= rate;
|
||||||
if (symbolSize > 100) symbolSize = 100;
|
if (symbolSize > 100) symbolSize = 100;
|
||||||
if (serie.type == SerieType.EffectScatter)
|
if (serie.type == SerieType.EffectScatter)
|
||||||
{
|
{
|
||||||
@@ -53,6 +56,13 @@ namespace XCharts
|
|||||||
DrawSymbol(vh, serie.symbol.type, symbolSize, 3, pos, color);
|
DrawSymbol(vh, serie.symbol.type, symbolSize, 3, pos, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!serie.animation.IsFinish())
|
||||||
|
{
|
||||||
|
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
||||||
|
float speed = 1 / duration;
|
||||||
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,10 +206,12 @@ namespace XCharts
|
|||||||
int indicatorNum = radar.indicatorList.Count;
|
int indicatorNum = radar.indicatorList.Count;
|
||||||
var angle = 2 * Mathf.PI / indicatorNum;
|
var angle = 2 * Mathf.PI / indicatorNum;
|
||||||
Vector3 p = radar.centerPos;
|
Vector3 p = radar.centerPos;
|
||||||
|
serie.animation.InitProgress(1,0,1);
|
||||||
if (!IsActive(i))
|
if (!IsActive(i))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
var rate = serie.animation.GetCurrRate();
|
||||||
for (int j = 0; j < serie.data.Count; j++)
|
for (int j = 0; j < serie.data.Count; j++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
@@ -263,6 +265,7 @@ namespace XCharts
|
|||||||
var radius = max < 0 ? radar.actualRadius - radar.actualRadius * value / max
|
var radius = max < 0 ? radar.actualRadius - radar.actualRadius * value / max
|
||||||
: radar.actualRadius * value / max;
|
: radar.actualRadius * value / max;
|
||||||
var currAngle = n * angle;
|
var currAngle = n * angle;
|
||||||
|
radius *= rate;
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
|
startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
|
||||||
@@ -304,6 +307,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!serie.animation.IsFinish())
|
||||||
|
{
|
||||||
|
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
||||||
|
float speed = 1 / duration;
|
||||||
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user