拼ui 一些业务逻辑x实现
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using EasyChart.Layers;
|
||||
|
||||
namespace EasyChart
|
||||
{
|
||||
public sealed class DefaultChartHitTestPolicy : IChartHitTestPolicy
|
||||
{
|
||||
public static readonly DefaultChartHitTestPolicy Instance = new DefaultChartHitTestPolicy();
|
||||
|
||||
private DefaultChartHitTestPolicy() { }
|
||||
|
||||
public bool TryBuildTooltipItems(
|
||||
TooltipContext context,
|
||||
IList<BaseSeriesRenderer> renderers,
|
||||
List<TooltipItem> items,
|
||||
ref Vector2? cursorPosition,
|
||||
ref string categoryLabel)
|
||||
{
|
||||
if (renderers == null || items == null) return false;
|
||||
|
||||
bool exclusiveHit = false;
|
||||
for (int i = renderers.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var renderer = renderers[i];
|
||||
if (renderer == null) continue;
|
||||
|
||||
bool hit = renderer.GetTooltip(context, items, ref cursorPosition, ref categoryLabel);
|
||||
if (hit && renderer is IExclusiveTooltipRenderer)
|
||||
{
|
||||
exclusiveHit = true;
|
||||
}
|
||||
|
||||
if (exclusiveHit) break;
|
||||
}
|
||||
|
||||
return items.Count > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user