mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 07:20:08 +00:00
增加双坐标轴支持
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -12,24 +13,22 @@ namespace XCharts
|
||||
|
||||
[NonSerialized] private GameObject m_GameObject;
|
||||
[NonSerialized] private GameObject m_Content;
|
||||
[NonSerialized] private GameObject m_LabelX;
|
||||
[NonSerialized] private GameObject m_LabelY;
|
||||
[NonSerialized] private Text m_ContentText;
|
||||
[NonSerialized] private Text m_LabelTextX;
|
||||
[NonSerialized] private Text m_LabelTextY;
|
||||
[NonSerialized] private RectTransform m_ContentRect;
|
||||
[NonSerialized] private RectTransform m_LabelRectX;
|
||||
[NonSerialized] private RectTransform m_LabelRectY;
|
||||
|
||||
public bool show { get { return m_Show; } set { m_Show = value; SetActive(value); } }
|
||||
public bool crossLabel { get { return m_CrossLabel; } set { m_CrossLabel = value; } }
|
||||
|
||||
public int dataIndex { get; set; }
|
||||
|
||||
public float[] xValues { get; set; }
|
||||
public float[] yValues { get; set; }
|
||||
public int lastDataIndex { get; set; }
|
||||
public Vector2 pointerPos { get; set; }
|
||||
public float width { get { return m_ContentRect.sizeDelta.x; } }
|
||||
public float height { get { return m_ContentRect.sizeDelta.y; } }
|
||||
public bool isInited { get { return m_GameObject != null; } }
|
||||
public GameObject gameObject { get { return m_GameObject; } }
|
||||
|
||||
public static Tooltip defaultTooltip
|
||||
{
|
||||
@@ -38,7 +37,9 @@ namespace XCharts
|
||||
var tooltip = new Tooltip
|
||||
{
|
||||
m_Show = true,
|
||||
m_CrossLabel = false
|
||||
m_CrossLabel = false,
|
||||
xValues = new float[2],
|
||||
yValues = new float[2],
|
||||
};
|
||||
return tooltip;
|
||||
}
|
||||
@@ -57,16 +58,9 @@ namespace XCharts
|
||||
m_ContentText = m_Content.GetComponentInChildren<Text>();
|
||||
}
|
||||
|
||||
public void SetLabelObj(GameObject labelX, GameObject labelY)
|
||||
{
|
||||
m_LabelX = labelX;
|
||||
m_LabelRectX = labelX.GetComponent<RectTransform>();
|
||||
m_LabelTextX = labelX.GetComponentInChildren<Text>();
|
||||
m_LabelY = labelY;
|
||||
m_LabelRectY = labelY.GetComponent<RectTransform>();
|
||||
m_LabelTextY = labelY.GetComponentInChildren<Text>();
|
||||
m_LabelX.SetActive(false);
|
||||
m_LabelY.SetActive(false);
|
||||
public void UpdateToTop(){
|
||||
int count = m_GameObject.transform.parent.childCount;
|
||||
m_GameObject.GetComponent<RectTransform>().SetSiblingIndex(count - 1);
|
||||
}
|
||||
|
||||
public void SetContentBackgroundColor(Color color)
|
||||
@@ -82,18 +76,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLabelBackgroundColor(Color color)
|
||||
{
|
||||
m_LabelX.GetComponent<Image>().color = color;
|
||||
m_LabelY.GetComponent<Image>().color = color;
|
||||
}
|
||||
|
||||
public void SetLabelTextColor(Color color)
|
||||
{
|
||||
m_LabelTextX.color = color;
|
||||
m_LabelTextY.color = color;
|
||||
}
|
||||
|
||||
public void UpdateContentText(string txt)
|
||||
{
|
||||
if (m_ContentText)
|
||||
@@ -104,20 +86,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateLabelText(string labelX, string labelY)
|
||||
public void ClearValue()
|
||||
{
|
||||
if (m_LabelTextX)
|
||||
{
|
||||
m_LabelTextX.text = labelX;
|
||||
m_LabelRectX.sizeDelta = new Vector2(m_LabelTextX.preferredWidth + 8,
|
||||
m_LabelTextX.preferredHeight + 8);
|
||||
}
|
||||
if (m_LabelTextY)
|
||||
{
|
||||
m_LabelTextY.text = labelY;
|
||||
m_LabelRectY.sizeDelta = new Vector2(m_LabelTextY.preferredWidth + 8,
|
||||
m_LabelTextY.preferredHeight + 8);
|
||||
}
|
||||
dataIndex = 0;
|
||||
xValues[0] = xValues[1] = 0;
|
||||
yValues[0] = yValues[1] = 0;
|
||||
}
|
||||
|
||||
public void SetActive(bool flag)
|
||||
@@ -127,30 +100,12 @@ namespace XCharts
|
||||
m_GameObject.SetActive(flag);
|
||||
}
|
||||
|
||||
public void SetLabelActive(bool flag)
|
||||
{
|
||||
if (m_LabelX && m_LabelX.activeInHierarchy != flag) m_LabelX.SetActive(flag);
|
||||
if (m_LabelY && m_LabelY.activeInHierarchy != flag) m_LabelY.SetActive(flag);
|
||||
}
|
||||
|
||||
public void UpdateContentPos(Vector2 pos)
|
||||
{
|
||||
if (m_Content)
|
||||
m_Content.transform.localPosition = pos;
|
||||
}
|
||||
|
||||
public void UpdateLabelPos(Vector2 xLabelPos, Vector2 yLabelPos)
|
||||
{
|
||||
if (m_LabelX)
|
||||
{
|
||||
m_LabelX.transform.localPosition = xLabelPos;
|
||||
}
|
||||
if (m_LabelY)
|
||||
{
|
||||
m_LabelY.transform.localPosition = yLabelPos;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetContentPos()
|
||||
{
|
||||
if (m_Content)
|
||||
|
||||
Reference in New Issue
Block a user