serie增加自定义参数

This commit is contained in:
monitor1394
2021-05-20 21:51:52 +08:00
parent 0c549bf23b
commit d9f99e0d27
4 changed files with 59 additions and 6 deletions

View File

@@ -182,6 +182,18 @@ namespace XCharts
PropertyField(prop, filed); 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; break;
} }
PropertyField(prop, "m_ItemStyle"); PropertyField(prop, "m_ItemStyle");

View File

@@ -196,9 +196,9 @@ namespace XCharts
/// <param name="type">the type of serie</param> /// <param name="type">the type of serie</param>
/// <param name="show">whether to show this serie</param> /// <param name="show">whether to show this serie</param>
/// <returns>the added serie</returns> /// <returns>the added serie</returns>
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);
} }
/// <summary> /// <summary>
@@ -209,7 +209,7 @@ namespace XCharts
/// <param name="serieName"></param> /// <param name="serieName"></param>
/// <param name="show"></param> /// <param name="show"></param>
/// <returns></returns> /// <returns></returns>
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 type = SerieType.Custom;
var list = Enum.GetNames(typeof(SerieType)); var list = Enum.GetNames(typeof(SerieType));
@@ -217,7 +217,7 @@ namespace XCharts
{ {
if (t.Equals(serieType)) type = (SerieType)Enum.Parse(typeof(SerieType), t); if (t.Equals(serieType)) type = (SerieType)Enum.Parse(typeof(SerieType), t);
} }
return AddSerie(type, serieName, show); return AddSerie(type, serieName, show, addToHead);
} }
/// <summary> /// <summary>
@@ -761,6 +761,10 @@ namespace XCharts
{ {
return null; return null;
} }
public virtual string[][] GetCustomSerieInspectorCustomFileds()
{
return null;
}
public virtual string[] GetCustomChartInspectorShowFileds() public virtual string[] GetCustomChartInspectorShowFileds()
{ {
return null; return null;

View File

@@ -307,6 +307,12 @@ namespace XCharts
[SerializeField] private float m_Right; [SerializeField] private float m_Right;
[SerializeField] private float m_Top; [SerializeField] private float m_Top;
[SerializeField] private float m_Bottom; [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<SerieData> m_Data = new List<SerieData>(); [SerializeField] private List<SerieData> m_Data = new List<SerieData>();
@@ -928,6 +934,36 @@ namespace XCharts
get { return m_Bottom; } get { return m_Bottom; }
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); } 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(); }
}
/// <summary> /// <summary>
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。 /// 系列中的数据内容数组。SerieData可以设置1到n维数据。
/// </summary> /// </summary>

View File

@@ -254,7 +254,7 @@ namespace XCharts
/// <param name="type"></param> /// <param name="type"></param>
/// <param name="show"></param> /// <param name="show"></param>
/// <returns></returns> /// <returns></returns>
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(); var serie = new Serie();
serie.type = type; serie.type = type;
@@ -277,7 +277,8 @@ namespace XCharts
serie.symbol.show = false; serie.symbol.show = false;
} }
serie.animation.Restart(); serie.animation.Restart();
m_Series.Add(serie); if (addToHead) m_Series.Insert(0, serie);
else m_Series.Add(serie);
SetVerticesDirty(); SetVerticesDirty();
return serie; return serie;
} }