增加chartName检测

This commit is contained in:
monitor1394
2020-05-19 07:08:57 +08:00
parent 008e2210d4
commit 5d41ede8eb
4 changed files with 37 additions and 32 deletions

View File

@@ -1,7 +1,7 @@
# 更新日志
* (2020.05.18) 增加`chartName`属性,可通过`XChartMgr.Instance.GetChart(chartName)`获取图表
* (2020.05.18) 增加`chartName`属性可指定图表的别称,可通过`XChartMgr.Instance.GetChart(chartName)`获取图表
* (2020.05.16) 增加部分鼠标事件回调
* (2020.05.15) 优化自带例子,`Demo`改名为`Example`
* (2020.05.13) 增加`Serie``large``largeThreshold`参数配置折线图和柱状图的性能模式

View File

@@ -16,12 +16,6 @@ namespace XCharts
public class BarChart : CoordinateChart
{
protected override void Awake()
{
base.Awake();
XChartsMgr.Instance.AddChart(this);
}
#if UNITY_EDITOR
protected override void Reset()
{

View File

@@ -19,6 +19,7 @@ namespace XCharts
{
var sb = ChartHelper.sb;
sb.Length = 0;
CheckName(chart, sb);
CheckSize(chart, sb);
CheckTheme(chart, sb);
CheckTitle(chart, sb);
@@ -28,6 +29,16 @@ namespace XCharts
return sb.ToString();
}
private static void CheckName(BaseChart chart, StringBuilder sb)
{
if (string.IsNullOrEmpty(chart.chartName)) return;
var list = XChartsMgr.Instance.GetCharts(chart.chartName);
if (list.Count > 1)
{
sb.AppendFormat("warning:chart name is repeated: {0}\n", chart.chartName);
}
}
private static void CheckSize(BaseChart chart, StringBuilder sb)
{
if (chart.chartWidth == 0 || chart.chartHeight == 0)

View File

@@ -52,33 +52,33 @@ namespace XCharts
[SerializeField] protected Series m_Series = Series.defaultSeries;
[SerializeField] protected Settings m_Settings = new Settings();
[NonSerialized] protected Action<VertexHelper> m_OnCustomDrawCallback;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerClick;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerDown;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerUp;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerEnter;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerExit;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnBeginDrag;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnDrag;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnEndDrag;
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnScroll;
protected Action<VertexHelper> m_OnCustomDrawCallback;
protected Action<BaseChart, PointerEventData> m_OnPointerClick;
protected Action<BaseChart, PointerEventData> m_OnPointerDown;
protected Action<BaseChart, PointerEventData> m_OnPointerUp;
protected Action<BaseChart, PointerEventData> m_OnPointerEnter;
protected Action<BaseChart, PointerEventData> m_OnPointerExit;
protected Action<BaseChart, PointerEventData> m_OnBeginDrag;
protected Action<BaseChart, PointerEventData> m_OnDrag;
protected Action<BaseChart, PointerEventData> m_OnEndDrag;
protected Action<BaseChart, PointerEventData> m_OnScroll;
[NonSerialized] protected Vector3 m_ChartPosition = Vector3.zero;
[NonSerialized] protected Vector2 m_ChartMinAnchor;
[NonSerialized] protected Vector2 m_ChartMaxAnchor;
[NonSerialized] protected Vector2 m_ChartPivot;
[NonSerialized] protected Vector2 m_ChartSizeDelta;
[NonSerialized] protected Rect m_ChartRect = new Rect(0, 0, 0, 0);
protected Vector3 m_ChartPosition = Vector3.zero;
protected Vector2 m_ChartMinAnchor;
protected Vector2 m_ChartMaxAnchor;
protected Vector2 m_ChartPivot;
protected Vector2 m_ChartSizeDelta;
protected Rect m_ChartRect = new Rect(0, 0, 0, 0);
[NonSerialized] protected bool m_RefreshChart = false;
[NonSerialized] protected bool m_RefreshLabel = false;
[NonSerialized] protected bool m_ReinitLabel = false;
[NonSerialized] protected bool m_ReinitTitle = false;
[NonSerialized] protected bool m_CheckAnimation = false;
[NonSerialized] protected bool m_IsPlayingAnimation = false;
[NonSerialized] protected List<string> m_LegendRealShowName = new List<string>();
[NonSerialized] protected GameObject m_SerieLabelRoot;
[NonSerialized] protected bool m_ForceOpenRaycastTarget;
protected bool m_RefreshChart = false;
protected bool m_RefreshLabel = false;
protected bool m_ReinitLabel = false;
protected bool m_ReinitTitle = false;
protected bool m_CheckAnimation = false;
protected bool m_IsPlayingAnimation = false;
protected List<string> m_LegendRealShowName = new List<string>();
protected GameObject m_SerieLabelRoot;
protected bool m_ForceOpenRaycastTarget;
protected Vector2 chartAnchorMax { get { return m_ChartMinAnchor; } }
protected Vector2 chartAnchorMin { get { return m_ChartMaxAnchor; } }