mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 23:10:06 +00:00
3.0 - serie extra component
This commit is contained in:
@@ -39,12 +39,7 @@ namespace XCharts.Editor
|
||||
PropertyField("m_LargeThreshold");
|
||||
PropertyField("m_Clip");
|
||||
});
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ namespace XCharts.Editor
|
||||
PropertyField("m_LargeThreshold");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ namespace XCharts.Editor
|
||||
PropertyField("m_Symbol");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,6 @@ namespace XCharts.Editor
|
||||
PropertyField("m_IgnoreValue");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +36,7 @@ namespace XCharts.Editor
|
||||
});
|
||||
PropertyField("m_Symbol");
|
||||
PropertyField("m_LineStyle");
|
||||
PropertyField("m_LineArrow");
|
||||
PropertyField("m_AreaStyle");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@ namespace XCharts.Editor
|
||||
PropertyField("m_WaveOffset");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,6 @@ namespace XCharts.Editor
|
||||
});
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,10 @@ namespace XCharts.Editor
|
||||
{
|
||||
PropertyField("m_RadarType");
|
||||
PropertyField("m_RadarIndex");
|
||||
|
||||
PropertyField("m_Symbol");
|
||||
PropertyField("m_LineStyle");
|
||||
PropertyField("m_AreaStyle");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,9 @@ namespace XCharts.Editor
|
||||
PropertyField("m_RingGap");
|
||||
PropertyField("m_RoundCap");
|
||||
PropertyField("m_Clockwise");
|
||||
PropertyField("m_TitleStyle");
|
||||
|
||||
PropertyField("m_TitleStyle");
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,9 @@ namespace XCharts.Editor
|
||||
PropertyField("m_YAxisIndex");
|
||||
}
|
||||
PropertyField("m_Clip");
|
||||
PropertyField("m_Symbol");
|
||||
|
||||
PropertyField("m_Symbol");
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
PropertyField("m_Label");
|
||||
PropertyField("m_LabelLine");
|
||||
PropertyField("m_Emphasis");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace XCharts.Editor
|
||||
return ObjectNames.NicifyVariableName(title);
|
||||
}
|
||||
|
||||
protected SerializedProperty FindProperty(string path)
|
||||
internal SerializedProperty FindProperty(string path)
|
||||
{
|
||||
return baseProperty.FindPropertyRelative(path);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace XCharts.Editor
|
||||
}
|
||||
}
|
||||
OnCustomInspectorGUI();
|
||||
OnExtraInspectorGUI();
|
||||
PropertyFieldData();
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
@@ -37,6 +38,16 @@ namespace XCharts.Editor
|
||||
{
|
||||
}
|
||||
|
||||
private void OnExtraInspectorGUI()
|
||||
{
|
||||
foreach (var kv in Serie.extraComponentFieldNameDict)
|
||||
{
|
||||
var prop = FindProperty(kv.Value);
|
||||
if (prop.arraySize > 0)
|
||||
PropertyField(prop.GetArrayElementAtIndex(0));
|
||||
}
|
||||
}
|
||||
|
||||
private void PropertyFieldData()
|
||||
{
|
||||
m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null,
|
||||
|
||||
@@ -6,7 +6,6 @@ using UnityEditor;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
namespace XCharts.Editor
|
||||
{
|
||||
public sealed class SerieListEditor
|
||||
@@ -151,7 +150,28 @@ namespace XCharts.Editor
|
||||
CovertSerie(editor.serie, type);
|
||||
}));
|
||||
}
|
||||
|
||||
if (editor.serie.GetType().IsDefined(typeof(SerieExtraComponentAttribute), false))
|
||||
{
|
||||
var attribute = editor.serie.GetType().GetAttribute<SerieExtraComponentAttribute>();
|
||||
foreach (var type in attribute.types)
|
||||
{
|
||||
var size = editor.FindProperty(Serie.extraComponentFieldNameDict[type]).arraySize;
|
||||
editor.menus.Add(new HeaderMenuInfo("Add " + type.Name, () =>
|
||||
{
|
||||
editor.serie.AddExtraComponent(type);
|
||||
RefreshEditors();
|
||||
}, size == 0));
|
||||
}
|
||||
foreach (var type in attribute.types)
|
||||
{
|
||||
var size = editor.FindProperty(Serie.extraComponentFieldNameDict[type]).arraySize;
|
||||
editor.menus.Add(new HeaderMenuInfo("Remove " + type.Name, () =>
|
||||
{
|
||||
editor.serie.RemoveExtraComponent(type);
|
||||
RefreshEditors();
|
||||
}, size > 0));
|
||||
}
|
||||
}
|
||||
if (index < 0)
|
||||
m_Editors.Add(editor);
|
||||
else
|
||||
@@ -181,7 +201,8 @@ namespace XCharts.Editor
|
||||
RefreshEditors();
|
||||
}
|
||||
|
||||
public void CloneSerie(Serie serie){
|
||||
public void CloneSerie(Serie serie)
|
||||
{
|
||||
var newSerie = serie.Clone();
|
||||
newSerie.serieName = chart.GenerateDefaultSerieName();
|
||||
chart.InsertSerie(newSerie);
|
||||
|
||||
@@ -116,6 +116,7 @@ namespace XCharts.Example
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "AreaStyle 面积图";
|
||||
|
||||
serie.AddExtraComponent<AreaStyle>();
|
||||
serie.areaStyle.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1f);
|
||||
@@ -144,6 +145,7 @@ namespace XCharts.Example
|
||||
IEnumerator LineArrowSettings()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "LineArrow 头部箭头";
|
||||
chart.GetSerie(0).AddExtraComponent<LineArrow>();
|
||||
serie.lineArrow.show = true;
|
||||
serie.lineArrow.position = LineArrow.Position.Start;
|
||||
chart.RefreshChart();
|
||||
@@ -205,6 +207,7 @@ namespace XCharts.Example
|
||||
IEnumerator LineLabelSettings()
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "SerieLabel 文本标签";
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
serie.label.border = false;
|
||||
chart.RefreshChart();
|
||||
|
||||
@@ -140,6 +140,7 @@ namespace XCharts.Example
|
||||
|
||||
serie.barPercentStack = true;
|
||||
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
serie.label.position = LabelStyle.Position.Center;
|
||||
serie.label.border = false;
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace XCharts.Example
|
||||
{
|
||||
chart.GetChartComponent<Title>().subText = "显示文本标签";
|
||||
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
chart.RefreshChart();
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace XCharts.Example
|
||||
var serieIndex = 0;
|
||||
var serie = chart.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
serie.label.position = LabelStyle.Position.Outside;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace XCharts.Example
|
||||
serie.itemStyle.borderColor = Color.clear;
|
||||
|
||||
//设置高亮样式
|
||||
serie.AddExtraComponent<Emphasis>();
|
||||
serie.emphasis.show = true;
|
||||
serie.emphasis.itemStyle.show = true;
|
||||
serie.emphasis.itemStyle.borderWidth = 1;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace XCharts
|
||||
/// 区域填充样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AreaStyle : ChildComponent
|
||||
public class AreaStyle : ChildComponent, ISerieExtraComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Origin position of area.
|
||||
@@ -33,11 +33,11 @@ namespace XCharts
|
||||
/// </summary>
|
||||
End
|
||||
}
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private AreaOrigin m_Origin;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 0.6f;
|
||||
[SerializeField] private bool m_TooltipHighlight;
|
||||
[SerializeField] private Color32 m_HighlightColor;
|
||||
[SerializeField] private Color32 m_HighlightToColor;
|
||||
@@ -114,21 +114,6 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public static AreaStyle defaultAreaStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
var area = new AreaStyle
|
||||
{
|
||||
m_Show = false,
|
||||
m_Color = Color.clear,
|
||||
m_ToColor = Color.clear,
|
||||
m_Opacity = 0.6f
|
||||
};
|
||||
return area;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1)
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace XCharts
|
||||
/// 高亮的图形样式和文本标签样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Emphasis : ChildComponent, ISerieDataComponent
|
||||
public class Emphasis : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
||||
|
||||
11
Assets/XCharts/Runtime/Component/Child/EndLabelStyle.cs
Normal file
11
Assets/XCharts/Runtime/Component/Child/EndLabelStyle.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class EndLabelStyle : LabelStyle
|
||||
{
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/Component/Child/EndLabelStyle.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Child/EndLabelStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3ca55f3ab0314339ae171c8ac07c4e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,7 +5,7 @@ using UnityEngine.UI;
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class IconStyle : ChildComponent, ISerieDataComponent
|
||||
public class IconStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
{
|
||||
public enum Layer
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class LabelLine : ChildComponent,ISerieDataComponent
|
||||
public class LabelLine : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 标签视觉引导线类型
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace XCharts
|
||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class LabelStyle : ChildComponent,ISerieDataComponent
|
||||
public class LabelStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// The position of label.
|
||||
@@ -69,7 +69,7 @@ namespace XCharts
|
||||
End
|
||||
}
|
||||
|
||||
|
||||
|
||||
[SerializeField] private bool m_Show = false;
|
||||
[SerializeField] Position m_Position = Position.Outside;
|
||||
[SerializeField] private Vector3 m_Offset;
|
||||
@@ -299,4 +299,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class LineArrow : ChildComponent
|
||||
public class LineArrow : ChildComponent, ISerieExtraComponent
|
||||
{
|
||||
public enum Position
|
||||
{
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace XCharts
|
||||
{
|
||||
if (!serie.IsPerformanceMode() && serieData != null && serieData.emphasis != null && serieData.emphasis.show)
|
||||
return serieData.emphasis.itemStyle;
|
||||
else if (serie.emphasis.show) return serie.emphasis.itemStyle;
|
||||
else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.itemStyle;
|
||||
else return null;
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace XCharts
|
||||
{
|
||||
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
|
||||
return serieData.emphasis.label;
|
||||
else if (serie.emphasis.show) return serie.emphasis.label;
|
||||
else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.label;
|
||||
else return serie.label;
|
||||
}
|
||||
else
|
||||
@@ -431,7 +431,7 @@ namespace XCharts
|
||||
{
|
||||
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
|
||||
return serieData.emphasis.label;
|
||||
else if (serie.emphasis.show) return serie.emphasis.label;
|
||||
else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.label;
|
||||
else return null;
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace XCharts
|
||||
{
|
||||
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
|
||||
return serieData.emphasis.labelLine;
|
||||
else if (serie.emphasis.show) return serie.emphasis.labelLine;
|
||||
else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.labelLine;
|
||||
else return serie.labelLine;
|
||||
}
|
||||
else
|
||||
@@ -466,11 +466,16 @@ namespace XCharts
|
||||
public static Color32 GetAreaColor(Serie serie, ThemeStyle theme, int index, bool highlight)
|
||||
{
|
||||
var areaStyle = serie.areaStyle;
|
||||
var color = !ChartHelper.IsClearColor(areaStyle.color) ? areaStyle.color : theme.GetColor(index);
|
||||
if (areaStyle == null || !areaStyle.show)
|
||||
return ColorUtil.clearColor32;
|
||||
var color = !ChartHelper.IsClearColor(areaStyle.color)
|
||||
? areaStyle.color : theme.GetColor(index);
|
||||
if (highlight)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(areaStyle.highlightColor)) color = areaStyle.highlightColor;
|
||||
else color = ChartHelper.GetHighlightColor(color);
|
||||
if (!ChartHelper.IsClearColor(areaStyle.highlightColor))
|
||||
color = areaStyle.highlightColor;
|
||||
else
|
||||
color = ChartHelper.GetHighlightColor(color);
|
||||
}
|
||||
ChartHelper.SetColorOpacity(ref color, areaStyle.opacity);
|
||||
return color;
|
||||
@@ -479,6 +484,8 @@ namespace XCharts
|
||||
public static Color32 GetAreaToColor(Serie serie, ThemeStyle theme, int index, bool highlight)
|
||||
{
|
||||
var areaStyle = serie.areaStyle;
|
||||
if (areaStyle == null || !areaStyle.show)
|
||||
return ColorUtil.clearColor32;
|
||||
if (!ChartHelper.IsClearColor(areaStyle.toColor))
|
||||
{
|
||||
var color = areaStyle.toColor;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace XCharts
|
||||
|
||||
public static Color GetLabelColor(Serie serie, ThemeStyle theme, int index)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(serie.label.textStyle.color))
|
||||
if (serie.label != null && !ChartHelper.IsClearColor(serie.label.textStyle.color))
|
||||
{
|
||||
return serie.label.textStyle.color;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace XCharts
|
||||
{
|
||||
serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
}
|
||||
var numericFormatter = serieLabel == null ? serie.label.numericFormatter : serieLabel.numericFormatter;
|
||||
var numericFormatter = serieLabel == null ? "" : serieLabel.numericFormatter;
|
||||
var serieName = serie.serieName;
|
||||
var dataName = serieData != null ? serieData.name : null;
|
||||
if (serieLabel.formatterFunction != null)
|
||||
@@ -62,14 +62,16 @@ namespace XCharts
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData == null) return;
|
||||
if (serieData.labelObject == null) return;
|
||||
var label = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
if(label == null) return;
|
||||
var value = serieData.GetData(1);
|
||||
var total = serie.max;
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, null, Color.clear);
|
||||
serieData.labelObject.SetText(content);
|
||||
serieData.labelObject.SetLabelPosition(serie.context.center + serie.label.offset);
|
||||
if (!ChartHelper.IsClearColor(serie.label.textStyle.color))
|
||||
serieData.labelObject.SetLabelPosition(serie.context.center + label.offset);
|
||||
if (!ChartHelper.IsClearColor(label.textStyle.color))
|
||||
{
|
||||
serieData.labelObject.label.SetColor(serie.label.textStyle.color);
|
||||
serieData.labelObject.label.SetColor(label.textStyle.color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +81,7 @@ namespace XCharts
|
||||
{
|
||||
var serieData = serie.data[i];
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlight);
|
||||
if (serieLabel.show && serieData.labelObject != null)
|
||||
if (serieLabel != null && serieLabel.show && serieData.labelObject != null)
|
||||
{
|
||||
if (!serie.show || !serieData.show)
|
||||
{
|
||||
@@ -93,7 +95,7 @@ namespace XCharts
|
||||
serieData.labelObject.SetText(content);
|
||||
serieData.labelObject.SetTextColor(GetLabelColor(serie, theme, i));
|
||||
|
||||
if (serie.label.position == LabelStyle.Position.Bottom)
|
||||
if (serieLabel.position == LabelStyle.Position.Bottom)
|
||||
{
|
||||
var labelWidth = serieData.GetLabelWidth();
|
||||
if (serie.clockwise)
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace XCharts
|
||||
if (string.IsNullOrEmpty(stack)) return false;
|
||||
foreach (var serie in series)
|
||||
{
|
||||
if (serie.show && serie.areaStyle.show && stack.Equals(serie.stack))
|
||||
if (serie.show && serie.areaStyle != null && serie.areaStyle.show && stack.Equals(serie.stack))
|
||||
{
|
||||
if (!ChartHelper.IsValueEqualsColor(serie.areaStyle.color, serie.areaStyle.toColor)
|
||||
&& !ChartHelper.IsClearColor(serie.areaStyle.toColor))
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class SerieExtraComponentAttribute : Attribute
|
||||
{
|
||||
public readonly List<Type> types = new List<Type>();
|
||||
|
||||
public SerieExtraComponentAttribute()
|
||||
{
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1)
|
||||
{
|
||||
types.Add(type1);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2)
|
||||
{
|
||||
types.Add(type1);
|
||||
types.Add(type2);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3)
|
||||
{
|
||||
types.Add(type1);
|
||||
types.Add(type2);
|
||||
types.Add(type3);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4)
|
||||
{
|
||||
types.Add(type1);
|
||||
types.Add(type2);
|
||||
types.Add(type3);
|
||||
types.Add(type4);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
|
||||
{
|
||||
types.Add(type1);
|
||||
types.Add(type2);
|
||||
types.Add(type3);
|
||||
types.Add(type4);
|
||||
types.Add(type5);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
|
||||
{
|
||||
types.Add(type1);
|
||||
types.Add(type2);
|
||||
types.Add(type3);
|
||||
types.Add(type4);
|
||||
types.Add(type5);
|
||||
types.Add(type6);
|
||||
}
|
||||
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
|
||||
{
|
||||
types.Add(type1);
|
||||
types.Add(type2);
|
||||
types.Add(type3);
|
||||
types.Add(type4);
|
||||
types.Add(type5);
|
||||
types.Add(type6);
|
||||
types.Add(type7);
|
||||
}
|
||||
|
||||
public bool Contains<T>() where T : ISerieExtraComponent
|
||||
{
|
||||
return Contains(typeof(T));
|
||||
}
|
||||
|
||||
public bool Contains(Type type)
|
||||
{
|
||||
return types.Contains(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d61861a0f45f43af8915ae23cc326e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,10 +1,4 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.component/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
12
Assets/XCharts/Runtime/Internal/Misc/ISerieExtraComponent.cs
Normal file
12
Assets/XCharts/Runtime/Internal/Misc/ISerieExtraComponent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public interface ISerieExtraComponent
|
||||
{
|
||||
bool show { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20d76dbb8ca234b439951f6e72826c43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -50,18 +50,6 @@ namespace XCharts
|
||||
raycastTarget = false;
|
||||
}
|
||||
|
||||
// protected override void OnPopulateMesh(VertexHelper vh)
|
||||
// {
|
||||
// if (m_BackgroundColor != Color.clear || m_BackgroundImage != null)
|
||||
// {
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vh.Clear();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void SetLabel(GameObject labelObj, bool autoSize, float paddingLeftRight, float paddingTopBottom)
|
||||
{
|
||||
m_LabelAutoSize = autoSize;
|
||||
@@ -108,7 +96,9 @@ namespace XCharts
|
||||
|
||||
public void UpdateIcon(IconStyle iconStyle, Sprite sprite = null)
|
||||
{
|
||||
if (m_IconImage == null) return;
|
||||
if (m_IconImage == null || iconStyle == null)
|
||||
return;
|
||||
|
||||
SetIconActive(iconStyle.show);
|
||||
if (iconStyle.show)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,10 @@ namespace XCharts
|
||||
[SerieConvert(typeof(Line),typeof(Pie))]
|
||||
[RequireChartComponent(typeof(GridCoord))]
|
||||
[DefaultAnimation(AnimationType.BottomToTop)]
|
||||
[SerieExtraComponent(
|
||||
typeof(LabelStyle),
|
||||
typeof(IconStyle),
|
||||
typeof(Emphasis))]
|
||||
public class Bar : Serie, INeedSerieContainer
|
||||
{
|
||||
public int containerIndex { get; internal set; }
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(CandlestickHandler), true)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent()]
|
||||
public class Candlestick : Serie, INeedSerieContainer
|
||||
{
|
||||
public int containerIndex { get; internal set; }
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0eb5955894da4c8daac165364c5363a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,6 +6,7 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(HeatmapHandler), true)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
|
||||
public class Heatmap : Serie, INeedSerieContainer
|
||||
{
|
||||
public int containerIndex { get; internal set; }
|
||||
@@ -16,10 +17,12 @@ namespace XCharts
|
||||
serie.itemStyle.show = true;
|
||||
serie.itemStyle.borderWidth = 1;
|
||||
serie.itemStyle.borderColor = Color.clear;
|
||||
serie.emphasis.show = true;
|
||||
serie.emphasis.itemStyle.show = true;
|
||||
serie.emphasis.itemStyle.borderWidth = 1;
|
||||
serie.emphasis.itemStyle.borderColor = Color.black;
|
||||
|
||||
var emphasis = serie.AddExtraComponent<Emphasis>();
|
||||
emphasis.show = true;
|
||||
emphasis.itemStyle.show = true;
|
||||
emphasis.itemStyle.borderWidth = 1;
|
||||
emphasis.itemStyle.borderColor = Color.black;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,7 @@ namespace XCharts
|
||||
xAxis.boundaryGap = true;
|
||||
yAxis.boundaryGap = true;
|
||||
var visualMap = chart.GetVisualMapOfSerie(serie);
|
||||
var emphasis = serie.emphasis;
|
||||
var xCount = xAxis.data.Count;
|
||||
var yCount = yAxis.data.Count;
|
||||
var xWidth = grid.context.width / xCount;
|
||||
@@ -153,7 +154,7 @@ namespace XCharts
|
||||
color = visualMap.GetColor(value);
|
||||
if (animationIndex >= 0 && i > animationIndex) continue;
|
||||
serieData.context.canShowLabel = true;
|
||||
var emphasis = (serieData.context.highlight)
|
||||
var highlight = (serieData.context.highlight)
|
||||
|| visualMap.context.pointerIndex > 0;
|
||||
|
||||
UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color);
|
||||
@@ -161,14 +162,14 @@ namespace XCharts
|
||||
{
|
||||
UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor, borderToColor);
|
||||
}
|
||||
if (visualMap.hoverLink && emphasis && serie.emphasis.show
|
||||
&& serie.emphasis.itemStyle.borderWidth > 0)
|
||||
if (visualMap.hoverLink && highlight && emphasis != null && emphasis.show
|
||||
&& emphasis.itemStyle.borderWidth > 0)
|
||||
{
|
||||
var emphasisBorderWidth = serie.emphasis.itemStyle.borderWidth;
|
||||
var emphasisBorderColor = serie.emphasis.itemStyle.opacity > 0
|
||||
? serie.emphasis.itemStyle.borderColor : ChartConst.clearColor32;
|
||||
var emphasisBorderToColor = serie.emphasis.itemStyle.opacity > 0
|
||||
? serie.emphasis.itemStyle.borderToColor : ChartConst.clearColor32;
|
||||
var emphasisBorderWidth = emphasis.itemStyle.borderWidth;
|
||||
var emphasisBorderColor = emphasis.itemStyle.opacity > 0
|
||||
? emphasis.itemStyle.borderColor : ChartConst.clearColor32;
|
||||
var emphasisBorderToColor = emphasis.itemStyle.opacity > 0
|
||||
? emphasis.itemStyle.borderToColor : ChartConst.clearColor32;
|
||||
UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor,
|
||||
emphasisBorderToColor);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,14 @@ namespace XCharts
|
||||
[SerieConvert(typeof(Bar), typeof(Pie))]
|
||||
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[SerieExtraComponent(
|
||||
typeof(LabelStyle),
|
||||
typeof(LabelLine),
|
||||
typeof(EndLabelStyle),
|
||||
typeof(LineArrow),
|
||||
typeof(AreaStyle),
|
||||
typeof(IconStyle),
|
||||
typeof(Emphasis))]
|
||||
public class Line : Serie, INeedSerieContainer
|
||||
{
|
||||
public int containerIndex { get; internal set; }
|
||||
@@ -17,8 +25,6 @@ namespace XCharts
|
||||
{
|
||||
var serie = chart.AddSerie<Line>(serieName);
|
||||
serie.symbol.show = true;
|
||||
serie.label.offset = new Vector3(0, 15f, 0);
|
||||
serie.label.autoOffset = true;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
chart.AddData(serie.index, UnityEngine.Random.Range(10, 90));
|
||||
|
||||
@@ -184,6 +184,7 @@ namespace XCharts
|
||||
var clip = SeriesHelper.IsAnyClipSerie(chart.series);
|
||||
var theme = chart.theme;
|
||||
var interacting = false;
|
||||
var lineArrow = serie.lineArrow;
|
||||
//var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -202,11 +203,11 @@ namespace XCharts
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
if (serie.lineArrow.show)
|
||||
if (lineArrow != null && lineArrow.show)
|
||||
{
|
||||
if (serie.lineArrow.position == LineArrow.Position.Start && i == 0)
|
||||
if (lineArrow.position == LineArrow.Position.Start && i == 0)
|
||||
continue;
|
||||
if (serie.lineArrow.position == LineArrow.Position.End && i == count - 1)
|
||||
if (lineArrow.position == LineArrow.Position.End && i == count - 1)
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ namespace XCharts
|
||||
|
||||
private void DrawLineArrow(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (!serie.show || !serie.lineArrow.show)
|
||||
if (!serie.show || serie.lineArrow == null || !serie.lineArrow.show)
|
||||
return;
|
||||
|
||||
if (serie.context.dataPoints.Count < 2)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace XCharts
|
||||
public static void DrawSerieLineArea(VertexHelper vh, Serie serie, Serie lastStackSerie,
|
||||
ThemeStyle theme, bool isY, Axis axis, Axis relativedAxis, GridCoord grid)
|
||||
{
|
||||
if (!serie.areaStyle.show)
|
||||
if (serie.areaStyle == null || !serie.areaStyle.show)
|
||||
return;
|
||||
|
||||
var srcAreaColor = SerieHelper.GetAreaColor(serie, theme, serie.context.colorIndex, false);
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(LiquidHandler), true)]
|
||||
[RequireChartComponent(typeof(Vessel))]
|
||||
[SerieExtraComponent()]
|
||||
public class Liquid : Serie, INeedSerieContainer
|
||||
{
|
||||
[SerializeField] private float m_WaveHeight = 10f;
|
||||
@@ -55,6 +56,7 @@ namespace XCharts
|
||||
var serie = chart.AddSerie<Liquid>(serieName);
|
||||
serie.min = 0;
|
||||
serie.max = 100;
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
serie.label.textStyle.fontSize = 40;
|
||||
serie.label.formatter = "{d}%";
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace XCharts
|
||||
[SerieConvert(typeof(Line), typeof(Bar))]
|
||||
[SerieHandler(typeof(PieHandler), true)]
|
||||
[DefaultAnimation(AnimationType.Clockwise)]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(IconStyle), typeof(Emphasis))]
|
||||
public class Pie : Serie
|
||||
{
|
||||
public override bool useDataNameForColor { get { return true; } }
|
||||
|
||||
@@ -413,9 +413,9 @@ namespace XCharts
|
||||
{
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
|
||||
if (serieLabel.show
|
||||
&& serieLabel.position == LabelStyle.Position.Outside
|
||||
&& labelLine.show)
|
||||
if (serieLabel != null && serieLabel.show
|
||||
&& labelLine != null && labelLine.show
|
||||
&& serieLabel.position == LabelStyle.Position.Outside)
|
||||
{
|
||||
var insideRadius = serieData.context.insideRadius;
|
||||
var outSideRadius = serieData.context.outsideRadius;
|
||||
@@ -495,8 +495,9 @@ namespace XCharts
|
||||
private void DrawPieLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
|
||||
{
|
||||
if (serieData.labelObject == null) return;
|
||||
var emphasis = serie.emphasis;
|
||||
var currAngle = serieData.context.halfAngle;
|
||||
var isHighlight = (serieData.context.highlight && serie.emphasis.label.show);
|
||||
var isHighlight = (serieData.context.highlight && emphasis != null && emphasis.label.show);
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
@@ -514,9 +515,9 @@ namespace XCharts
|
||||
Color color = serieColor;
|
||||
if (isHighlight)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(serie.emphasis.label.textStyle.color))
|
||||
if (!ChartHelper.IsClearColor(emphasis.label.textStyle.color))
|
||||
{
|
||||
color = serie.emphasis.label.textStyle.color;
|
||||
color = emphasis.label.textStyle.color;
|
||||
}
|
||||
}
|
||||
else if (!ChartHelper.IsClearColor(serieLabel.textStyle.color))
|
||||
@@ -528,10 +529,10 @@ namespace XCharts
|
||||
color = isInsidePosition ? Color.white : serieColor;
|
||||
}
|
||||
var fontSize = isHighlight
|
||||
? serie.emphasis.label.textStyle.GetFontSize(chart.theme.common)
|
||||
? emphasis.label.textStyle.GetFontSize(chart.theme.common)
|
||||
: serieLabel.textStyle.GetFontSize(chart.theme.common);
|
||||
var fontStyle = isHighlight
|
||||
? serie.emphasis.label.textStyle.fontStyle
|
||||
? emphasis.label.textStyle.fontStyle
|
||||
: serieLabel.textStyle.fontStyle;
|
||||
|
||||
serieData.labelObject.label.SetColor(color);
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(RadarHandler), true)]
|
||||
[RequireChartComponent(typeof(RadarCoord))]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(AreaStyle), typeof(Emphasis))]
|
||||
public class Radar : Serie, INeedSerieContainer
|
||||
{
|
||||
public int containerIndex { get; internal set; }
|
||||
|
||||
@@ -226,6 +226,8 @@ namespace XCharts
|
||||
serie.containerIndex = m_RadarCoord.index;
|
||||
serie.containterInstanceId = m_RadarCoord.instanceId;
|
||||
|
||||
var areaStyle = serie.areaStyle;
|
||||
|
||||
var startPoint = Vector3.zero;
|
||||
var toPoint = Vector3.zero;
|
||||
var firstPoint = Vector3.zero;
|
||||
@@ -281,7 +283,7 @@ namespace XCharts
|
||||
{
|
||||
toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle),
|
||||
centerPos.y + radius * Mathf.Cos(currAngle));
|
||||
if (serie.areaStyle.show)
|
||||
if (areaStyle != null && areaStyle.show)
|
||||
{
|
||||
UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor);
|
||||
}
|
||||
@@ -293,7 +295,7 @@ namespace XCharts
|
||||
}
|
||||
serieData.context.dataPoints.Add(startPoint);
|
||||
}
|
||||
if (serie.areaStyle.show)
|
||||
if (areaStyle != null && areaStyle.show)
|
||||
{
|
||||
UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(RingHandler), true)]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
|
||||
public class Ring : Serie
|
||||
{
|
||||
public override bool useDataNameForColor { get { return true; } }
|
||||
@@ -15,6 +16,7 @@ namespace XCharts
|
||||
serie.radius = new float[] { 0.3f, 0.35f };
|
||||
serie.titleStyle.show = false;
|
||||
serie.titleStyle.textStyle.offset = new Vector2(0, 30);
|
||||
serie.AddExtraComponent<LabelStyle>();
|
||||
serie.label.show = true;
|
||||
serie.label.position = LabelStyle.Position.Center;
|
||||
serie.label.formatter = "{d:f0}%";
|
||||
|
||||
@@ -213,22 +213,23 @@ namespace XCharts
|
||||
private void UpateLabelPosition(Serie serie, SerieData serieData, int index, float startAngle,
|
||||
float toAngle, float centerRadius)
|
||||
{
|
||||
if (!serie.label.show) return;
|
||||
var label = serie.label;
|
||||
if (label == null || !label.show) return;
|
||||
if (serieData.labelObject == null) return;
|
||||
switch (serie.label.position)
|
||||
switch (label.position)
|
||||
{
|
||||
case LabelStyle.Position.Center:
|
||||
serieData.context.labelPosition = serie.context.center + serie.label.offset;
|
||||
serieData.context.labelPosition = serie.context.center + label.offset;
|
||||
break;
|
||||
case LabelStyle.Position.Bottom:
|
||||
var px1 = Mathf.Sin(startAngle * Mathf.Deg2Rad) * centerRadius;
|
||||
var py1 = Mathf.Cos(startAngle * Mathf.Deg2Rad) * centerRadius;
|
||||
var xDiff = serie.clockwise ? -serie.label.margin : serie.label.margin;
|
||||
var xDiff = serie.clockwise ? -label.margin : label.margin;
|
||||
serieData.context.labelPosition = serie.context.center + new Vector3(px1 + xDiff, py1);
|
||||
break;
|
||||
case LabelStyle.Position.Top:
|
||||
startAngle += serie.clockwise ? -serie.label.margin : serie.label.margin;
|
||||
toAngle += serie.clockwise ? serie.label.margin : -serie.label.margin;
|
||||
startAngle += serie.clockwise ? -label.margin : label.margin;
|
||||
toAngle += serie.clockwise ? label.margin : -label.margin;
|
||||
var px2 = Mathf.Sin(toAngle * Mathf.Deg2Rad) * centerRadius;
|
||||
var py2 = Mathf.Cos(toAngle * Mathf.Deg2Rad) * centerRadius;
|
||||
serieData.context.labelPosition = serie.context.center + new Vector3(px2, py2);
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(EffectScatterHandler), true)]
|
||||
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
|
||||
public class EffectScatter : BaseScatter
|
||||
{
|
||||
public static void AddDefaultSerie(BaseChart chart, string serieName)
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(ScatterHandler), true)]
|
||||
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
|
||||
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
|
||||
public class Scatter : BaseScatter
|
||||
{
|
||||
public static void AddDefaultSerie(BaseChart chart, string serieName)
|
||||
|
||||
139
Assets/XCharts/Runtime/Serie/Serie.ExtraComponent.cs
Normal file
139
Assets/XCharts/Runtime/Serie/Serie.ExtraComponent.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public partial class Serie
|
||||
{
|
||||
public static Dictionary<Type, string> extraComponentFieldNameDict = new Dictionary<Type, string>
|
||||
{
|
||||
{typeof(LabelStyle), "m_Labels"},
|
||||
{typeof(LabelLine), "m_LabelLines"},
|
||||
{typeof(EndLabelStyle), "m_EndLabels"},
|
||||
{typeof(LineArrow), "m_LineArrows"},
|
||||
{typeof(AreaStyle), "m_AreaStyles"},
|
||||
{typeof(IconStyle), "m_IconStyles"},
|
||||
{typeof(Emphasis), "m_Emphases"},
|
||||
};
|
||||
|
||||
[SerializeField] private List<LabelStyle> m_Labels = new List<LabelStyle>();
|
||||
[SerializeField] private List<LabelLine> m_LabelLines = new List<LabelLine>();
|
||||
[SerializeField] private List<EndLabelStyle> m_EndLabels = new List<EndLabelStyle>();
|
||||
[SerializeField] private List<LineArrow> m_LineArrows = new List<LineArrow>();
|
||||
[SerializeField] private List<AreaStyle> m_AreaStyles = new List<AreaStyle>();
|
||||
[SerializeField] private List<IconStyle> m_IconStyles = new List<IconStyle>();
|
||||
[SerializeField] private List<Emphasis> m_Emphases = new List<Emphasis>();
|
||||
|
||||
/// <summary>
|
||||
/// The style of area.
|
||||
/// 区域填充样式。
|
||||
/// </summary>
|
||||
public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } }
|
||||
/// <summary>
|
||||
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。s
|
||||
/// </summary>
|
||||
public LabelStyle label { get { return m_Labels.Count > 0 ? m_Labels[0] : null; } }
|
||||
public LabelStyle endLabel { get { return m_EndLabels.Count > 0 ? m_EndLabels[0] : null; } }
|
||||
/// <summary>
|
||||
/// The line of label.
|
||||
/// 标签上的视觉引导线。
|
||||
/// </summary>
|
||||
public LabelLine labelLine { get { return m_LabelLines.Count > 0 ? m_LabelLines[0] : null; } }
|
||||
/// <summary>
|
||||
/// The arrow of line.
|
||||
/// 折线图的箭头。
|
||||
/// </summary>
|
||||
public LineArrow lineArrow { get { return m_LineArrows.Count > 0 ? m_LineArrows[0] : null; } }
|
||||
/// <summary>
|
||||
/// 高亮的图形样式和文本标签样式。
|
||||
/// </summary>
|
||||
public Emphasis emphasis { get { return m_Emphases.Count > 0 ? m_Emphases[0] : null; } }
|
||||
/// <summary>
|
||||
/// the icon of data.
|
||||
/// 数据项图标样式。
|
||||
/// </summary>
|
||||
public IconStyle iconStyle { get { return m_IconStyles.Count > 0 ? m_IconStyles[0] : null; } }
|
||||
|
||||
public void RemoveAllExtraComponent()
|
||||
{
|
||||
var serieType = GetType();
|
||||
foreach (var kv in extraComponentFieldNameDict)
|
||||
{
|
||||
ReflectionUtil.InvokeListClear(this, serieType.GetField(kv.Value));
|
||||
}
|
||||
SetAllDirty();
|
||||
}
|
||||
|
||||
public T AddExtraComponent<T>() where T : ChildComponent
|
||||
{
|
||||
return AddExtraComponent(typeof(T)) as T;
|
||||
}
|
||||
|
||||
public ISerieExtraComponent AddExtraComponent(Type type)
|
||||
{
|
||||
if (GetType().IsDefined(typeof(SerieExtraComponentAttribute), false))
|
||||
{
|
||||
var attr = GetType().GetAttribute<SerieExtraComponentAttribute>();
|
||||
if (attr.Contains(type))
|
||||
{
|
||||
var fieldName = string.Empty;
|
||||
if (extraComponentFieldNameDict.TryGetValue(type, out fieldName))
|
||||
{
|
||||
var field = typeof(Serie).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
if (ReflectionUtil.InvokeListCount(this, field) <= 0)
|
||||
{
|
||||
var extraComponent = Activator.CreateInstance(type) as ISerieExtraComponent;
|
||||
ReflectionUtil.InvokeListAdd(this, field, extraComponent);
|
||||
SetAllDirty();
|
||||
return extraComponent;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ReflectionUtil.InvokeListGet<ISerieExtraComponent>(this, field, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new System.Exception(string.Format("Serie {0} not support extra component: {1}",
|
||||
GetType().Name, type.Name));
|
||||
}
|
||||
|
||||
public void RemoveExtraComponent<T>() where T : ISerieExtraComponent
|
||||
{
|
||||
RemoveExtraComponent(typeof(T));
|
||||
}
|
||||
|
||||
public void RemoveExtraComponent(Type type)
|
||||
{
|
||||
if (GetType().IsDefined(typeof(SerieExtraComponentAttribute), false))
|
||||
{
|
||||
var attr = GetType().GetAttribute<SerieExtraComponentAttribute>();
|
||||
if (attr.Contains(type))
|
||||
{
|
||||
var fieldName = string.Empty;
|
||||
if (extraComponentFieldNameDict.TryGetValue(type, out fieldName))
|
||||
{
|
||||
var field = typeof(Serie).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
ReflectionUtil.InvokeListClear(this, field);
|
||||
SetAllDirty();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/Serie/Serie.ExtraComponent.cs.meta
Normal file
11
Assets/XCharts/Runtime/Serie/Serie.ExtraComponent.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c4f3a01039fd4e7fbf771a65ede0069
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -76,7 +76,7 @@ namespace XCharts
|
||||
Capsule
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 雷达图类型
|
||||
@@ -159,7 +159,7 @@ namespace XCharts
|
||||
/// 系列。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Serie : BaseSerie, IComparable
|
||||
public partial class Serie : BaseSerie, IComparable
|
||||
{
|
||||
[SerializeField] private int m_Index;
|
||||
[SerializeField] private bool m_Show = true;
|
||||
@@ -177,16 +177,12 @@ namespace XCharts
|
||||
[SerializeField] protected int m_MinShow;
|
||||
[SerializeField] protected int m_MaxShow;
|
||||
[SerializeField] protected int m_MaxCache;
|
||||
[SerializeField] private AreaStyle m_AreaStyle = AreaStyle.defaultAreaStyle;
|
||||
[SerializeField] private SymbolStyle m_Symbol = new SymbolStyle();
|
||||
|
||||
[SerializeField] private float m_SampleDist = 0;
|
||||
[SerializeField] private SampleType m_SampleType = SampleType.Average;
|
||||
[SerializeField] private float m_SampleAverage = 0;
|
||||
|
||||
[SerializeField] private LineType m_LineType = LineType.Normal;
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
||||
|
||||
[SerializeField] private BarType m_BarType = BarType.Normal;
|
||||
[SerializeField] private bool m_BarPercentStack = false;
|
||||
[SerializeField] private float m_BarWidth = 0.6f;
|
||||
@@ -211,14 +207,7 @@ namespace XCharts
|
||||
[SerializeField] private float m_Space;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f };
|
||||
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
|
||||
[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
||||
[SerializeField] private LabelLine m_LabelLine = new LabelLine();
|
||||
[SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
|
||||
[SerializeField] private LineArrow m_LineArrow = new LineArrow();
|
||||
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
||||
[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
||||
[SerializeField] private TitleStyle m_TitleStyle = new TitleStyle();
|
||||
[SerializeField] private IconStyle m_IconStyle = new IconStyle();
|
||||
|
||||
[SerializeField] [Range(1, 10)] private int m_ShowDataDimension;
|
||||
[SerializeField] private bool m_ShowDataName;
|
||||
[SerializeField] private bool m_ShowDataIcon;
|
||||
@@ -240,6 +229,18 @@ namespace XCharts
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
[SerializeField] private bool m_InsertDataToHead;
|
||||
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
||||
//[SerializeField] private AreaStyle m_AreaStyle = AreaStyle.defaultAreaStyle;
|
||||
[SerializeField] private SymbolStyle m_Symbol = new SymbolStyle();
|
||||
//[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
||||
//[SerializeField] private LabelLine m_LabelLine = new LabelLine();
|
||||
[SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
|
||||
//[SerializeField] private LineArrow m_LineArrow = new LineArrow();
|
||||
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
||||
//[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
||||
[SerializeField] private TitleStyle m_TitleStyle = new TitleStyle();
|
||||
//[SerializeField] private IconStyle m_IconStyle = new IconStyle();
|
||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||
|
||||
[NonSerialized] internal int m_FilterStart;
|
||||
@@ -398,15 +399,7 @@ namespace XCharts
|
||||
get { return m_MaxCache; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// The style of area.
|
||||
/// 区域填充样式。
|
||||
/// </summary>
|
||||
public AreaStyle areaStyle
|
||||
{
|
||||
get { return m_AreaStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_AreaStyle, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the symbol of serie data item.
|
||||
/// 标记的图形。
|
||||
@@ -703,25 +696,6 @@ namespace XCharts
|
||||
get { return m_RadarType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||
/// </summary>
|
||||
public LabelStyle label
|
||||
{
|
||||
get { return m_Label; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Label, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The line of label.
|
||||
/// 标签上的视觉引导线。
|
||||
/// </summary>
|
||||
public LabelLine labelLine
|
||||
{
|
||||
get { return m_LabelLine; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LabelLine, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The start animation.
|
||||
/// 起始动画。
|
||||
@@ -732,15 +706,6 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The arrow of line.
|
||||
/// 折线图的箭头。
|
||||
/// </summary>
|
||||
public LineArrow lineArrow
|
||||
{
|
||||
get { return m_LineArrow; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LineArrow, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The style of data item.
|
||||
/// 图形样式。
|
||||
/// </summary>
|
||||
@@ -750,14 +715,6 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 高亮的图形样式和文本标签样式。
|
||||
/// </summary>
|
||||
public Emphasis emphasis
|
||||
{
|
||||
get { return m_Emphasis; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Emphasis, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 标题样式。
|
||||
/// </summary>
|
||||
public TitleStyle titleStyle
|
||||
@@ -766,15 +723,6 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the icon of data.
|
||||
/// 数据项图标样式。
|
||||
/// </summary>
|
||||
public IconStyle iconStyle
|
||||
{
|
||||
get { return m_IconStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_IconStyle, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项里的数据维数。
|
||||
/// </summary>
|
||||
public int showDataDimension { get { return m_ShowDataDimension; } set { m_ShowDataDimension = value; } }
|
||||
@@ -813,7 +761,8 @@ namespace XCharts
|
||||
if (PropertyUtil.SetStruct(ref m_Large, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
if (label != null)
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -828,7 +777,8 @@ namespace XCharts
|
||||
if (PropertyUtil.SetStruct(ref m_LargeThreshold, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
if (label != null)
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -922,11 +872,11 @@ namespace XCharts
|
||||
return m_VertsDirty ||
|
||||
symbol.vertsDirty ||
|
||||
lineStyle.vertsDirty ||
|
||||
lineArrow.vertsDirty ||
|
||||
(lineArrow != null && lineArrow.vertsDirty) ||
|
||||
itemStyle.vertsDirty ||
|
||||
areaStyle.vertsDirty ||
|
||||
label.vertsDirty ||
|
||||
emphasis.vertsDirty;
|
||||
(areaStyle != null && areaStyle.vertsDirty) ||
|
||||
(label != null && label.vertsDirty) ||
|
||||
(emphasis != null && emphasis.vertsDirty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -936,13 +886,18 @@ namespace XCharts
|
||||
base.ClearVerticesDirty();
|
||||
symbol.ClearVerticesDirty();
|
||||
lineStyle.ClearVerticesDirty();
|
||||
lineArrow.ClearVerticesDirty();
|
||||
itemStyle.ClearVerticesDirty();
|
||||
areaStyle.ClearVerticesDirty();
|
||||
label.ClearVerticesDirty();
|
||||
emphasis.ClearVerticesDirty();
|
||||
titleStyle.ClearVerticesDirty();
|
||||
iconStyle.ClearVerticesDirty();
|
||||
if (iconStyle != null)
|
||||
iconStyle.ClearVerticesDirty();
|
||||
if (areaStyle != null)
|
||||
areaStyle.ClearVerticesDirty();
|
||||
if (label != null)
|
||||
label.ClearVerticesDirty();
|
||||
if (emphasis != null)
|
||||
emphasis.ClearVerticesDirty();
|
||||
if (lineArrow != null)
|
||||
lineArrow?.ClearVerticesDirty();
|
||||
}
|
||||
|
||||
public override void ClearComponentDirty()
|
||||
@@ -950,13 +905,19 @@ namespace XCharts
|
||||
base.ClearComponentDirty();
|
||||
symbol.ClearComponentDirty();
|
||||
lineStyle.ClearComponentDirty();
|
||||
lineArrow.ClearComponentDirty();
|
||||
itemStyle.ClearComponentDirty();
|
||||
areaStyle.ClearComponentDirty();
|
||||
label.ClearComponentDirty();
|
||||
emphasis.ClearComponentDirty();
|
||||
titleStyle.ClearComponentDirty();
|
||||
iconStyle.ClearComponentDirty();
|
||||
if (iconStyle != null)
|
||||
iconStyle.ClearComponentDirty();
|
||||
if (areaStyle != null)
|
||||
areaStyle.ClearComponentDirty();
|
||||
if (label != null)
|
||||
label.ClearComponentDirty();
|
||||
if (emphasis != null)
|
||||
emphasis.ClearComponentDirty();
|
||||
if (lineArrow != null)
|
||||
lineArrow.ClearComponentDirty();
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the serie is highlighted.
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace XCharts
|
||||
if (m_InitedLabel)
|
||||
InternalRefreshLabel();
|
||||
}
|
||||
if (serie.labelDirty || serie.label.componentDirty)
|
||||
if (serie.label != null && (serie.labelDirty || serie.label.componentDirty))
|
||||
{
|
||||
serie.labelDirty = false;
|
||||
serie.label.ClearComponentDirty();
|
||||
@@ -172,13 +172,23 @@ namespace XCharts
|
||||
|
||||
protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
|
||||
{
|
||||
if (serieLabelRoot == null) return false;
|
||||
if (serie.IsPerformanceMode()) return false;
|
||||
if (serieLabelRoot == null)
|
||||
return false;
|
||||
if (serie.IsPerformanceMode())
|
||||
return false;
|
||||
|
||||
if (count == -1) count = serie.dataCount;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
if (serieLabel == null)
|
||||
return false;
|
||||
|
||||
var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
if (!serieLabel.show && (serieEmphasisLabel == null || !serieEmphasisLabel.show) && !iconStyle.show) return false;
|
||||
|
||||
if (!serieLabel.show && (serieEmphasisLabel == null || !serieEmphasisLabel.show)
|
||||
&& (iconStyle != null && !iconStyle.show))
|
||||
return false;
|
||||
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
|
||||
var color = Color.grey;
|
||||
if (serie.useDataNameForColor)
|
||||
@@ -191,14 +201,16 @@ namespace XCharts
|
||||
color = !ChartHelper.IsClearColor(serieLabel.textStyle.color) ? serieLabel.textStyle.color :
|
||||
(Color)chart.theme.GetColor(serie.index);
|
||||
}
|
||||
var iconWidth = iconStyle != null ? iconStyle.width : 20;
|
||||
var iconHeight = iconStyle != null ? iconStyle.height : 20;
|
||||
var labelObj = SerieLabelPool.Get(textName, serieLabelRoot.transform, serieLabel, color,
|
||||
iconStyle.width, iconStyle.height, chart.theme);
|
||||
iconWidth, iconHeight, chart.theme);
|
||||
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||
var item = ChartHelper.GetOrAddComponent<ChartLabel>(labelObj);
|
||||
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||
item.SetIcon(iconImage);
|
||||
item.SetIconActive(iconStyle.show);
|
||||
item.SetIconActive(iconStyle != null && iconStyle.show);
|
||||
item.color = serieLabel.textStyle.backgroundColor;
|
||||
serieData.labelObject = item;
|
||||
|
||||
@@ -251,7 +263,7 @@ namespace XCharts
|
||||
var isIgnore = serie.IsIgnoreIndex(serieData.index);
|
||||
serieData.labelObject.SetPosition(serieData.context.position);
|
||||
serieData.labelObject.UpdateIcon(iconStyle);
|
||||
if (serie.show && serieLabel.show && serieData.context.canShowLabel && !isIgnore)
|
||||
if (serie.show && serieLabel != null && serieLabel.show && serieData.context.canShowLabel && !isIgnore)
|
||||
{
|
||||
var value = serieData.GetData(1);
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
||||
@@ -259,7 +271,7 @@ namespace XCharts
|
||||
var invert = serieLabel.autoOffset
|
||||
&& serie is Line
|
||||
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
||||
&& !serie.areaStyle.show;
|
||||
&& (serie.areaStyle == null || !serie.areaStyle.show);
|
||||
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme, colorIndex);
|
||||
serieData.SetLabelActive(!isIgnore);
|
||||
serieData.labelObject.SetPosition(serieData.context.position + (invert ? -serieLabel.offset : serieLabel.offset));
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace XCharts
|
||||
var method = list.GetType().GetMethod("Clear");
|
||||
method.Invoke(list, new object[] { });
|
||||
}
|
||||
public static int InvokeListCount(object obj, FieldInfo field)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
return (int)list.GetType().GetProperty("Count").GetValue(list);
|
||||
}
|
||||
|
||||
public static void InvokeListAdd(object obj, FieldInfo field, object item)
|
||||
{
|
||||
@@ -20,6 +25,14 @@ namespace XCharts
|
||||
method.Invoke(list, new object[] { item });
|
||||
}
|
||||
|
||||
public static T InvokeListGet<T>(object obj, FieldInfo field, int i)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
var item = list.GetType().GetProperty("Item").GetValue(list, new object[] { i });
|
||||
return (T)item;
|
||||
}
|
||||
|
||||
|
||||
public static void InvokeListAddTo<T>(object obj, FieldInfo field, Action<T> callback)
|
||||
{
|
||||
var list = field.GetValue(obj);
|
||||
|
||||
Reference in New Issue
Block a user