优化代码,更好的支持自定义图表

This commit is contained in:
monitor1394
2021-04-28 06:56:28 +08:00
parent 59f1fda131
commit 6291fd27b0
5 changed files with 6 additions and 8 deletions

View File

@@ -209,14 +209,12 @@ namespace XCharts
if (m_Flodouts[prop.displayName]) if (m_Flodouts[prop.displayName])
{ {
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
//prop.arraySize = EditorGUILayout.IntField("Size", prop.arraySize);
var currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0)); var currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0));
currRect.y -= EditorGUIUtility.singleLineHeight; currRect.y -= EditorGUIUtility.singleLineHeight;
var rect1 = new Rect(currRect.width + k_IconXOffset, var rect1 = new Rect(currRect.width + k_IconXOffset,
currRect.y + k_IconYOffset, currRect.y + k_IconYOffset,
k_IconWidth, EditorGUIUtility.singleLineHeight); k_IconWidth, EditorGUIUtility.singleLineHeight);
EditorGUI.DrawRect(rect1, Color.blue); if (GUI.Button(rect1, ChartEditorHelper.Styles.iconAdd, ChartEditorHelper.Styles.invisibleButton))
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconAdd))// ChartEditorHelper.Styles.invisibleButton))
{ {
prop.InsertArrayElementAtIndex(prop.arraySize > 0 ? prop.arraySize - 1 : 0); prop.InsertArrayElementAtIndex(prop.arraySize > 0 ? prop.arraySize - 1 : 0);
var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart; var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart;

View File

@@ -471,6 +471,7 @@ namespace XCharts
/// <returns></returns> /// <returns></returns>
public bool IsDataIndexChanged() public bool IsDataIndexChanged()
{ {
if (runtimeDataIndex.Count < 2 || lastDataIndex.Count < 2) return false;
return runtimeDataIndex[0] != lastDataIndex[0] || return runtimeDataIndex[0] != lastDataIndex[0] ||
runtimeDataIndex[1] != lastDataIndex[1]; runtimeDataIndex[1] != lastDataIndex[1];
} }

View File

@@ -277,7 +277,7 @@ namespace XCharts
int count = 0; int count = 0;
foreach (var serie in series.list) foreach (var serie in series.list)
{ {
if (serie.show && serie.type == type) if (serie.show && (serie.type == type || serie.type == SerieType.Custom))
{ {
if (stackName.Equals(serie.stack)) count++; if (stackName.Equals(serie.stack)) count++;
if (count >= 2) return true; if (count >= 2) return true;

View File

@@ -583,7 +583,7 @@ namespace XCharts
public float Internal_GetBarGap() public float Internal_GetBarGap()
{ {
float gap = 0.3f; float gap = 0f;
for (int i = 0; i < m_Series.Count; i++) for (int i = 0; i < m_Series.Count; i++)
{ {
var serie = m_Series.list[i]; var serie = m_Series.list[i];
@@ -675,7 +675,7 @@ namespace XCharts
for (int i = 0; i < m_Series.Count; i++) for (int i = 0; i < m_Series.Count; i++)
{ {
var serie = m_Series.GetSerie(i); var serie = m_Series.GetSerie(i);
if (serie.type != SerieType.Bar || serie.type == SerieType.Custom) continue; if (serie.type != SerieType.Bar && serie.type != SerieType.Custom) continue;
if (string.IsNullOrEmpty(serie.stack)) if (string.IsNullOrEmpty(serie.stack))
{ {
if (serie.index == currSerie.index) return index; if (serie.index == currSerie.index) return index;

View File

@@ -1005,10 +1005,9 @@ namespace XCharts
} }
} }
public static Color32 GetHighlightColor(Color32 color) public static Color32 GetHighlightColor(Color32 color, float rate = 0.8f)
{ {
var newColor = color; var newColor = color;
var rate = 0.8f;
newColor.r = (byte)(color.r * rate); newColor.r = (byte)(color.r * rate);
newColor.g = (byte)(color.g * rate); newColor.g = (byte)(color.g * rate);
newColor.b = (byte)(color.b * rate); newColor.b = (byte)(color.b * rate);