mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
增加Tooltip的Auto自动设置显示类型和触发类型
This commit is contained in:
17
Runtime/Internal/Attributes/DefaultTooltipAttribute.cs
Normal file
17
Runtime/Internal/Attributes/DefaultTooltipAttribute.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class DefaultTooltipAttribute : Attribute
|
||||
{
|
||||
public readonly Tooltip.Type type;
|
||||
public readonly Tooltip.Trigger trigger;
|
||||
|
||||
public DefaultTooltipAttribute(Tooltip.Type type, Tooltip.Trigger trigger)
|
||||
{
|
||||
this.type = type;
|
||||
this.trigger = trigger;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Internal/Attributes/DefaultTooltipAttribute.cs.meta
Normal file
11
Runtime/Internal/Attributes/DefaultTooltipAttribute.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a994dc47021bb4031ba6cf23eaf82e7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -976,6 +976,15 @@ namespace XCharts.Runtime
|
||||
if (serie == null)
|
||||
throw new ArgumentNullException("serie is null");
|
||||
|
||||
if (serie.GetType().IsDefined(typeof(DefaultTooltipAttribute), false))
|
||||
{
|
||||
var attribute1 = serie.GetType().GetAttribute<DefaultTooltipAttribute>();
|
||||
if (attribute1 != null)
|
||||
{
|
||||
serie.context.tooltipTrigger = attribute1.trigger;
|
||||
serie.context.tooltipType = attribute1.type;
|
||||
}
|
||||
}
|
||||
if (!serie.GetType().IsDefined(typeof(SerieHandlerAttribute), false))
|
||||
{
|
||||
Debug.LogError("Serie no Handler:" + serie.GetType());
|
||||
|
||||
@@ -146,10 +146,9 @@ namespace XCharts.Runtime
|
||||
{
|
||||
RemoveAllChartComponent();
|
||||
OnBeforeSerialize();
|
||||
AddChartComponentWhenNoExist<Title>();
|
||||
AddChartComponentWhenNoExist<Tooltip>();
|
||||
|
||||
GetChartComponent<Title>().text = GetType().Name;
|
||||
EnsureChartComponent<Title>();
|
||||
EnsureChartComponent<Tooltip>();
|
||||
EnsureChartComponent<Title>().text = GetType().Name;
|
||||
|
||||
if (m_Theme.sharedTheme != null)
|
||||
m_Theme.sharedTheme.CopyTheme(ThemeType.Default);
|
||||
|
||||
Reference in New Issue
Block a user