mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 18:30:14 +00:00
增加chartName属性可指定图表的别称
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.05.18) 增加`chartName`属性,可通过`XChartMgr.Instance.GetChart(chartName)`获取图表
|
||||||
* (2020.05.16) 增加部分鼠标事件回调
|
* (2020.05.16) 增加部分鼠标事件回调
|
||||||
* (2020.05.15) 优化自带例子,`Demo`改名为`Example`
|
* (2020.05.15) 优化自带例子,`Demo`改名为`Example`
|
||||||
* (2020.05.13) 增加`Serie`的`large`和`largeThreshold`参数配置折线图和柱状图的性能模式
|
* (2020.05.13) 增加`Serie`的`large`和`largeThreshold`参数配置折线图和柱状图的性能模式
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
* `BaseChart.legend`:图例组件`Legend`。
|
* `BaseChart.legend`:图例组件`Legend`。
|
||||||
* `BaseChart.tooltip`:提示框组件`Tooltip`。
|
* `BaseChart.tooltip`:提示框组件`Tooltip`。
|
||||||
* `BaseChart.series`:系列列表`Series`。
|
* `BaseChart.series`:系列列表`Series`。
|
||||||
|
* `BaseChart.chartName`:图表的别称。
|
||||||
* `BaseChart.chartWidth`:图表的宽。
|
* `BaseChart.chartWidth`:图表的宽。
|
||||||
* `BaseChart.chartHeight`:图表的高。
|
* `BaseChart.chartHeight`:图表的高。
|
||||||
* `BaseChart.forceOpenRaycastTarget`:强制开启鼠标事件检测。一般不用手动设置,内部会自动判断是否需要检测。
|
* `BaseChart.forceOpenRaycastTarget`:强制开启鼠标事件检测。一般不用手动设置,内部会自动判断是否需要检测。
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ namespace XCharts
|
|||||||
protected SerializedProperty m_Settings;
|
protected SerializedProperty m_Settings;
|
||||||
protected SerializedProperty m_Large;
|
protected SerializedProperty m_Large;
|
||||||
protected SerializedProperty m_ChartName;
|
protected SerializedProperty m_ChartName;
|
||||||
protected SerializedProperty m_ChartUUID;
|
|
||||||
|
|
||||||
protected float m_DefaultLabelWidth;
|
protected float m_DefaultLabelWidth;
|
||||||
protected float m_DefaultFieldWidth;
|
protected float m_DefaultFieldWidth;
|
||||||
@@ -43,7 +42,6 @@ namespace XCharts
|
|||||||
m_Target = (BaseChart)target;
|
m_Target = (BaseChart)target;
|
||||||
m_Script = serializedObject.FindProperty("m_Script");
|
m_Script = serializedObject.FindProperty("m_Script");
|
||||||
m_ChartName = serializedObject.FindProperty("m_ChartName");
|
m_ChartName = serializedObject.FindProperty("m_ChartName");
|
||||||
m_ChartUUID = serializedObject.FindProperty("m_ChartUUID");
|
|
||||||
m_ChartWidth = serializedObject.FindProperty("m_ChartWidth");
|
m_ChartWidth = serializedObject.FindProperty("m_ChartWidth");
|
||||||
m_ChartHeight = serializedObject.FindProperty("m_ChartHeight");
|
m_ChartHeight = serializedObject.FindProperty("m_ChartHeight");
|
||||||
m_Theme = serializedObject.FindProperty("m_Theme");
|
m_Theme = serializedObject.FindProperty("m_Theme");
|
||||||
@@ -79,21 +77,8 @@ namespace XCharts
|
|||||||
protected virtual void OnStartInspectorGUI()
|
protected virtual void OnStartInspectorGUI()
|
||||||
{
|
{
|
||||||
EditorGUILayout.PropertyField(m_Script);
|
EditorGUILayout.PropertyField(m_Script);
|
||||||
// EditorGUI.BeginChangeCheck();
|
EditorGUI.BeginChangeCheck();
|
||||||
// EditorGUILayout.PropertyField(m_ChartName);
|
EditorGUILayout.PropertyField(m_ChartName);
|
||||||
// if (EditorGUI.EndChangeCheck())
|
|
||||||
// {
|
|
||||||
// if (XChartsMgr.Instance.ContainsChart(m_ChartName.stringValue))
|
|
||||||
// {
|
|
||||||
// m_ChartName.stringValue = "";
|
|
||||||
// serializedObject.ApplyModifiedProperties();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// m_ChartUUID.stringValue = m_ChartName.stringValue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// EditorGUILayout.PropertyField(m_ChartUUID);
|
|
||||||
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
||||||
EditorGUILayout.PropertyField(m_Title, true);
|
EditorGUILayout.PropertyField(m_Title, true);
|
||||||
EditorGUILayout.PropertyField(m_Legend, true);
|
EditorGUILayout.PropertyField(m_Legend, true);
|
||||||
|
|||||||
@@ -27,15 +27,16 @@ namespace XCharts
|
|||||||
get { return m_ChartName; }
|
get { return m_ChartName; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (XChartsMgr.Instance.ContainsChart(value)) Debug.LogError("chartName repeated:" + value);
|
if (!string.IsNullOrEmpty(value) && XChartsMgr.Instance.ContainsChart(value))
|
||||||
|
{
|
||||||
|
Debug.LogError("chartName repeated:" + value);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ChartName = value;
|
m_ChartName = value;
|
||||||
m_ChartUUID = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string chartUUID { get { return m_ChartUUID; } }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The theme info.
|
/// The theme info.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ namespace XCharts
|
|||||||
public class BarChart : CoordinateChart
|
public class BarChart : CoordinateChart
|
||||||
{
|
{
|
||||||
|
|
||||||
|
protected override void Awake()
|
||||||
|
{
|
||||||
|
base.Awake();
|
||||||
|
XChartsMgr.Instance.AddChart(this);
|
||||||
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
protected override void Reset()
|
protected override void Reset()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ namespace XCharts
|
|||||||
protected static readonly string s_SerieTitleObjectName = "serie";
|
protected static readonly string s_SerieTitleObjectName = "serie";
|
||||||
|
|
||||||
[SerializeField] protected string m_ChartName;
|
[SerializeField] protected string m_ChartName;
|
||||||
[SerializeField] protected string m_ChartUUID;
|
|
||||||
[SerializeField] protected float m_ChartWidth;
|
[SerializeField] protected float m_ChartWidth;
|
||||||
[SerializeField] protected float m_ChartHeight;
|
[SerializeField] protected float m_ChartHeight;
|
||||||
[SerializeField] protected float m_ChartX;
|
[SerializeField] protected float m_ChartX;
|
||||||
@@ -52,22 +51,18 @@ namespace XCharts
|
|||||||
[SerializeField] protected Tooltip m_Tooltip = Tooltip.defaultTooltip;
|
[SerializeField] protected Tooltip m_Tooltip = Tooltip.defaultTooltip;
|
||||||
[SerializeField] protected Series m_Series = Series.defaultSeries;
|
[SerializeField] protected Series m_Series = Series.defaultSeries;
|
||||||
[SerializeField] protected Settings m_Settings = new Settings();
|
[SerializeField] protected Settings m_Settings = new Settings();
|
||||||
[SerializeField] protected float m_Large = 1;
|
|
||||||
[SerializeField] protected string m_DebugInfo = "";
|
|
||||||
|
|
||||||
[SerializeField] protected Action<VertexHelper> m_OnCustomDrawCallback;
|
[NonSerialized] protected Action<VertexHelper> m_OnCustomDrawCallback;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnPointerClick;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerClick;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnPointerDown;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerDown;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnPointerUp;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerUp;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnPointerEnter;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerEnter;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnPointerExit;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnPointerExit;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnBeginDrag;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnBeginDrag;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnDrag;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnDrag;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnEndDrag;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnEndDrag;
|
||||||
[SerializeField] protected Action<BaseChart, PointerEventData> m_OnScroll;
|
[NonSerialized] protected Action<BaseChart, PointerEventData> m_OnScroll;
|
||||||
|
|
||||||
|
|
||||||
[NonSerialized] private Theme m_CheckTheme = 0;
|
|
||||||
[NonSerialized] protected Vector3 m_ChartPosition = Vector3.zero;
|
[NonSerialized] protected Vector3 m_ChartPosition = Vector3.zero;
|
||||||
[NonSerialized] protected Vector2 m_ChartMinAnchor;
|
[NonSerialized] protected Vector2 m_ChartMinAnchor;
|
||||||
[NonSerialized] protected Vector2 m_ChartMaxAnchor;
|
[NonSerialized] protected Vector2 m_ChartMaxAnchor;
|
||||||
@@ -89,6 +84,8 @@ namespace XCharts
|
|||||||
protected Vector2 chartAnchorMin { get { return m_ChartMaxAnchor; } }
|
protected Vector2 chartAnchorMin { get { return m_ChartMaxAnchor; } }
|
||||||
protected Vector2 chartPivot { get { return m_ChartPivot; } }
|
protected Vector2 chartPivot { get { return m_ChartPivot; } }
|
||||||
|
|
||||||
|
private Theme m_CheckTheme = 0;
|
||||||
|
|
||||||
protected virtual void InitComponent()
|
protected virtual void InitComponent()
|
||||||
{
|
{
|
||||||
InitTitle();
|
InitTitle();
|
||||||
|
|||||||
@@ -225,12 +225,6 @@ namespace XCharts
|
|||||||
case SerieType.Scatter:
|
case SerieType.Scatter:
|
||||||
case SerieType.EffectScatter:
|
case SerieType.EffectScatter:
|
||||||
DrawScatterSerie(vh, colorIndex, serie);
|
DrawScatterSerie(vh, colorIndex, serie);
|
||||||
if (vh.currentVertCount > 60000)
|
|
||||||
{
|
|
||||||
m_Large++;
|
|
||||||
RefreshChart();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SerieType.Heatmap:
|
case SerieType.Heatmap:
|
||||||
DrawHeatmapSerie(vh, colorIndex, serie);
|
DrawHeatmapSerie(vh, colorIndex, serie);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ namespace XCharts
|
|||||||
Transform obj = transform;
|
Transform obj = transform;
|
||||||
while (obj.transform.parent)
|
while (obj.transform.parent)
|
||||||
{
|
{
|
||||||
name += "/" + obj.transform.parent.name;
|
name = obj.transform.parent.name + "/" + name;
|
||||||
obj = obj.transform.parent;
|
obj = obj.transform.parent;
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
/* */
|
/* */
|
||||||
/* Copyright (c) 2018 monitor1394 */
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
@@ -34,7 +35,7 @@ namespace XCharts
|
|||||||
|
|
||||||
[SerializeField] private string m_NowVersion;
|
[SerializeField] private string m_NowVersion;
|
||||||
[SerializeField] private string m_NewVersion;
|
[SerializeField] private string m_NewVersion;
|
||||||
private Dictionary<string, BaseChart> m_ChartDic = new Dictionary<string, BaseChart>();
|
[SerializeField] private List<BaseChart> m_ChartList = new List<BaseChart>();
|
||||||
private static XChartsMgr m_XCharts;
|
private static XChartsMgr m_XCharts;
|
||||||
|
|
||||||
public static XChartsMgr Instance
|
public static XChartsMgr Instance
|
||||||
@@ -73,6 +74,7 @@ namespace XCharts
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
SerieLabelPool.ClearAll();
|
SerieLabelPool.ClearAll();
|
||||||
|
m_ChartList.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string changeLog { get; private set; }
|
public string changeLog { get; private set; }
|
||||||
@@ -238,25 +240,45 @@ namespace XCharts
|
|||||||
|
|
||||||
public void AddChart(BaseChart chart)
|
public void AddChart(BaseChart chart)
|
||||||
{
|
{
|
||||||
//TODO:
|
var sameNameChart = GetChart(chart.chartName);
|
||||||
}
|
if (sameNameChart != null)
|
||||||
|
|
||||||
public BaseChart GetChart(string uuid)
|
|
||||||
{
|
|
||||||
return m_ChartDic[uuid];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveChart(string uuid)
|
|
||||||
{
|
|
||||||
if (m_ChartDic.ContainsKey(uuid))
|
|
||||||
{
|
{
|
||||||
m_ChartDic.Remove(uuid);
|
var path = ChartHelper.GetFullName(sameNameChart.transform);
|
||||||
|
Debug.LogError("A chart named `" + chart.chartName + "` already exists:" + path);
|
||||||
|
}
|
||||||
|
if (!ContainsChart(chart))
|
||||||
|
{
|
||||||
|
m_ChartList.Add(chart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsChart(string uuid)
|
public BaseChart GetChart(string chartName)
|
||||||
{
|
{
|
||||||
return m_ChartDic.ContainsKey(uuid);
|
if (string.IsNullOrEmpty(chartName)) return null;
|
||||||
|
return m_ChartList.Find(chart => chartName.Equals(chart.chartName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BaseChart> GetCharts(string chartName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(chartName)) return null;
|
||||||
|
return m_ChartList.FindAll(chart => chartName.Equals(chartName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveChart(string chartName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(chartName)) return;
|
||||||
|
m_ChartList.RemoveAll(chart => chartName.Equals(chart.chartName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsChart(string chartName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(chartName)) return false;
|
||||||
|
return GetCharts(chartName) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsChart(BaseChart chart)
|
||||||
|
{
|
||||||
|
return m_ChartList.Contains(chart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user