diff --git a/Assets/XCharts/Scripts/Editor/PropertyDrawers/SerieDrawer.cs b/Assets/XCharts/Scripts/Editor/PropertyDrawers/SerieDrawer.cs index 2f834723..995d9a51 100644 --- a/Assets/XCharts/Scripts/Editor/PropertyDrawers/SerieDrawer.cs +++ b/Assets/XCharts/Scripts/Editor/PropertyDrawers/SerieDrawer.cs @@ -44,7 +44,9 @@ namespace XCharts drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_AxisIndex); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - if (type.enumValueIndex == (int)SerieType.Line || type.enumValueIndex == (int)SerieType.Scatter) + if (type.enumValueIndex == (int)SerieType.Line + || type.enumValueIndex == (int)SerieType.Scatter + || type.enumValueIndex == (int)SerieType.EffectScatter) { EditorGUI.PropertyField(drawRect, m_Symbol); drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol); @@ -169,7 +171,9 @@ namespace XCharts { height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; SerializedProperty type = prop.FindPropertyRelative("m_Type"); - if (type.enumValueIndex == (int)SerieType.Line || type.enumValueIndex == (int)SerieType.Scatter) + if (type.enumValueIndex == (int)SerieType.Line + || type.enumValueIndex == (int)SerieType.Scatter + || type.enumValueIndex == (int)SerieType.EffectScatter) { height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol")); diff --git a/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs b/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs index feb9a27f..27e686e2 100644 --- a/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs +++ b/Assets/XCharts/Scripts/UI/Internal/CoordinateChart.cs @@ -176,7 +176,8 @@ namespace XCharts { var xdata = serie.xData[n]; var ydata = serie.yData[n]; - var symbolSize = serie.symbol.GetSize(serie.data[n].data); + var serieData = serie.GetSerieData(n); + var symbolSize = serie.symbol.GetSize(serieData == null?null:serieData.data); if (Mathf.Abs(xValue - xdata) / xRate < symbolSize && Mathf.Abs(yValue - ydata) / yRate < symbolSize) { diff --git a/Assets/XCharts/Scripts/UI/Internal/Serie.cs b/Assets/XCharts/Scripts/UI/Internal/Serie.cs index e7a99e88..f2ced880 100644 --- a/Assets/XCharts/Scripts/UI/Internal/Serie.cs +++ b/Assets/XCharts/Scripts/UI/Internal/Serie.cs @@ -82,8 +82,13 @@ namespace XCharts public SymbolSizeCallback sizeCallback { get { return m_SizeCallback; } set { m_SizeCallback = value; } } public SymbolSizeCallback selectedSizeCallback { get { return m_SelectedSizeCallback; } set { m_SelectedSizeCallback = value; } } + private List m_AnimationSize = new List(){0,5,10}; + public List animationSize { get{return m_AnimationSize;}} + public Color animationColor { get; set; } + public float GetSize(List data) { + if(data == null) return size; switch (m_SizeType) { case SerieSymbolSizeType.Custom: @@ -106,6 +111,7 @@ namespace XCharts public float GetSelectedSize(List data) { + if(data == null) return selectedSize; switch (m_SizeType) { case SerieSymbolSizeType.Custom: @@ -305,6 +311,15 @@ namespace XCharts return 0; } + public SerieData GetSerieData(int index,DataZoom dataZoom = null){ + var data = GetDataList(dataZoom); + if (index >= 0 && index <= data.Count - 1) + { + return data[index]; + } + return null; + } + public void GetXYData(int index, DataZoom dataZoom, out float xValue, out float yVlaue) { xValue = 0; @@ -372,6 +387,8 @@ namespace XCharts } } + + public void UpdateFilterData(DataZoom dataZoom) { if (dataZoom != null && dataZoom.show) diff --git a/Assets/XCharts/Scripts/UI/ScatterChart.cs b/Assets/XCharts/Scripts/UI/ScatterChart.cs index f91d4ad9..7f2c6d78 100644 --- a/Assets/XCharts/Scripts/UI/ScatterChart.cs +++ b/Assets/XCharts/Scripts/UI/ScatterChart.cs @@ -14,6 +14,10 @@ namespace XCharts public Scatter scatter { get { return m_Scatter; } } + private float m_EffectScatterSpeed = 15; + private float m_EffectScatterSize; + private float m_EffectScatterAplha; + #if UNITY_EDITOR protected override void Reset() { @@ -34,6 +38,31 @@ namespace XCharts } #endif + protected override void Update() + { + base.Update(); + bool hasEffectScatter = false; + foreach (var serie in m_Series.series) + { + if (serie.type == SerieType.EffectScatter) + { + hasEffectScatter = true; + for (int i = 0; i < serie.symbol.animationSize.Count; ++i) + { + serie.symbol.animationSize[i] += m_EffectScatterSpeed * Time.deltaTime; + if (serie.symbol.animationSize[i] > serie.symbol.size) + { + serie.symbol.animationSize[i] = i*5; + } + } + } + } + if (hasEffectScatter) + { + RefreshChart(); + } + } + protected override void DrawChart(VertexHelper vh) { base.DrawChart(vh); @@ -55,6 +84,8 @@ namespace XCharts { continue; } + var color = m_ThemeInfo.GetColor(serieNameCount); + color.a = 200; int maxCount = maxShowDataNumber > 0 ? (maxShowDataNumber > serie.dataCount ? serie.dataCount : maxShowDataNumber) : serie.dataCount; @@ -68,8 +99,7 @@ namespace XCharts float xDataHig = (xValue - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWid; float yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHig; var pos = new Vector3(pX + xDataHig, pY + yDataHig); - var color = m_ThemeInfo.GetColor(serieNameCount); - color.a = 200; + var datas = serie.data[n].data; float symbolSize = 0; if (serie.selected && n == m_Tooltip.dataIndex[serie.axisIndex]) @@ -81,7 +111,20 @@ namespace XCharts symbolSize = serie.symbol.GetSize(datas); } if (symbolSize > 100) symbolSize = 100; - DrawSymbol(vh, serie.symbol.type, symbolSize, 3, pos, color); + if (serie.type == SerieType.EffectScatter) + { + for (int count = 0; count < serie.symbol.animationSize.Count; count++) + { + var nowSize = serie.symbol.animationSize[count]; + color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize); + DrawSymbol(vh, serie.symbol.type, nowSize, 3, pos, color); + } + RefreshChart(); + } + else + { + DrawSymbol(vh, serie.symbol.type, symbolSize, 3, pos, color); + } } if (vh.currentVertCount > 60000) { diff --git a/README.md b/README.md index f7259894..5669d558 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ QQ交流群:XCharts交流群(202030963) ## 更新日志 +* (2019.07.22)增加`EffectScatter`类型的散点图 * (2019.07.21)增加`ScatterChart`散点图 * (2019.07.21)增加`SerieData`支持多维数据配置 * (2019.07.20)增加`Symbol`配置`Serie`标志图形的显示,支持`EmptyCircle`,`Cricle`,`Rect`,`Triangle`,`Diamond`,`None`等图形形状