mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 09:50:15 +00:00
重构Component相关代码,调整API接口
This commit is contained in:
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
||||
AddChartComponentWhenNoExist<XAxis>();
|
||||
AddChartComponentWhenNoExist<YAxis>();
|
||||
|
||||
var tooltip = GetOrAddChartComponent<Tooltip>();
|
||||
var tooltip = EnsureChartComponent<Tooltip>();
|
||||
tooltip.type = Tooltip.Type.Shadow;
|
||||
tooltip.trigger = Tooltip.Trigger.Axis;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
||||
AddChartComponentWhenNoExist<XAxis>();
|
||||
AddChartComponentWhenNoExist<YAxis>();
|
||||
|
||||
var tooltip = GetOrAddChartComponent<Tooltip>();
|
||||
var tooltip = EnsureChartComponent<Tooltip>();
|
||||
tooltip.type = Tooltip.Type.Shadow;
|
||||
tooltip.trigger = Tooltip.Trigger.Axis;
|
||||
|
||||
|
||||
@@ -15,15 +15,15 @@ namespace XCharts.Runtime
|
||||
tooltip.type = Tooltip.Type.None;
|
||||
tooltip.trigger = Tooltip.Trigger.Axis;
|
||||
|
||||
var grid = GetOrAddChartComponent<GridCoord>();
|
||||
var grid = EnsureChartComponent<GridCoord>();
|
||||
grid.left = 0.12f;
|
||||
|
||||
var xAxis = GetOrAddChartComponent<XAxis>();
|
||||
var xAxis = EnsureChartComponent<XAxis>();
|
||||
xAxis.type = Axis.AxisType.Category;
|
||||
xAxis.boundaryGap = true;
|
||||
xAxis.splitNumber = 10;
|
||||
|
||||
var yAxis = GetOrAddChartComponent<YAxis>();
|
||||
var yAxis = EnsureChartComponent<YAxis>();
|
||||
yAxis.type = Axis.AxisType.Category;
|
||||
yAxis.boundaryGap = true;
|
||||
yAxis.splitNumber = 10;
|
||||
@@ -35,7 +35,7 @@ namespace XCharts.Runtime
|
||||
|
||||
Heatmap.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
|
||||
var visualMap = GetOrAddChartComponent<VisualMap>();
|
||||
var visualMap = EnsureChartComponent<VisualMap>();
|
||||
visualMap.autoMinMax = true;
|
||||
visualMap.orient = Orient.Vertical;
|
||||
visualMap.calculable = true;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
||||
AddChartComponentWhenNoExist<XAxis>();
|
||||
AddChartComponentWhenNoExist<YAxis>();
|
||||
|
||||
var tooltip = GetOrAddChartComponent<Tooltip>();
|
||||
var tooltip = EnsureChartComponent<Tooltip>();
|
||||
tooltip.type = Tooltip.Type.Line;
|
||||
tooltip.trigger = Tooltip.Trigger.Axis;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
protected override void DefaultChart()
|
||||
{
|
||||
var legend = GetOrAddChartComponent<Legend>();
|
||||
var legend = EnsureChartComponent<Legend>();
|
||||
legend.show = true;
|
||||
|
||||
RemoveData();
|
||||
|
||||
@@ -12,15 +12,15 @@ namespace XCharts.Runtime
|
||||
{
|
||||
AddChartComponentWhenNoExist<GridCoord>();
|
||||
|
||||
var tooltip = GetOrAddChartComponent<Tooltip>();
|
||||
var tooltip = EnsureChartComponent<Tooltip>();
|
||||
tooltip.type = Tooltip.Type.None;
|
||||
tooltip.trigger = Tooltip.Trigger.Item;
|
||||
|
||||
var xAxis = GetOrAddChartComponent<XAxis>();
|
||||
var xAxis = EnsureChartComponent<XAxis>();
|
||||
xAxis.type = Axis.AxisType.Value;
|
||||
xAxis.boundaryGap = false;
|
||||
|
||||
var yAxis = GetOrAddChartComponent<YAxis>();
|
||||
var yAxis = EnsureChartComponent<YAxis>();
|
||||
yAxis.type = Axis.AxisType.Value;
|
||||
yAxis.boundaryGap = false;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace XCharts.Runtime
|
||||
/// |区域填充样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AreaStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
public class AreaStyle : ChildComponent, ISerieComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Origin position of area.
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine.UI;
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class ImageStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
public class ImageStyle : ChildComponent, ISerieComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Sprite m_Sprite;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace XCharts.Runtime
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class LineArrow : ChildComponent, ISerieExtraComponent
|
||||
public class LineArrow : ChildComponent, ISerieComponent
|
||||
{
|
||||
public enum Position
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace XCharts.Runtime
|
||||
/// 标签的引导线
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class LabelLine : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
public class LabelLine : ChildComponent, ISerieComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签视觉引导线类型
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace XCharts.Runtime
|
||||
/// |图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class LabelStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
public class LabelStyle : ChildComponent, ISerieComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// The position of label.
|
||||
|
||||
@@ -8,6 +8,6 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
[Since("v3.2.0")]
|
||||
public class BlurStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent
|
||||
public class BlurStyle : StateStyle, ISerieComponent, ISerieDataComponent
|
||||
{ }
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
[Since("v3.2.0")]
|
||||
public class EmphasisStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent
|
||||
public class EmphasisStyle : StateStyle, ISerieComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// focus type.
|
||||
|
||||
@@ -8,6 +8,6 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
[Since("v3.2.0")]
|
||||
public class SelectStyle : StateStyle, ISerieExtraComponent, ISerieDataComponent
|
||||
public class SelectStyle : StateStyle, ISerieComponent, ISerieDataComponent
|
||||
{ }
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace XCharts.Runtime
|
||||
/// |标题相关设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TitleStyle : LabelStyle, ISerieDataComponent, ISerieExtraComponent
|
||||
public class TitleStyle : LabelStyle, ISerieDataComponent, ISerieComponent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -3,36 +3,40 @@ using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The attribute for serie component.
|
||||
/// |可添加到Serie的组件。
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class SerieExtraComponentAttribute : Attribute
|
||||
public sealed class SerieComponentAttribute : Attribute
|
||||
{
|
||||
public readonly List<Type> types = new List<Type>();
|
||||
|
||||
public SerieExtraComponentAttribute()
|
||||
public SerieComponentAttribute()
|
||||
{ }
|
||||
public SerieExtraComponentAttribute(Type type1)
|
||||
public SerieComponentAttribute(Type type1)
|
||||
{
|
||||
AddType(type1);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2)
|
||||
public SerieComponentAttribute(Type type1, Type type2)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3)
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4)
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
AddType(type4);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
@@ -40,7 +44,7 @@ namespace XCharts.Runtime
|
||||
AddType(type4);
|
||||
AddType(type5);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
@@ -49,7 +53,7 @@ namespace XCharts.Runtime
|
||||
AddType(type5);
|
||||
AddType(type6);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
|
||||
public SerieComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
@@ -67,7 +71,7 @@ namespace XCharts.Runtime
|
||||
types.Add(type);
|
||||
}
|
||||
|
||||
public bool Contains<T>() where T : ISerieExtraComponent
|
||||
public bool Contains<T>() where T : ISerieComponent
|
||||
{
|
||||
return Contains(typeof(T));
|
||||
}
|
||||
@@ -2,10 +2,11 @@ using System;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
/// <summary>
|
||||
/// What serie can convert to me
|
||||
/// The attribute for which serie types can be converted to.
|
||||
/// |可转化为哪些Serie类型。
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class SerieConvertAttribute : Attribute
|
||||
{
|
||||
public readonly Type type0;
|
||||
|
||||
@@ -3,36 +3,41 @@ using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The attribute for serie data component.
|
||||
/// |可添加到SerieData的组件。
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class SerieDataExtraComponentAttribute : Attribute
|
||||
public sealed class SerieDataComponentAttribute : Attribute
|
||||
{
|
||||
public readonly List<Type> types = new List<Type>();
|
||||
|
||||
public SerieDataExtraComponentAttribute()
|
||||
{ }
|
||||
public SerieDataExtraComponentAttribute(Type type1)
|
||||
public SerieDataComponentAttribute()
|
||||
{
|
||||
}
|
||||
public SerieDataComponentAttribute(Type type1)
|
||||
{
|
||||
AddType(type1);
|
||||
}
|
||||
public SerieDataExtraComponentAttribute(Type type1, Type type2)
|
||||
public SerieDataComponentAttribute(Type type1, Type type2)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
}
|
||||
public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3)
|
||||
public SerieDataComponentAttribute(Type type1, Type type2, Type type3)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
}
|
||||
public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4)
|
||||
public SerieDataComponentAttribute(Type type1, Type type2, Type type3, Type type4)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
AddType(type3);
|
||||
AddType(type4);
|
||||
}
|
||||
public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
|
||||
public SerieDataComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
@@ -40,7 +45,7 @@ namespace XCharts.Runtime
|
||||
AddType(type4);
|
||||
AddType(type5);
|
||||
}
|
||||
public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
|
||||
public SerieDataComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
@@ -49,7 +54,7 @@ namespace XCharts.Runtime
|
||||
AddType(type5);
|
||||
AddType(type6);
|
||||
}
|
||||
public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
|
||||
public SerieDataComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
|
||||
{
|
||||
AddType(type1);
|
||||
AddType(type2);
|
||||
@@ -67,7 +72,7 @@ namespace XCharts.Runtime
|
||||
types.Add(type);
|
||||
}
|
||||
|
||||
public bool Contains<T>() where T : ISerieExtraComponent
|
||||
public bool Contains<T>() where T : ISerieComponent
|
||||
{
|
||||
return Contains(typeof(T));
|
||||
}
|
||||
@@ -69,7 +69,15 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public Vector3 chartPosition { get { return m_ChartPosition; } }
|
||||
public Rect chartRect { get { return m_ChartRect; } }
|
||||
/// <summary>
|
||||
/// The callback function of chart init.
|
||||
/// |图表的初始化完成回调。
|
||||
/// </summary>
|
||||
public Action onInit { set { m_OnInit = value; } }
|
||||
/// <summary>
|
||||
/// The callback function of chart update.
|
||||
/// |图表的Update回调。
|
||||
/// </summary>
|
||||
public Action onUpdate { set { m_OnUpdate = value; } }
|
||||
/// <summary>
|
||||
/// 自定义绘制回调。在绘制Serie前调用。
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public T AddChartComponent<T>() where T : MainComponent
|
||||
{
|
||||
return (T) AddChartComponent(typeof(T));
|
||||
return (T)AddChartComponent(typeof(T));
|
||||
}
|
||||
|
||||
public T AddChartComponentWhenNoExist<T>() where T : MainComponent
|
||||
@@ -118,7 +118,7 @@ namespace XCharts.Runtime
|
||||
if (attrubte.handler == null)
|
||||
return;
|
||||
|
||||
var handler = (MainComponentHandler) Activator.CreateInstance(attrubte.handler);
|
||||
var handler = (MainComponentHandler)Activator.CreateInstance(attrubte.handler);
|
||||
handler.attribute = attrubte;
|
||||
handler.chart = this;
|
||||
handler.SetComponent(component);
|
||||
@@ -221,9 +221,9 @@ namespace XCharts.Runtime
|
||||
return GetChartComponentNum(typeof(T));
|
||||
}
|
||||
|
||||
private static List<MainComponent> list;
|
||||
public int GetChartComponentNum(Type type)
|
||||
{
|
||||
List<MainComponent> list;
|
||||
if (m_ComponentMaps.TryGetValue(type, out list))
|
||||
return list.Count;
|
||||
else
|
||||
@@ -245,6 +245,7 @@ namespace XCharts.Runtime
|
||||
return m_ComponentMaps[typeof(T)];
|
||||
}
|
||||
|
||||
[Obsolete("'GetOrAddChartComponent' is obsolete, Use 'EnsureChartComponent' instead.")]
|
||||
public T GetOrAddChartComponent<T>() where T : MainComponent
|
||||
{
|
||||
var component = GetChartComponent<T>();
|
||||
@@ -253,6 +254,15 @@ namespace XCharts.Runtime
|
||||
else
|
||||
return component;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure the chart has the component, if not, add it.
|
||||
/// Note: it may fail to add.
|
||||
/// |确保图表有该组件,如果没有则添加。注意:有可能添加不成功。
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns>component, or null if add failed.</returns>
|
||||
[Since("v3.6.0")]
|
||||
public T EnsureChartComponent<T>() where T : MainComponent
|
||||
{
|
||||
var component = GetChartComponent<T>();
|
||||
@@ -261,7 +271,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
return component;
|
||||
}
|
||||
|
||||
|
||||
public bool TryGetChartComponent<T>(out T component, int index = 0)
|
||||
where T : MainComponent
|
||||
{
|
||||
@@ -270,7 +280,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (com is T && com.index == index)
|
||||
{
|
||||
component = (T) com;
|
||||
component = (T)com;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -425,11 +435,11 @@ namespace XCharts.Runtime
|
||||
var yAxis = GetChartComponent<YAxis>();
|
||||
if (yAxis.IsCategory())
|
||||
{
|
||||
return yAxis.GetData((int) yAxis.context.pointerValue, dataZoom);
|
||||
return yAxis.GetData((int)yAxis.context.pointerValue, dataZoom);
|
||||
}
|
||||
else if (xAxis.IsCategory())
|
||||
{
|
||||
return xAxis.GetData((int) xAxis.context.pointerValue, dataZoom);
|
||||
return xAxis.GetData((int)xAxis.context.pointerValue, dataZoom);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -439,11 +449,11 @@ namespace XCharts.Runtime
|
||||
var yAxis = GetChartComponent<YAxis>(serie.yAxisIndex);
|
||||
if (yAxis.IsCategory())
|
||||
{
|
||||
return yAxis.GetData((int) yAxis.context.pointerValue, dataZoom);
|
||||
return yAxis.GetData((int)yAxis.context.pointerValue, dataZoom);
|
||||
}
|
||||
else if (xAxis.IsCategory())
|
||||
{
|
||||
return xAxis.GetData((int) xAxis.context.pointerValue, dataZoom);
|
||||
return xAxis.GetData((int)xAxis.context.pointerValue, dataZoom);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
11
Runtime/Internal/Misc/ISerieComponent.cs
Normal file
11
Runtime/Internal/Misc/ISerieComponent.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The interface for serie component.
|
||||
/// |可用于Serie的组件。
|
||||
/// </summary>
|
||||
public interface ISerieComponent
|
||||
{
|
||||
bool show { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ namespace XCharts.Runtime
|
||||
{
|
||||
public interface ISerieContainer
|
||||
{
|
||||
//bool runtimeIsPointerEnter { get; }
|
||||
int index { get; }
|
||||
bool IsPointerEnter();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The interface for serie data component.
|
||||
/// |可用于SerieData的组件。
|
||||
/// </summary>
|
||||
public interface ISerieDataComponent
|
||||
{ }
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public interface ISerieExtraComponent
|
||||
{
|
||||
bool show { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ namespace XCharts.Runtime
|
||||
[SerieConvert(typeof(Line), typeof(Pie))]
|
||||
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
|
||||
[DefaultAnimation(AnimationType.BottomToTop)]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField("m_Ignore")]
|
||||
public class Bar : Serie, INeedSerieContainer
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace XCharts.Runtime
|
||||
[SerieConvert(typeof(SimplifiedLine), typeof(Bar))]
|
||||
[CoordOptions(typeof(GridCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent()]
|
||||
[SerieDataExtraComponent()]
|
||||
[SerieComponent()]
|
||||
[SerieDataComponent()]
|
||||
[SerieDataExtraField()]
|
||||
public class SimplifiedBar : Serie, INeedSerieContainer, ISimplifiedSerie
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(CandlestickHandler), true)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent()]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent()]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField()]
|
||||
public class Candlestick : Serie, INeedSerieContainer
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(SimplifiedCandlestickHandler), true)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent()]
|
||||
[SerieDataExtraComponent()]
|
||||
[SerieComponent()]
|
||||
[SerieDataComponent()]
|
||||
[SerieDataExtraField()]
|
||||
public class SimplifiedCandlestick : Serie, INeedSerieContainer, ISimplifiedSerie
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace XCharts.Runtime
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[RequireChartComponent(typeof(VisualMap))]
|
||||
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField()]
|
||||
public class Heatmap : Serie, INeedSerieContainer
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace XCharts.Runtime
|
||||
[SerieConvert(typeof(Bar), typeof(Pie))]
|
||||
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent(
|
||||
[SerieComponent(
|
||||
typeof(LabelStyle),
|
||||
typeof(EndLabelStyle),
|
||||
typeof(LineArrow),
|
||||
@@ -15,7 +15,7 @@ namespace XCharts.Runtime
|
||||
typeof(EmphasisStyle),
|
||||
typeof(BlurStyle),
|
||||
typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(
|
||||
[SerieDataComponent(
|
||||
typeof(ItemStyle),
|
||||
typeof(LabelStyle),
|
||||
typeof(SerieSymbol),
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace XCharts.Runtime
|
||||
[SerieConvert(typeof(SimplifiedBar), typeof(Line))]
|
||||
[CoordOptions(typeof(GridCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent(typeof(AreaStyle))]
|
||||
[SerieDataExtraComponent()]
|
||||
[SerieComponent(typeof(AreaStyle))]
|
||||
[SerieDataComponent()]
|
||||
[SerieDataExtraField()]
|
||||
public class SimplifiedLine : Serie, INeedSerieContainer, ISimplifiedSerie
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(ParallelHandler), true)]
|
||||
[RequireChartComponent(typeof(ParallelCoord))]
|
||||
[SerieExtraComponent(typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField()]
|
||||
public class Parallel : Serie, INeedSerieContainer
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace XCharts.Runtime
|
||||
[SerieConvert(typeof(Line), typeof(Bar))]
|
||||
[SerieHandler(typeof(PieHandler), true)]
|
||||
[DefaultAnimation(AnimationType.Clockwise)]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField("m_Ignore", "m_Selected", "m_Radius")]
|
||||
public class Pie : Serie
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(RadarHandler), true)]
|
||||
[RequireChartComponent(typeof(RadarCoord))]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField()]
|
||||
public class Radar : Serie, INeedSerieContainer
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(RingHandler), true)]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField()]
|
||||
public class Ring : Serie
|
||||
{
|
||||
@@ -17,14 +17,14 @@ namespace XCharts.Runtime
|
||||
serie.gap = 10;
|
||||
serie.radius = new float[] { 0.3f, 0.35f };
|
||||
|
||||
var label = serie.AddExtraComponent<LabelStyle>();
|
||||
var label = serie.EnsureComponent<LabelStyle>();
|
||||
label.show = true;
|
||||
label.position = LabelStyle.Position.Center;
|
||||
label.formatter = "{d:f0}%";
|
||||
label.textStyle.autoColor = true;
|
||||
label.textStyle.fontSize = 28;
|
||||
|
||||
var titleStyle = serie.AddExtraComponent<TitleStyle>();
|
||||
var titleStyle = serie.EnsureComponent<TitleStyle>();
|
||||
titleStyle.show = false;
|
||||
titleStyle.offset = new Vector2(0, 30);
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(EffectScatterHandler), true)]
|
||||
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField("m_Radius")]
|
||||
public class EffectScatter : BaseScatter
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(ScatterHandler), true)]
|
||||
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField("m_Radius")]
|
||||
public class Scatter : BaseScatter
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace XCharts.Runtime
|
||||
public partial class Serie
|
||||
{
|
||||
public static Dictionary<Type, string> extraComponentMap = new Dictionary<Type, string>
|
||||
{ { typeof(LabelStyle), "m_Labels" },
|
||||
{
|
||||
{ typeof(LabelStyle), "m_Labels" },
|
||||
{ typeof(LabelLine), "m_LabelLines" },
|
||||
{ typeof(EndLabelStyle), "m_EndLabels" },
|
||||
{ typeof(LineArrow), "m_LineArrows" },
|
||||
@@ -71,7 +72,11 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public SelectStyle selectStyle { get { return m_SelectStyles.Count > 0 ? m_SelectStyles[0] : null; } }
|
||||
|
||||
public void RemoveAllExtraComponent()
|
||||
/// <summary>
|
||||
/// Remove all extra components.
|
||||
/// |移除所有额外组件。
|
||||
/// </summary>
|
||||
public void RemoveAllComponents()
|
||||
{
|
||||
var serieType = GetType();
|
||||
foreach (var kv in extraComponentMap)
|
||||
@@ -81,16 +86,72 @@ namespace XCharts.Runtime
|
||||
SetAllDirty();
|
||||
}
|
||||
|
||||
public T AddExtraComponent<T>() where T : ChildComponent, ISerieExtraComponent
|
||||
[Obsolete("Use EnsureComponent<T>() instead.")]
|
||||
public T AddExtraComponent<T>() where T : ChildComponent, ISerieComponent
|
||||
{
|
||||
return AddExtraComponent(typeof(T)) as T;
|
||||
return EnsureComponent<T>();
|
||||
}
|
||||
|
||||
public ISerieExtraComponent AddExtraComponent(Type type)
|
||||
public T GetComponent<T>() where T : ChildComponent, ISerieComponent
|
||||
{
|
||||
if (GetType().IsDefined(typeof(SerieExtraComponentAttribute), false))
|
||||
return GetComponent(typeof(T)) as T;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure the serie has the component. If not, add it.
|
||||
/// |确保系列有该组件。如果没有,则添加。
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns>component or null</returns>
|
||||
public T EnsureComponent<T>() where T : ChildComponent, ISerieComponent
|
||||
{
|
||||
return EnsureComponent(typeof(T)) as T;
|
||||
}
|
||||
|
||||
public bool CanAddComponent<T>() where T : ChildComponent, ISerieComponent
|
||||
{
|
||||
return CanAddComponent(typeof(T));
|
||||
}
|
||||
|
||||
public bool CanAddComponent(Type type)
|
||||
{
|
||||
if (GetType().IsDefined(typeof(SerieComponentAttribute), false))
|
||||
{
|
||||
var attr = GetType().GetAttribute<SerieExtraComponentAttribute>();
|
||||
var attr = GetType().GetAttribute<SerieComponentAttribute>();
|
||||
if (attr.Contains(type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ISerieComponent GetComponent(Type type)
|
||||
{
|
||||
if (GetType().IsDefined(typeof(SerieComponentAttribute), false))
|
||||
{
|
||||
var attr = GetType().GetAttribute<SerieComponentAttribute>();
|
||||
if (attr.Contains(type))
|
||||
{
|
||||
var fieldName = string.Empty;
|
||||
if (extraComponentMap.TryGetValue(type, out fieldName))
|
||||
{
|
||||
var field = typeof(Serie).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (ReflectionUtil.InvokeListCount(this, field) > 0)
|
||||
{
|
||||
return ReflectionUtil.InvokeListGet<ISerieComponent>(this, field, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ISerieComponent EnsureComponent(Type type)
|
||||
{
|
||||
if (GetType().IsDefined(typeof(SerieComponentAttribute), false))
|
||||
{
|
||||
var attr = GetType().GetAttribute<SerieComponentAttribute>();
|
||||
if (attr.Contains(type))
|
||||
{
|
||||
var fieldName = string.Empty;
|
||||
@@ -99,32 +160,32 @@ namespace XCharts.Runtime
|
||||
var field = typeof(Serie).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (ReflectionUtil.InvokeListCount(this, field) <= 0)
|
||||
{
|
||||
var extraComponent = Activator.CreateInstance(type) as ISerieExtraComponent;
|
||||
var extraComponent = Activator.CreateInstance(type) as ISerieComponent;
|
||||
ReflectionUtil.InvokeListAdd(this, field, extraComponent);
|
||||
SetAllDirty();
|
||||
return extraComponent;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ReflectionUtil.InvokeListGet<ISerieExtraComponent>(this, field, 0);
|
||||
return ReflectionUtil.InvokeListGet<ISerieComponent>(this, field, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new System.Exception(string.Format("Serie {0} not support extra component: {1}",
|
||||
throw new System.Exception(string.Format("Serie {0} not support component: {1}",
|
||||
GetType().Name, type.Name));
|
||||
}
|
||||
|
||||
public void RemoveExtraComponent<T>() where T : ISerieExtraComponent
|
||||
public void RemoveComponent<T>() where T : ISerieComponent
|
||||
{
|
||||
RemoveExtraComponent(typeof(T));
|
||||
RemoveComponent(typeof(T));
|
||||
}
|
||||
|
||||
public void RemoveExtraComponent(Type type)
|
||||
public void RemoveComponent(Type type)
|
||||
{
|
||||
if (GetType().IsDefined(typeof(SerieExtraComponentAttribute), false))
|
||||
if (GetType().IsDefined(typeof(SerieComponentAttribute), false))
|
||||
{
|
||||
var attr = GetType().GetAttribute<SerieExtraComponentAttribute>();
|
||||
var attr = GetType().GetAttribute<SerieComponentAttribute>();
|
||||
if (attr.Contains(type))
|
||||
{
|
||||
var fieldName = string.Empty;
|
||||
@@ -137,17 +198,6 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new System.Exception(string.Format("Serie {0} not support extra component: {1}",
|
||||
GetType().Name, type.Name));
|
||||
}
|
||||
|
||||
private void RemoveExtraComponentList<T>(List<T> list) where T : ISerieExtraComponent
|
||||
{
|
||||
if (list.Count > 0)
|
||||
{
|
||||
list.Clear();
|
||||
SetAllDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,71 +234,157 @@ namespace XCharts.Runtime
|
||||
m_SelectStyles.Clear();
|
||||
}
|
||||
|
||||
[Obsolete("GetOrAddComponent is obsolete. Use EnsureComponent instead.")]
|
||||
public T GetOrAddComponent<T>() where T : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
return GetOrAddComponent(typeof(T)) as T;
|
||||
return EnsureComponent<T>();
|
||||
}
|
||||
|
||||
public ISerieDataComponent GetOrAddComponent(Type type)
|
||||
/// <summary>
|
||||
/// Get the component of the serie data. return null if not exist.
|
||||
/// |获取数据项的指定类型的组件,如果不存在则返回null。
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public T GetComponent<T>() where T : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
return GetComponentInternal(typeof(T), false) as T;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure the serie data has the component, if not, add it.
|
||||
/// |确保数据项有指定类型的组件,如果没有则添加。
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
[Since("v3.6.0")]
|
||||
public T EnsureComponent<T>() where T : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
return GetComponentInternal(typeof(T), true) as T;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure the serie data has the component, if not, add it.
|
||||
/// |确保数据项有指定类型的组件,如果没有则添加。
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[Since("v3.6.0")]
|
||||
public ISerieDataComponent EnsureComponent(Type type)
|
||||
{
|
||||
return GetComponentInternal(type, true);
|
||||
}
|
||||
|
||||
private ISerieDataComponent GetComponentInternal(Type type, bool addIfNotExist)
|
||||
{
|
||||
if (type == typeof(ItemStyle))
|
||||
{
|
||||
if (m_ItemStyles.Count == 0)
|
||||
m_ItemStyles.Add(new ItemStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_ItemStyles.Add(new ItemStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_ItemStyles[0];
|
||||
}
|
||||
else if (type == typeof(LabelStyle))
|
||||
{
|
||||
if (m_Labels.Count == 0)
|
||||
m_Labels.Add(new LabelStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_Labels.Add(new LabelStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_Labels[0];
|
||||
}
|
||||
else if (type == typeof(LabelLine))
|
||||
{
|
||||
if (m_LabelLines.Count == 0)
|
||||
m_LabelLines.Add(new LabelLine() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_LabelLines.Add(new LabelLine() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_LabelLines[0];
|
||||
}
|
||||
else if (type == typeof(EmphasisStyle))
|
||||
{
|
||||
if (m_EmphasisStyles.Count == 0)
|
||||
m_EmphasisStyles.Add(new EmphasisStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_EmphasisStyles.Add(new EmphasisStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_EmphasisStyles[0];
|
||||
}
|
||||
else if (type == typeof(BlurStyle))
|
||||
{
|
||||
if (m_BlurStyles.Count == 0)
|
||||
m_BlurStyles.Add(new BlurStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_BlurStyles.Add(new BlurStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_BlurStyles[0];
|
||||
}
|
||||
else if (type == typeof(SelectStyle))
|
||||
{
|
||||
if (m_SelectStyles.Count == 0)
|
||||
m_SelectStyles.Add(new SelectStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_SelectStyles.Add(new SelectStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_SelectStyles[0];
|
||||
}
|
||||
else if (type == typeof(SerieSymbol))
|
||||
{
|
||||
if (m_Symbols.Count == 0)
|
||||
m_Symbols.Add(new SerieSymbol() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_Symbols.Add(new SerieSymbol() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_Symbols[0];
|
||||
}
|
||||
else if (type == typeof(LineStyle))
|
||||
{
|
||||
if (m_LineStyles.Count == 0)
|
||||
m_LineStyles.Add(new LineStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_LineStyles.Add(new LineStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_LineStyles[0];
|
||||
}
|
||||
else if (type == typeof(AreaStyle))
|
||||
{
|
||||
if (m_AreaStyles.Count == 0)
|
||||
m_AreaStyles.Add(new AreaStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_AreaStyles.Add(new AreaStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_AreaStyles[0];
|
||||
}
|
||||
else if (type == typeof(TitleStyle))
|
||||
{
|
||||
if (m_TitleStyles.Count == 0)
|
||||
m_TitleStyles.Add(new TitleStyle() { show = true });
|
||||
{
|
||||
if (addIfNotExist)
|
||||
m_TitleStyles.Add(new TitleStyle() { show = true });
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return m_TitleStyles[0];
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user