This commit is contained in:
monitor1394
2022-03-29 22:06:10 +08:00
parent b784900fda
commit 1ad87920d0
17 changed files with 130 additions and 117 deletions

View File

@@ -1,6 +1,4 @@

using System;
using UnityEngine;
using UnityEngine;
namespace XCharts.Runtime
{
@@ -69,7 +67,6 @@ namespace XCharts.Runtime
End
}
[SerializeField] private bool m_Show = true;
[SerializeField] Position m_Position = Position.Outside;
[SerializeField] private Vector3 m_Offset;
@@ -81,7 +78,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_BackgroundHeight = 0;
[SerializeField] private string m_NumericFormatter = "";
[SerializeField] private bool m_AutoOffset = false;
[SerializeField] private bool m_AutoColor = false;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
private SerieLabelFormatterFunction m_FormatterFunction;
@@ -97,7 +94,6 @@ namespace XCharts.Runtime
m_BackgroundHeight = 0;
m_NumericFormatter = "";
m_AutoOffset = false;
m_AutoColor = false;
}
/// <summary>
@@ -211,14 +207,7 @@ namespace XCharts.Runtime
get { return m_AutoOffset; }
set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
}
/// <summary>
/// 是否开启自动颜色。当开启时会根据已支持的serie自动设置颜色。
/// </summary>
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); }
}
/// <summary>
/// the sytle of text.

View File

@@ -20,6 +20,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_Rotate = 0;
[SerializeField] private float m_ExtraWidth = 0;
[SerializeField] private Vector2 m_Offset = Vector2.zero;
[SerializeField] private bool m_AutoColor = false;
[SerializeField] private Color m_Color = Color.clear;
[SerializeField] private bool m_AutoBackgroundColor = false;
[SerializeField] private Color m_BackgroundColor = Color.clear;
@@ -61,9 +62,15 @@ namespace XCharts.Runtime
get { return m_Offset; }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
}
public Vector3 offsetv3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
/// <summary>
/// 是否开启自动颜色。当开启时,会自动设置颜色。
/// </summary>
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); }
}
/// <summary>
/// the color of text.
/// |文本的颜色。
@@ -207,7 +214,9 @@ namespace XCharts.Runtime
font = textStyle.font;
rotate = textStyle.rotate;
offset = textStyle.offset;
autoColor = textStyle.autoColor;
color = textStyle.color;
autoBackgroundColor = textStyle.autoBackgroundColor;
backgroundColor = textStyle.backgroundColor;
fontSize = textStyle.fontSize;
fontStyle = textStyle.fontStyle;
@@ -251,5 +260,13 @@ namespace XCharts.Runtime
{
return m_AutoAlign ? systemAlignment : alignment;
}
public Color32 GetBackgroundColor(Color32 chartBackgroundColor)
{
if (m_AutoColor || ChartHelper.IsClearColor(m_BackgroundColor))
return chartBackgroundColor;
else
return m_BackgroundColor;
}
}
}