mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 06:50:18 +00:00
3.0
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
@@ -83,10 +82,10 @@ namespace XCharts.Runtime
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_ComponentDirty
|
||||
|| location.componentDirty
|
||||
|| m_LabelStyle.componentDirty
|
||||
|| m_SubLabelStyle.componentDirty;
|
||||
return m_ComponentDirty ||
|
||||
location.componentDirty ||
|
||||
m_LabelStyle.componentDirty ||
|
||||
m_SubLabelStyle.componentDirty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -8,12 +7,14 @@ namespace XCharts.Runtime
|
||||
{
|
||||
private static readonly string s_TitleObjectName = "title";
|
||||
private static readonly string s_SubTitleObjectName = "title_sub";
|
||||
private ChartLabel m_LabelObject;
|
||||
private ChartLabel m_SubLabelObject;
|
||||
|
||||
public override void InitComponent()
|
||||
{
|
||||
var title = component;
|
||||
title.painter = null;
|
||||
title.refreshComponent = delegate ()
|
||||
title.refreshComponent = delegate()
|
||||
{
|
||||
title.OnChanged();
|
||||
var anchorMin = title.location.runtimeAnchorMin;
|
||||
@@ -36,16 +37,52 @@ namespace XCharts.Runtime
|
||||
titleObject.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(titleObject);
|
||||
|
||||
var label = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
|
||||
title.text, Color.clear, title.location.runtimeTextAlignment);
|
||||
label.SetActive(title.show && title.labelStyle.show);
|
||||
m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
|
||||
GetTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_LabelObject.SetActive(title.show && title.labelStyle.show);
|
||||
|
||||
var subLabel = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
|
||||
title.subText, Color.clear, title.location.runtimeTextAlignment);
|
||||
subLabel.SetActive(title.show && title.subLabelStyle.show);
|
||||
subLabel.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
|
||||
m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
|
||||
GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show);
|
||||
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
|
||||
};
|
||||
title.refreshComponent();
|
||||
}
|
||||
|
||||
public override void OnSerieDataUpdate(int serieIndex)
|
||||
{
|
||||
if (m_LabelObject != null && FormatterHelper.NeedFormat(component.text))
|
||||
m_LabelObject.SetText(GetTitleText(component));
|
||||
if (m_SubLabelObject != null && FormatterHelper.NeedFormat(component.subText))
|
||||
m_SubLabelObject.SetText(GetSubTitleText(component));
|
||||
}
|
||||
|
||||
private string GetTitleText(Title title)
|
||||
{
|
||||
if (FormatterHelper.NeedFormat(title.text))
|
||||
{
|
||||
var content = title.text;
|
||||
FormatterHelper.ReplaceContent(ref content, 0, title.labelStyle.numericFormatter, null, chart);
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
return title.text;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSubTitleText(Title title)
|
||||
{
|
||||
if (FormatterHelper.NeedFormat(title.subText))
|
||||
{
|
||||
var content = title.subText;
|
||||
FormatterHelper.ReplaceContent(ref content, 0, title.subLabelStyle.numericFormatter, null, chart);
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
return title.subText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,6 +10,6 @@ namespace XCharts.Runtime
|
||||
[Serializable]
|
||||
public class TitleStyle : LabelStyle, ISerieDataComponent, ISerieExtraComponent
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user