mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 18:00:26 +00:00
v3.0.0-preivew8
This commit is contained in:
@@ -75,7 +75,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private bool m_ItemAutoColor = true;
|
||||
[SerializeField] private bool m_TextAutoColor = false;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle() { offset = new Vector2(2f, 0), fontSize = 0 };
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
[SerializeField] private List<string> m_Data = new List<string>();
|
||||
[SerializeField] private List<Sprite> m_Icons = new List<Sprite>();
|
||||
|
||||
@@ -195,10 +195,10 @@ namespace XCharts.Runtime
|
||||
/// the style of text.
|
||||
/// |文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle
|
||||
public LabelStyle labelStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
get { return m_LabelStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,
|
||||
@@ -229,14 +229,14 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public override bool componentDirty
|
||||
{
|
||||
get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty; }
|
||||
get { return m_ComponentDirty || location.componentDirty || labelStyle.componentDirty; }
|
||||
}
|
||||
|
||||
public override void ClearComponentDirty()
|
||||
{
|
||||
base.ClearComponentDirty();
|
||||
location.ClearComponentDirty();
|
||||
textStyle.ClearComponentDirty();
|
||||
labelStyle.ClearComponentDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace XCharts.Runtime
|
||||
public override void CheckComponent(System.Text.StringBuilder sb)
|
||||
{
|
||||
var legend = component;
|
||||
if (ChartHelper.IsColorAlphaZero(legend.textStyle.color))
|
||||
if (ChartHelper.IsColorAlphaZero(legend.labelStyle.textStyle.color))
|
||||
sb.AppendFormat("warning:legend{0}->textStyle->color alpha is 0\n", legend.index);
|
||||
var serieNameList = SeriesHelper.GetLegalSerieNameList(chart.series);
|
||||
if (serieNameList.Count == 0)
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
public static Color GetContentColor(int legendIndex, Legend legend, ThemeStyle theme, bool active)
|
||||
{
|
||||
var textStyle = legend.textStyle;
|
||||
var textStyle = legend.labelStyle.textStyle;
|
||||
if (active)
|
||||
{
|
||||
if (legend.textAutoColor) return theme.GetColor(legendIndex);
|
||||
@@ -40,7 +40,7 @@ namespace XCharts.Runtime
|
||||
var pivot = new Vector2(0, 0.5f);
|
||||
var sizeDelta = new Vector2(100, 30);
|
||||
var iconSizeDelta = new Vector2(legend.itemWidth, legend.itemHeight);
|
||||
var textStyle = legend.textStyle;
|
||||
var textStyle = legend.labelStyle.textStyle;
|
||||
var contentColor = GetContentColor(legendIndex, legend, theme, active);
|
||||
|
||||
var objAnchorMin = new Vector2(0, 1);
|
||||
@@ -48,16 +48,15 @@ namespace XCharts.Runtime
|
||||
var objPivot = new Vector2(0, 1);
|
||||
var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta, i);
|
||||
var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta);
|
||||
var contentObj = ChartHelper.AddObject("content", btnObj.transform, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
var img = ChartHelper.GetOrAddComponent<Image>(btnObj);
|
||||
img.color = Color.clear;
|
||||
ChartHelper.GetOrAddComponent<Button>(btnObj);
|
||||
ChartHelper.GetOrAddComponent<Image>(iconObj);
|
||||
ChartHelper.GetOrAddComponent<Image>(contentObj);
|
||||
var txt = ChartHelper.AddTextObject("Text", contentObj.transform, anchorMin, anchorMax, pivot, sizeDelta,
|
||||
textStyle, theme.legend);
|
||||
txt.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleLeft));
|
||||
txt.SetColor(contentColor);
|
||||
|
||||
var label = ChartHelper.AddChartLabel("content", btnObj.transform, legend.labelStyle, theme.legend,
|
||||
content, contentColor, TextAnchor.MiddleLeft);
|
||||
label.SetActive(true);
|
||||
|
||||
var item = new LegendItem();
|
||||
item.index = i;
|
||||
item.name = objName;
|
||||
@@ -66,9 +65,8 @@ namespace XCharts.Runtime
|
||||
item.SetIconSize(legend.itemWidth, legend.itemHeight);
|
||||
item.SetIconColor(itemColor);
|
||||
item.SetIconImage(legend.GetIcon(i));
|
||||
item.SetContentPosition(textStyle.offsetv3);
|
||||
item.SetContentPosition(legend.labelStyle.offset);
|
||||
item.SetContent(content);
|
||||
item.SetContentBackgroundColor(textStyle.backgroundColor);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user