add tooltip delegate function: positionFunction

This commit is contained in:
monitor1394
2021-11-27 22:06:15 +08:00
parent cc72f303f1
commit 4d6e896d32
4 changed files with 25 additions and 3 deletions

View File

@@ -40,6 +40,7 @@
## master ## master
* (2021.11.27) Added `Tooltip` delegate function `positionFunction`
* (2021.10.29) Removed settings for `TextMeshPro` when package first imported * (2021.10.29) Removed settings for `TextMeshPro` when package first imported
* (2021.10.29) Added support for `{e}` in `Tooltip` #170 * (2021.10.29) Added support for `{e}` in `Tooltip` #170
* (2021.09.08) Improved `RadarChart` * (2021.09.08) Improved `RadarChart`

View File

@@ -40,6 +40,7 @@
## master ## master
* (2021.11.27) 增加`Tooltip``positionFunction`的坐标设置委托函数
* (2021.10.29) 移除`XCharts`首次导入时`TextMeshPro`的相关设置 * (2021.10.29) 移除`XCharts`首次导入时`TextMeshPro`的相关设置
* (2021.10.29) 增加`Tooltip`对通配符`{e}`的支持 #170 * (2021.10.29) 增加`Tooltip`对通配符`{e}`的支持 #170
* (2021.09.08) 完善`RadarChart` * (2021.09.08) 完善`RadarChart`

View File

@@ -65,6 +65,7 @@ namespace XCharts
[SerializeField] private Sprite m_BackgroundImage; [SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(); [SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None); [SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
private DelegateTooltipPosition m_PositionFunction;
private GameObject m_GameObject; private GameObject m_GameObject;
private GameObject m_Content; private GameObject m_Content;
@@ -300,6 +301,12 @@ namespace XCharts
public int runtimeGridIndex { get; internal set; } public int runtimeGridIndex { get; internal set; }
public int runtimePolarIndex { get; internal set; } public int runtimePolarIndex { get; internal set; }
public DelegateTooltipPosition positionFunction
{
get { return m_PositionFunction; }
set { m_PositionFunction = value; }
}
public static Tooltip defaultTooltip public static Tooltip defaultTooltip
{ {
get get
@@ -449,7 +456,12 @@ namespace XCharts
public void UpdateContentPos(Vector2 pos) public void UpdateContentPos(Vector2 pos)
{ {
if (m_Content) if (m_Content)
m_Content.transform.localPosition = pos; {
if (m_PositionFunction != null)
m_Content.transform.localPosition = m_PositionFunction(pos);
else
m_Content.transform.localPosition = pos;
}
} }
/// <summary> /// <summary>

View File

@@ -6,11 +6,13 @@
/* */ /* */
/************************************************/ /************************************************/
using UnityEngine;
namespace XCharts namespace XCharts
{ {
/// <summary> /// <summary>
/// The delegate function for AxisLabel's formatter. | /// The delegate function for AxisLabel's formatter. |
/// AxisLabel的formatter自定义委托。 /// AxisLabel的formatter自定义委托函数
/// </summary> /// </summary>
/// <param name="labelIndex">label索引</param> /// <param name="labelIndex">label索引</param>
/// <param name="value">当前label对应的数值数据Value轴或Time轴有效</param> /// <param name="value">当前label对应的数值数据Value轴或Time轴有效</param>
@@ -19,10 +21,16 @@ namespace XCharts
public delegate string DelegateAxisLabelFormatter(int labelIndex, double value, string category); public delegate string DelegateAxisLabelFormatter(int labelIndex, double value, string category);
/// <summary> /// <summary>
/// The delegate function for SerieLabels formatter. /// The delegate function for SerieLabels formatter.
/// SerieLabel的formatter自定义委托。 /// SerieLabel的formatter自定义委托函数
/// </summary> /// </summary>
/// <param name="dataIndex">数据索引</param> /// <param name="dataIndex">数据索引</param>
/// <param name="value">数值</param> /// <param name="value">数值</param>
/// <returns>最终显示的文本内容</returns> /// <returns>最终显示的文本内容</returns>
public delegate string DelegateSerieLabelFormatter(int dataIndex, double value); public delegate string DelegateSerieLabelFormatter(int dataIndex, double value);
/// <summary>
/// Tooltip的position自定义委托函数。
/// </summary>
/// <param name="pos">Tooltip的当前坐标</param>
/// <returns>Tooltip的最终坐标</returns>
public delegate Vector3 DelegateTooltipPosition(Vector3 pos);
} }