3.0 - tooltip

This commit is contained in:
monitor1394
2022-02-12 20:10:29 +08:00
parent cc4ee3735c
commit a19b796a02
16 changed files with 88 additions and 36 deletions

View File

@@ -77,7 +77,8 @@ namespace XCharts
[SerializeField] private int m_PaddingTopBottom = 10;
[SerializeField] private bool m_IgnoreDataShow = false;
[SerializeField] private string m_IgnoreDataDefaultContent = "-";
[SerializeField] private bool m_AlwayShow = false;
[SerializeField] private bool m_ShowContent = true;
[SerializeField] private bool m_AlwayShowContent = false;
[SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f);
[SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private Color m_BackgroundColor;
@@ -241,9 +242,15 @@ namespace XCharts
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; SetComponentDirty(); } }
/// <summary>
/// Whether to trigger after always display.
/// 是否触发后一直显示。
/// 是否触发后一直显示提示框浮层
/// </summary>
public bool alwayShow { get { return m_AlwayShow; } set { m_AlwayShow = value; } }
public bool alwayShowContent { get { return m_AlwayShowContent; } set { m_AlwayShowContent = value; } }
/// <summary>
/// Whether to show the tooltip floating layer, whose default value is true.
/// It should be configurated to be false, if you only need tooltip to trigger the event or show the axisPointer without content.
/// 是否显示提示框浮层默认显示。只需tooltip触发事件或显示axisPointer而不需要显示内容时可配置该项为false。
/// </summary>
public bool showContent { get { return m_ShowContent; } set { m_ShowContent = value; } }
/// <summary>
/// The position offset of tooltip relative to the mouse position.
/// 提示框相对于鼠标位置的偏移。
@@ -395,7 +402,7 @@ namespace XCharts
{
if (gameObject && gameObject.activeInHierarchy != flag)
{
gameObject.SetActive(alwayShow ? true : flag);
gameObject.SetActive(alwayShowContent ? true : flag);
}
SetContentActive(flag);
}
@@ -422,7 +429,8 @@ namespace XCharts
{
if (view == null)
return;
view.SetActive(alwayShow ? true : flag);
view.SetActive(alwayShowContent ? true : flag);
}
/// <summary>

View File

@@ -478,7 +478,7 @@ namespace XCharts
Vector2 sp = new Vector2(pX, grid.context.y);
Vector2 ep = new Vector2(pX, grid.context.y + grid.context.height);
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme);
if (xAxis.IsCategory())
if (xAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
{
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
pX = (float)(grid.context.x + splitWidth * xAxis.context.pointerValue -
@@ -542,7 +542,7 @@ namespace XCharts
Vector2 sp = new Vector2(grid.context.x, pY);
Vector2 ep = new Vector2(grid.context.x + grid.context.width, pY);
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme);
if (yAxis.IsCategory())
if (yAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
{
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
float pX = grid.context.x + grid.context.width;

View File

@@ -57,8 +57,8 @@ namespace XCharts
public void SetActive(bool flag)
{
m_Active = flag;
ChartHelper.SetActive(gameObject, flag);
m_Active = flag && tooltip.showContent;
ChartHelper.SetActive(gameObject, m_Active);
}
public void Refresh()