diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index 7db5bc95..07fcd601 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -2,6 +2,7 @@ # 更新日志 [master](#master) +[v2.2.2](#v2.2.2) [v2.2.1](#v2.2.1) [v2.2.0](#v2.2.0) [v2.1.1](#v2.1.1) @@ -36,6 +37,14 @@ ## master +## v2.2.2 + +* (2021.06.18) Release `v2.2.2` version +* (2021.06.18) Optimize `Axis` to automatically hide `Icon` when `Label` is empty +* (2021.06.17) Fixed an issue where `maxCache` was set to one more number of actual data +* (2021.06.17) Fixed an issue where `TextMeshPro` could not be opened and closed in time to refresh +* (2021.06.17) Fixed an issue where `XCharts` always pops up when importing `XCharts` + ## v2.2.1 * (2021.06.13) Release `v2.2.1` version diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index d871044f..023d0b8b 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -2,6 +2,7 @@ # 更新日志 [master](#master) +[v2.2.2](#v2.2.2) [v2.2.1](#v2.2.1) [v2.2.0](#v2.2.0) [v2.1.1](#v2.1.1) @@ -36,6 +37,14 @@ ## master +## v2.2.2 + +* (2021.06.18) 发布`v2.2.2`版本 +* (2021.06.18) 优化`Axis`的`Label`为空时自动隐藏`Icon` +* (2021.06.17) 修复`maxCache`设置时实际数据个数多一个的问题 +* (2021.06.17) 修复`TextMeshPro`的开启和关闭不及时刷新的问题 +* (2021.06.17) 修复`XCharts`导入时总是弹出`XCharts Importer`的问题 + ## v2.2.1 * (2021.06.13) 发布`v2.2.1`版本 diff --git a/Assets/XCharts/Editor/Utility/XChartsBuild.cs b/Assets/XCharts/Editor/Utility/XChartsBuild.cs index 9c8f2f28..0f589bce 100644 --- a/Assets/XCharts/Editor/Utility/XChartsBuild.cs +++ b/Assets/XCharts/Editor/Utility/XChartsBuild.cs @@ -5,13 +5,12 @@ /* */ /************************************************/ -using System.IO; using UnityEditor; using UnityEditor.Build; -using UnityEngine; namespace XCharts { + [System.Obsolete] public class XChartsBuild : IPreprocessBuild, IPostprocessBuild { public int callbackOrder => 1; diff --git a/Assets/XCharts/Editor/XChartEditor.cs b/Assets/XCharts/Editor/XChartEditor.cs index a66d5264..25039491 100644 --- a/Assets/XCharts/Editor/XChartEditor.cs +++ b/Assets/XCharts/Editor/XChartEditor.cs @@ -165,13 +165,14 @@ public static void EnableTextMeshPro() Debug.LogError("TextMeshPro is not in the project, please import TextMeshPro package first."); return; } - XChartsMgr.ModifyTMPRefence(); XChartsMgr.EnableTextMeshPro(); + XChartsMgr.ModifyTMPRefence(); } [MenuItem("XCharts/TextMeshPro Disable")] public static void DisableTextMeshPro() { + XChartsMgr.ModifyTMPRefence(true); XChartsMgr.DisableTextMeshPro(); } } diff --git a/Assets/XCharts/Runtime/Component/Main/Axis.cs b/Assets/XCharts/Runtime/Component/Main/Axis.cs index fcdd6167..c26969bd 100644 --- a/Assets/XCharts/Runtime/Component/Main/Axis.cs +++ b/Assets/XCharts/Runtime/Component/Main/Axis.cs @@ -570,7 +570,7 @@ public void AddData(string category) { if (maxCache > 0) { - while (m_Data.Count > maxCache) + while (m_Data.Count >= maxCache) { m_NeedUpdateFilterData = true; m_Data.RemoveAt(m_InsertDataToHead ? m_Data.Count - 1 : 0); diff --git a/Assets/XCharts/Runtime/Component/Main/DataZoom.cs b/Assets/XCharts/Runtime/Component/Main/DataZoom.cs index 08e8ee8c..9136f69e 100644 --- a/Assets/XCharts/Runtime/Component/Main/DataZoom.cs +++ b/Assets/XCharts/Runtime/Component/Main/DataZoom.cs @@ -1024,7 +1024,6 @@ private void DrawDataZoomSlider(VertexHelper vh, DataZoom dataZoom) var p2 = new Vector3(dataZoom.runtimeX, dataZoom.runtimeY + dataZoom.runtimeHeight); var p3 = new Vector3(dataZoom.runtimeX + dataZoom.runtimeWidth, dataZoom.runtimeY + dataZoom.runtimeHeight); var p4 = new Vector3(dataZoom.runtimeX + dataZoom.runtimeWidth, dataZoom.runtimeY); - var xAxis = chart.GetXAxis(0); var lineColor = dataZoom.lineStyle.GetColor(chart.theme.dataZoom.dataLineColor); var lineWidth = dataZoom.lineStyle.GetWidth(chart.theme.dataZoom.dataLineWidth); var borderWidth = dataZoom.borderWidth == 0 ? chart.theme.dataZoom.borderWidth : dataZoom.borderWidth; diff --git a/Assets/XCharts/Runtime/Component/Main/Serie.cs b/Assets/XCharts/Runtime/Component/Main/Serie.cs index 6879292b..e92f1b2a 100644 --- a/Assets/XCharts/Runtime/Component/Main/Serie.cs +++ b/Assets/XCharts/Runtime/Component/Main/Serie.cs @@ -1497,7 +1497,7 @@ public SerieData AddData(List valueList, string dataName = null) private void CheckMaxCache() { if (m_MaxCache <= 0) return; - while (m_Data.Count > m_MaxCache) + while (m_Data.Count >= m_MaxCache) { m_NeedUpdateFilterData = true; if (m_InsertDataToHead) RemoveData(m_Data.Count - 1); diff --git a/Assets/XCharts/Runtime/Component/Main/VisualMap.cs b/Assets/XCharts/Runtime/Component/Main/VisualMap.cs index 952e4ed9..de614c0d 100644 --- a/Assets/XCharts/Runtime/Component/Main/VisualMap.cs +++ b/Assets/XCharts/Runtime/Component/Main/VisualMap.cs @@ -928,7 +928,6 @@ private void DrawPiecewiseVisualMap(VertexHelper vh, VisualMap visualMap) var halfWid = visualMap.itemWidth / 2; var halfHig = visualMap.itemHeight / 2; var splitNum = visualMap.runtimeInRange.Count; - var splitWid = visualMap.itemHeight / (splitNum - 1); var colors = visualMap.runtimeInRange; switch (visualMap.orient) { diff --git a/Assets/XCharts/Runtime/Helper/DataZoomHelper.cs b/Assets/XCharts/Runtime/Helper/DataZoomHelper.cs index d359bb86..f16aa38f 100644 --- a/Assets/XCharts/Runtime/Helper/DataZoomHelper.cs +++ b/Assets/XCharts/Runtime/Helper/DataZoomHelper.cs @@ -12,7 +12,7 @@ public static class DataZoomHelper { public static DataZoom GetDataZoom(Serie serie, List dataZooms) { - if(serie == null) return null; + if (serie == null) return null; foreach (var dataZoom in dataZooms) { if (!dataZoom.enable) continue; @@ -25,13 +25,36 @@ public static DataZoom GetDataZoom(Serie serie, List dataZooms) return null; } - public static void UpdateDataZoomRuntimeStartEndValue(DataZoom dataZoom, Serie serie){ - if(dataZoom == null || serie == null) return; + public static void UpdateDataZoomRuntimeStartEndValue(DataZoom dataZoom, Serie serie) + { + if (dataZoom == null || serie == null) return; float min = 0; float max = 0; SerieHelper.GetMinMaxData(serie, out min, out max, null); - dataZoom.runtimeStartValue = min + (max-min) * dataZoom.start / 100; - dataZoom.runtimeEndValue = min +(max-min) * dataZoom.end / 100; + dataZoom.runtimeStartValue = min + (max - min) * dataZoom.start / 100; + dataZoom.runtimeEndValue = min + (max - min) * dataZoom.end / 100; + } + + public static void UpdateDataZoomRuntimeStartEndValue(List dataZooms, Series series, SerieType serieType) + { + foreach (var dataZoom in dataZooms) + { + if (!dataZoom.enable) continue; + float min = float.MaxValue; + float max = float.MinValue; + foreach (var serie in series.list) + { + if (!serie.show || serie.type != serieType) continue; + if (!dataZoom.IsXAxisIndexValue(serie.xAxisIndex)) continue; + var serieMinValue = 0f; + var serieMaxValue = 0f; + SerieHelper.GetMinMaxData(serie, out serieMinValue, out serieMaxValue, null, 2); + if (serieMinValue < min) min = serieMinValue; + if (serieMaxValue > max) max = serieMaxValue; + } + dataZoom.runtimeStartValue = min + (max - min) * dataZoom.start / 100; + dataZoom.runtimeEndValue = min + (max - min) * dataZoom.end / 100; + } } } } \ No newline at end of file diff --git a/Assets/XCharts/Runtime/Helper/SerieHelper.cs b/Assets/XCharts/Runtime/Helper/SerieHelper.cs index 025f9571..a4c871e1 100644 --- a/Assets/XCharts/Runtime/Helper/SerieHelper.cs +++ b/Assets/XCharts/Runtime/Helper/SerieHelper.cs @@ -48,7 +48,7 @@ public static void GetMinMaxData(Serie serie, int dimension, out float min, out /// /// /// - public static void GetMinMaxData(Serie serie, out float min, out float max, DataZoom dataZoom = null) + public static void GetMinMaxData(Serie serie, out float min, out float max, DataZoom dataZoom = null, int dimension = 0) { max = float.MinValue; min = float.MaxValue; @@ -58,7 +58,9 @@ public static void GetMinMaxData(Serie serie, out float min, out float max, Data var serieData = dataList[i]; if (serieData.show) { - var count = serie.showDataDimension > serieData.data.Count + var count = 0; + if (dimension > 0) count = dimension; + else count = serie.showDataDimension > serieData.data.Count ? serieData.data.Count : serie.showDataDimension; for (int j = 0; j < count; j++) diff --git a/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs b/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs index 341059f8..57b64a1f 100644 --- a/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs +++ b/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs @@ -12,6 +12,7 @@ namespace XCharts { public class ChartLabel : ChartObject { + private bool m_EmptyStringHideIcon = false; private bool m_LabelAutoSize = true; private float m_LabelPaddingLeftRight = 3f; private float m_LabelPaddingTopBottom = 3f; @@ -48,6 +49,8 @@ public ChartText label } } + public bool emptyStringHideIcon { set { m_EmptyStringHideIcon = value; } } + public ChartLabel() { } @@ -179,6 +182,10 @@ public bool SetText(string text) return sizeChange; } AdjustIconPos(); + if (m_EmptyStringHideIcon) + { + ChartHelper.SetActive(m_IconImage.gameObject, !string.IsNullOrEmpty(text)); + } } return false; } diff --git a/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs b/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs index d4774439..4dd596ee 100644 --- a/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs +++ b/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs @@ -405,6 +405,7 @@ public static ChartLabel AddAxisLabelObject(int index, string name, Transform pa var textStyle = axis.axisLabel.textStyle; var iconStyle = axis.iconStyle; var label = new ChartLabel(); + label.emptyStringHideIcon = true; label.gameObject = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); // TODO: 为了兼容旧版本,这里后面版本可以去掉 diff --git a/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs b/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs index e1f8b40f..16b6360c 100644 --- a/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs +++ b/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs @@ -180,7 +180,6 @@ public static bool ExportTheme(ChartTheme theme) { Directory.CreateDirectory(themeAssetPath); } - var assetPath = string.Format("{0}/{1}", XChartsSettings.THEME_ASSET_FOLDER, themeAssetName); var themeAssetFilePath = string.Format("{0}/{1}.json", themeAssetPath, themeAssetName); var json = JsonUtility.ToJson(theme, true); File.WriteAllText(themeAssetFilePath, json); diff --git a/Assets/XCharts/Runtime/XChartsMgr.cs b/Assets/XCharts/Runtime/XChartsMgr.cs index 6e049d9b..713ed8f3 100644 --- a/Assets/XCharts/Runtime/XChartsMgr.cs +++ b/Assets/XCharts/Runtime/XChartsMgr.cs @@ -33,8 +33,8 @@ class XChartsVersion [ExecuteInEditMode] public class XChartsMgr : MonoBehaviour { - internal static string _version = "2.2.1"; - internal static int _versionDate = 20210613; + internal static string _version = "2.2.2"; + internal static int _versionDate = 20210618; public static string version { get { return _version; } } public static int versionDate { get { return _versionDate; } } public static string fullVersion { get { return version + "-" + versionDate; } } @@ -64,14 +64,6 @@ public static XChartsMgr Instance } } -#if UNITY_EDITOR - [InitializeOnLoadMethod] - private static void OnInitializeOnLoadMethod() - { - XThemeMgr.ReloadThemeList(); - } -#endif - private void Awake() { SerieLabelPool.ClearAll(); @@ -414,6 +406,7 @@ private static bool ModifyTMPRefence(string asmdefPath, bool removeTMP = false) var addedTMP = false; var removedTMP = false; var tmpName = "\"Unity.TextMeshPro\""; + var refCount = 0; foreach (var line in lines) { if (string.IsNullOrEmpty(line)) continue; @@ -427,6 +420,12 @@ private static bool ModifyTMPRefence(string asmdefPath, bool removeTMP = false) if (line.Contains("],")) { referencesStart = false; + if (refCount > 0) + { + var old = dest[dest.Count - 1]; + if (old.EndsWith(",")) + dest[dest.Count - 1] = old.Substring(0, old.Length - 1); + } if (!removeTMP && !refs.Contains(tmpName)) { if (refs.Count > 0) @@ -446,8 +445,12 @@ private static bool ModifyTMPRefence(string asmdefPath, bool removeTMP = false) { if (!line.Contains(tmpName)) { - removedTMP = true; dest.Add(line); + refCount++; + } + else + { + removedTMP = true; } } else @@ -462,7 +465,12 @@ private static bool ModifyTMPRefence(string asmdefPath, bool removeTMP = false) dest.Add(line); } } - if (addedTMP || removedTMP) File.WriteAllText(asmdefPath, string.Join("\n", dest.ToArray())); + if (addedTMP || removedTMP) + { + File.WriteAllText(asmdefPath, string.Join("\n", dest.ToArray())); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + } return true; } catch (System.Exception e) diff --git a/Assets/XCharts/package.json b/Assets/XCharts/package.json index 61040b8c..872a21d0 100644 --- a/Assets/XCharts/package.json +++ b/Assets/XCharts/package.json @@ -1,9 +1,9 @@ { "name": "com.monitor1394.xcharts", "displayName": "XCharts", - "version": "2.2.1", - "date": "20210613", - "checkdate": "20210613", + "version": "2.2.2", + "date": "20210618", + "checkdate": "20210618", "desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!", "unity": "2018.3", "description": "A charting and data visualization library for Unity.", diff --git a/Assets/XCharts/version.json b/Assets/XCharts/version.json index 8feeb7ed..3144966e 100644 --- a/Assets/XCharts/version.json +++ b/Assets/XCharts/version.json @@ -1,7 +1,7 @@ { - "version": "2.2.1", - "date": "20210613", - "checkdate": "20210613", + "version": "2.2.2", + "date": "20210618", + "checkdate": "20210618", "desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!", "homepage": "https://github.com/monitor1394/unity-ugui-XCharts" } \ No newline at end of file