diff --git a/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs index fb1a3790..aebf1a3a 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/SerieDrawer.cs @@ -182,6 +182,18 @@ namespace XCharts PropertyField(prop, filed); } } + var customs = chart.GetCustomSerieInspectorCustomFileds(); + if (customs != null && customs.Length > 0) + { + foreach (var custom in customs) + { + var customProp = prop.FindPropertyRelative(custom[0]); + var anatherName = custom[1] + " (" + customProp.displayName + ")"; + EditorGUI.PropertyField(m_DrawRect, customProp, new GUIContent(anatherName)); + m_DrawRect.y += EditorGUI.GetPropertyHeight(prop); + m_Heights[m_KeyName] += hig; + } + } break; } PropertyField(prop, "m_ItemStyle"); diff --git a/Assets/XCharts/Runtime/API/BaseChart_API.cs b/Assets/XCharts/Runtime/API/BaseChart_API.cs index 9d7c67ff..d8ee434d 100644 --- a/Assets/XCharts/Runtime/API/BaseChart_API.cs +++ b/Assets/XCharts/Runtime/API/BaseChart_API.cs @@ -196,9 +196,9 @@ namespace XCharts /// the type of serie /// whether to show this serie /// the added serie - public virtual Serie AddSerie(SerieType type, string serieName = null, bool show = true) + public virtual Serie AddSerie(SerieType type, string serieName = null, bool show = true, bool addToHead = false) { - return m_Series.AddSerie(type, serieName); + return m_Series.AddSerie(type, serieName, addToHead); } /// @@ -209,7 +209,7 @@ namespace XCharts /// /// /// - public virtual Serie AddSerie(string serieType, string serieName = null, bool show = true) + public virtual Serie AddSerie(string serieType, string serieName = null, bool show = true, bool addToHead = false) { var type = SerieType.Custom; var list = Enum.GetNames(typeof(SerieType)); @@ -217,7 +217,7 @@ namespace XCharts { if (t.Equals(serieType)) type = (SerieType)Enum.Parse(typeof(SerieType), t); } - return AddSerie(type, serieName, show); + return AddSerie(type, serieName, show, addToHead); } /// @@ -761,6 +761,10 @@ namespace XCharts { return null; } + public virtual string[][] GetCustomSerieInspectorCustomFileds() + { + return null; + } public virtual string[] GetCustomChartInspectorShowFileds() { return null; diff --git a/Assets/XCharts/Runtime/Component/Main/Serie.cs b/Assets/XCharts/Runtime/Component/Main/Serie.cs index 79b2f053..af2bfd43 100644 --- a/Assets/XCharts/Runtime/Component/Main/Serie.cs +++ b/Assets/XCharts/Runtime/Component/Main/Serie.cs @@ -307,6 +307,12 @@ namespace XCharts [SerializeField] private float m_Right; [SerializeField] private float m_Top; [SerializeField] private float m_Bottom; + [SerializeField] private bool m_CustomBool1; + [SerializeField] private bool m_CustomBool2; + [SerializeField] private int m_CustomInt1; + [SerializeField] private int m_CustomInt2; + [SerializeField] private float m_CustomFloat1; + [SerializeField] private float m_CustomFloat2; [SerializeField] private List m_Data = new List(); @@ -928,6 +934,36 @@ namespace XCharts get { return m_Bottom; } set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); } } + public bool customBool1 + { + get { return m_CustomBool1; } + set { if (PropertyUtil.SetStruct(ref m_CustomBool1, value)) SetAllDirty(); } + } + public bool customBool2 + { + get { return m_CustomBool2; } + set { if (PropertyUtil.SetStruct(ref m_CustomBool2, value)) SetAllDirty(); } + } + public int customInt1 + { + get { return m_CustomInt1; } + set { if (PropertyUtil.SetStruct(ref m_CustomInt1, value)) SetAllDirty(); } + } + public int customInt2 + { + get { return m_CustomInt2; } + set { if (PropertyUtil.SetStruct(ref m_CustomInt2, value)) SetAllDirty(); } + } + public float customFloat1 + { + get { return m_CustomFloat1; } + set { if (PropertyUtil.SetStruct(ref m_CustomFloat1, value)) SetAllDirty(); } + } + public float customFloat2 + { + get { return m_CustomFloat2; } + set { if (PropertyUtil.SetStruct(ref m_CustomFloat2, value)) SetAllDirty(); } + } /// /// 系列中的数据内容数组。SerieData可以设置1到n维数据。 /// diff --git a/Assets/XCharts/Runtime/Component/Main/Series.cs b/Assets/XCharts/Runtime/Component/Main/Series.cs index ca1eb5c8..70248679 100644 --- a/Assets/XCharts/Runtime/Component/Main/Series.cs +++ b/Assets/XCharts/Runtime/Component/Main/Series.cs @@ -254,7 +254,7 @@ namespace XCharts /// /// /// - public Serie AddSerie(SerieType type, string serieName, bool show = true) + public Serie AddSerie(SerieType type, string serieName, bool show = true, bool addToHead = false) { var serie = new Serie(); serie.type = type; @@ -277,7 +277,8 @@ namespace XCharts serie.symbol.show = false; } serie.animation.Restart(); - m_Series.Add(serie); + if (addToHead) m_Series.Insert(0, serie); + else m_Series.Add(serie); SetVerticesDirty(); return serie; }