diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index a4864095..c63512e2 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -38,6 +38,7 @@ ## master +* (2021.07.22) Improved `SerieSymbol` to support `PictorialBarchart` extension * (2021.07.19) Fixed issue where `Tooltip` was not displayed on `WdbGL` platform * (2021.07.18) Added `iconStyle` for serie * (2021.07.15) Added `MarkLine` (#142) diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index a79fb82e..ddc5e40e 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -38,6 +38,7 @@ ## master +* (2021.07.22) 完善`SerieSymbol`以支持象形柱图`PictorialBarChart`扩展 * (2021.07.19) 修复`WdbGL`平台上`Tooltip`不显示的问题 * (2021.07.18) 增加`Serie`的`iconStyle`统一配置图标 * (2021.07.15) 增加`MarkLine`标线 (#142) diff --git a/Assets/XCharts/Editor/PropertyDrawers/SerieSymbolDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/SerieSymbolDrawer.cs index db7f3dde..8381ea24 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/SerieSymbolDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/SerieSymbolDrawer.cs @@ -21,19 +21,28 @@ namespace XCharts if (MakeFoldout(prop, "m_Show")) { ++EditorGUI.indentLevel; + var type = (SerieSymbolType)prop.FindPropertyRelative("m_Type").enumValueIndex; PropertyField(prop, "m_Type"); + if (type == SerieSymbolType.Custom) + { + PropertyField(prop, "m_Image"); + PropertyField(prop, "m_ImageType"); + PropertyField(prop, "m_Width"); + // PropertyField(prop, "m_Height"); + // PropertyField(prop, "m_Offset"); + } PropertyField(prop, "m_Gap"); PropertyField(prop, "m_SizeType"); switch ((SerieSymbolSizeType)prop.FindPropertyRelative("m_SizeType").enumValueIndex) { case SerieSymbolSizeType.Custom: - PropertyField(prop, "m_Size"); - PropertyField(prop, "m_SelectedSize"); + PropertyField(prop, "m_Size"); + PropertyField(prop, "m_SelectedSize"); break; case SerieSymbolSizeType.FromData: - PropertyField(prop, "m_DataIndex"); - PropertyField(prop, "m_DataScale"); - PropertyField(prop, "m_SelectedDataScale"); + PropertyField(prop, "m_DataIndex"); + PropertyField(prop, "m_DataScale"); + PropertyField(prop, "m_SelectedDataScale"); break; case SerieSymbolSizeType.Callback: break; @@ -41,6 +50,7 @@ namespace XCharts PropertyField(prop, "m_StartIndex"); PropertyField(prop, "m_Interval"); PropertyField(prop, "m_ForceShowLast"); + PropertyField(prop, "m_Repeat"); --EditorGUI.indentLevel; } } diff --git a/Assets/XCharts/Runtime/API/BaseGraph_API.cs b/Assets/XCharts/Runtime/API/BaseGraph_API.cs index 8d35077f..fa2e04b0 100644 --- a/Assets/XCharts/Runtime/API/BaseGraph_API.cs +++ b/Assets/XCharts/Runtime/API/BaseGraph_API.cs @@ -166,8 +166,10 @@ namespace XCharts public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint) { -#if UNITY_STANDALONE - screenPoint = Display.RelativeMouseAt(screenPoint); +#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX + var relative = Display.RelativeMouseAt(screenPoint); + if(relative != Vector3.zero) + screenPoint = relative; #endif var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, diff --git a/Assets/XCharts/Runtime/Component/Sub/SerieData.cs b/Assets/XCharts/Runtime/Component/Sub/SerieData.cs index d206589c..90f6c1c7 100644 --- a/Assets/XCharts/Runtime/Component/Sub/SerieData.cs +++ b/Assets/XCharts/Runtime/Component/Sub/SerieData.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; namespace XCharts { @@ -176,6 +177,7 @@ namespace XCharts public float runtimeAngle { get; set; } public Vector3 runtiemPieOffsetCenter { get; set; } public float runtimeStackHig { get; set; } + public Image runtimeSymbol { get; set; } private List m_PreviousData = new List(); private List m_DataUpdateTime = new List(); private List m_DataUpdateFlag = new List(); diff --git a/Assets/XCharts/Runtime/Component/Sub/SerieSymbol.cs b/Assets/XCharts/Runtime/Component/Sub/SerieSymbol.cs index a4658fde..35305ea8 100644 --- a/Assets/XCharts/Runtime/Component/Sub/SerieSymbol.cs +++ b/Assets/XCharts/Runtime/Component/Sub/SerieSymbol.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; namespace XCharts { @@ -43,7 +44,11 @@ namespace XCharts /// /// 箭头。 /// - Arrow + Arrow, + /// + /// 自定义标记。 + /// + Custom } /// @@ -96,6 +101,12 @@ namespace XCharts [SerializeField] private int m_Interval; [SerializeField] private bool m_ForceShowLast = false; [SerializeField] private float m_Gap = 0; + [SerializeField] private float m_Width = 0f; + [SerializeField] private float m_Height = 0f; + [SerializeField] private bool m_Repeat = false; + [SerializeField] private Vector2 m_Offset = Vector2.zero; + [SerializeField] private Sprite m_Image; + [SerializeField] private Image.Type m_ImageType; public void Reset() { @@ -113,6 +124,12 @@ namespace XCharts m_Interval = 0; m_ForceShowLast = false; m_Gap = 0; + m_Width = 0f; + m_Height = 0f; + m_Repeat = false; + m_Offset = Vector2.zero; + m_Image = null; + m_ImageType = Image.Type.Simple; } /// @@ -241,6 +258,52 @@ namespace XCharts get { return m_Gap; } set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); } } + /// + /// 图形的宽。 + /// + public float width + { + get { return m_Width; } + set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); } + } + /// + /// 图形的高。 + /// + public float height + { + get { return m_Height; } + set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); } + } + /// + /// 图形是否重复。 + /// + public bool repeat + { + get { return m_Repeat; } + set { if (PropertyUtil.SetStruct(ref m_Repeat, value)) SetAllDirty(); } + } + /// + /// 自定义的标记图形。 + /// + public Sprite image + { + get { return m_Image; } + set { if (PropertyUtil.SetClass(ref m_Image, value)) SetAllDirty(); } + } + public Image.Type imageType + { + get { return m_ImageType; } + set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetAllDirty(); } + } + /// + /// 图形的偏移。 + /// + public Vector2 offset + { + get { return m_Offset; } + set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); } + } + public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } } private List m_AnimationSize = new List() { 0, 5, 10 }; /// /// the setting for effect scatter. diff --git a/Assets/XCharts/Runtime/Internal/BaseChart.cs b/Assets/XCharts/Runtime/Internal/BaseChart.cs index 8e8f63c9..1681f07a 100644 --- a/Assets/XCharts/Runtime/Internal/BaseChart.cs +++ b/Assets/XCharts/Runtime/Internal/BaseChart.cs @@ -163,7 +163,7 @@ namespace XCharts foreach (var draw in m_ComponentHandlers) draw.Update(); } - internal Painter GetPainter(int index) + public Painter GetPainter(int index) { if (index >= 0 && index < m_PainterList.Count) { diff --git a/Assets/XCharts/Runtime/Internal/BaseGraph.cs b/Assets/XCharts/Runtime/Internal/BaseGraph.cs index 35c08818..7a055939 100644 --- a/Assets/XCharts/Runtime/Internal/BaseGraph.cs +++ b/Assets/XCharts/Runtime/Internal/BaseGraph.cs @@ -56,7 +56,7 @@ namespace XCharts protected Vector2 graphAnchorMax { get { return m_GraphMinAnchor; } } protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } } protected Vector2 graphPivot { get { return m_GraphPivot; } } - internal HideFlags chartHideFlags { get { return m_DebugMode ? HideFlags.None : HideFlags.HideInHierarchy; } } + public HideFlags chartHideFlags { get { return m_DebugMode ? HideFlags.None : HideFlags.HideInHierarchy; } } private ScrollRect m_ScrollRect; diff --git a/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs b/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs index ae66e4c2..ec5f779d 100644 --- a/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs +++ b/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs @@ -387,7 +387,8 @@ namespace XCharts return ChartHelper.GetOrAddComponent(painterObj); } - public static Image AddIcon(string name, Transform parent, float width, float height) + public static Image AddIcon(string name, Transform parent, float width, float height, Sprite sprite = null, + Image.Type type = Image.Type.Simple) { var anchorMax = new Vector2(0.5f, 0.5f); var anchorMin = new Vector2(0.5f, 0.5f); @@ -396,6 +397,15 @@ namespace XCharts GameObject iconObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var img = GetOrAddComponent(iconObj); img.raycastTarget = false; + img.type = type; + if (sprite != null) + { + img.sprite = sprite; + if (width == 0 || height == 0) + { + img.SetNativeSize(); + } + } return img; }