3.0 - serie extra component

This commit is contained in:
monitor1394
2021-12-28 08:18:24 +08:00
parent 90cb25b74f
commit 3a41f1e00e
57 changed files with 505 additions and 245 deletions

View File

@@ -39,12 +39,7 @@ namespace XCharts.Editor
PropertyField("m_LargeThreshold"); PropertyField("m_LargeThreshold");
PropertyField("m_Clip"); PropertyField("m_Clip");
}); });
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -18,10 +18,6 @@ namespace XCharts.Editor
PropertyField("m_LargeThreshold"); PropertyField("m_LargeThreshold");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -20,10 +20,6 @@ namespace XCharts.Editor
PropertyField("m_Symbol"); PropertyField("m_Symbol");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -11,10 +11,6 @@ namespace XCharts.Editor
PropertyField("m_IgnoreValue"); PropertyField("m_IgnoreValue");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -36,14 +36,7 @@ namespace XCharts.Editor
}); });
PropertyField("m_Symbol"); PropertyField("m_Symbol");
PropertyField("m_LineStyle"); PropertyField("m_LineStyle");
PropertyField("m_LineArrow");
PropertyField("m_AreaStyle");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -16,10 +16,6 @@ namespace XCharts.Editor
PropertyField("m_WaveOffset"); PropertyField("m_WaveOffset");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -22,10 +22,6 @@ namespace XCharts.Editor
}); });
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -9,15 +9,10 @@ namespace XCharts.Editor
{ {
PropertyField("m_RadarType"); PropertyField("m_RadarType");
PropertyField("m_RadarIndex"); PropertyField("m_RadarIndex");
PropertyField("m_Symbol"); PropertyField("m_Symbol");
PropertyField("m_LineStyle"); PropertyField("m_LineStyle");
PropertyField("m_AreaStyle");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -13,13 +13,9 @@ namespace XCharts.Editor
PropertyField("m_RingGap"); PropertyField("m_RingGap");
PropertyField("m_RoundCap"); PropertyField("m_RoundCap");
PropertyField("m_Clockwise"); PropertyField("m_Clockwise");
PropertyField("m_TitleStyle");
PropertyField("m_TitleStyle");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -17,13 +17,9 @@ namespace XCharts.Editor
PropertyField("m_YAxisIndex"); PropertyField("m_YAxisIndex");
} }
PropertyField("m_Clip"); PropertyField("m_Clip");
PropertyField("m_Symbol");
PropertyField("m_Symbol");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_IconStyle");
PropertyField("m_Label");
PropertyField("m_LabelLine");
PropertyField("m_Emphasis");
PropertyField("m_Animation"); PropertyField("m_Animation");
} }
} }

View File

@@ -86,7 +86,7 @@ namespace XCharts.Editor
return ObjectNames.NicifyVariableName(title); return ObjectNames.NicifyVariableName(title);
} }
protected SerializedProperty FindProperty(string path) internal SerializedProperty FindProperty(string path)
{ {
return baseProperty.FindPropertyRelative(path); return baseProperty.FindPropertyRelative(path);
} }

View File

