mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 18:30:14 +00:00
增加Symbol配置Serie标志图形的显示
This commit is contained in:
@@ -34,7 +34,6 @@ public class Demo11_AddSinCurve : MonoBehaviour
|
|||||||
chart.xAxises[0].boundaryGap = false;
|
chart.xAxises[0].boundaryGap = false;
|
||||||
chart.maxCacheDataNumber = 0;
|
chart.maxCacheDataNumber = 0;
|
||||||
|
|
||||||
chart.line.point = false;
|
|
||||||
chart.line.step = false;
|
chart.line.step = false;
|
||||||
chart.line.smooth = false;
|
chart.line.smooth = false;
|
||||||
chart.line.area = false;
|
chart.line.area = false;
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ public class Demo_Dynamic : MonoBehaviour
|
|||||||
{
|
{
|
||||||
chart = gameObject.GetComponentInChildren<CoordinateChart>();
|
chart = gameObject.GetComponentInChildren<CoordinateChart>();
|
||||||
chart.RemoveData();
|
chart.RemoveData();
|
||||||
chart.AddSerie("data", SerieType.Line);
|
var serie = chart.AddSerie("data", SerieType.Line);
|
||||||
|
serie.symbol = SerieSymbolType.None;
|
||||||
chart.maxCacheDataNumber = maxCacheDataNumber;
|
chart.maxCacheDataNumber = maxCacheDataNumber;
|
||||||
timeNow = DateTime.Now;
|
timeNow = DateTime.Now;
|
||||||
timeNow = timeNow.AddSeconds(-maxCacheDataNumber);
|
timeNow = timeNow.AddSeconds(-maxCacheDataNumber);
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ namespace XCharts
|
|||||||
public class LineDrawer : PropertyDrawer
|
public class LineDrawer : PropertyDrawer
|
||||||
{
|
{
|
||||||
SerializedProperty m_Tickness;
|
SerializedProperty m_Tickness;
|
||||||
SerializedProperty m_Point;
|
|
||||||
SerializedProperty m_PointWidth;
|
|
||||||
SerializedProperty m_PointSelectedWidth;
|
|
||||||
SerializedProperty m_Smooth;
|
SerializedProperty m_Smooth;
|
||||||
SerializedProperty m_SmoothStyle;
|
SerializedProperty m_SmoothStyle;
|
||||||
SerializedProperty m_Area;
|
SerializedProperty m_Area;
|
||||||
@@ -21,9 +18,6 @@ namespace XCharts
|
|||||||
private void InitProperty(SerializedProperty prop)
|
private void InitProperty(SerializedProperty prop)
|
||||||
{
|
{
|
||||||
m_Tickness = prop.FindPropertyRelative("m_Tickness");
|
m_Tickness = prop.FindPropertyRelative("m_Tickness");
|
||||||
m_Point = prop.FindPropertyRelative("m_Point");
|
|
||||||
m_PointWidth = prop.FindPropertyRelative("m_PointWidth");
|
|
||||||
m_PointSelectedWidth = prop.FindPropertyRelative("m_PointSelectedWidth");
|
|
||||||
m_Smooth = prop.FindPropertyRelative("m_Smooth");
|
m_Smooth = prop.FindPropertyRelative("m_Smooth");
|
||||||
m_SmoothStyle = prop.FindPropertyRelative("m_SmoothStyle");
|
m_SmoothStyle = prop.FindPropertyRelative("m_SmoothStyle");
|
||||||
m_Area = prop.FindPropertyRelative("m_Area");
|
m_Area = prop.FindPropertyRelative("m_Area");
|
||||||
@@ -45,18 +39,6 @@ namespace XCharts
|
|||||||
EditorGUI.PropertyField(drawRect, m_Tickness);
|
EditorGUI.PropertyField(drawRect, m_Tickness);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Point);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
if (m_Point.boolValue)
|
|
||||||
{
|
|
||||||
++EditorGUI.indentLevel;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_PointWidth);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
|
|
||||||
EditorGUI.PropertyField(drawRect, m_PointSelectedWidth);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
--EditorGUI.indentLevel;
|
|
||||||
}
|
|
||||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||||
EditorGUI.PropertyField(drawRect, m_Smooth);
|
EditorGUI.PropertyField(drawRect, m_Smooth);
|
||||||
if (m_Smooth.boolValue)
|
if (m_Smooth.boolValue)
|
||||||
@@ -101,10 +83,6 @@ namespace XCharts
|
|||||||
if (m_LineModuleToggle)
|
if (m_LineModuleToggle)
|
||||||
{
|
{
|
||||||
height = 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
height = 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
var m_Point = prop.FindPropertyRelative("m_Point");
|
|
||||||
if(m_Point.boolValue){
|
|
||||||
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ namespace XCharts
|
|||||||
SerializedProperty name = prop.FindPropertyRelative("m_Name");
|
SerializedProperty name = prop.FindPropertyRelative("m_Name");
|
||||||
SerializedProperty stack = prop.FindPropertyRelative("m_Stack");
|
SerializedProperty stack = prop.FindPropertyRelative("m_Stack");
|
||||||
SerializedProperty m_AxisIndex = prop.FindPropertyRelative("m_AxisIndex");
|
SerializedProperty m_AxisIndex = prop.FindPropertyRelative("m_AxisIndex");
|
||||||
|
SerializedProperty m_Symbol = prop.FindPropertyRelative("m_Symbol");
|
||||||
|
SerializedProperty m_SymbolSize = prop.FindPropertyRelative("m_SymbolSize");
|
||||||
|
SerializedProperty m_SymbolSelectedSize = prop.FindPropertyRelative("m_SymbolSelectedSize");
|
||||||
SerializedProperty m_TwoDimensionData = prop.FindPropertyRelative("m_TwoDimensionData");
|
SerializedProperty m_TwoDimensionData = prop.FindPropertyRelative("m_TwoDimensionData");
|
||||||
SerializedProperty m_XData = prop.FindPropertyRelative("m_XData");
|
SerializedProperty m_XData = prop.FindPropertyRelative("m_XData");
|
||||||
SerializedProperty m_YData = prop.FindPropertyRelative("m_YData");
|
SerializedProperty m_YData = prop.FindPropertyRelative("m_YData");
|
||||||
@@ -42,6 +45,15 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_AxisIndex);
|
EditorGUI.PropertyField(drawRect, m_AxisIndex);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (type.enumValueIndex == (int)SerieType.Line || type.enumValueIndex == (int)SerieType.Scatter)
|
||||||
|
{
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SymbolSize);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SymbolSelectedSize);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
EditorGUI.PropertyField(drawRect, m_TwoDimensionData);
|
EditorGUI.PropertyField(drawRect, m_TwoDimensionData);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||||
@@ -132,6 +144,11 @@ namespace XCharts
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
||||||
|
if (type.enumValueIndex == (int)SerieType.Line || type.enumValueIndex == (int)SerieType.Scatter)
|
||||||
|
{
|
||||||
|
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
if (m_DataFoldout[index])
|
if (m_DataFoldout[index])
|
||||||
{
|
{
|
||||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_YData");
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_YData");
|
||||||
@@ -150,7 +167,7 @@ namespace XCharts
|
|||||||
private int InitToggle(SerializedProperty prop)
|
private int InitToggle(SerializedProperty prop)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int.TryParse(prop.displayName.Split(' ')[1],out index);
|
int.TryParse(prop.displayName.Split(' ')[1], out index);
|
||||||
if (index >= m_DataFoldout.Count)
|
if (index >= m_DataFoldout.Count)
|
||||||
{
|
{
|
||||||
m_DataFoldout.Add(false);
|
m_DataFoldout.Add(false);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using UnityEngine;
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
@@ -147,52 +146,62 @@ namespace XCharts
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a data to serie.
|
/// Add a data to serie.
|
||||||
/// If serie doesn't exist,will be add to series.
|
/// When serie doesn't exist, the data is ignored.
|
||||||
/// If serieName doesn't exist in legend,will be add to legend.
|
/// If serieName doesn't exist in legend,will be add to legend.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serieName">the name of serie</param>
|
/// <param name="serieName">the name of serie</param>
|
||||||
/// <param name="value">the data to add</param>
|
/// <param name="value">the data to add</param>
|
||||||
public virtual void AddData(string serieName, float value)
|
/// <returns>Returns True on success</returns>
|
||||||
|
public virtual bool AddData(string serieName, float value)
|
||||||
{
|
{
|
||||||
m_Legend.AddData(serieName);
|
m_Legend.AddData(serieName);
|
||||||
m_Series.AddData(serieName, value, m_MaxCacheDataNumber);
|
var success = m_Series.AddData(serieName, value, m_MaxCacheDataNumber);
|
||||||
RefreshChart();
|
if (success) RefreshChart();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a data to serie.
|
/// Add a data to serie.
|
||||||
/// If serie doesn't exist, the data is ignored.
|
/// When serie doesn't exist, the data is ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serieIndex">the index of serie</param>
|
/// <param name="serieIndex">the index of serie</param>
|
||||||
/// <param name="value">the data to add</param>
|
/// <param name="value">the data to add</param>
|
||||||
public virtual void AddData(int serieIndex, float value)
|
/// <returns>Returns True on success</returns>
|
||||||
|
public virtual bool AddData(int serieIndex, float value)
|
||||||
{
|
{
|
||||||
m_Series.AddData(serieIndex, value, m_MaxCacheDataNumber);
|
var success = m_Series.AddData(serieIndex, value, m_MaxCacheDataNumber);
|
||||||
RefreshChart();
|
if (success) RefreshChart();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a (x,y) data to serie
|
/// Add a (x,y) data to serie.
|
||||||
|
/// When serie doesn't exist, the data is ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serieName">the name of serie</param>
|
/// <param name="serieName">the name of serie</param>
|
||||||
/// <param name="xValue">x data</param>
|
/// <param name="xValue">x data</param>
|
||||||
/// <param name="yValue">y data</param>
|
/// <param name="yValue">y data</param>
|
||||||
public virtual void AddXYData(string serieName, float xValue, float yValue)
|
/// <returns>Returns True on success</returns>
|
||||||
|
public virtual bool AddXYData(string serieName, float xValue, float yValue)
|
||||||
{
|
{
|
||||||
m_Series.AddXYData(serieName, xValue, yValue, m_MaxCacheDataNumber);
|
var success = m_Series.AddXYData(serieName, xValue, yValue, m_MaxCacheDataNumber);
|
||||||
RefreshChart();
|
if (success) RefreshChart();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a (x,y) data to serie
|
/// Add a (x,y) data to serie.
|
||||||
|
/// When serie doesn't exist, the data is ignored.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serieIndex">the index of serie</param>
|
/// <param name="serieIndex">the index of serie</param>
|
||||||
/// <param name="xValue">x data</param>
|
/// <param name="xValue">x data</param>
|
||||||
/// <param name="yValue">y data</param>
|
/// <param name="yValue">y data</param>
|
||||||
public virtual void AddXYData(int serieIndex, float xValue, float yValue)
|
/// <returns>Returns True on success</returns>
|
||||||
|
public virtual bool AddXYData(int serieIndex, float xValue, float yValue)
|
||||||
{
|
{
|
||||||
m_Series.AddXYData(serieIndex, xValue, yValue, m_MaxCacheDataNumber);
|
var success = m_Series.AddXYData(serieIndex, xValue, yValue, m_MaxCacheDataNumber);
|
||||||
RefreshChart();
|
if (success) RefreshChart();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update serie data by serie name.
|
/// Update serie data by serie name.
|
||||||
@@ -652,6 +661,40 @@ namespace XCharts
|
|||||||
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.backgroundColor);
|
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize, float tickness, Vector3 pos, Color color)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case SerieSymbolType.None:
|
||||||
|
break;
|
||||||
|
case SerieSymbolType.Circle:
|
||||||
|
ChartHelper.DrawCricle(vh, pos, symbolSize, color);
|
||||||
|
break;
|
||||||
|
case SerieSymbolType.EmptyCircle:
|
||||||
|
ChartHelper.DrawCricle(vh, pos, symbolSize, m_ThemeInfo.backgroundColor);
|
||||||
|
ChartHelper.DrawDoughnut(vh, pos, symbolSize - tickness, symbolSize, 0, 360, color);
|
||||||
|
break;
|
||||||
|
case SerieSymbolType.Rect:
|
||||||
|
ChartHelper.DrawPolygon(vh, pos, symbolSize, color);
|
||||||
|
break;
|
||||||
|
case SerieSymbolType.Triangle:
|
||||||
|
var x = symbolSize * Mathf.Cos(30 * Mathf.PI / 180);
|
||||||
|
var y = symbolSize * Mathf.Sin(30 * Mathf.PI / 180);
|
||||||
|
var p1 = new Vector2(pos.x - x, pos.y - y);
|
||||||
|
var p2 = new Vector2(pos.x, pos.y + symbolSize);
|
||||||
|
var p3 = new Vector2(pos.x + x, pos.y - y);
|
||||||
|
ChartHelper.DrawTriangle(vh, p1, p2, p3, color);
|
||||||
|
break;
|
||||||
|
case SerieSymbolType.Diamond:
|
||||||
|
p1 = new Vector2(pos.x - symbolSize, pos.y);
|
||||||
|
p2 = new Vector2(pos.x, pos.y + symbolSize);
|
||||||
|
p3 = new Vector2(pos.x + symbolSize, pos.y);
|
||||||
|
var p4 = new Vector2(pos.x, pos.y - symbolSize);
|
||||||
|
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void OnPointerDown(PointerEventData eventData)
|
public virtual void OnPointerDown(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ namespace XCharts
|
|||||||
End
|
End
|
||||||
}
|
}
|
||||||
[SerializeField] private float m_Tickness;
|
[SerializeField] private float m_Tickness;
|
||||||
[SerializeField] private bool m_Point;
|
|
||||||
[SerializeField] private float m_PointWidth;
|
|
||||||
[SerializeField] private float m_PointSelectedWidth;
|
|
||||||
[SerializeField] private bool m_Smooth;
|
[SerializeField] private bool m_Smooth;
|
||||||
[SerializeField] [Range(1f, 10f)] private float m_SmoothStyle;
|
[SerializeField] [Range(1f, 10f)] private float m_SmoothStyle;
|
||||||
[SerializeField] private bool m_Area;
|
[SerializeField] private bool m_Area;
|
||||||
@@ -22,9 +19,6 @@ namespace XCharts
|
|||||||
[SerializeField] private StepType m_StepType;
|
[SerializeField] private StepType m_StepType;
|
||||||
|
|
||||||
public float tickness { get { return m_Tickness; } set { m_Tickness = value; } }
|
public float tickness { get { return m_Tickness; } set { m_Tickness = value; } }
|
||||||
public bool point { get { return m_Point; } set { m_Point = value; } }
|
|
||||||
public float pointWidth { get { return m_PointWidth; } set { m_PointWidth = value; } }
|
|
||||||
public float pointSelectedWidth { get { return m_PointSelectedWidth; } set { m_PointSelectedWidth = value; } }
|
|
||||||
public float smoothStyle { get { return m_SmoothStyle; } set { m_SmoothStyle = value; } }
|
public float smoothStyle { get { return m_SmoothStyle; } set { m_SmoothStyle = value; } }
|
||||||
public bool smooth { get { return m_Smooth; } set { m_Smooth = value; } }
|
public bool smooth { get { return m_Smooth; } set { m_Smooth = value; } }
|
||||||
public bool area { get { return m_Area; } set { m_Area = value; } }
|
public bool area { get { return m_Area; } set { m_Area = value; } }
|
||||||
@@ -38,9 +32,6 @@ namespace XCharts
|
|||||||
var line = new Line
|
var line = new Line
|
||||||
{
|
{
|
||||||
m_Tickness = 0.8f,
|
m_Tickness = 0.8f,
|
||||||
m_Point = true,
|
|
||||||
m_PointWidth = 2.5f,
|
|
||||||
m_PointSelectedWidth = 5.5f,
|
|
||||||
m_Smooth = false,
|
m_Smooth = false,
|
||||||
m_SmoothStyle = 2f,
|
m_SmoothStyle = 2f,
|
||||||
m_Area = false,
|
m_Area = false,
|
||||||
|
|||||||
@@ -7,34 +7,52 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
public enum SerieType
|
public enum SerieType
|
||||||
{
|
{
|
||||||
None,
|
|
||||||
Line,
|
Line,
|
||||||
Bar,
|
Bar,
|
||||||
Pie,
|
Pie,
|
||||||
Radar
|
Radar,
|
||||||
|
Scatter,
|
||||||
|
EffectScatter
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SerieSymbolType
|
||||||
|
{
|
||||||
|
EmptyCircle,
|
||||||
|
Circle,
|
||||||
|
Rect,
|
||||||
|
Triangle,
|
||||||
|
Diamond,
|
||||||
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class Serie : JsonDataSupport
|
public class Serie : JsonDataSupport
|
||||||
{
|
{
|
||||||
[SerializeField] [DefaultValue("true")] private bool m_Show;
|
[SerializeField] [DefaultValue("true")] private bool m_Show = true;
|
||||||
[SerializeField] private SerieType m_Type;
|
[SerializeField] private SerieType m_Type;
|
||||||
[SerializeField] private bool m_Selected;
|
[SerializeField] private bool m_Selected;
|
||||||
[SerializeField] private string m_Name;
|
[SerializeField] private string m_Name;
|
||||||
[SerializeField] private string m_Stack;
|
[SerializeField] private string m_Stack;
|
||||||
[SerializeField] private int m_AxisIndex;
|
[SerializeField] private int m_AxisIndex;
|
||||||
|
[SerializeField] private SerieSymbolType m_Symbol = SerieSymbolType.Circle;
|
||||||
|
[SerializeField] private float m_SymbolSize = 2.5f;
|
||||||
|
[SerializeField] private float m_SymbolSelectedSize = 5f;
|
||||||
[SerializeField] private bool m_TwoDimensionData;
|
[SerializeField] private bool m_TwoDimensionData;
|
||||||
[FormerlySerializedAs("m_Data")]
|
[FormerlySerializedAs("m_Data")]
|
||||||
[SerializeField] private List<float> m_YData = new List<float>();
|
[SerializeField] private List<float> m_YData = new List<float>();
|
||||||
[SerializeField] private List<float> m_XData = new List<float>();
|
[SerializeField] private List<float> m_XData = new List<float>();
|
||||||
|
|
||||||
public int index { get; set; }
|
public int index { get; set; }
|
||||||
|
public int dataCount { get { return m_YData.Count; } }
|
||||||
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
|
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||||
public SerieType type { get { return m_Type; } set { m_Type = value; } }
|
public SerieType type { get { return m_Type; } set { m_Type = value; } }
|
||||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||||
public string stack { get { return m_Stack; } set { m_Stack = value; } }
|
public string stack { get { return m_Stack; } set { m_Stack = value; } }
|
||||||
public int axisIndex { get { return m_AxisIndex; } set { m_AxisIndex = value; } }
|
public int axisIndex { get { return m_AxisIndex; } set { m_AxisIndex = value; } }
|
||||||
|
public SerieSymbolType symbol { get { return m_Symbol; } set { m_Symbol = value; } }
|
||||||
|
public float symbolSize { get { return m_SymbolSize; } set { m_SymbolSize = value; } }
|
||||||
|
public float symbolSelectedSize { get { return m_SymbolSelectedSize; } set { m_SymbolSelectedSize = value; } }
|
||||||
public List<float> yData { get { return m_YData; } set { m_YData = value; } }
|
public List<float> yData { get { return m_YData; } set { m_YData = value; } }
|
||||||
public List<float> xData { get { return m_XData; } set { m_XData = value; } }
|
public List<float> xData { get { return m_XData; } set { m_XData = value; } }
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,23 @@ namespace XCharts
|
|||||||
serie.name = serieName;
|
serie.name = serieName;
|
||||||
serie.index = m_Series.Count;
|
serie.index = m_Series.Count;
|
||||||
serie.yData = new List<float>();
|
serie.yData = new List<float>();
|
||||||
|
|
||||||
|
if (type == SerieType.Scatter)
|
||||||
|
{
|
||||||
|
serie.symbol = SerieSymbolType.Circle;
|
||||||
|
serie.symbolSize = 20f;
|
||||||
|
serie.symbolSelectedSize = 30f;
|
||||||
|
}
|
||||||
|
else if (type == SerieType.Line)
|
||||||
|
{
|
||||||
|
serie.symbol = SerieSymbolType.EmptyCircle;
|
||||||
|
serie.symbolSize = 2.5f;
|
||||||
|
serie.symbolSelectedSize = 5f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serie.symbol = SerieSymbolType.None;
|
||||||
|
}
|
||||||
m_Series.Add(serie);
|
m_Series.Add(serie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -134,41 +151,48 @@ namespace XCharts
|
|||||||
return serie;
|
return serie;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serie AddData(string name, float value, int maxDataNumber = 0)
|
public bool AddData(string serieName, float value, int maxDataNumber = 0)
|
||||||
{
|
{
|
||||||
var serie = AddSerie(name, SerieType.None);
|
var serie = GetSerie(serieName);
|
||||||
serie.AddYData(value, maxDataNumber);
|
if (serie != null)
|
||||||
return serie;
|
{
|
||||||
|
serie.AddYData(value, maxDataNumber);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serie AddData(int index, float value, int maxDataNumber = 0)
|
public bool AddData(int index, float value, int maxDataNumber = 0)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(index);
|
var serie = GetSerie(index);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.AddYData(value, maxDataNumber);
|
serie.AddYData(value, maxDataNumber);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return serie;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serie AddXYData(string serieName, float xValue, float yValue, int maxDataNumber = 0)
|
public bool AddXYData(string serieName, float xValue, float yValue, int maxDataNumber = 0)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.AddXYData(xValue, yValue, maxDataNumber);
|
serie.AddXYData(xValue, yValue, maxDataNumber);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return serie;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Serie AddXYData(int index, float xValue, float yValue, int maxDataNumber = 0)
|
public bool AddXYData(int index, float xValue, float yValue, int maxDataNumber = 0)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(index);
|
var serie = GetSerie(index);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.AddXYData(xValue, yValue, maxDataNumber);
|
serie.AddXYData(xValue, yValue, maxDataNumber);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return serie;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateData(string name, float value, int dataIndex = 0)
|
public void UpdateData(string name, float value, int dataIndex = 0)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace XCharts
|
|||||||
|
|
||||||
int serieCount = 0;
|
int serieCount = 0;
|
||||||
List<Vector3> points = new List<Vector3>();
|
List<Vector3> points = new List<Vector3>();
|
||||||
List<Color> colors = new List<Color>();
|
List<int> pointSerieIndex = new List<int>();
|
||||||
int dataCount = 0;
|
int dataCount = 0;
|
||||||
HashSet<string> serieNameSet = new HashSet<string>();
|
HashSet<string> serieNameSet = new HashSet<string>();
|
||||||
int serieNameCount = -1;
|
int serieNameCount = -1;
|
||||||
@@ -70,13 +70,13 @@ namespace XCharts
|
|||||||
serieNameCount++;
|
serieNameCount++;
|
||||||
}
|
}
|
||||||
Color color = m_ThemeInfo.GetColor(serieNameCount);
|
Color color = m_ThemeInfo.GetColor(serieNameCount);
|
||||||
DrawXLineSerie(vh, serieCount, color, serie, ref dataCount, ref points, ref colors, ref seriesCurrHig);
|
DrawXLineSerie(vh, serieCount, color, serie, ref dataCount, ref points, ref pointSerieIndex, ref seriesCurrHig);
|
||||||
if (serie.show)
|
if (serie.show)
|
||||||
{
|
{
|
||||||
serieCount++;
|
serieCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawLinePoint(vh, dataCount, points, colors);
|
DrawLinePoint(vh, dataCount, points, pointSerieIndex);
|
||||||
}
|
}
|
||||||
DrawXTooltipIndicator(vh);
|
DrawXTooltipIndicator(vh);
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ namespace XCharts
|
|||||||
int seriesCount = stackSeries.Count;
|
int seriesCount = stackSeries.Count;
|
||||||
int serieCount = 0;
|
int serieCount = 0;
|
||||||
List<Vector3> points = new List<Vector3>();
|
List<Vector3> points = new List<Vector3>();
|
||||||
List<Color> colors = new List<Color>();
|
List<int> pointSerieIndex = new List<int>();
|
||||||
int dataCount = 0;
|
int dataCount = 0;
|
||||||
HashSet<string> serieNameSet = new HashSet<string>();
|
HashSet<string> serieNameSet = new HashSet<string>();
|
||||||
int serieNameCount = -1;
|
int serieNameCount = -1;
|
||||||
@@ -105,54 +105,45 @@ namespace XCharts
|
|||||||
serieNameCount++;
|
serieNameCount++;
|
||||||
}
|
}
|
||||||
Color color = m_ThemeInfo.GetColor(serieNameCount);
|
Color color = m_ThemeInfo.GetColor(serieNameCount);
|
||||||
DrawYLineSerie(vh, serieCount, color, serie, ref dataCount, ref points, ref colors, ref seriesHig);
|
DrawYLineSerie(vh, serieCount, color, serie, ref dataCount, ref points, ref pointSerieIndex, ref seriesHig);
|
||||||
if (serie.show)
|
if (serie.show)
|
||||||
{
|
{
|
||||||
serieCount++;
|
serieCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawLinePoint(vh, dataCount, points, colors);
|
DrawLinePoint(vh, dataCount, points, pointSerieIndex);
|
||||||
}
|
}
|
||||||
DrawYTooltipIndicator(vh);
|
DrawYTooltipIndicator(vh);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawLinePoint(VertexHelper vh, int dataCount, List<Vector3> points, List<Color> colors)
|
private void DrawLinePoint(VertexHelper vh, int dataCount, List<Vector3> points, List<int> pointSerieIndex)
|
||||||
{
|
{
|
||||||
if (m_Line.point)
|
for (int i = 0; i < points.Count; i++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < points.Count; i++)
|
Vector3 p = points[i];
|
||||||
|
var serie = m_Series.GetSerie(pointSerieIndex[i]);
|
||||||
|
float symbolSize = serie.symbolSize;
|
||||||
|
if (m_Tooltip.show && m_Tooltip.IsSelectedDataIndex(i % dataCount))
|
||||||
{
|
{
|
||||||
Vector3 p = points[i];
|
if (IsCartesian())
|
||||||
float pointWid = m_Line.pointWidth;
|
|
||||||
if (m_Tooltip.show && m_Tooltip.IsSelectedDataIndex(i % dataCount))
|
|
||||||
{
|
{
|
||||||
if (IsCartesian())
|
if (m_Series.IsTooltipSelected(i / dataCount))
|
||||||
{
|
{
|
||||||
if (m_Series.IsTooltipSelected(i / dataCount))
|
symbolSize = serie.symbolSelectedSize;
|
||||||
{
|
|
||||||
pointWid = m_Line.pointSelectedWidth;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
pointWid = m_Line.pointSelectedWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_Theme == Theme.Dark)
|
|
||||||
{
|
|
||||||
ChartHelper.DrawCricle(vh, p, pointWid, colors[i], (int)m_Line.pointWidth * 5);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChartHelper.DrawCricle(vh, p, pointWid, Color.white);
|
symbolSize = serie.symbolSelectedSize;
|
||||||
ChartHelper.DrawDoughnut(vh, p, pointWid - m_Line.tickness, pointWid, 0, 360, colors[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var color = m_ThemeInfo.GetColor(serie.index);
|
||||||
|
DrawSymbol(vh, serie.symbol, symbolSize, m_Line.tickness, p, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawXLineSerie(VertexHelper vh, int serieIndex, Color color, Serie serie, ref int dataCount,
|
private void DrawXLineSerie(VertexHelper vh, int serieIndex, Color color, Serie serie, ref int dataCount,
|
||||||
ref List<Vector3> points, ref List<Color> colors, ref Dictionary<int, float> seriesHig)
|
ref List<Vector3> points, ref List<int> pointSerieIndexs, ref Dictionary<int, float> seriesHig)
|
||||||
{
|
{
|
||||||
if (!IsActive(serie.index)) return;
|
if (!IsActive(serie.index)) return;
|
||||||
List<Vector3> lastPoints = new List<Vector3>();
|
List<Vector3> lastPoints = new List<Vector3>();
|
||||||
@@ -337,10 +328,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_Line.point)
|
if (serie.symbol != SerieSymbolType.None || m_Line.area)
|
||||||
{
|
{
|
||||||
points.Add(np);
|
points.Add(np);
|
||||||
colors.Add(color);
|
pointSerieIndexs.Add(serie.index);
|
||||||
}
|
}
|
||||||
seriesHig[i] += yDataHig;
|
seriesHig[i] += yDataHig;
|
||||||
lp = np;
|
lp = np;
|
||||||
@@ -348,7 +339,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawYLineSerie(VertexHelper vh, int serieIndex, Color color, Serie serie, ref int dataCount,
|
private void DrawYLineSerie(VertexHelper vh, int serieIndex, Color color, Serie serie, ref int dataCount,
|
||||||
ref List<Vector3> points, ref List<Color> colors, ref Dictionary<int, float> seriesHig)
|
ref List<Vector3> points, ref List<int> pointSerieIndexs, ref Dictionary<int, float> seriesHig)
|
||||||
{
|
{
|
||||||
if (!IsActive(serie.index)) return;
|
if (!IsActive(serie.index)) return;
|
||||||
List<Vector3> lastPoints = new List<Vector3>();
|
List<Vector3> lastPoints = new List<Vector3>();
|
||||||
@@ -515,10 +506,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_Line.point)
|
if (serie.symbol != SerieSymbolType.None || m_Line.area)
|
||||||
{
|
{
|
||||||
points.Add(np);
|
points.Add(np);
|
||||||
colors.Add(color);
|
pointSerieIndexs.Add(serie.index);
|
||||||
}
|
}
|
||||||
seriesHig[i] += dataHig;
|
seriesHig[i] += dataHig;
|
||||||
lp = np;
|
lp = np;
|
||||||
|
|||||||
@@ -26,13 +26,15 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serieName">the name of data</param>
|
/// <param name="serieName">the name of data</param>
|
||||||
/// <param name="value">the data</param>
|
/// <param name="value">the data</param>
|
||||||
public override void AddData(string serieName, float value)
|
/// <returns>Return true forever</returns>
|
||||||
|
public override bool AddData(string serieName, float value)
|
||||||
{
|
{
|
||||||
m_Legend.AddData(serieName);
|
m_Legend.AddData(serieName);
|
||||||
var serie = m_Series.AddSerie(serieName, SerieType.Pie);
|
var serie = m_Series.AddSerie(serieName, SerieType.Pie);
|
||||||
serie.ClearData();
|
serie.ClearData();
|
||||||
serie.AddYData(value);
|
serie.AddYData(value);
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ QQ交流群:XCharts交流群(202030963)
|
|||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
|
* (2019.07.20)增加`Symbol`配置`Serie`标志图形的显示,支持`EmptyCircle`,`Cricle`,`Rect`,`Triangle`,`Diamond`,`None`等图形形状
|
||||||
* (2019.07.19)增加用代码添加动态正弦曲线的示例`Demo11_AddSinCurve`
|
* (2019.07.19)增加用代码添加动态正弦曲线的示例`Demo11_AddSinCurve`
|
||||||
* (2019.07.19)优化`Legend`的显示和控制
|
* (2019.07.19)优化`Legend`的显示和控制
|
||||||
* (2019.07.18)优化抗锯齿,曲线更平滑
|
* (2019.07.18)优化抗锯齿,曲线更平滑
|
||||||
|
|||||||
Reference in New Issue
Block a user