完善SerieSymbol以支持象形柱图PictorialBarChart扩展

This commit is contained in:
monitor1394
2021-07-22 08:11:12 +08:00
parent f452905f7a
commit 16d6a5a3a0
9 changed files with 100 additions and 11 deletions

View File

@@ -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,

View File

@@ -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<double> m_PreviousData = new List<double>();
private List<float> m_DataUpdateTime = new List<float>();
private List<bool> m_DataUpdateFlag = new List<bool>();

View File

@@ -7,6 +7,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
@@ -43,7 +44,11 @@ namespace XCharts
/// <summary>
/// 箭头。
/// </summary>
Arrow
Arrow,
/// <summary>
/// 自定义标记。
/// </summary>
Custom
}
/// <summary>
@@ -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;
}
/// <summary>
@@ -241,6 +258,52 @@ namespace XCharts
get { return m_Gap; }
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 图形的宽。
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); }
}
/// <summary>
/// 图形的高。
/// </summary>
public float height
{
get { return m_Height; }
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
}
/// <summary>
/// 图形是否重复。
/// </summary>
public bool repeat
{
get { return m_Repeat; }
set { if (PropertyUtil.SetStruct(ref m_Repeat, value)) SetAllDirty(); }
}
/// <summary>
/// 自定义的标记图形。
/// </summary>
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(); }
}
/// <summary>
/// 图形的偏移。
/// </summary>
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<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
/// <summary>
/// the setting for effect scatter.

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -387,7 +387,8 @@ namespace XCharts
return ChartHelper.GetOrAddComponent<Painter>(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<Image>(iconObj);
img.raycastTarget = false;
img.type = type;
if (sprite != null)
{
img.sprite = sprite;
if (width == 0 || height == 0)
{
img.SetNativeSize();
}
}
return img;
}