@@ -29,6 +29,7 @@ namespace XCharts.Editor
} }
} }
OnCustomInspectorGUI(); OnCustomInspectorGUI();
OnExtraInspectorGUI();
PropertyFieldData(); PropertyFieldData();
--EditorGUI.indentLevel; --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() private void PropertyFieldData()
{ {
m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null, m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null,

View File

@@ -6,7 +6,6 @@ using UnityEditor;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
namespace XCharts.Editor namespace XCharts.Editor
{ {
public sealed class SerieListEditor public sealed class SerieListEditor
@@ -151,7 +150,28 @@ namespace XCharts.Editor
CovertSerie(editor.serie, type); 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) if (index < 0)
m_Editors.Add(editor); m_Editors.Add(editor);
else else
@@ -181,7 +201,8 @@ namespace XCharts.Editor
RefreshEditors(); RefreshEditors();
} }
public void CloneSerie(Serie serie){ public void CloneSerie(Serie serie)
{
var newSerie = serie.Clone(); var newSerie = serie.Clone();
newSerie.serieName = chart.GenerateDefaultSerieName(); newSerie.serieName = chart.GenerateDefaultSerieName();
chart.InsertSerie(newSerie); chart.InsertSerie(newSerie);

View File

@@ -116,6 +116,7 @@ namespace XCharts.Example
{ {
chart.GetChartComponent<Title>().subText = "AreaStyle 面积图"; chart.GetChartComponent<Title>().subText = "AreaStyle 面积图";
serie.AddExtraComponent<AreaStyle>();
serie.areaStyle.show = true; serie.areaStyle.show = true;
chart.RefreshChart(); chart.RefreshChart();
yield return new WaitForSeconds(1f); yield return new WaitForSeconds(1f);
@@ -144,6 +145,7 @@ namespace XCharts.Example
IEnumerator LineArrowSettings() IEnumerator LineArrowSettings()
{ {
chart.GetChartComponent<Title>().subText = "LineArrow 头部箭头"; chart.GetChartComponent<Title>().subText = "LineArrow 头部箭头";
chart.GetSerie(0).AddExtraComponent<LineArrow>();
serie.lineArrow.show = true; serie.lineArrow.show = true;
serie.lineArrow.position = LineArrow.Position.Start; serie.lineArrow.position = LineArrow.Position.Start;
chart.RefreshChart(); chart.RefreshChart();
@@ -205,6 +207,7 @@ namespace XCharts.Example
IEnumerator LineLabelSettings() IEnumerator LineLabelSettings()
{ {
chart.GetChartComponent<Title>().subText = "SerieLabel 文本标签"; chart.GetChartComponent<Title>().subText = "SerieLabel 文本标签";
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true; serie.label.show = true;
serie.label.border = false; serie.label.border = false;
chart.RefreshChart(); chart.RefreshChart();

View File

@@ -140,6 +140,7 @@ namespace XCharts.Example
serie.barPercentStack = true; serie.barPercentStack = true;
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true; serie.label.show = true;
serie.label.position = LabelStyle.Position.Center; serie.label.position = LabelStyle.Position.Center;
serie.label.border = false; serie.label.border = false;

View File

@@ -83,6 +83,7 @@ namespace XCharts.Example
{ {
chart.GetChartComponent<Title>().subText = "显示文本标签"; chart.GetChartComponent<Title>().subText = "显示文本标签";
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true; serie.label.show = true;
chart.RefreshChart(); chart.RefreshChart();
yield return new WaitForSeconds(1); yield return new WaitForSeconds(1);

View File

@@ -19,6 +19,7 @@ namespace XCharts.Example
var serieIndex = 0; var serieIndex = 0;
var serie = chart.GetSerie(serieIndex); var serie = chart.GetSerie(serieIndex);
if (serie == null) return; if (serie == null) return;
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true; serie.label.show = true;
serie.label.position = LabelStyle.Position.Outside; serie.label.position = LabelStyle.Position.Outside;
} }

View File

@@ -47,6 +47,7 @@ namespace XCharts.Example
serie.itemStyle.borderColor = Color.clear; serie.itemStyle.borderColor = Color.clear;
//设置高亮样式 //设置高亮样式
serie.AddExtraComponent<Emphasis>();
serie.emphasis.show = true; serie.emphasis.show = true;
serie.emphasis.itemStyle.show = true; serie.emphasis.itemStyle.show = true;
serie.emphasis.itemStyle.borderWidth = 1; serie.emphasis.itemStyle.borderWidth = 1;

View File

@@ -9,7 +9,7 @@ namespace XCharts
/// 区域填充样式。 /// 区域填充样式。
/// </summary> /// </summary>
[System.Serializable] [System.Serializable]
public class AreaStyle : ChildComponent public class AreaStyle : ChildComponent, ISerieExtraComponent
{ {
/// <summary> /// <summary>
/// Origin position of area. /// Origin position of area.
@@ -33,11 +33,11 @@ namespace XCharts
/// </summary> /// </summary>
End End
} }
[SerializeField] private bool m_Show; [SerializeField] private bool m_Show = true;
[SerializeField] private AreaOrigin m_Origin; [SerializeField] private AreaOrigin m_Origin;
[SerializeField] private Color32 m_Color; [SerializeField] private Color32 m_Color;
[SerializeField] private Color32 m_ToColor; [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 bool m_TooltipHighlight;
[SerializeField] private Color32 m_HighlightColor; [SerializeField] private Color32 m_HighlightColor;
[SerializeField] private Color32 m_HighlightToColor; [SerializeField] private Color32 m_HighlightToColor;
@@ -114,21 +114,6 @@ namespace XCharts
set { if (PropertyUtil.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); } 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() public Color32 GetColor()
{ {
if (m_Opacity == 1) if (m_Opacity == 1)

View File

@@ -8,7 +8,7 @@ namespace XCharts
/// 高亮的图形样式和文本标签样式。 /// 高亮的图形样式和文本标签样式。
/// </summary> /// </summary>
[System.Serializable] [System.Serializable]
public class Emphasis : ChildComponent, ISerieDataComponent public class Emphasis : ChildComponent, ISerieExtraComponent, ISerieDataComponent
{ {
[SerializeField] private bool m_Show; [SerializeField] private bool m_Show;
[SerializeField] private LabelStyle m_Label = new LabelStyle(); [SerializeField] private LabelStyle m_Label = new LabelStyle();

View File

@@ -0,0 +1,11 @@
using System;
using UnityEngine;
namespace XCharts
{
[System.Serializable]
public class EndLabelStyle : LabelStyle
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b3ca55f3ab0314339ae171c8ac07c4e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -5,7 +5,7 @@ using UnityEngine.UI;
namespace XCharts namespace XCharts
{ {
[System.Serializable] [System.Serializable]
public class IconStyle : ChildComponent, ISerieDataComponent public class IconStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
{ {
public enum Layer public enum Layer
{ {

View File

@@ -5,7 +5,7 @@ using UnityEngine;
namespace XCharts namespace XCharts
{ {
[System.Serializable] [System.Serializable]
public class LabelLine : ChildComponent,ISerieDataComponent public class LabelLine : ChildComponent, ISerieExtraComponent, ISerieDataComponent
{ {
/// <summary> /// <summary>
/// 标签视觉引导线类型 /// 标签视觉引导线类型

View File

@@ -9,7 +9,7 @@ namespace XCharts
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。 /// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
/// </summary> /// </summary>
[System.Serializable] [System.Serializable]
public class LabelStyle : ChildComponent,ISerieDataComponent public class LabelStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
{ {
/// <summary> /// <summary>
/// The position of label. /// The position of label.
@@ -69,7 +69,7 @@ namespace XCharts
End End
} }
[SerializeField] private bool m_Show = false; [SerializeField] private bool m_Show = false;
[SerializeField] Position m_Position = Position.Outside; [SerializeField] Position m_Position = Position.Outside;
[SerializeField] private Vector3 m_Offset; [SerializeField] private Vector3 m_Offset;
@@ -299,4 +299,6 @@ namespace XCharts
} }
} }
} }
} }

View File

@@ -7,7 +7,7 @@ namespace XCharts
/// <summary> /// <summary>
/// </summary> /// </summary>
[Serializable] [Serializable]
public class LineArrow : ChildComponent public class LineArrow : ChildComponent, ISerieExtraComponent
{ {
public enum Position public enum Position
{ {

View File

@@ -407,7 +407,7 @@ namespace XCharts
{ {
if (!serie.IsPerformanceMode() && serieData != null && serieData.emphasis != null && serieData.emphasis.show) if (!serie.IsPerformanceMode() && serieData != null && serieData.emphasis != null && serieData.emphasis.show)
return serieData.emphasis.itemStyle; 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; else return null;
} }
@@ -417,7 +417,7 @@ namespace XCharts
{ {
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show) if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
return serieData.emphasis.label; 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 return serie.label;
} }
else else
@@ -431,7 +431,7 @@ namespace XCharts
{ {
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show) if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
return serieData.emphasis.label; 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; else return null;
} }
@@ -441,7 +441,7 @@ namespace XCharts
{ {
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show) if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
return serieData.emphasis.labelLine; 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 return serie.labelLine;
} }
else else
@@ -466,11 +466,16 @@ namespace XCharts
public static Color32 GetAreaColor(Serie serie, ThemeStyle theme, int index, bool highlight) public static Color32 GetAreaColor(Serie serie, ThemeStyle theme, int index, bool highlight)
{ {
var areaStyle = serie.areaStyle; 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 (highlight)
{ {
if (!ChartHelper.IsClearColor(areaStyle.highlightColor)) color = areaStyle.highlightColor; if (!ChartHelper.IsClearColor(areaStyle.highlightColor))
else color = ChartHelper.GetHighlightColor(color); color = areaStyle.highlightColor;
else
color = ChartHelper.GetHighlightColor(color);
} }
ChartHelper.SetColorOpacity(ref color, areaStyle.opacity); ChartHelper.SetColorOpacity(ref color, areaStyle.opacity);
return color; return color;
@@ -479,6 +484,8 @@ namespace XCharts
public static Color32 GetAreaToColor(Serie serie, ThemeStyle theme, int index, bool highlight) public static Color32 GetAreaToColor(Serie serie, ThemeStyle theme, int index, bool highlight)
{ {
var areaStyle = serie.areaStyle; var areaStyle = serie.areaStyle;
if (areaStyle == null || !areaStyle.show)
return ColorUtil.clearColor32;
if (!ChartHelper.IsClearColor(areaStyle.toColor)) if (!ChartHelper.IsClearColor(areaStyle.toColor))
{ {
var color = areaStyle.toColor; var color = areaStyle.toColor;

View File

@@ -8,7 +8,7 @@ namespace XCharts
public static Color GetLabelColor(Serie serie, ThemeStyle theme, int index) 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; return serie.label.textStyle.color;
} }
@@ -39,7 +39,7 @@ namespace XCharts
{ {
serieLabel = SerieHelper.GetSerieLabel(serie, serieData); 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 serieName = serie.serieName;
var dataName = serieData != null ? serieData.name : null; var dataName = serieData != null ? serieData.name : null;
if (serieLabel.formatterFunction != null) if (serieLabel.formatterFunction != null)
@@ -62,14 +62,16 @@ namespace XCharts
var serieData = serie.GetSerieData(0); var serieData = serie.GetSerieData(0);
if (serieData == null) return; if (serieData == null) return;
if (serieData.labelObject == null) return; if (serieData.labelObject == null) return;
var label = SerieHelper.GetSerieLabel(serie, serieData);
if(label == null) return;
var value = serieData.GetData(1); var value = serieData.GetData(1);
var total = serie.max; var total = serie.max;
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, null, Color.clear); var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, null, Color.clear);
serieData.labelObject.SetText(content); serieData.labelObject.SetText(content);
serieData.labelObject.SetLabelPosition(serie.context.center + serie.label.offset); serieData.labelObject.SetLabelPosition(serie.context.center + label.offset);
if (!ChartHelper.IsClearColor(serie.label.textStyle.color)) 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 serieData = serie.data[i];
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlight); 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) if (!serie.show || !serieData.show)
{ {
@@ -93,7 +95,7 @@ namespace XCharts
serieData.labelObject.SetText(content); serieData.labelObject.SetText(content);
serieData.labelObject.SetTextColor(GetLabelColor(serie, theme, i)); serieData.labelObject.SetTextColor(GetLabelColor(serie, theme, i));
if (serie.label.position == LabelStyle.Position.Bottom) if (serieLabel.position == LabelStyle.Position.Bottom)
{ {
var labelWidth = serieData.GetLabelWidth(); var labelWidth = serieData.GetLabelWidth();
if (serie.clockwise) if (serie.clockwise)

View File

@@ -119,7 +119,7 @@ namespace XCharts
if (string.IsNullOrEmpty(stack)) return false; if (string.IsNullOrEmpty(stack)) return false;
foreach (var serie in series) 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) if (!ChartHelper.IsValueEqualsColor(serie.areaStyle.color, serie.areaStyle.toColor)
&& !ChartHelper.IsClearColor(serie.areaStyle.toColor)) && !ChartHelper.IsClearColor(serie.areaStyle.toColor))

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7d61861a0f45f43af8915ae23cc326e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,10 +1,4 @@
/************************************************/ 
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.component/monitor1394 */
/* */
/************************************************/
using UnityEngine; using UnityEngine;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;

View File

@@ -0,0 +1,12 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace XCharts
{
public interface ISerieExtraComponent
{
bool show { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20d76dbb8ca234b439951f6e72826c43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -50,18 +50,6 @@ namespace XCharts
raycastTarget = false; 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) public void SetLabel(GameObject labelObj, bool autoSize, float paddingLeftRight, float paddingTopBottom)
{ {
m_LabelAutoSize = autoSize; m_LabelAutoSize = autoSize;
@@ -108,7 +96,9 @@ namespace XCharts
public void UpdateIcon(IconStyle iconStyle, Sprite sprite = null) public void UpdateIcon(IconStyle iconStyle, Sprite sprite = null)
{ {
if (m_IconImage == null) return; if (m_IconImage == null || iconStyle == null)
return;
SetIconActive(iconStyle.show); SetIconActive(iconStyle.show);
if (iconStyle.show) if (iconStyle.show)
{ {

View File

@@ -10,6 +10,10 @@ namespace XCharts
[SerieConvert(typeof(Line),typeof(Pie))] [SerieConvert(typeof(Line),typeof(Pie))]
[RequireChartComponent(typeof(GridCoord))] [RequireChartComponent(typeof(GridCoord))]
[DefaultAnimation(AnimationType.BottomToTop)] [DefaultAnimation(AnimationType.BottomToTop)]
[SerieExtraComponent(
typeof(LabelStyle),
typeof(IconStyle),
typeof(Emphasis))]
public class Bar : Serie, INeedSerieContainer public class Bar : Serie, INeedSerieContainer
{ {
public int containerIndex { get; internal set; } public int containerIndex { get; internal set; }

View File

@@ -6,6 +6,7 @@ namespace XCharts
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(CandlestickHandler), true)] [SerieHandler(typeof(CandlestickHandler), true)]
[DefaultAnimation(AnimationType.LeftToRight)] [DefaultAnimation(AnimationType.LeftToRight)]
[SerieExtraComponent()]
public class Candlestick : Serie, INeedSerieContainer public class Candlestick : Serie, INeedSerieContainer
{ {
public int containerIndex { get; internal set; } public int containerIndex { get; internal set; }

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e0eb5955894da4c8daac165364c5363a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -6,6 +6,7 @@ namespace XCharts
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(HeatmapHandler), true)] [SerieHandler(typeof(HeatmapHandler), true)]
[DefaultAnimation(AnimationType.LeftToRight)] [DefaultAnimation(AnimationType.LeftToRight)]
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
public class Heatmap : Serie, INeedSerieContainer public class Heatmap : Serie, INeedSerieContainer
{ {
public int containerIndex { get; internal set; } public int containerIndex { get; internal set; }
@@ -16,10 +17,12 @@ namespace XCharts
serie.itemStyle.show = true; serie.itemStyle.show = true;
serie.itemStyle.borderWidth = 1; serie.itemStyle.borderWidth = 1;
serie.itemStyle.borderColor = Color.clear; serie.itemStyle.borderColor = Color.clear;
serie.emphasis.show = true;
serie.emphasis.itemStyle.show = true; var emphasis = serie.AddExtraComponent<Emphasis>();
serie.emphasis.itemStyle.borderWidth = 1; emphasis.show = true;
serie.emphasis.itemStyle.borderColor = Color.black; emphasis.itemStyle.show = true;
emphasis.itemStyle.borderWidth = 1;
emphasis.itemStyle.borderColor = Color.black;
} }
} }
} }

View File

@@ -96,6 +96,7 @@ namespace XCharts
xAxis.boundaryGap = true; xAxis.boundaryGap = true;
yAxis.boundaryGap = true; yAxis.boundaryGap = true;
var visualMap = chart.GetVisualMapOfSerie(serie); var visualMap = chart.GetVisualMapOfSerie(serie);
var emphasis = serie.emphasis;
var xCount = xAxis.data.Count; var xCount = xAxis.data.Count;
var yCount = yAxis.data.Count; var yCount = yAxis.data.Count;
var xWidth = grid.context.width / xCount; var xWidth = grid.context.width / xCount;
@@ -153,7 +154,7 @@ namespace XCharts
color = visualMap.GetColor(value); color = visualMap.GetColor(value);
if (animationIndex >= 0 && i > animationIndex) continue; if (animationIndex >= 0 && i > animationIndex) continue;
serieData.context.canShowLabel = true; serieData.context.canShowLabel = true;
var emphasis = (serieData.context.highlight) var highlight = (serieData.context.highlight)
|| visualMap.context.pointerIndex > 0; || visualMap.context.pointerIndex > 0;
UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color); UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color);
@@ -161,14 +162,14 @@ namespace XCharts
{ {
UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor, borderToColor); UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor, borderToColor);
} }
if (visualMap.hoverLink && emphasis && serie.emphasis.show if (visualMap.hoverLink && highlight && emphasis != null && emphasis.show
&& serie.emphasis.itemStyle.borderWidth > 0) && emphasis.itemStyle.borderWidth > 0)
{ {
var emphasisBorderWidth = serie.emphasis.itemStyle.borderWidth; var emphasisBorderWidth = emphasis.itemStyle.borderWidth;
var emphasisBorderColor = serie.emphasis.itemStyle.opacity > 0 var emphasisBorderColor = emphasis.itemStyle.opacity > 0
? serie.emphasis.itemStyle.borderColor : ChartConst.clearColor32; ? emphasis.itemStyle.borderColor : ChartConst.clearColor32;
var emphasisBorderToColor = serie.emphasis.itemStyle.opacity > 0 var emphasisBorderToColor = emphasis.itemStyle.opacity > 0
? serie.emphasis.itemStyle.borderToColor : ChartConst.clearColor32; ? emphasis.itemStyle.borderToColor : ChartConst.clearColor32;
UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor, UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor,
emphasisBorderToColor); emphasisBorderToColor);
} }

View File

@@ -9,6 +9,14 @@ namespace XCharts
[SerieConvert(typeof(Bar), typeof(Pie))] [SerieConvert(typeof(Bar), typeof(Pie))]
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))] [CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
[DefaultAnimation(AnimationType.LeftToRight)] [DefaultAnimation(AnimationType.LeftToRight)]
[SerieExtraComponent(
typeof(LabelStyle),
typeof(LabelLine),
typeof(EndLabelStyle),
typeof(LineArrow),
typeof(AreaStyle),
typeof(IconStyle),
typeof(Emphasis))]
public class Line : Serie, INeedSerieContainer public class Line : Serie, INeedSerieContainer
{ {
public int containerIndex { get; internal set; } public int containerIndex { get; internal set; }
@@ -17,8 +25,6 @@ namespace XCharts
{ {
var serie = chart.AddSerie<Line>(serieName); var serie = chart.AddSerie<Line>(serieName);
serie.symbol.show = true; serie.symbol.show = true;
serie.label.offset = new Vector3(0, 15f, 0);
serie.label.autoOffset = true;
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
chart.AddData(serie.index, UnityEngine.Random.Range(10, 90)); chart.AddData(serie.index, UnityEngine.Random.Range(10, 90));

View File

@@ -184,6 +184,7 @@ namespace XCharts
var clip = SeriesHelper.IsAnyClipSerie(chart.series); var clip = SeriesHelper.IsAnyClipSerie(chart.series);
var theme = chart.theme; var theme = chart.theme;
var interacting = false; var interacting = false;
var lineArrow = serie.lineArrow;
//var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components); //var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@@ -202,11 +203,11 @@ namespace XCharts
// { // {
// continue; // 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; continue;
if (serie.lineArrow.position == LineArrow.Position.End && i == count - 1) if (lineArrow.position == LineArrow.Position.End && i == count - 1)
continue; continue;
} }
@@ -246,7 +247,7 @@ namespace XCharts
private void DrawLineArrow(VertexHelper vh, Serie serie) private void DrawLineArrow(VertexHelper vh, Serie serie)
{ {
if (!serie.show || !serie.lineArrow.show) if (!serie.show || serie.lineArrow == null || !serie.lineArrow.show)
return; return;
if (serie.context.dataPoints.Count < 2) if (serie.context.dataPoints.Count < 2)

View File

@@ -25,7 +25,7 @@ namespace XCharts
public static void DrawSerieLineArea(VertexHelper vh, Serie serie, Serie lastStackSerie, public static void DrawSerieLineArea(VertexHelper vh, Serie serie, Serie lastStackSerie,
ThemeStyle theme, bool isY, Axis axis, Axis relativedAxis, GridCoord grid) ThemeStyle theme, bool isY, Axis axis, Axis relativedAxis, GridCoord grid)
{ {
if (!serie.areaStyle.show) if (serie.areaStyle == null || !serie.areaStyle.show)
return; return;
var srcAreaColor = SerieHelper.GetAreaColor(serie, theme, serie.context.colorIndex, false); var srcAreaColor = SerieHelper.GetAreaColor(serie, theme, serie.context.colorIndex, false);

View File

@@ -6,6 +6,7 @@ namespace XCharts
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(LiquidHandler), true)] [SerieHandler(typeof(LiquidHandler), true)]
[RequireChartComponent(typeof(Vessel))] [RequireChartComponent(typeof(Vessel))]
[SerieExtraComponent()]
public class Liquid : Serie, INeedSerieContainer public class Liquid : Serie, INeedSerieContainer
{ {
[SerializeField] private float m_WaveHeight = 10f; [SerializeField] private float m_WaveHeight = 10f;
@@ -55,6 +56,7 @@ namespace XCharts
var serie = chart.AddSerie<Liquid>(serieName); var serie = chart.AddSerie<Liquid>(serieName);
serie.min = 0; serie.min = 0;
serie.max = 100; serie.max = 100;
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true; serie.label.show = true;
serie.label.textStyle.fontSize = 40; serie.label.textStyle.fontSize = 40;
serie.label.formatter = "{d}%"; serie.label.formatter = "{d}%";

View File

@@ -5,6 +5,7 @@ namespace XCharts
[SerieConvert(typeof(Line), typeof(Bar))] [SerieConvert(typeof(Line), typeof(Bar))]
[SerieHandler(typeof(PieHandler), true)] [SerieHandler(typeof(PieHandler), true)]
[DefaultAnimation(AnimationType.Clockwise)] [DefaultAnimation(AnimationType.Clockwise)]
[SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(IconStyle), typeof(Emphasis))]
public class Pie : Serie public class Pie : Serie
{ {
public override bool useDataNameForColor { get { return true; } } public override bool useDataNameForColor { get { return true; } }

View File

@@ -413,9 +413,9 @@ namespace XCharts
{ {
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData); var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
if (serieLabel.show if (serieLabel != null && serieLabel.show
&& serieLabel.position == LabelStyle.Position.Outside && labelLine != null && labelLine.show
&& labelLine.show) && serieLabel.position == LabelStyle.Position.Outside)
{ {
var insideRadius = serieData.context.insideRadius; var insideRadius = serieData.context.insideRadius;
var outSideRadius = serieData.context.outsideRadius; var outSideRadius = serieData.context.outsideRadius;
@@ -495,8 +495,9 @@ namespace XCharts
private void DrawPieLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor) private void DrawPieLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
{ {
if (serieData.labelObject == null) return; if (serieData.labelObject == null) return;
var emphasis = serie.emphasis;
var currAngle = serieData.context.halfAngle; 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 serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData); var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
var iconStyle = SerieHelper.GetIconStyle(serie, serieData); var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
@@ -514,9 +515,9 @@ namespace XCharts
Color color = serieColor; Color color = serieColor;
if (isHighlight) 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)) else if (!ChartHelper.IsClearColor(serieLabel.textStyle.color))
@@ -528,10 +529,10 @@ namespace XCharts
color = isInsidePosition ? Color.white : serieColor; color = isInsidePosition ? Color.white : serieColor;
} }
var fontSize = isHighlight var fontSize = isHighlight
? serie.emphasis.label.textStyle.GetFontSize(chart.theme.common) ? emphasis.label.textStyle.GetFontSize(chart.theme.common)
: serieLabel.textStyle.GetFontSize(chart.theme.common); : serieLabel.textStyle.GetFontSize(chart.theme.common);
var fontStyle = isHighlight var fontStyle = isHighlight
? serie.emphasis.label.textStyle.fontStyle ? emphasis.label.textStyle.fontStyle
: serieLabel.textStyle.fontStyle; : serieLabel.textStyle.fontStyle;
serieData.labelObject.label.SetColor(color); serieData.labelObject.label.SetColor(color);

View File

@@ -7,6 +7,7 @@ namespace XCharts
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(RadarHandler), true)] [SerieHandler(typeof(RadarHandler), true)]
[RequireChartComponent(typeof(RadarCoord))] [RequireChartComponent(typeof(RadarCoord))]
[SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(AreaStyle), typeof(Emphasis))]
public class Radar : Serie, INeedSerieContainer public class Radar : Serie, INeedSerieContainer
{ {
public int containerIndex { get; internal set; } public int containerIndex { get; internal set; }

View File

@@ -226,6 +226,8 @@ namespace XCharts
serie.containerIndex = m_RadarCoord.index; serie.containerIndex = m_RadarCoord.index;
serie.containterInstanceId = m_RadarCoord.instanceId; serie.containterInstanceId = m_RadarCoord.instanceId;
var areaStyle = serie.areaStyle;
var startPoint = Vector3.zero; var startPoint = Vector3.zero;
var toPoint = Vector3.zero; var toPoint = Vector3.zero;
var firstPoint = Vector3.zero; var firstPoint = Vector3.zero;
@@ -281,7 +283,7 @@ namespace XCharts
{ {
toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle), toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle),
centerPos.y + radius * Mathf.Cos(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); UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor);
} }
@@ -293,7 +295,7 @@ namespace XCharts
} }
serieData.context.dataPoints.Add(startPoint); serieData.context.dataPoints.Add(startPoint);
} }
if (serie.areaStyle.show) if (areaStyle != null && areaStyle.show)
{ {
UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
} }

View File

@@ -5,6 +5,7 @@ namespace XCharts
{ {
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(RingHandler), true)] [SerieHandler(typeof(RingHandler), true)]
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
public class Ring : Serie public class Ring : Serie
{ {
public override bool useDataNameForColor { get { return true; } } public override bool useDataNameForColor { get { return true; } }
@@ -15,6 +16,7 @@ namespace XCharts
serie.radius = new float[] { 0.3f, 0.35f }; serie.radius = new float[] { 0.3f, 0.35f };
serie.titleStyle.show = false; serie.titleStyle.show = false;
serie.titleStyle.textStyle.offset = new Vector2(0, 30); serie.titleStyle.textStyle.offset = new Vector2(0, 30);
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true; serie.label.show = true;
serie.label.position = LabelStyle.Position.Center; serie.label.position = LabelStyle.Position.Center;
serie.label.formatter = "{d:f0}%"; serie.label.formatter = "{d:f0}%";

View File

@@ -213,22 +213,23 @@ namespace XCharts
private void UpateLabelPosition(Serie serie, SerieData serieData, int index, float startAngle, private void UpateLabelPosition(Serie serie, SerieData serieData, int index, float startAngle,
float toAngle, float centerRadius) float toAngle, float centerRadius)
{ {
if (!serie.label.show) return; var label = serie.label;
if (label == null || !label.show) return;
if (serieData.labelObject == null) return; if (serieData.labelObject == null) return;
switch (serie.label.position) switch (label.position)
{ {
case LabelStyle.Position.Center: case LabelStyle.Position.Center:
serieData.context.labelPosition = serie.context.center + serie.label.offset; serieData.context.labelPosition = serie.context.center + label.offset;
break; break;
case LabelStyle.Position.Bottom: case LabelStyle.Position.Bottom:
var px1 = Mathf.Sin(startAngle * Mathf.Deg2Rad) * centerRadius; var px1 = Mathf.Sin(startAngle * Mathf.Deg2Rad) * centerRadius;
var py1 = Mathf.Cos(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); serieData.context.labelPosition = serie.context.center + new Vector3(px1 + xDiff, py1);
break; break;
case LabelStyle.Position.Top: case LabelStyle.Position.Top:
startAngle += serie.clockwise ? -serie.label.margin : serie.label.margin; startAngle += serie.clockwise ? -label.margin : label.margin;
toAngle += serie.clockwise ? serie.label.margin : -serie.label.margin; toAngle += serie.clockwise ? label.margin : -label.margin;
var px2 = Mathf.Sin(toAngle * Mathf.Deg2Rad) * centerRadius; var px2 = Mathf.Sin(toAngle * Mathf.Deg2Rad) * centerRadius;
var py2 = Mathf.Cos(toAngle * Mathf.Deg2Rad) * centerRadius; var py2 = Mathf.Cos(toAngle * Mathf.Deg2Rad) * centerRadius;
serieData.context.labelPosition = serie.context.center + new Vector3(px2, py2); serieData.context.labelPosition = serie.context.center + new Vector3(px2, py2);

View File

@@ -6,6 +6,7 @@ namespace XCharts
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(EffectScatterHandler), true)] [SerieHandler(typeof(EffectScatterHandler), true)]
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))] [CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
public class EffectScatter : BaseScatter public class EffectScatter : BaseScatter
{ {
public static void AddDefaultSerie(BaseChart chart, string serieName) public static void AddDefaultSerie(BaseChart chart, string serieName)

View File

@@ -8,6 +8,7 @@ namespace XCharts
[System.Serializable] [System.Serializable]
[SerieHandler(typeof(ScatterHandler), true)] [SerieHandler(typeof(ScatterHandler), true)]
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))] [CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
public class Scatter : BaseScatter public class Scatter : BaseScatter
{ {
public static void AddDefaultSerie(BaseChart chart, string serieName) public static void AddDefaultSerie(BaseChart chart, string serieName)

View 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();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c4f3a01039fd4e7fbf771a65ede0069
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -76,7 +76,7 @@ namespace XCharts
Capsule Capsule
} }
/// <summary> /// <summary>
/// 雷达图类型 /// 雷达图类型
@@ -159,7 +159,7 @@ namespace XCharts
/// 系列。 /// 系列。
/// </summary> /// </summary>
[System.Serializable] [System.Serializable]
public class Serie : BaseSerie, IComparable public partial class Serie : BaseSerie, IComparable
{ {
[SerializeField] private int m_Index; [SerializeField] private int m_Index;
[SerializeField] private bool m_Show = true; [SerializeField] private bool m_Show = true;
@@ -177,16 +177,12 @@ namespace XCharts
[SerializeField] protected int m_MinShow; [SerializeField] protected int m_MinShow;
[SerializeField] protected int m_MaxShow; [SerializeField] protected int m_MaxShow;
[SerializeField] protected int m_MaxCache; [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 float m_SampleDist = 0;
[SerializeField] private SampleType m_SampleType = SampleType.Average; [SerializeField] private SampleType m_SampleType = SampleType.Average;
[SerializeField] private float m_SampleAverage = 0; [SerializeField] private float m_SampleAverage = 0;
[SerializeField] private LineType m_LineType = LineType.Normal; [SerializeField] private LineType m_LineType = LineType.Normal;
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
[SerializeField] private BarType m_BarType = BarType.Normal; [SerializeField] private BarType m_BarType = BarType.Normal;
[SerializeField] private bool m_BarPercentStack = false; [SerializeField] private bool m_BarPercentStack = false;
[SerializeField] private float m_BarWidth = 0.6f; [SerializeField] private float m_BarWidth = 0.6f;
@@ -211,14 +207,7 @@ namespace XCharts
[SerializeField] private float m_Space; [SerializeField] private float m_Space;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f }; [SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f };
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 }; [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] [Range(1, 10)] private int m_ShowDataDimension;
[SerializeField] private bool m_ShowDataName; [SerializeField] private bool m_ShowDataName;
[SerializeField] private bool m_ShowDataIcon; [SerializeField] private bool m_ShowDataIcon;
@@ -240,6 +229,18 @@ namespace XCharts
[SerializeField] private float m_Top; [SerializeField] private float m_Top;
[SerializeField] private float m_Bottom; [SerializeField] private float m_Bottom;
[SerializeField] private bool m_InsertDataToHead; [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>(); [SerializeField] private List<SerieData> m_Data = new List<SerieData>();
[NonSerialized] internal int m_FilterStart; [NonSerialized] internal int m_FilterStart;
@@ -398,15 +399,7 @@ namespace XCharts
get { return m_MaxCache; } get { return m_MaxCache; }
set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } } 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> /// <summary>
/// the symbol of serie data item. /// the symbol of serie data item.
/// 标记的图形。 /// 标记的图形。
@@ -703,25 +696,6 @@ namespace XCharts
get { return m_RadarType; } get { return m_RadarType; }
set { if (PropertyUtil.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); } 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> /// <summary>
/// The start animation. /// The start animation.
/// 起始动画。 /// 起始动画。
@@ -732,15 +706,6 @@ namespace XCharts
set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); } set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
} }
/// <summary> /// <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. /// The style of data item.
/// 图形样式。 /// 图形样式。
/// </summary> /// </summary>
@@ -750,14 +715,6 @@ namespace XCharts
set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); } set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
} }
/// <summary> /// <summary>
/// 高亮的图形样式和文本标签样式。
/// </summary>
public Emphasis emphasis
{
get { return m_Emphasis; }
set { if (PropertyUtil.SetClass(ref m_Emphasis, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 标题样式。 /// 标题样式。
/// </summary> /// </summary>
public TitleStyle titleStyle public TitleStyle titleStyle
@@ -766,15 +723,6 @@ namespace XCharts
set { if (PropertyUtil.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); } set { if (PropertyUtil.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
} }
/// <summary> /// <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> /// </summary>
public int showDataDimension { get { return m_ShowDataDimension; } set { m_ShowDataDimension = value; } } public int showDataDimension { get { return m_ShowDataDimension; } set { m_ShowDataDimension = value; } }
@@ -813,7 +761,8 @@ namespace XCharts
if (PropertyUtil.SetStruct(ref m_Large, value)) if (PropertyUtil.SetStruct(ref m_Large, value))
{ {
SetAllDirty(); SetAllDirty();
label.SetComponentDirty(); if (label != null)
label.SetComponentDirty();
} }
} }
} }
@@ -828,7 +777,8 @@ namespace XCharts
if (PropertyUtil.SetStruct(ref m_LargeThreshold, value)) if (PropertyUtil.SetStruct(ref m_LargeThreshold, value))
{ {
SetAllDirty(); SetAllDirty();
label.SetComponentDirty(); if (label != null)
label.SetComponentDirty();
} }
} }
} }
@@ -922,11 +872,11 @@ namespace XCharts
return m_VertsDirty || return m_VertsDirty ||
symbol.vertsDirty || symbol.vertsDirty ||
lineStyle.vertsDirty || lineStyle.vertsDirty ||
lineArrow.vertsDirty || (lineArrow != null && lineArrow.vertsDirty) ||
itemStyle.vertsDirty || itemStyle.vertsDirty ||
areaStyle.vertsDirty || (areaStyle != null && areaStyle.vertsDirty) ||
label.vertsDirty || (label != null && label.vertsDirty) ||
emphasis.vertsDirty; (emphasis != null && emphasis.vertsDirty);
} }
} }
@@ -936,13 +886,18 @@ namespace XCharts
base.ClearVerticesDirty(); base.ClearVerticesDirty();
symbol.ClearVerticesDirty(); symbol.ClearVerticesDirty();
lineStyle.ClearVerticesDirty(); lineStyle.ClearVerticesDirty();
lineArrow.ClearVerticesDirty();
itemStyle.ClearVerticesDirty(); itemStyle.ClearVerticesDirty();
areaStyle.ClearVerticesDirty();
label.ClearVerticesDirty();
emphasis.ClearVerticesDirty();
titleStyle.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() public override void ClearComponentDirty()
@@ -950,13 +905,19 @@ namespace XCharts
base.ClearComponentDirty(); base.ClearComponentDirty();
symbol.ClearComponentDirty(); symbol.ClearComponentDirty();
lineStyle.ClearComponentDirty(); lineStyle.ClearComponentDirty();
lineArrow.ClearComponentDirty();
itemStyle.ClearComponentDirty(); itemStyle.ClearComponentDirty();
areaStyle.ClearComponentDirty();
label.ClearComponentDirty();
emphasis.ClearComponentDirty(); emphasis.ClearComponentDirty();
titleStyle.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> /// <summary>
/// Whether the serie is highlighted. /// Whether the serie is highlighted.

View File

@@ -63,7 +63,7 @@ namespace XCharts
if (m_InitedLabel) if (m_InitedLabel)
InternalRefreshLabel(); InternalRefreshLabel();
} }
if (serie.labelDirty || serie.label.componentDirty) if (serie.label != null && (serie.labelDirty || serie.label.componentDirty))
{ {
serie.labelDirty = false; serie.labelDirty = false;
serie.label.ClearComponentDirty(); serie.label.ClearComponentDirty();
@@ -172,13 +172,23 @@ namespace XCharts
protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count) protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
{ {
if (serieLabelRoot == null) return false; if (serieLabelRoot == null)
if (serie.IsPerformanceMode()) return false; return false;
if (serie.IsPerformanceMode())
return false;
if (count == -1) count = serie.dataCount; if (count == -1) count = serie.dataCount;
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
if (serieLabel == null)
return false;
var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData); var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
var iconStyle = SerieHelper.GetIconStyle(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 textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
var color = Color.grey; var color = Color.grey;
if (serie.useDataNameForColor) if (serie.useDataNameForColor)
@@ -191,14 +201,16 @@ namespace XCharts
color = !ChartHelper.IsClearColor(serieLabel.textStyle.color) ? serieLabel.textStyle.color : color = !ChartHelper.IsClearColor(serieLabel.textStyle.color) ? serieLabel.textStyle.color :
(Color)chart.theme.GetColor(serie.index); (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, 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 iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0; var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
var item = ChartHelper.GetOrAddComponent<ChartLabel>(labelObj); var item = ChartHelper.GetOrAddComponent<ChartLabel>(labelObj);
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom); item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
item.SetIcon(iconImage); item.SetIcon(iconImage);
item.SetIconActive(iconStyle.show); item.SetIconActive(iconStyle != null && iconStyle.show);
item.color = serieLabel.textStyle.backgroundColor; item.color = serieLabel.textStyle.backgroundColor;
serieData.labelObject = item; serieData.labelObject = item;
@@ -251,7 +263,7 @@ namespace XCharts
var isIgnore = serie.IsIgnoreIndex(serieData.index); var isIgnore = serie.IsIgnoreIndex(serieData.index);
serieData.labelObject.SetPosition(serieData.context.position); serieData.labelObject.SetPosition(serieData.context.position);
serieData.labelObject.UpdateIcon(iconStyle); 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 value = serieData.GetData(1);
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total, var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
@@ -259,7 +271,7 @@ namespace XCharts
var invert = serieLabel.autoOffset var invert = serieLabel.autoOffset
&& serie is Line && serie is Line
&& SerieHelper.IsDownPoint(serie, serieData.index) && SerieHelper.IsDownPoint(serie, serieData.index)
&& !serie.areaStyle.show; && (serie.areaStyle == null || !serie.areaStyle.show);
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme, colorIndex); SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme, colorIndex);
serieData.SetLabelActive(!isIgnore); serieData.SetLabelActive(!isIgnore);
serieData.labelObject.SetPosition(serieData.context.position + (invert ? -serieLabel.offset : serieLabel.offset)); serieData.labelObject.SetPosition(serieData.context.position + (invert ? -serieLabel.offset : serieLabel.offset));

View File

@@ -12,6 +12,11 @@ namespace XCharts
var method = list.GetType().GetMethod("Clear"); var method = list.GetType().GetMethod("Clear");
method.Invoke(list, new object[] { }); 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) public static void InvokeListAdd(object obj, FieldInfo field, object item)
{ {
@@ -20,6 +25,14 @@ namespace XCharts
method.Invoke(list, new object[] { item }); 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) public static void InvokeListAddTo<T>(object obj, FieldInfo field, Action<T> callback)
{ {
var list = field.GetValue(obj); var list = field.GetValue(obj);