mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 06:50:18 +00:00
增加代码API注释文档,整理代码
This commit is contained in:
@@ -10,31 +10,6 @@ namespace XCharts
|
||||
[DisallowMultipleComponent]
|
||||
public class BarChart : CoordinateChart
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Bar
|
||||
{
|
||||
[SerializeField] private bool m_InSameBar;
|
||||
[SerializeField] private float m_BarWidth = 0.7f;
|
||||
[SerializeField] private float m_Space;
|
||||
|
||||
public bool inSameBar { get { return m_InSameBar; } set { m_InSameBar = value; } }
|
||||
public float barWidth { get { return m_BarWidth; } set { m_BarWidth = value; } }
|
||||
public float space { get { return m_Space; } set { m_Space = value; } }
|
||||
|
||||
public static Bar defaultBar
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Bar()
|
||||
{
|
||||
m_InSameBar = false,
|
||||
m_BarWidth = 0.6f,
|
||||
m_Space = 10
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private Bar m_Bar = Bar.defaultBar;
|
||||
|
||||
public Bar bar { get { return m_Bar; } }
|
||||
@@ -85,7 +60,7 @@ namespace XCharts
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
float value = serie.yData[i];
|
||||
float pX = seriesHig[i] + coordinateX + xAxis.zeroXOffset + m_Coordinate.tickness;
|
||||
float pX = seriesHig[i] + coordinateX + xAxis.zeroXOffset + yAxis.axisLine.width;
|
||||
float pY = coordinateY + +i * scaleWid;
|
||||
if (!yAxis.boundaryGap) pY -= scaleWid / 2;
|
||||
float barHig = (xAxis.minValue > 0 ? value - xAxis.minValue : value)
|
||||
@@ -97,7 +72,7 @@ namespace XCharts
|
||||
Vector3 p2 = new Vector3(pX + barHig, pY + space + barWid);
|
||||
Vector3 p3 = new Vector3(pX + barHig, pY + space);
|
||||
Vector3 p4 = new Vector3(pX, pY + space);
|
||||
if ((m_Tooltip.show && m_Tooltip.IsSelectedDataIndex(i))
|
||||
if ((m_Tooltip.show && m_Tooltip.IsSelected(i))
|
||||
|| serie.data[i].highlighted
|
||||
|| serie.highlighted)
|
||||
{
|
||||
@@ -143,7 +118,7 @@ namespace XCharts
|
||||
float pX = coordinateX + i * scaleWid;
|
||||
float zeroY = coordinateY + yAxis.zeroYOffset;
|
||||
if (!xAxis.boundaryGap) pX -= scaleWid / 2;
|
||||
float pY = seriesHig[i] + zeroY + m_Coordinate.tickness;
|
||||
float pY = seriesHig[i] + zeroY + xAxis.axisLine.width;
|
||||
float barHig = (yAxis.minValue > 0 ? value - yAxis.minValue : value)
|
||||
/ (yAxis.maxValue - yAxis.minValue) * coordinateHig;
|
||||
seriesHig[i] += barHig;
|
||||
@@ -153,7 +128,7 @@ namespace XCharts
|
||||
Vector3 p2 = new Vector3(pX + space, pY + barHig);
|
||||
Vector3 p3 = new Vector3(pX + space + barWid, pY + barHig);
|
||||
Vector3 p4 = new Vector3(pX + space + barWid, pY);
|
||||
if ((m_Tooltip.show && m_Tooltip.IsSelectedDataIndex(i))
|
||||
if ((m_Tooltip.show && m_Tooltip.IsSelected(i))
|
||||
|| serie.data[i].highlighted
|
||||
|| serie.highlighted)
|
||||
{
|
||||
|
||||
8
Scripts/UI/Component.meta
Normal file
8
Scripts/UI/Component.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3be5f1d3b129a47dd8e41cffe3b8e428
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,29 +6,75 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// The axis in rectangular coordinate.
|
||||
/// 直角坐标系的坐标轴组件。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Axis : JsonDataSupport, IEquatable<Axis>
|
||||
{
|
||||
/// <summary>
|
||||
/// the type of axis.
|
||||
/// 坐标轴类型。
|
||||
/// </summary>
|
||||
public enum AxisType
|
||||
{
|
||||
/// <summary>
|
||||
/// Numerical axis, suitable for continuous data.
|
||||
/// 数值轴,适用于连续数据。
|
||||
/// </summary>
|
||||
Value,
|
||||
Category,
|
||||
//Time,
|
||||
//Log
|
||||
/// <summary>
|
||||
/// Category axis, suitable for discrete category data. Data should only be set via data for this type.
|
||||
/// 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
|
||||
/// </summary>
|
||||
Category
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the type of axis min and max value.
|
||||
/// 坐标轴最大最小刻度显示类型。
|
||||
/// </summary>
|
||||
public enum AxisMinMaxType
|
||||
{
|
||||
/// <summary>
|
||||
/// 0 - maximum.
|
||||
/// 0-最大值。
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// minimum - maximum.
|
||||
/// 最小值-最大值。
|
||||
/// </summary>
|
||||
MinMax,
|
||||
/// <summary>
|
||||
/// Customize the minimum and maximum.
|
||||
/// 自定义最小值最大值。
|
||||
/// </summary>
|
||||
Custom
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the type of split line.
|
||||
/// 分割线类型
|
||||
/// </summary>
|
||||
public enum SplitLineType
|
||||
{
|
||||
/// <summary>
|
||||
/// 不显示分割线
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 实线
|
||||
/// </summary>
|
||||
Solid,
|
||||
/// <summary>
|
||||
/// 破折线
|
||||
/// </summary>
|
||||
Dashed,
|
||||
/// <summary>
|
||||
/// 虚线
|
||||
/// </summary>
|
||||
Dotted
|
||||
}
|
||||
|
||||
@@ -48,34 +94,111 @@ namespace XCharts
|
||||
[SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
|
||||
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis from showing.
|
||||
/// 是否显示坐标轴。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// the type of axis.
|
||||
/// 坐标轴类型。
|
||||
/// </summary>
|
||||
public AxisType type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// the type of axis minmax.
|
||||
/// 坐标轴刻度最大最小值显示类型。
|
||||
/// </summary>
|
||||
public AxisMinMaxType minMaxType { get { return m_MinMaxType; } set { m_MinMaxType = value; } }
|
||||
/// <summary>
|
||||
/// The minimun value of axis.
|
||||
/// 设定的坐标轴刻度最小值,当minMaxType为Custom时有效。
|
||||
/// </summary>
|
||||
public int min { get { return m_Min; } set { m_Min = value; } }
|
||||
/// <summary>
|
||||
/// The maximum value of axis.
|
||||
/// 设定的坐标轴刻度最大值,当minMaxType为Custom时有效。
|
||||
/// </summary>
|
||||
public int max { get { return m_Max; } set { m_Max = value; } }
|
||||
/// <summary>
|
||||
/// Number of segments that the axis is split into.
|
||||
/// 坐标轴的分割段数。
|
||||
/// </summary>
|
||||
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
||||
/// <summary>
|
||||
/// showSplitLineSet this to false to prevent the splitLine from showing. value type axes are shown by default, while category type axes are hidden.
|
||||
/// 是否显示分隔线。默认数值轴显示,类目轴不显示。
|
||||
/// </summary>
|
||||
public bool showSplitLine { get { return m_ShowSplitLine; } set { m_ShowSplitLine = value; } }
|
||||
/// <summary>
|
||||
/// the type of split line.
|
||||
/// 分割线类型。
|
||||
/// </summary>
|
||||
public SplitLineType splitLineType { get { return m_SplitLineType; } set { m_SplitLineType = value; } }
|
||||
/// <summary>
|
||||
/// The boundary gap on both sides of a coordinate axis.
|
||||
/// 坐标轴两边是否留白。
|
||||
/// </summary>
|
||||
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
|
||||
/// <summary>
|
||||
/// Category data, available in type: 'Category' axis.
|
||||
/// 类目数据,在类目轴(type: 'category')中有效。
|
||||
/// </summary>
|
||||
public List<string> data { get { return m_Data; } }
|
||||
|
||||
/// <summary>
|
||||
/// axis Line.
|
||||
/// 坐标轴轴线。
|
||||
/// </summary>
|
||||
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
|
||||
/// <summary>
|
||||
/// axis name.
|
||||
/// 坐标轴名称。
|
||||
/// </summary>
|
||||
public AxisName axisName { get { return m_AxisName; } set { m_AxisName = value; } }
|
||||
/// <summary>
|
||||
/// axis tick.
|
||||
/// 坐标轴刻度。
|
||||
/// </summary>
|
||||
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
||||
/// <summary>
|
||||
/// axis label.
|
||||
/// 坐标轴刻度标签。
|
||||
/// </summary>
|
||||
public AxisLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
|
||||
/// <summary>
|
||||
/// axis split area.
|
||||
/// 坐标轴分割区域。
|
||||
/// </summary>
|
||||
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
|
||||
|
||||
public int filterStart { get; set; }
|
||||
public int filterEnd { get; set; }
|
||||
public List<string> filterData { get; set; }
|
||||
|
||||
public float minValue { get; set; }
|
||||
public float maxValue { get; set; }
|
||||
public float zeroXOffset { get; set; }
|
||||
public float zeroYOffset { get; set; }
|
||||
private List<Text> m_AxisLabelTextList = new List<Text>();
|
||||
/// <summary>
|
||||
/// the axis label text list.
|
||||
/// 坐标轴刻度标签的Text列表。
|
||||
/// </summary>
|
||||
public List<Text> axisLabelTextList { get { return m_AxisLabelTextList; } set { m_AxisLabelTextList = value; } }
|
||||
/// <summary>
|
||||
/// the current minimun value.
|
||||
/// 当前最小值。
|
||||
/// </summary>
|
||||
public float minValue { get; set; }
|
||||
/// <summary>
|
||||
/// the current maximum value.
|
||||
/// 当前最大值。
|
||||
/// </summary>
|
||||
public float maxValue { get; set; }
|
||||
/// <summary>
|
||||
/// the x offset of zero position.
|
||||
/// 坐标轴原点在X轴的偏移。
|
||||
/// </summary>
|
||||
public float zeroXOffset { get; set; }
|
||||
/// <summary>
|
||||
/// the y offset of zero position.
|
||||
/// 坐标轴原点在Y轴的偏移。
|
||||
/// </summary>
|
||||
public float zeroYOffset { get; set; }
|
||||
|
||||
private int filterStart;
|
||||
private int filterEnd;
|
||||
private List<string> filterData;
|
||||
private List<Text> m_AxisLabelTextList = new List<Text>();
|
||||
private GameObject m_TooltipLabel;
|
||||
private Text m_TooltipLabelText;
|
||||
private RectTransform m_TooltipLabelRect;
|
||||
@@ -97,21 +220,37 @@ namespace XCharts
|
||||
foreach (var d in other.data) m_Data.Add(d);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空类目数据
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
m_Data.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前坐标轴是否时类目轴
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsCategory()
|
||||
{
|
||||
return type == AxisType.Category;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前坐标轴是否时数值轴
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsValue()
|
||||
{
|
||||
return type == AxisType.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个类目到类目数据列表
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddData(string category, int maxDataNumber)
|
||||
{
|
||||
if (maxDataNumber > 0)
|
||||
@@ -121,6 +260,12 @@ namespace XCharts
|
||||
m_Data.Add(category);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得在dataZoom范围内指定索引的类目数据
|
||||
/// </summary>
|
||||
/// <param name="index">类目数据索引</param>
|
||||
/// <param name="dataZoom">区域缩放</param>
|
||||
/// <returns></returns>
|
||||
public string GetData(int index, DataZoom dataZoom)
|
||||
{
|
||||
var showData = GetDataList(dataZoom);
|
||||
@@ -130,6 +275,11 @@ namespace XCharts
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定区域缩放的类目数据列表
|
||||
/// </summary>
|
||||
/// <param name="dataZoom">区域缩放</param>
|
||||
/// <returns></returns>
|
||||
public List<string> GetDataList(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.show)
|
||||
@@ -149,6 +299,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新dataZoom对应的类目数据列表
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
public void UpdateFilterData(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.show)
|
||||
@@ -176,6 +330,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割段数
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public int GetSplitNumber(DataZoom dataZoom)
|
||||
{
|
||||
if (type == AxisType.Value) return m_SplitNumber;
|
||||
@@ -186,16 +345,33 @@ namespace XCharts
|
||||
return dataCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割段的宽度
|
||||
/// </summary>
|
||||
/// <param name="coordinateWidth"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
|
||||
{
|
||||
return coordinateWidth / (m_BoundaryGap ? GetSplitNumber(dataZoom) : GetSplitNumber(dataZoom) - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得类目数据个数
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public int GetDataNumber(DataZoom dataZoom)
|
||||
{
|
||||
return GetDataList(dataZoom).Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得一个类目数据在坐标系中代表的宽度
|
||||
/// </summary>
|
||||
/// <param name="coordinateWidth"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public float GetDataWidth(float coordinateWidth, DataZoom dataZoom)
|
||||
{
|
||||
var dataCount = GetDataNumber(dataZoom);
|
||||
@@ -203,6 +379,14 @@ namespace XCharts
|
||||
}
|
||||
|
||||
private Dictionary<float, string> _cacheValue2str = new Dictionary<float, string>();
|
||||
/// <summary>
|
||||
/// 获得标签显示的名称
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public string GetLabelName(int index, float minValue, float maxValue, DataZoom dataZoom)
|
||||
{
|
||||
if (m_Type == AxisType.Value)
|
||||
@@ -237,6 +421,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割线条数
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public int GetScaleNumber(DataZoom dataZoom)
|
||||
{
|
||||
if (type == AxisType.Value)
|
||||
@@ -254,6 +443,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割段宽度
|
||||
/// </summary>
|
||||
/// <param name="coordinateWidth"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public float GetScaleWidth(float coordinateWidth, DataZoom dataZoom)
|
||||
{
|
||||
int num = GetScaleNumber(dataZoom) - 1;
|
||||
@@ -261,6 +456,10 @@ namespace XCharts
|
||||
return coordinateWidth / num;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新刻度标签文字
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
public void UpdateLabelText(DataZoom dataZoom)
|
||||
{
|
||||
for (int i = 0; i < axisLabelTextList.Count; i++)
|
||||
@@ -312,6 +511,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调整最大最小值
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public void AdjustMinMaxValue(ref int minValue, ref int maxValue)
|
||||
{
|
||||
if (minMaxType == Axis.AxisMinMaxType.Custom)
|
||||
@@ -416,10 +620,14 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The x axis in cartesian(rectangular) coordinate. a grid component can place at most 2 x axis,
|
||||
/// one on the bottom and another on the top.
|
||||
/// <para>直角坐标系 grid 中的 x 轴,单个 grid 组件最多只能放上下两个 x 轴。</para>
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class XAxis : Axis
|
||||
{
|
||||
|
||||
public XAxis Clone()
|
||||
{
|
||||
var axis = new XAxis();
|
||||
@@ -463,6 +671,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The x axis in cartesian(rectangular) coordinate. a grid component can place at most 2 x axis,
|
||||
/// one on the bottom and another on the top.
|
||||
/// <para>直角坐标系 grid 中的 y 轴,单个 grid 组件最多只能放左右两个 y 轴</para>
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class YAxis : Axis
|
||||
{
|
||||
@@ -496,7 +709,7 @@ namespace XCharts
|
||||
m_Min = 0,
|
||||
m_Max = 0,
|
||||
m_SplitNumber = 5,
|
||||
m_ShowSplitLine = false,
|
||||
m_ShowSplitLine = true,
|
||||
m_SplitLineType = SplitLineType.Dashed,
|
||||
m_BoundaryGap = false,
|
||||
m_Data = new List<string>(5),
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1dd59b655decf420ca27dfb742be4fdf
|
||||
guid: 42232255fb44747ba8d680aa7d76c2ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
45
Scripts/UI/Component/Bar.cs
Normal file
45
Scripts/UI/Component/Bar.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// bar component.global setting for bar chart.
|
||||
/// 柱状图的全局配置组件。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Bar
|
||||
{
|
||||
[SerializeField] private bool m_InSameBar = false;
|
||||
[SerializeField] private float m_BarWidth = 0.7f;
|
||||
[SerializeField] private float m_Space = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to draw all bar in the same bar,but not stacked.
|
||||
/// 非堆叠同柱。多序列绘制在同一bar上,但不堆叠,而是覆盖绘制。
|
||||
/// </summary>
|
||||
public bool inSameBar { get { return m_InSameBar; } set { m_InSameBar = value; } }
|
||||
/// <summary>
|
||||
/// the width of bar.
|
||||
/// 状态的宽度。
|
||||
/// </summary>
|
||||
public float barWidth { get { return m_BarWidth; } set { m_BarWidth = value; } }
|
||||
/// <summary>
|
||||
/// the space of bars.
|
||||
/// 多柱状间的间距。
|
||||
/// </summary>
|
||||
public float space { get { return m_Space; } set { m_Space = value; } }
|
||||
|
||||
public static Bar defaultBar
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Bar()
|
||||
{
|
||||
m_InSameBar = false,
|
||||
m_BarWidth = 0.6f,
|
||||
m_Space = 10
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84f640465300fb34facae554552063b9
|
||||
timeCreated: 1554422468
|
||||
licenseType: Free
|
||||
guid: 4f4f93f97ce4c4274a4153986a3e5752
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -7,6 +7,7 @@ namespace XCharts
|
||||
/// DataZoom component is used for zooming a specific area,
|
||||
/// which enables user to investigate data in detail,
|
||||
/// or get an overview of the data, or get rid of outlier points.
|
||||
/// <para>DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息,或者概览数据整体,或者去除离群点的影响。</para>
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class DataZoom
|
||||
@@ -16,11 +17,13 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// DataZoom functionalities is embeded inside coordinate systems, enable user to
|
||||
/// zoom or roam coordinate system by mouse dragging, mouse move or finger touch (in touch screen).
|
||||
/// 内置于坐标系中,使用户可以在坐标系上通过鼠标拖拽、鼠标滚轮、手指滑动(触屏上)来缩放或漫游坐标系。
|
||||
/// </summary>
|
||||
Inside,
|
||||
/// <summary>
|
||||
/// A special slider bar is provided, on which coordinate systems can be zoomed or
|
||||
/// roamed by mouse dragging or finger touch (in touch screen).
|
||||
/// 有单独的滑动条,用户在滑动条上进行缩放或漫游。
|
||||
/// </summary>
|
||||
Slider
|
||||
}
|
||||
@@ -28,34 +31,42 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// Generally dataZoom component zoom or roam coordinate system through data filtering
|
||||
/// and set the windows of axes internally.
|
||||
/// Its behaviours vary according to filtering mode settings
|
||||
/// Its behaviours vary according to filtering mode settings.
|
||||
/// dataZoom 的运行原理是通过 数据过滤 来达到 数据窗口缩放 的效果。数据过滤模式的设置不同,效果也不同。
|
||||
/// </summary>
|
||||
public enum FilterMode
|
||||
{
|
||||
/// <summary>
|
||||
/// data that outside the window will be filtered, which may lead to some changes of windows of other axes.
|
||||
/// For each data item, it will be filtered if one of the relevant dimensions is out of the window.
|
||||
/// 当前数据窗口外的数据,被 过滤掉。即 会 影响其他轴的数据范围。每个数据项,只要有一个维度在数据窗口外,整个数据项就会被过滤掉。
|
||||
/// </summary>
|
||||
Filter,
|
||||
/// <summary>
|
||||
/// data that outside the window will be filtered, which may lead to some changes of windows of other axes.
|
||||
/// For each data item, it will be filtered only if all of the relevant dimensions are out of the same side of the window.
|
||||
/// 当前数据窗口外的数据,被 过滤掉。即 会 影响其他轴的数据范围。每个数据项,只有当全部维度都在数据窗口同侧外部,整个数据项才会被过滤掉。
|
||||
/// </summary>
|
||||
WeakFilter,
|
||||
/// <summary>
|
||||
/// data that outside the window will be set to NaN, which will not lead to changes of windows of other axes
|
||||
/// data that outside the window will be set to NaN, which will not lead to changes of windows of other axes.
|
||||
/// 当前数据窗口外的数据,被 设置为空。即 不会 影响其他轴的数据范围。
|
||||
/// </summary>
|
||||
Empty,
|
||||
/// <summary>
|
||||
/// Do not filter data.
|
||||
/// 不过滤数据,只改变数轴范围。
|
||||
/// </summary>
|
||||
None
|
||||
}
|
||||
/// <summary>
|
||||
/// The value type of start and end.取值类型
|
||||
/// </summary>
|
||||
public enum RangeMode
|
||||
{
|
||||
//Value,
|
||||
/// <summary>
|
||||
/// percent value
|
||||
/// percent value. 百分比
|
||||
/// </summary>
|
||||
Percent
|
||||
}
|
||||
@@ -65,7 +76,6 @@ namespace XCharts
|
||||
[SerializeField] private Orient m_Orient;
|
||||
[SerializeField] private int m_XAxisIndex;
|
||||
[SerializeField] private int m_YAxisIndex;
|
||||
|
||||
[SerializeField] private bool m_ShowDataShadow;
|
||||
[SerializeField] private bool m_ShowDetail;
|
||||
[SerializeField] private bool m_ZoomLock;
|
||||
@@ -81,83 +91,118 @@ namespace XCharts
|
||||
[Range(1f, 20f)]
|
||||
[SerializeField] private float m_ScrollSensitivity;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show dataZoom.
|
||||
/// 是否显示缩放区域。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// The type of dataZoom.
|
||||
/// 缩放区域的类型。
|
||||
/// </summary>
|
||||
public DataZoomType type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// The mode of data filter.
|
||||
/// 数据过滤类型。
|
||||
/// </summary>
|
||||
public FilterMode filterMode { get { return m_FilterMode; } set { m_FilterMode = value; } }
|
||||
/// <summary>
|
||||
/// Specify whether the layout of dataZoom component is horizontal or vertical.
|
||||
/// 水平还是垂直显示。
|
||||
/// </summary>
|
||||
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
|
||||
/// <summary>
|
||||
/// Specify which xAxis is controlled by the dataZoom.
|
||||
/// 控制哪个一 x 轴。
|
||||
/// </summary>
|
||||
public int xAxisIndex { get { return m_XAxisIndex; } set { m_XAxisIndex = value; } }
|
||||
/// <summary>
|
||||
/// Specify which yAxis is controlled by the dataZoom.
|
||||
/// 控制哪一个 y 轴。
|
||||
/// </summary>
|
||||
public int yAxisIndex { get { return m_YAxisIndex; } set { m_YAxisIndex = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show data shadow, to indicate the data tendency in brief.
|
||||
/// default:true
|
||||
/// 是否显示数据阴影。数据阴影可以简单地反应数据走势。
|
||||
/// </summary>
|
||||
public bool showDataShadow { get { return m_ShowDataShadow; } set { m_ShowDataShadow = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show detail, that is, show the detailed data information when dragging.
|
||||
/// 是否显示detail,即拖拽时候显示详细数值信息。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public bool showDetail { get { return m_ShowDetail; } set { m_ShowDetail = value; } }
|
||||
/// <summary>
|
||||
/// Specify whether to lock the size of window (selected area).
|
||||
/// default:false
|
||||
/// 是否锁定选择区域(或叫做数据窗口)的大小。
|
||||
/// 如果设置为 true 则锁定选择区域的大小,也就是说,只能平移,不能缩放。
|
||||
/// </summary>
|
||||
public bool zoomLock { get { return m_ZoomLock; } set { m_ZoomLock = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show data shadow in dataZoom-silder component, to indicate the data tendency in brief.
|
||||
/// default:true
|
||||
/// 如果设置为 true 则锁定选择区域的大小,也就是说,只能平移,不能缩放。
|
||||
/// </summary>
|
||||
public bool realtime { get { return m_Realtime; } set { m_Realtime = value; } }
|
||||
/// <summary>
|
||||
/// The background color of the component.
|
||||
/// 组件的背景颜色。
|
||||
/// </summary>
|
||||
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
|
||||
/// <summary>
|
||||
/// Distance between dataZoom component and the bottom side of the container.
|
||||
/// bottom value is a instant pixel value like 10.
|
||||
/// default:10
|
||||
/// 组件离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
||||
/// <summary>
|
||||
/// The height of dataZoom component.
|
||||
/// height value is a instant pixel value like 10.
|
||||
/// default:50
|
||||
/// 组件高度。
|
||||
/// </summary>
|
||||
public float height { get { return m_Height; } set { m_Height = value; } }
|
||||
/// <summary>
|
||||
/// Use absolute value or percent value in DataZoom.start and DataZoom.end.
|
||||
/// default:RangeMode.Percent
|
||||
/// default:RangeMode.Percent.
|
||||
/// 取绝对值还是百分比。
|
||||
/// </summary>
|
||||
public RangeMode rangeMode { get { return m_RangeMode; } set { m_RangeMode = value; } }
|
||||
/// <summary>
|
||||
/// The start percentage of the window out of the data extent, in the range of 0 ~ 100.
|
||||
/// default:30
|
||||
/// 数据窗口范围的起始百分比。范围是:0 ~ 100。
|
||||
/// </summary>
|
||||
public float start { get { return m_Start; } set { m_Start = value; } }
|
||||
/// <summary>
|
||||
/// The end percentage of the window out of the data extent, in the range of 0 ~ 100.
|
||||
/// default:70
|
||||
/// 数据窗口范围的结束百分比。范围是:0 ~ 100。
|
||||
/// </summary>
|
||||
public float end { get { return m_End; } set { m_End = value; } }
|
||||
/// <summary>
|
||||
/// The sensitivity of dataZoom scroll.
|
||||
/// The larger the number, the more sensitive it is.
|
||||
/// default:10
|
||||
/// 缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
||||
/// </summary>
|
||||
public float scrollSensitivity { get { return m_ScrollSensitivity; } set { m_ScrollSensitivity = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// DataZoom is in draging.
|
||||
/// 正在拖拽组件。
|
||||
/// </summary>
|
||||
public bool isDraging { get; set; }
|
||||
/// <summary>
|
||||
/// The start label.
|
||||
/// 组件的开始信息文本。
|
||||
/// </summary>
|
||||
public Text startLabel { get; set; }
|
||||
/// <summary>
|
||||
/// The end label.
|
||||
/// 组件的结束信息文本。
|
||||
/// </summary>
|
||||
public Text endLabel { get; set; }
|
||||
|
||||
@@ -186,12 +231,26 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给定的坐标是否在缩放区域内
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInZoom(Vector2 pos, float startX, float width)
|
||||
{
|
||||
Rect rect = Rect.MinMaxRect(startX, m_Bottom, startX + width, m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给定的坐标是否在选中区域内
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInSelectedZoom(Vector2 pos, float startX, float width)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
@@ -200,6 +259,13 @@ namespace XCharts
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给定的坐标是否在开始活动条触发区域内
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInStartZoom(Vector2 pos, float startX, float width)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
@@ -207,6 +273,13 @@ namespace XCharts
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给定的坐标是否在结束活动条触发区域内
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInEndZoom(Vector2 pos, float startX, float width)
|
||||
{
|
||||
var end = startX + width * m_End / 100;
|
||||
@@ -214,6 +287,10 @@ namespace XCharts
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示文本
|
||||
/// </summary>
|
||||
/// <param name="flag"></param>
|
||||
public void SetLabelActive(bool flag)
|
||||
{
|
||||
if (startLabel && startLabel.gameObject.activeInHierarchy != flag)
|
||||
@@ -226,11 +303,19 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置开始文本内容
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
public void SetStartLabelText(string text)
|
||||
{
|
||||
if (startLabel) startLabel.text = text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置结束文本内容
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
public void SetEndLabelText(string text)
|
||||
{
|
||||
if (endLabel) endLabel.text = text;
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55000eccffd85064ea6a4d1d39ff63bb
|
||||
timeCreated: 1559526210
|
||||
licenseType: Free
|
||||
guid: 46383c1c58e1f4c1a891ab60c86446eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
136
Scripts/UI/Component/Grid.cs
Normal file
136
Scripts/UI/Component/Grid.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Grid component.
|
||||
/// Drawing grid in rectangular coordinate. In a single grid, at most two X and Y axes each is allowed.
|
||||
/// Line chart, bar chart, and scatter chart can be drawn in grid.
|
||||
/// There is only one single grid component at most in a single echarts instance.
|
||||
/// <para>
|
||||
/// 网格组件。
|
||||
/// 直角坐标系内绘图网格,单个 grid 内最多可以放置上下两个 X 轴,左右两个 Y 轴。可以在网格上绘制折线图,柱状图,散点图。
|
||||
/// 单个xcharts实例中只能存在一个grid组件。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Grid : IEquatable<Grid>
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private float m_Left;
|
||||
[SerializeField] private float m_Right;
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
[SerializeField] private Color m_BackgroundColor;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the grid in rectangular coordinate.
|
||||
/// 是否显示直角坐标系网格。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// Distance between grid component and the left side of the container.
|
||||
/// grid 组件离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left { get { return m_Left; } set { m_Left = value; } }
|
||||
/// <summary>
|
||||
/// Distance between grid component and the right side of the container.
|
||||
/// grid 组件离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right { get { return m_Right; } set { m_Right = value; } }
|
||||
/// <summary>
|
||||
/// Distance between grid component and the top side of the container.
|
||||
/// grid 组件离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top { get { return m_Top; } set { m_Top = value; } }
|
||||
/// <summary>
|
||||
/// Distance between grid component and the bottom side of the container.
|
||||
/// grid 组件离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
||||
/// <summary>
|
||||
/// Background color of grid, which is transparent by default.
|
||||
/// 网格背景色,默认透明。
|
||||
/// </summary>
|
||||
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
|
||||
|
||||
public static Grid defaultGrid
|
||||
{
|
||||
get
|
||||
{
|
||||
var coordinate = new Grid
|
||||
{
|
||||
m_Show = false,
|
||||
m_Left = 50,
|
||||
m_Right = 30,
|
||||
m_Top = 50,
|
||||
m_Bottom = 30
|
||||
};
|
||||
return coordinate;
|
||||
}
|
||||
}
|
||||
public void Copy(Grid other)
|
||||
{
|
||||
m_Show = other.show;
|
||||
m_Left = other.left;
|
||||
m_Right = other.right;
|
||||
m_Top = other.top;
|
||||
m_Bottom = other.bottom;
|
||||
m_BackgroundColor = other.backgroundColor;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj is Grid)
|
||||
{
|
||||
return Equals((Grid)obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(Grid other)
|
||||
{
|
||||
if (ReferenceEquals(null, other))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_Show == other.show &&
|
||||
m_Left == other.left &&
|
||||
m_Right == other.right &&
|
||||
m_Top == other.top &&
|
||||
m_Bottom == other.bottom &&
|
||||
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.backgroundColor);
|
||||
}
|
||||
|
||||
public static bool operator ==(Grid left, Grid right)
|
||||
{
|
||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(Grid left, Grid right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7dea6e12aeb93945888247ea97dbd13
|
||||
timeCreated: 1554422468
|
||||
licenseType: Free
|
||||
guid: 15d97f34ea6674855859ef7d7941e2e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -5,6 +5,10 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 图例组件。
|
||||
/// 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Legend : JsonDataSupport, IPropertyChanged, IEquatable<Legend>
|
||||
{
|
||||
@@ -19,22 +23,53 @@ namespace XCharts
|
||||
|
||||
private Dictionary<string, Button> m_DataBtnList = new Dictionary<string, Button>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show legend component.
|
||||
/// 是否显示图例组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Specify whether the layout of legend component is horizontal or vertical.
|
||||
/// 布局方式是横还是竖。
|
||||
/// </summary>
|
||||
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The location of legend.
|
||||
/// 图例显示的位置。
|
||||
/// </summary>
|
||||
public Location location { get { return m_Location; } set { m_Location = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// the width of legend item.
|
||||
/// 每个图例项的宽度。
|
||||
/// </summary>
|
||||
public float itemWidth { get { return m_ItemWidth; } set { m_ItemWidth = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// the height of legend item.
|
||||
/// 每个图例项的高度。
|
||||
/// </summary>
|
||||
public float itemHeight { get { return m_ItemHeight; } set { m_ItemHeight = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
|
||||
/// 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
|
||||
/// </summary>
|
||||
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// font size of item text.
|
||||
/// 图例项的字体大小。
|
||||
/// </summary>
|
||||
public int itemFontSize { get { return m_ItemFontSize; } set { m_ItemFontSize = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,
|
||||
/// it could also be the name of a single data in the pie chart) of a series.
|
||||
/// If data is not specified, it will be auto collected from series.
|
||||
/// 图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 name(如果是饼图,也可以是饼图单个数据的 name)。
|
||||
/// 如果 data 没有被指定,会自动从当前系列中获取。指定data时里面的数据项和serie匹配时才会生效。
|
||||
/// </summary>
|
||||
public List<string> data { get { return m_Data; } }
|
||||
|
||||
/// <summary>
|
||||
/// 一个在顶部居中显示的默认图例。
|
||||
/// </summary>
|
||||
public static Legend defaultLegend
|
||||
{
|
||||
get
|
||||
@@ -121,16 +156,28 @@ namespace XCharts
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
m_Data.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包括由指定名字的图例
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public bool ContainsData(string name)
|
||||
{
|
||||
return m_Data.Contains(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除指定名字的图例
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public void RemoveData(string name)
|
||||
{
|
||||
if (m_Data.Contains(name))
|
||||
@@ -139,6 +186,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加图例项
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public void AddData(string name)
|
||||
{
|
||||
if (!m_Data.Contains(name) && !string.IsNullOrEmpty(name))
|
||||
@@ -147,6 +198,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的图例
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public string GetData(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
@@ -156,16 +212,30 @@ namespace XCharts
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定图例的索引
|
||||
/// </summary>
|
||||
/// <param name="legendName"></param>
|
||||
/// <returns></returns>
|
||||
public int GetIndex(string legendName)
|
||||
{
|
||||
return m_Data.IndexOf(legendName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除所有图例按钮
|
||||
/// </summary>
|
||||
public void RemoveButton()
|
||||
{
|
||||
m_DataBtnList.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给图例绑定按钮
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="btn"></param>
|
||||
/// <param name="total"></param>
|
||||
public void SetButton(string name, Button btn, int total)
|
||||
{
|
||||
int index = m_DataBtnList.Values.Count;
|
||||
@@ -175,6 +245,11 @@ namespace XCharts
|
||||
btn.GetComponentInChildren<Text>().text = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新图例按钮颜色
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="color"></param>
|
||||
public void UpdateButtonColor(string name, Color color)
|
||||
{
|
||||
if (m_DataBtnList.ContainsKey(name))
|
||||
@@ -183,11 +258,20 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 参数变更时的回调处理
|
||||
/// </summary>
|
||||
public void OnChanged()
|
||||
{
|
||||
m_Location.OnChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据图例的布局和位置类型获得具体位置
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
private Vector2 GetButtonLocationPosition(int size, int index)
|
||||
{
|
||||
switch (m_Orient)
|
||||
@@ -238,6 +322,10 @@ namespace XCharts
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从json字符串解析数据,json格式如:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
|
||||
/// </summary>
|
||||
/// <param name="jsonData"></param>
|
||||
public override void ParseJsonData(string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fba76b49d7dd644cb3953355d6caae4
|
||||
timeCreated: 1554222818
|
||||
licenseType: Free
|
||||
guid: f7a925c1e6149497098620272a65057f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -2,13 +2,30 @@
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// The global settings of line chart.
|
||||
/// LineChart的全局配置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Line
|
||||
{
|
||||
/// <summary>
|
||||
/// the type fo step line.
|
||||
/// 阶梯线图类型。
|
||||
/// </summary>
|
||||
public enum StepType
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前点。
|
||||
/// </summary>
|
||||
Start,
|
||||
/// <summary>
|
||||
/// 当前点和下一个点的中间。
|
||||
/// </summary>
|
||||
Middle,
|
||||
/// <summary>
|
||||
/// 下一个拐点
|
||||
/// </summary>
|
||||
End
|
||||
}
|
||||
[SerializeField] private float m_Tickness;
|
||||
@@ -18,11 +35,35 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Step;
|
||||
[SerializeField] private StepType m_StepType;
|
||||
|
||||
/// <summary>
|
||||
/// the tickness of lines.
|
||||
/// 线条粗细。
|
||||
/// </summary>
|
||||
public float tickness { get { return m_Tickness; } set { m_Tickness = value; } }
|
||||
/// <summary>
|
||||
/// smoothness.
|
||||
/// 平滑风格。
|
||||
/// </summary>
|
||||
public float smoothStyle { get { return m_SmoothStyle; } set { m_SmoothStyle = value; } }
|
||||
/// <summary>
|
||||
/// Whether the lines are displayed smoothly.
|
||||
/// 是否平滑显示。
|
||||
/// </summary>
|
||||
public bool smooth { get { return m_Smooth; } set { m_Smooth = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show area.
|
||||
/// 是否显示区域填充颜色。
|
||||
/// </summary>
|
||||
public bool area { get { return m_Area; } set { m_Area = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show as a step line.
|
||||
/// 是否是阶梯线图。
|
||||
/// </summary>
|
||||
public bool step { get { return m_Step; } set { m_Step = value; } }
|
||||
/// <summary>
|
||||
/// the type of step line.
|
||||
/// 阶梯线图类型。
|
||||
/// </summary>
|
||||
public StepType stepTpe { get { return m_StepType; } set { m_StepType = value; } }
|
||||
|
||||
public static Line defaultLine
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86acdbfd671c43949bf0cc4880a4ccb7
|
||||
timeCreated: 1555671450
|
||||
licenseType: Free
|
||||
guid: 1a4ce8176d040474db7238ccc962c79f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -2,12 +2,24 @@
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// the global setting of pie chart.
|
||||
/// 饼图的全局设置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Pie
|
||||
{
|
||||
[SerializeField] private float m_TooltipExtraRadius;
|
||||
[SerializeField] private float m_SelectedOffset;
|
||||
/// <summary>
|
||||
/// the extra dadius of pie chart when the tooltip indicatored pie.
|
||||
/// 提示框指示时的额外半径。
|
||||
/// </summary>
|
||||
public float tooltipExtraRadius { get { return m_TooltipExtraRadius; } set { m_TooltipExtraRadius = value; } }
|
||||
/// <summary>
|
||||
/// the offset of pie when the pie item is selected.
|
||||
/// 饼图项被选中时的偏移。
|
||||
/// </summary>
|
||||
public float selectedOffset { get { return m_SelectedOffset; } set { m_SelectedOffset = value; } }
|
||||
|
||||
public static Pie defaultPie
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f38ef4633bae5247a8c382a4d20fc39
|
||||
timeCreated: 1555671161
|
||||
licenseType: Free
|
||||
guid: a657ed0fd5aeb4312801338fb5308811
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -5,24 +5,52 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Coordinate for radar charts.
|
||||
/// 雷达图坐标系组件,只适用于雷达图。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Radar : JsonDataSupport, IEquatable<Radar>
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicator of radar chart, which is used to assign multiple variables(dimensions) in radar chart.
|
||||
/// 雷达图的指示器,用来指定雷达图中的多个变量(维度)。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Indicator : IEquatable<Indicator>
|
||||
{
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private float m_Max;
|
||||
|
||||
[SerializeField] private float m_Min;
|
||||
[SerializeField] private Color m_Color;
|
||||
/// <summary>
|
||||
/// 指示器名称。
|
||||
/// </summary>
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
/// <summary>
|
||||
/// The maximum value of indicator, with default value of 0, but we recommend to set it manually.
|
||||
/// 指示器的最大值,默认为 0 无限制。
|
||||
/// </summary>
|
||||
public float max { get { return m_Max; } set { m_Max = value; } }
|
||||
/// <summary>
|
||||
/// The minimum value of indicator, with default value of 0.
|
||||
/// 指示器的最小值,默认为 0 无限制。
|
||||
/// </summary>
|
||||
public float min { get { return m_Min; } set { m_Min = value; } }
|
||||
/// <summary>
|
||||
/// Specfy a color the the indicator.
|
||||
/// 标签特定的颜色。
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public Indicator Clone()
|
||||
{
|
||||
return new Indicator()
|
||||
{
|
||||
name = name,
|
||||
max = max
|
||||
m_Name = name,
|
||||
m_Max = max,
|
||||
m_Min = min,
|
||||
m_Color = color
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,23 +81,80 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Indicator = true;
|
||||
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
||||
|
||||
/// <summary>
|
||||
/// True is render radar as cricle,otherwise render as polygon.
|
||||
///雷达图是否绘制成圆形,true为圆形,false为多边形。
|
||||
/// </summary>
|
||||
public bool cricle { get { return m_Cricle; } set { m_Cricle = value; } }
|
||||
/// <summary>
|
||||
/// Whether to fill color in area.
|
||||
/// 是否区域填充颜色
|
||||
/// </summary>
|
||||
public bool area { get { return m_Area; } set { m_Area = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// the radius of radar.
|
||||
/// 雷达图的半径。
|
||||
/// </summary>
|
||||
public float radius { get { return m_Radius; } set { m_Radius = value; } }
|
||||
/// <summary>
|
||||
/// Segments of indicator axis.
|
||||
/// 指示器轴的分割段数。
|
||||
/// </summary>
|
||||
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Distance between radar component and the left side of the container.
|
||||
/// 雷达图离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left { get { return m_Left; } set { m_Left = value; } }
|
||||
/// <summary>
|
||||
/// Distance between radar component and the right side of the container.
|
||||
/// 雷达图离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right { get { return m_Right; } set { m_Right = value; } }
|
||||
/// <summary>
|
||||
/// Distance between radar component and the top side of the container.
|
||||
/// 雷达图离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top { get { return m_Top; } set { m_Top = value; } }
|
||||
/// <summary>
|
||||
/// Distance between radar component and the bottom side of the container.
|
||||
/// 雷达图离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// the tickness of line.
|
||||
/// 线的粗细。
|
||||
/// </summary>
|
||||
public float lineTickness { get { return m_LineTickness; } set { m_LineTickness = value; } }
|
||||
/// <summary>
|
||||
/// the size of point.
|
||||
/// 圆点大小。
|
||||
/// </summary>
|
||||
public float linePointSize { get { return m_LinePointSize; } set { m_LinePointSize = value; } }
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 线的颜色。
|
||||
/// </summary>
|
||||
public Color lineColor { get { return m_LineColor; } set { m_LineColor = value; } }
|
||||
public int areaAipha { get { return m_AreaAlpha; } set { m_AreaAlpha = value; } }
|
||||
/// <summary>
|
||||
/// the alpha of area color.
|
||||
/// 区域填充时的颜色alpha值
|
||||
/// </summary>
|
||||
public int areaAlpha { get { return m_AreaAlpha; } set { m_AreaAlpha = value; } }
|
||||
/// <summary>
|
||||
/// the color list of split area.
|
||||
/// 分割区域颜色列表。
|
||||
/// </summary>
|
||||
public List<Color> backgroundColorList { get { return m_BackgroundColorList; } }
|
||||
/// <summary>
|
||||
/// Whether to show indicator.
|
||||
/// 是否显示指示器。
|
||||
/// </summary>
|
||||
public bool indicator { get { return m_Indicator; } set { m_Indicator = value; } }
|
||||
/// <summary>
|
||||
/// the indicator list.
|
||||
/// 指示器列表。
|
||||
/// </summary>
|
||||
public List<Indicator> indicatorList { get { return m_IndicatorList; } }
|
||||
|
||||
public static Radar defaultRadar
|
||||
@@ -116,7 +201,7 @@ namespace XCharts
|
||||
m_Top = other.top;
|
||||
m_Bottom = other.bottom;
|
||||
m_Indicator = other.indicator;
|
||||
m_AreaAlpha = other.areaAipha;
|
||||
m_AreaAlpha = other.areaAlpha;
|
||||
indicatorList.Clear();
|
||||
foreach (var d in other.indicatorList) indicatorList.Add(d.Clone());
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3a368484f9598e4eb9dfce2471d34da
|
||||
timeCreated: 1555562622
|
||||
licenseType: Free
|
||||
guid: 0edd44f3a0d104bcbb1371b511d15550
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -6,20 +6,44 @@ using UnityEngine.Serialization;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// the type of serie.
|
||||
/// 系列类型。
|
||||
/// </summary>
|
||||
public enum SerieType
|
||||
{
|
||||
/// <summary>
|
||||
/// 折线图。折线图是用折线将各个数据点标志连接起来的图表,用于展现数据的变化趋势。可用于直角坐标系和极坐标系上。
|
||||
/// </summary>
|
||||
Line,
|
||||
/// <summary>
|
||||
/// 柱状图。柱状/条形图 通过 柱形的高度/条形的宽度 来表现数据的大小,用于有至少一个类目轴或时间轴的直角坐标系上。
|
||||
/// </summary>
|
||||
Bar,
|
||||
/// <summary>
|
||||
/// 饼图。饼图主要用于表现不同类目的数据在总和中的占比。每个的弧度表示数据数量的比例。
|
||||
/// 饼图更适合表现数据相对于总数的百分比等关系。
|
||||
/// </summary>
|
||||
Pie,
|
||||
/// <summary>
|
||||
/// 雷达图。雷达图主要用于表现多变量的数据,例如球员的各个属性分析。依赖 radar 组件。
|
||||
/// </summary>
|
||||
Radar,
|
||||
/// <summary>
|
||||
/// 散点图。直角坐标系上的散点图可以用来展现数据的 x,y 之间的关系,如果数据项有多个维度,
|
||||
/// 其它维度的值可以通过不同大小的 symbol 展现成气泡图,也可以用颜色来表现。
|
||||
/// </summary>
|
||||
Scatter,
|
||||
/// <summary>
|
||||
/// 带有涟漪特效动画的散点图。利用动画特效可以将某些想要突出的数据进行视觉突出。
|
||||
/// </summary>
|
||||
EffectScatter
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show as Nightingale chart, which distinguishs data through radius.
|
||||
/// 是否展示成南丁格尔图,通过半径区分数据大小。
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Whether to show as Nightingale chart, which distinguishs data through radius.
|
||||
/// 是否展示成南丁格尔图,通过半径区分数据大小。
|
||||
/// </summary>
|
||||
public enum RoseType
|
||||
{
|
||||
/// <summary>
|
||||
@@ -38,6 +62,9 @@ namespace XCharts
|
||||
Area
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系列。每个系列通过 type 决定自己的图表类型。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Serie : JsonDataSupport
|
||||
{
|
||||
@@ -47,7 +74,7 @@ namespace XCharts
|
||||
[SerializeField] private string m_Stack;
|
||||
[SerializeField] [Range(0, 1)] private int m_AxisIndex;
|
||||
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
|
||||
#region PieChart
|
||||
#region PieChart field
|
||||
[SerializeField] private bool m_ClickOffset = true;
|
||||
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
||||
[SerializeField] private float m_Space;
|
||||
@@ -63,29 +90,82 @@ namespace XCharts
|
||||
[SerializeField] private List<float> m_XData = new List<float>();
|
||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show serie in chart.
|
||||
/// 系列是否显示在图表上。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// the chart type of serie.
|
||||
/// 系列的图表类型。
|
||||
/// </summary>
|
||||
public SerieType type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// Series name used for displaying in tooltip and filtering with legend.
|
||||
/// 系列名称,用于 tooltip 的显示,legend 的图例筛选。
|
||||
/// </summary>
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
/// <summary>
|
||||
/// If stack the value. On the same category axis, the series with the same stack name would be put on top of each other.
|
||||
/// 数据堆叠,同个类目轴上系列配置相同的stack值后,后一个系列的值会在前一个系列的值上相加。
|
||||
/// </summary>
|
||||
public string stack { get { return m_Stack; } set { m_Stack = value; } }
|
||||
/// <summary>
|
||||
/// Index of axis to combine with, which is useful for multiple x axes in one chart.
|
||||
/// 使用的坐标轴轴的 index,在单个图表实例中存在多个坐标轴轴的时候有用。
|
||||
/// </summary>
|
||||
public int axisIndex { get { return m_AxisIndex; } set { m_AxisIndex = value; } }
|
||||
/// <summary>
|
||||
/// the symbol of serie data item.
|
||||
/// 标记的图形。
|
||||
/// </summary>
|
||||
public SerieSymbol symbol { get { return m_Symbol; } set { m_Symbol = value; } }
|
||||
/// <summary>
|
||||
/// Whether offset when mouse click pie chart item.
|
||||
/// 鼠标点击时是否开启偏移,一般用在PieChart图表中。
|
||||
/// </summary>
|
||||
public bool clickOffset { get { return m_ClickOffset; } set { m_ClickOffset = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show as Nightingale chart.
|
||||
/// 是否展示成南丁格尔图,通过半径区分数据大小。
|
||||
/// </summary>
|
||||
public RoseType roseType { get { return m_RoseType; } set { m_RoseType = value; } }
|
||||
/// <summary>
|
||||
/// the space of pie chart item.
|
||||
/// 饼图项间的空隙留白。
|
||||
/// </summary>
|
||||
public float space { get { return m_Space; } set { m_Space = value; } }
|
||||
/// <summary>
|
||||
/// the center of pie chart.
|
||||
/// 饼图的中心点。
|
||||
/// </summary>
|
||||
public float[] center { get { return m_Center; } set { m_Center = value; } }
|
||||
/// <summary>
|
||||
/// the radius of pie chart.
|
||||
/// 饼图的半径。radius[0]表示内径,radius[1]表示外径。
|
||||
/// </summary>
|
||||
public float[] radius { get { return m_Radius; } set { m_Radius = value; } }
|
||||
/// <summary>
|
||||
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||
/// </summary>
|
||||
public SerieLabel label { get { return m_Label; } set { m_Label = value; } }
|
||||
/// <summary>
|
||||
/// Text label of highlight graphic element.
|
||||
/// 高亮时的文本标签配置。
|
||||
/// </summary>
|
||||
public SerieLabel highlightLabel { get { return m_HighlightLabel; } set { m_HighlightLabel = value; } }
|
||||
/// <summary>
|
||||
/// 维度Y的数据列表。默认对应yAxis。
|
||||
/// </summary>
|
||||
public List<float> yData { get { return m_YData; } }
|
||||
/// <summary>
|
||||
/// 维度X的数据列表。默认对应xAxis。
|
||||
/// </summary>
|
||||
public List<float> xData { get { return m_XData; } }
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
public List<SerieData> data { get { return m_Data; } }
|
||||
|
||||
/// <summary>
|
||||
@@ -98,14 +178,21 @@ namespace XCharts
|
||||
/// 该系列是否高亮,一般由图例悬停触发。
|
||||
/// </summary>
|
||||
public bool highlighted { get; set; }
|
||||
/// <summary>
|
||||
/// the count of data list.
|
||||
/// 数据项个数。
|
||||
/// </summary>
|
||||
public int dataCount { get { return m_Data.Count; } }
|
||||
public int filterStart { get; set; }
|
||||
public int filterEnd { get; set; }
|
||||
|
||||
private int filterStart { get; set; }
|
||||
private int filterEnd { get; set; }
|
||||
private List<float> yFilterData { get; set; }
|
||||
private List<float> xFilterData { get; set; }
|
||||
private List<SerieData> filterData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 维度Y对应数据中最大值。
|
||||
/// </summary>
|
||||
public float yMax
|
||||
{
|
||||
get
|
||||
@@ -122,6 +209,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维度X对应数据中的最大值。
|
||||
/// </summary>
|
||||
public float xMax
|
||||
{
|
||||
get
|
||||
@@ -138,6 +228,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维度Y对应数据的最小值。
|
||||
/// </summary>
|
||||
public float yMin
|
||||
{
|
||||
get
|
||||
@@ -154,6 +247,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维度X对应数据的最小值。
|
||||
/// </summary>
|
||||
public float xMin
|
||||
{
|
||||
get
|
||||
@@ -170,6 +266,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维度Y数据的总和。
|
||||
/// </summary>
|
||||
public float yTotal
|
||||
{
|
||||
get
|
||||
@@ -184,6 +283,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维度X数据的总和。
|
||||
/// </summary>
|
||||
public float xTotal
|
||||
{
|
||||
get
|
||||
@@ -198,6 +300,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
m_XData.Clear();
|
||||
@@ -205,6 +310,10 @@ namespace XCharts
|
||||
m_Data.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除指定索引的数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
public void RemoveData(int index)
|
||||
{
|
||||
m_XData.RemoveAt(index);
|
||||
@@ -212,6 +321,12 @@ namespace XCharts
|
||||
m_Data.RemoveAt(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个数据到维度Y(此时维度X对应的数据是索引)
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddYData(float value, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
if (maxDataNumber > 0)
|
||||
@@ -226,6 +341,13 @@ namespace XCharts
|
||||
m_Data.Add(new SerieData() { data = new List<float>() { xValue, value }, name = dataName });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加(x,y)数据到维度X和维度Y
|
||||
/// </summary>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddXYData(float xValue, float yValue, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
if (maxDataNumber > 0)
|
||||
@@ -238,7 +360,14 @@ namespace XCharts
|
||||
m_YData.Add(yValue);
|
||||
m_Data.Add(new SerieData() { data = new List<float>() { xValue, yValue }, name = dataName });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将一组数据添加到系列中。
|
||||
/// 如果数据只有一个,默认添加到维度Y中。
|
||||
/// </summary>
|
||||
/// <param name="valueList"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public void AddData(List<float> valueList, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
if (valueList == null || valueList.Count == 0) return;
|
||||
@@ -270,6 +399,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度Y索引对应的数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public float GetYData(int index, DataZoom dataZoom = null)
|
||||
{
|
||||
if (index < 0) return 0;
|
||||
@@ -281,6 +416,13 @@ namespace XCharts
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度Y索引对应的数据和数据名
|
||||
/// </summary>
|
||||
/// <param name="index">索引</param>
|
||||
/// <param name="yData">对应的数据值</param>
|
||||
/// <param name="dataName">对应的数据名</param>
|
||||
/// <param name="dataZoom">区域缩放</param>
|
||||
public void GetYData(int index, out float yData, out string dataName, DataZoom dataZoom = null)
|
||||
{
|
||||
yData = 0;
|
||||
@@ -294,6 +436,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的数据项
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public SerieData GetSerieData(int index, DataZoom dataZoom = null)
|
||||
{
|
||||
var data = GetDataList(dataZoom);
|
||||
@@ -304,6 +452,13 @@ namespace XCharts
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的维度X和维度Y的数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yVlaue"></param>
|
||||
public void GetXYData(int index, DataZoom dataZoom, out float xValue, out float yVlaue)
|
||||
{
|
||||
xValue = 0;
|
||||
@@ -318,6 +473,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度Y的数据列表
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public List<float> GetYDataList(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.show)
|
||||
@@ -337,6 +497,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度X的数据列表
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public List<float> GetXDataList(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.show)
|
||||
@@ -356,6 +521,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得系列的数据列表
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.show)
|
||||
@@ -375,6 +545,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据dataZoom更新数据列表缓存
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
public void UpdateFilterData(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.show)
|
||||
@@ -420,17 +594,34 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定索引的维度Y数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
public void UpdateYData(int index, float value)
|
||||
{
|
||||
UpdateData(index, 2, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定索引的维度X和维度Y的数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
public void UpdateXYData(int index, float xValue, float yValue)
|
||||
{
|
||||
UpdateData(index, 1, xValue);
|
||||
UpdateData(index, 2, yValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定索引指定维数的数据
|
||||
/// </summary>
|
||||
/// <param name="index">要更新数据的索引</param>
|
||||
/// <param name="dimension">要更新数据的维数</param>
|
||||
/// <param name="value">新的数据值</param>
|
||||
public void UpdateData(int index, int dimension, float value)
|
||||
{
|
||||
if (index < 0) return;
|
||||
@@ -448,6 +639,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除所有数据的高亮标志
|
||||
/// </summary>
|
||||
public void ClearHighlight()
|
||||
{
|
||||
highlighted = false;
|
||||
@@ -457,6 +651,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定索引的数据为高亮状态
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
public void SetHighlight(int index)
|
||||
{
|
||||
if (index <= 0) return;
|
||||
@@ -466,6 +664,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从json中导入数据
|
||||
/// </summary>
|
||||
/// <param name="jsonData"></param>
|
||||
public override void ParseJsonData(string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bde61eb0785bad4d91d84d5511514ba
|
||||
timeCreated: 1554222818
|
||||
licenseType: Free
|
||||
guid: 0e8779db31fe5441ba4491407ee03cd1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -3,13 +3,26 @@ using System.Collections.Generic;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// the list of series.
|
||||
/// 系列列表。每个系列通过 type 决定自己的图表类型。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Series : JsonDataSupport
|
||||
{
|
||||
[SerializeField] protected List<Serie> m_Series;
|
||||
|
||||
/// <summary>
|
||||
/// the list of serie
|
||||
/// 系列列表。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public List<Serie> series { get { return m_Series; } }
|
||||
|
||||
/// <summary>
|
||||
/// the size of serie list.
|
||||
/// 系列个数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public int Count { get { return m_Series.Count; } }
|
||||
|
||||
public static Series defaultSeries
|
||||
@@ -28,6 +41,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有系列的数据
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
@@ -36,6 +52,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定序列指定索引的数据值
|
||||
/// </summary>
|
||||
/// <param name="serieIndex"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <returns></returns>
|
||||
public float GetData(int serieIndex, int dataIndex)
|
||||
{
|
||||
if (serieIndex >= 0 && serieIndex < Count)
|
||||
@@ -48,6 +70,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定系列名的第一个系列
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public Serie GetSerie(string name)
|
||||
{
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
@@ -61,6 +88,11 @@ namespace XCharts
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定系列名的所有系列
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public List<Serie> GetSeries(string name)
|
||||
{
|
||||
var list = new List<Serie>();
|
||||
@@ -72,6 +104,11 @@ namespace XCharts
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的系列
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public Serie GetSerie(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_Series.Count)
|
||||
@@ -81,6 +118,11 @@ namespace XCharts
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含指定名字的系列
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public bool Contains(string name)
|
||||
{
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
@@ -95,6 +137,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Remove serie from series.
|
||||
/// 移除指定名字的系列。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
public void Remove(string serieName)
|
||||
@@ -108,12 +151,20 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Remove all serie from series.
|
||||
/// 移除所有系列。
|
||||
/// </summary>
|
||||
public void RemoveAll()
|
||||
{
|
||||
m_Series.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个系列到列表中。
|
||||
/// </summary>
|
||||
/// <param name="serieName"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="show"></param>
|
||||
/// <returns></returns>
|
||||
public Serie AddSerie(string serieName, SerieType type, bool show = true)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
@@ -150,6 +201,14 @@ namespace XCharts
|
||||
return serie;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个数据到指定系列的维度Y数据中
|
||||
/// </summary>
|
||||
/// <param name="serieName"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(string serieName, float value, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
@@ -161,6 +220,14 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个数据到指定系列的维度Y中
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(int index, float value, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
@@ -172,6 +239,14 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一组数据到指定的系列中
|
||||
/// </summary>
|
||||
/// <param name="serieName"></param>
|
||||
/// <param name="multidimensionalData"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(string serieName, List<float> multidimensionalData, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
@@ -183,6 +258,14 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一组数据到指定的系列中
|
||||
/// </summary>
|
||||
/// <param name="serieIndex"></param>
|
||||
/// <param name="multidimensionalData"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddData(int serieIndex, List<float> multidimensionalData, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
var serie = GetSerie(serieIndex);
|
||||
@@ -194,6 +277,15 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加(x,y)数据到指定的系列中
|
||||
/// </summary>
|
||||
/// <param name="serieName"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddXYData(string serieName, float xValue, float yValue, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
@@ -205,6 +297,15 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加(x,y)数据到指定的系列中
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="maxDataNumber"></param>
|
||||
/// <returns></returns>
|
||||
public bool AddXYData(int index, float xValue, float yValue, string dataName = null, int maxDataNumber = 0)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
@@ -216,6 +317,12 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定系列的维度Y数据
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
public void UpdateData(string name, float value, int dataIndex = 0)
|
||||
{
|
||||
var serie = GetSerie(name);
|
||||
@@ -225,15 +332,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateXYData(string name, float xValue, float yValue, int dataIndex = 0)
|
||||
{
|
||||
var serie = GetSerie(name);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定系列的维度Y数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
public void UpdateData(int index, float value, int dataIndex = 0)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
@@ -243,6 +347,30 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定系列的维度X和维度Y数据
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
public void UpdateXYData(string name, float xValue, float yValue, int dataIndex = 0)
|
||||
{
|
||||
var serie = GetSerie(name);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定系列的维度X和维度Y数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
public void UpdateXYData(int index, float xValue, float yValue, int dataIndex = 0)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
@@ -252,6 +380,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dataZoom由变化是更新系列的缓存数据
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
public void UpdateFilterData(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.show)
|
||||
@@ -263,18 +395,33 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定系列是否显示
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsActive(string name)
|
||||
{
|
||||
var serie = GetSerie(name);
|
||||
return serie == null ? false : serie.show;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定系列是否显示
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsActive(int index)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
return serie == null ? false : serie.show;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定系列是否显示
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="active"></param>
|
||||
public void SetActive(string name, bool active)
|
||||
{
|
||||
var serie = GetSerie(name);
|
||||
@@ -284,6 +431,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定系列是否显示
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="active"></param>
|
||||
public void SetActive(int index, bool active)
|
||||
{
|
||||
var serie = GetSerie(index);
|
||||
@@ -293,6 +445,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否由系列在用指定索引的axis
|
||||
/// </summary>
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsUsedAxisIndex(int axisIndex)
|
||||
{
|
||||
foreach (var serie in series)
|
||||
@@ -302,18 +459,37 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsTooltipSelected(int serieIndex)
|
||||
/// <summary>
|
||||
/// 指定系列是否处于高亮选中状态
|
||||
/// </summary>
|
||||
/// <param name="serieIndex"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsHighlight(int serieIndex)
|
||||
{
|
||||
var serie = GetSerie(serieIndex);
|
||||
if (serie != null) return serie.highlighted;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度X的最大最小值
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minVaule"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public void GetXMinMaxValue(DataZoom dataZoom, int axisIndex, out int minVaule, out int maxValue)
|
||||
{
|
||||
GetMinMaxValue(dataZoom, axisIndex, false, out minVaule, out maxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度Y的最大最小值
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minVaule"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public void GetYMinMaxValue(DataZoom dataZoom, int axisIndex, out int minVaule, out int maxValue)
|
||||
{
|
||||
GetMinMaxValue(dataZoom, axisIndex, true, out minVaule, out maxValue);
|
||||
@@ -382,6 +558,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定系列的最大值
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public float GetMaxValue(int index)
|
||||
{
|
||||
float max = int.MinValue;
|
||||
@@ -403,6 +584,11 @@ namespace XCharts
|
||||
return ChartHelper.GetMaxDivisibleValue(max);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定系列的最小值
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public float GetMinValue(int index)
|
||||
{
|
||||
float max = int.MinValue;
|
||||
@@ -425,6 +611,10 @@ namespace XCharts
|
||||
}
|
||||
|
||||
private HashSet<string> _setForStack = new HashSet<string>();
|
||||
/// <summary>
|
||||
/// 是否由数据堆叠
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsStack()
|
||||
{
|
||||
_setForStack.Clear();
|
||||
@@ -440,6 +630,10 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得堆叠系列列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<int, List<Serie>> GetStackSeries()
|
||||
{
|
||||
int count = 0;
|
||||
@@ -475,6 +669,11 @@ namespace XCharts
|
||||
}
|
||||
|
||||
private Dictionary<string, int> sets = new Dictionary<string, int>();
|
||||
/// <summary>
|
||||
/// 获得堆叠系列列表
|
||||
/// </summary>
|
||||
/// <param name="Dictionary<int"></param>
|
||||
/// <param name="stackSeries"></param>
|
||||
public void GetStackSeries(ref Dictionary<int, List<Serie>> stackSeries)
|
||||
{
|
||||
int count = 0;
|
||||
@@ -521,6 +720,10 @@ namespace XCharts
|
||||
}
|
||||
|
||||
private List<string> serieNameList = new List<string>();
|
||||
/// <summary>
|
||||
/// 获得所有系列名,不包含空名字。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<string> GetSerieNameList()
|
||||
{
|
||||
serieNameList.Clear();
|
||||
@@ -547,6 +750,11 @@ namespace XCharts
|
||||
return serieNameList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置获得标志图形大小的回调
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="selectedSize"></param>
|
||||
public void SetSerieSymbolSizeCallback(SymbolSizeCallback size, SymbolSizeCallback selectedSize)
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
@@ -556,6 +764,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从json中解析数据
|
||||
/// </summary>
|
||||
/// <param name="jsonData"></param>
|
||||
public override void ParseJsonData(string jsonData)
|
||||
{
|
||||
//TODO:
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 137f78d348f866943a9fb8c1c8eaceef
|
||||
timeCreated: 1556016849
|
||||
licenseType: Free
|
||||
guid: 96ea96c66cf5d47c481d8d692a35ed93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,24 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 主题
|
||||
/// </summary>
|
||||
public enum Theme
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
Light,
|
||||
/// <summary>
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
Dark
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
/// <summary>
|
||||
/// Theme.
|
||||
/// 主题相关配置。
|
||||
/// </summary>
|
||||
public class ThemeInfo : IEquatable<ThemeInfo>
|
||||
{
|
||||
[SerializeField] private Theme m_Theme = Theme.Default;
|
||||
[SerializeField] private Font m_Font;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
[SerializeField] private Color32 m_TextColor;
|
||||
[FormerlySerializedAs("m_TextColor")]
|
||||
[SerializeField] private Color32 m_TitleTextColor;
|
||||
[SerializeField] private Color32 m_TitleSubTextColor;
|
||||
[SerializeField] private Color32 m_LegendTextColor;
|
||||
[SerializeField] private Color32 m_LegendUnableColor;
|
||||
@@ -37,7 +54,8 @@ namespace XCharts
|
||||
|
||||
[SerializeField] private Font m_CustomFont;
|
||||
[SerializeField] private Color32 m_CustomBackgroundColor;
|
||||
[SerializeField] private Color32 m_CustomTextColor;
|
||||
[FormerlySerializedAs("m_CustomTextColor")]
|
||||
[SerializeField] private Color32 m_CustomTitleTextColor;
|
||||
[SerializeField] private Color32 m_CustomTitleSubTextColor;
|
||||
[SerializeField] private Color32 m_CustomLegendTextColor;
|
||||
[SerializeField] private Color32 m_CustomLegendUnableColor;
|
||||
@@ -53,95 +71,176 @@ namespace XCharts
|
||||
[SerializeField] private Color32 m_CustomDataZoomLineColor;
|
||||
[SerializeField] private Color32 m_CustomDataZoomSelectedColor;
|
||||
[SerializeField] private List<Color32> m_CustomColorPalette = new List<Color32>(13);
|
||||
|
||||
/// <summary>
|
||||
/// the theme of chart.
|
||||
/// 主题类型。
|
||||
/// </summary>
|
||||
public Theme theme { get { return m_Theme; } set { m_Theme = value; } }
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_CustomFont != null ? m_CustomFont : m_Font; }
|
||||
set { m_CustomFont = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of chart.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_CustomBackgroundColor != Color.clear ? m_CustomBackgroundColor : m_BackgroundColor; }
|
||||
set { m_CustomBackgroundColor = value; }
|
||||
}
|
||||
public Color32 textColor
|
||||
/// <summary>
|
||||
/// the main title text color.
|
||||
/// 主标题颜色。
|
||||
/// </summary>
|
||||
public Color32 titleTextColor
|
||||
{
|
||||
get { return m_CustomTextColor != Color.clear ? m_CustomTextColor : m_TextColor; }
|
||||
set { m_CustomTextColor = value; }
|
||||
get { return m_CustomTitleTextColor != Color.clear ? m_CustomTitleTextColor : m_TitleTextColor; }
|
||||
set { m_CustomTitleTextColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the subtitie text color.
|
||||
/// 副标题颜色。
|
||||
/// </summary>
|
||||
public Color32 titleSubTextColor
|
||||
{
|
||||
get { return m_CustomTitleSubTextColor != Color.clear ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
|
||||
set { m_CustomTitleSubTextColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the legend text color.
|
||||
/// 图例文字的颜色。
|
||||
/// </summary>
|
||||
public Color32 legendTextColor
|
||||
{
|
||||
get { return m_CustomLegendTextColor != Color.clear ? m_CustomLegendTextColor : m_LegendTextColor; }
|
||||
set { m_CustomLegendTextColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the legend unable text color.
|
||||
/// 图例变为不可用时的按钮颜色。
|
||||
/// </summary>
|
||||
public Color32 legendUnableColor
|
||||
{
|
||||
get { return m_CustomLegendUnableColor != Color.clear ? m_CustomLegendUnableColor : m_LegendUnableColor; }
|
||||
set { m_CustomLegendUnableColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the axis text color.
|
||||
/// 坐标轴上标签的颜色。
|
||||
/// </summary>
|
||||
public Color32 axisTextColor
|
||||
{
|
||||
get { return m_CustomAxisTextColor != Color.clear ? m_CustomAxisTextColor : m_AxisTextColor; }
|
||||
set { m_CustomAxisTextColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of axis line.
|
||||
/// 坐标轴轴线的颜色。
|
||||
/// </summary>
|
||||
public Color32 axisLineColor
|
||||
{
|
||||
get { return m_CustomAxisLineColor != Color.clear ? m_CustomAxisLineColor : m_AxisLineColor; }
|
||||
set { m_CustomAxisLineColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of axis split line.
|
||||
/// 分割线的颜色,默认和坐标轴轴线颜色一致。
|
||||
/// </summary>
|
||||
public Color32 axisSplitLineColor
|
||||
{
|
||||
get { return m_CustomAxisSplitLineColor != Color.clear ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
|
||||
set { m_CustomAxisSplitLineColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the tooltip background color.
|
||||
/// 提示框背景颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipBackgroundColor
|
||||
{
|
||||
get { return m_CustomTooltipBackgroundColor != Color.clear ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
|
||||
set { m_CustomTooltipBackgroundColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of tooltip shadow crosshair indicator.
|
||||
/// 提示框阴影指示器的颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipFlagAreaColor
|
||||
{
|
||||
get { return m_CustomTooltipFlagAreaColor != Color.clear ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
|
||||
set { m_CustomTooltipFlagAreaColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of tooltip text.
|
||||
/// 提示框文字颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipTextColor
|
||||
{
|
||||
get { return m_CustomTooltipTextColor != Color.clear ? m_CustomTooltipTextColor : m_TooltipTextColor; }
|
||||
set { m_CustomTooltipTextColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of tooltip cross indicator's axis label.
|
||||
/// 提示框的十字指示器坐标轴标签的背景颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipLabelColor
|
||||
{
|
||||
get { return m_CustomTooltipLabelColor != Color.clear ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
|
||||
set { m_CustomTooltipLabelColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color tooltip indicator line.
|
||||
/// 提示框的指示线的颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipLineColor
|
||||
{
|
||||
get { return m_CustomTooltipLineColor != Color.clear ? m_CustomTooltipLineColor : m_TooltipLineColor; }
|
||||
set { m_CustomTooltipLineColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of datazoom text.
|
||||
/// 区域缩放的文字颜色。
|
||||
/// </summary>
|
||||
public Color32 dataZoomTextColor
|
||||
{
|
||||
get { return m_CustomDataZoomTextColor != Color.clear ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
|
||||
set { m_CustomDataZoomTextColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of datazoom line.
|
||||
/// 区域缩放的线条颜色。
|
||||
/// </summary>
|
||||
public Color32 dataZoomLineColor
|
||||
{
|
||||
get { return m_CustomDataZoomLineColor != Color.clear ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
|
||||
set { m_CustomDataZoomLineColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of datazoom selected area.
|
||||
/// 区域缩放的选中区域颜色。
|
||||
/// </summary>
|
||||
public Color32 dataZoomSelectedColor
|
||||
{
|
||||
get { return m_CustomDataZoomSelectedColor != Color.clear ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
|
||||
set { m_CustomDataZoomSelectedColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series.
|
||||
/// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。
|
||||
/// </summary>
|
||||
public List<Color32> colorPalette { set { m_CustomColorPalette = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color of the specified index from the palette.
|
||||
/// 获得调色盘对应系列索引的颜色值。
|
||||
/// </summary>
|
||||
/// <param name="index">编号索引</param>
|
||||
/// <returns>the color,or Color.clear when failed.颜色值,失败时返回Color.clear</returns>
|
||||
public Color32 GetColor(int index)
|
||||
{
|
||||
if (index < 0) index = 0;
|
||||
@@ -160,6 +259,12 @@ namespace XCharts
|
||||
}
|
||||
|
||||
Dictionary<int, string> _colorDic = new Dictionary<int, string>();
|
||||
/// <summary>
|
||||
/// Gets the hexadecimal color string of the specified index from the palette.
|
||||
/// 获得指定索引的十六进制颜色值字符串。
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public string GetColorStr(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
@@ -175,13 +280,18 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy all configurations from theme.
|
||||
/// 复制主题的所有配置。
|
||||
/// </summary>
|
||||
/// <param name="theme"></param>
|
||||
public void Copy(ThemeInfo theme)
|
||||
{
|
||||
m_Theme = theme.theme;
|
||||
m_Font = theme.m_Font;
|
||||
m_BackgroundColor = theme.m_BackgroundColor;
|
||||
m_LegendUnableColor = theme.m_LegendUnableColor;
|
||||
m_TextColor = theme.m_TextColor;
|
||||
m_TitleTextColor = theme.m_TitleTextColor;
|
||||
m_TitleSubTextColor = theme.m_TitleSubTextColor;
|
||||
m_LegendTextColor = theme.m_LegendTextColor;
|
||||
m_AxisTextColor = theme.m_AxisTextColor;
|
||||
@@ -201,13 +311,17 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all custom configurations.
|
||||
/// 重置,清除所有自定义配置。
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
m_Theme = Theme.Default;
|
||||
m_Font = null;
|
||||
m_BackgroundColor = Color.clear;
|
||||
m_LegendUnableColor = Color.clear;
|
||||
m_TextColor = Color.clear;
|
||||
m_TitleTextColor = Color.clear;
|
||||
m_TitleSubTextColor = Color.clear;
|
||||
m_LegendTextColor = Color.clear;
|
||||
m_AxisTextColor = Color.clear;
|
||||
@@ -226,6 +340,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// default theme.
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ThemeInfo Default
|
||||
{
|
||||
get
|
||||
@@ -236,7 +355,7 @@ namespace XCharts
|
||||
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
|
||||
m_BackgroundColor = new Color32(255, 255, 255, 255),
|
||||
m_LegendUnableColor = GetColor("#cccccc"),
|
||||
m_TextColor = GetColor("#514D4D"),
|
||||
m_TitleTextColor = GetColor("#514D4D"),
|
||||
m_TitleSubTextColor = GetColor("#514D4D"),
|
||||
m_LegendTextColor = GetColor("#eee"),
|
||||
m_AxisTextColor = GetColor("#514D4D"),
|
||||
@@ -281,6 +400,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// light theme.
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ThemeInfo Light
|
||||
{
|
||||
get
|
||||
@@ -291,7 +415,7 @@ namespace XCharts
|
||||
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
|
||||
m_BackgroundColor = new Color32(255, 255, 255, 255),
|
||||
m_LegendUnableColor = GetColor("#cccccc"),
|
||||
m_TextColor = GetColor("#514D4D"),
|
||||
m_TitleTextColor = GetColor("#514D4D"),
|
||||
m_TitleSubTextColor = GetColor("#514D4D"),
|
||||
m_LegendTextColor = GetColor("#514D4D"),
|
||||
m_AxisTextColor = GetColor("#514D4D"),
|
||||
@@ -340,6 +464,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dark theme.
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ThemeInfo Dark
|
||||
{
|
||||
get
|
||||
@@ -350,7 +479,7 @@ namespace XCharts
|
||||
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
|
||||
m_LegendUnableColor = GetColor("#cccccc"),
|
||||
m_BackgroundColor = new Color32(34, 34, 34, 255),
|
||||
m_TextColor = GetColor("#eee"),
|
||||
m_TitleTextColor = GetColor("#eee"),
|
||||
m_TitleSubTextColor = GetColor("#eee"),
|
||||
m_LegendTextColor = GetColor("#eee"),
|
||||
m_AxisTextColor = GetColor("#eee"),
|
||||
@@ -395,6 +524,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the html string to color.
|
||||
/// 将字符串颜色值转成Color。
|
||||
/// </summary>
|
||||
/// <param name="hexColorStr"></param>
|
||||
/// <returns></returns>
|
||||
public static Color32 GetColor(string hexColorStr)
|
||||
{
|
||||
Color color;
|
||||
@@ -427,7 +562,7 @@ namespace XCharts
|
||||
return m_Font == other.m_Font &&
|
||||
ChartHelper.IsValueEqualsColor(m_LegendUnableColor, other.m_LegendUnableColor) &&
|
||||
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.m_BackgroundColor) &&
|
||||
ChartHelper.IsValueEqualsColor(m_TextColor, other.m_TextColor) &&
|
||||
ChartHelper.IsValueEqualsColor(m_TitleTextColor, other.m_TitleTextColor) &&
|
||||
ChartHelper.IsValueEqualsColor(m_TitleSubTextColor, other.m_TitleSubTextColor) &&
|
||||
ChartHelper.IsValueEqualsColor(m_AxisTextColor, other.m_AxisTextColor) &&
|
||||
ChartHelper.IsValueEqualsColor(m_AxisLineColor, other.m_AxisLineColor) &&
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 337565e835799d44bb794677abf84498
|
||||
timeCreated: 1554221927
|
||||
licenseType: Free
|
||||
guid: abf18feda656241b0be785d95b57aab9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -3,10 +3,14 @@ using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Title component, including main title and subtitle.
|
||||
/// 标题组件,包含主标题和副标题。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Title : IPropertyChanged, IEquatable<Title>
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Text;
|
||||
[SerializeField] private int m_TextFontSize;
|
||||
[SerializeField] private string m_SubText;
|
||||
@@ -14,12 +18,44 @@ namespace XCharts
|
||||
[SerializeField] private float m_ItemGap;
|
||||
[SerializeField] private Location m_Location;
|
||||
|
||||
/// <summary>
|
||||
/// [default:true]
|
||||
/// Set this to false to prevent the title from showing.
|
||||
/// 是否显示标题组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// The main title text, supporting for \n for newlines.
|
||||
/// 主标题文本,支持使用 \n 换行。
|
||||
/// </summary>
|
||||
public string text { get { return m_Text; } set { m_Text = value; } }
|
||||
/// <summary>
|
||||
/// [default:16]
|
||||
/// main title font size.
|
||||
/// 主标题文字的字体大小。
|
||||
/// </summary>
|
||||
public int textFontSize { get { return m_TextFontSize; } set { m_TextFontSize = value; } }
|
||||
/// <summary>
|
||||
/// Subtitle text, supporting for \n for newlines.
|
||||
/// 副标题文本,支持使用 \n 换行。
|
||||
/// </summary>
|
||||
public string subText { get { return m_SubText; } set { m_Text = value; } }
|
||||
/// <summary>
|
||||
/// [default:14]
|
||||
/// subtitle font size.
|
||||
/// 副标题文字的字体大小。
|
||||
/// </summary>
|
||||
public int subTextFontSize { get { return m_SubTextFontSize; } set { m_SubTextFontSize = value; } }
|
||||
/// <summary>
|
||||
/// [default:14]
|
||||
/// The gap between the main title and subtitle.
|
||||
/// 主副标题之间的间距。
|
||||
/// </summary>
|
||||
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
|
||||
/// <summary>
|
||||
/// The location of title component.
|
||||
/// 标题显示位置。
|
||||
/// </summary>
|
||||
public Location location { get { return m_Location; } set { m_Location = value; } }
|
||||
|
||||
public static Title defaultTitle
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e41a7f82b5a931408f301257fbc09e2
|
||||
timeCreated: 1554222818
|
||||
licenseType: Free
|
||||
guid: d24bcb046d3e74a898fc64f02a2a5985
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,79 +1,105 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Tooltip component.
|
||||
/// 提示框组件
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class Tooltip
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of triggering.
|
||||
/// </summary>
|
||||
public enum Trigger
|
||||
{
|
||||
/// <summary>
|
||||
/// Triggered by axes, which is mainly used for charts that have category axes,
|
||||
/// like bar charts or line charts.
|
||||
/// </summary>
|
||||
Axis,
|
||||
/// <summary>
|
||||
/// Triggered by data item, which is mainly used for charts that don't have a
|
||||
/// category axis like scatter charts or pie charts.
|
||||
/// </summary>
|
||||
Item
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicator type.
|
||||
/// 阴影指示器。
|
||||
/// </summary>
|
||||
public enum Type
|
||||
{
|
||||
/// <summary>
|
||||
/// line indicator.
|
||||
/// 直线指示器
|
||||
/// </summary>
|
||||
Line,
|
||||
/// <summary>
|
||||
/// shadow crosshair indicator.
|
||||
/// 阴影指示器
|
||||
/// </summary>
|
||||
Shadow,
|
||||
/// <summary>
|
||||
/// no indicator displayed.
|
||||
/// 无指示器
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes.
|
||||
/// 十字准星指示器。坐标轴显示Label和交叉线。
|
||||
/// </summary>
|
||||
Corss
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Type m_Type;
|
||||
[SerializeField] private Trigger m_Trigger;
|
||||
|
||||
[NonSerialized] private GameObject m_GameObject;
|
||||
[NonSerialized] private GameObject m_Content;
|
||||
[NonSerialized] private Text m_ContentText;
|
||||
[NonSerialized] private RectTransform m_ContentRect;
|
||||
private GameObject m_GameObject;
|
||||
private GameObject m_Content;
|
||||
private Text m_ContentText;
|
||||
private RectTransform m_ContentRect;
|
||||
private List<int> lastDataIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the tooltip component.
|
||||
/// 是否显示提示框组件。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; SetActive(value); } }
|
||||
/// <summary>
|
||||
/// Indicator type.
|
||||
/// 提示框指示器类型。
|
||||
/// </summary>
|
||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
public Trigger trigger { get { return m_Trigger; } set { m_Trigger = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// The data index currently indicated by Tooltip.
|
||||
/// 当前提示框所指示的数据项索引。
|
||||
/// </summary>
|
||||
public List<int> dataIndex { get; set; }
|
||||
public List<int> lastDataIndex { get; set; }
|
||||
/// <summary>
|
||||
/// the value for x indicator label.
|
||||
/// 指示器X轴上要显示的值。
|
||||
/// </summary>
|
||||
public float[] xValues { get; set; }
|
||||
/// <summary>
|
||||
/// the value for y indicator label.
|
||||
/// 指示器Y轴上要显示的值。
|
||||
/// </summary>
|
||||
public float[] yValues { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// the current pointer position.
|
||||
/// 当前鼠标位置。
|
||||
/// </summary>
|
||||
public Vector2 pointerPos { get; set; }
|
||||
/// <summary>
|
||||
/// the width of tooltip.
|
||||
/// 提示框宽。
|
||||
/// </summary>
|
||||
public float width { get { return m_ContentRect.sizeDelta.x; } }
|
||||
/// <summary>
|
||||
/// the height of tooltip.
|
||||
/// 提示框高。
|
||||
/// </summary>
|
||||
public float height { get { return m_ContentRect.sizeDelta.y; } }
|
||||
public bool isInited { get { return m_GameObject != null; } }
|
||||
/// <summary>
|
||||
/// Whether the tooltip has been initialized.
|
||||
/// 提示框是否已初始化。
|
||||
/// </summary>
|
||||
public bool inited { get { return m_GameObject != null; } }
|
||||
/// <summary>
|
||||
/// the gameObject of tooltip.
|
||||
/// 提示框的gameObject。
|
||||
/// </summary>
|
||||
public GameObject gameObject { get { return m_GameObject; } }
|
||||
|
||||
public static Tooltip defaultTooltip
|
||||
@@ -92,12 +118,20 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定提示框gameObject
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
public void SetObj(GameObject obj)
|
||||
{
|
||||
m_GameObject = obj;
|
||||
m_GameObject.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定提示框的文本框gameObject
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
public void SetContentObj(GameObject content)
|
||||
{
|
||||
m_Content = content;
|
||||
@@ -105,17 +139,29 @@ namespace XCharts
|
||||
m_ContentText = m_Content.GetComponentInChildren<Text>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keep Tooltiop displayed at the top.
|
||||
/// 保持Tooltiop显示在最顶上
|
||||
/// </summary>
|
||||
public void UpdateToTop()
|
||||
{
|
||||
int count = m_GameObject.transform.parent.childCount;
|
||||
m_GameObject.GetComponent<RectTransform>().SetSiblingIndex(count - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本背景色
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public void SetContentBackgroundColor(Color color)
|
||||
{
|
||||
m_Content.GetComponent<Image>().color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本字体颜色
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public void SetContentTextColor(Color color)
|
||||
{
|
||||
if (m_ContentText)
|
||||
@@ -124,6 +170,10 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框文本内容
|
||||
/// </summary>
|
||||
/// <param name="txt"></param>
|
||||
public void UpdateContentText(string txt)
|
||||
{
|
||||
if (m_ContentText)
|
||||
@@ -134,6 +184,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除提示框指示数据
|
||||
/// </summary>
|
||||
public void ClearValue()
|
||||
{
|
||||
dataIndex[0] = dataIndex[1] = -1;
|
||||
@@ -141,11 +194,19 @@ namespace XCharts
|
||||
yValues[0] = yValues[1] = -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提示框是否显示
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsActive()
|
||||
{
|
||||
return m_GameObject != null && m_GameObject.activeInHierarchy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示框是否显示
|
||||
/// </summary>
|
||||
/// <param name="flag"></param>
|
||||
public void SetActive(bool flag)
|
||||
{
|
||||
lastDataIndex[0] = lastDataIndex[1] = -1;
|
||||
@@ -153,12 +214,20 @@ namespace XCharts
|
||||
m_GameObject.SetActive(flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新文本框位置
|
||||
/// </summary>
|
||||
/// <param name="pos"></param>
|
||||
public void UpdateContentPos(Vector2 pos)
|
||||
{
|
||||
if (m_Content)
|
||||
m_Content.transform.localPosition = pos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得当前提示框的位置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Vector3 GetContentPos()
|
||||
{
|
||||
if (m_Content)
|
||||
@@ -167,24 +236,41 @@ namespace XCharts
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the data item indicated by tooltip has changed.
|
||||
/// 提示框所指示的数据项是否发生变化。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsDataIndexChanged()
|
||||
{
|
||||
return dataIndex[0] != lastDataIndex[0] ||
|
||||
dataIndex[1] != lastDataIndex[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前索引缓存
|
||||
/// </summary>
|
||||
public void UpdateLastDataIndex()
|
||||
{
|
||||
lastDataIndex[0] = dataIndex[0];
|
||||
lastDataIndex[1] = dataIndex[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前提示框是否选中数据项
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsSelected()
|
||||
{
|
||||
return dataIndex[0] >= 0 || dataIndex[1] >= 0;
|
||||
}
|
||||
|
||||
public bool IsSelectedDataIndex(int index)
|
||||
/// <summary>
|
||||
/// 指定索引的数据项是否被提示框选中
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsSelected(int index)
|
||||
{
|
||||
return dataIndex[0] == index || dataIndex[1] == index;
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 015f1aafb9c2e8940be9ef79b984b843
|
||||
timeCreated: 1554222818
|
||||
licenseType: Free
|
||||
guid: 1ffc80b624e394046a373c94978bbb04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 从json导入数据接口
|
||||
/// </summary>
|
||||
public interface IJsonData
|
||||
{
|
||||
void ParseJsonData(string json);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 属性变更接口
|
||||
/// </summary>
|
||||
public interface IPropertyChanged
|
||||
{
|
||||
void OnChanged();
|
||||
|
||||
@@ -3,25 +3,61 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to axis label.
|
||||
/// 坐标轴刻度标签的相关设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AxisLabel
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private bool m_Inside;
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private int m_Interval = 0;
|
||||
[SerializeField] private bool m_Inside = false;
|
||||
[SerializeField] private float m_Rotate;
|
||||
[SerializeField] private float m_Margin;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] private int m_FontSize;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis label from appearing.
|
||||
/// 是否显示刻度标签。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// The display interval of the axis label.
|
||||
/// 坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
/// </summary>
|
||||
public int interval { get { return m_Interval; } set { m_Interval = value; } }
|
||||
/// <summary>
|
||||
/// Set this to true so the axis labels face the inside direction.
|
||||
/// 刻度标签是否朝内,默认朝外。
|
||||
/// </summary>
|
||||
public bool inside { get { return m_Inside; } set { m_Inside = value; } }
|
||||
/// <summary>
|
||||
/// Rotation degree of axis label, which is especially useful when there is no enough space for category axis.
|
||||
/// 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠。
|
||||
/// </summary>
|
||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
||||
/// <summary>
|
||||
/// The margin between the axis label and the axis line.
|
||||
/// 刻度标签与轴线之间的距离。
|
||||
/// </summary>
|
||||
public float margin { get { return m_Margin; } set { m_Margin = value; } }
|
||||
/// <summary>
|
||||
/// the color of axis label text.
|
||||
/// 刻度标签文字的颜色,默认取Theme的axisTextColor。
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// font size.
|
||||
/// 文字的字体大小。
|
||||
/// </summary>
|
||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||
/// <summary>
|
||||
/// font style.
|
||||
/// 文字字体的风格。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||
|
||||
public static AxisLabel defaultAxisLabel
|
||||
|
||||
@@ -2,23 +2,61 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
/// <summary>
|
||||
/// Settings related to axis line.
|
||||
/// 坐标轴的分隔线。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AxisLine
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private bool m_OnZero;
|
||||
[SerializeField] private float m_Width = 0.6f;
|
||||
[SerializeField] private bool m_Symbol;
|
||||
[SerializeField] private float m_SymbolWidth;
|
||||
[SerializeField] private float m_SymbolHeight;
|
||||
[SerializeField] private float m_SymbolOffset;
|
||||
[SerializeField] private float m_SymbolDent;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis line from showing.
|
||||
/// 是否显示坐标轴轴线。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// When mutiple axes exists, this option can be used to specify which axis can be "onZero" to.
|
||||
/// X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
||||
/// </summary>
|
||||
public bool onZero { get { return m_OnZero; } set { m_OnZero = value; } }
|
||||
/// <summary>
|
||||
/// line style line width.
|
||||
/// 坐标轴线线宽。
|
||||
/// </summary>
|
||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show the arrow symbol of axis.
|
||||
/// 是否显示箭头。
|
||||
/// </summary>
|
||||
public bool symbol { get { return m_Symbol; } set { m_Symbol = value; } }
|
||||
/// <summary>
|
||||
/// the width of arrow symbol.
|
||||
/// 箭头宽。
|
||||
/// </summary>
|
||||
public float symbolWidth { get { return m_SymbolWidth; } set { m_SymbolWidth = value; } }
|
||||
/// <summary>
|
||||
/// the height of arrow symbol.
|
||||
/// 箭头高。
|
||||
/// </summary>
|
||||
public float symbolHeight { get { return m_SymbolHeight; } set { m_SymbolHeight = value; } }
|
||||
/// <summary>
|
||||
/// the offset of arrow symbol.
|
||||
/// 箭头偏移。
|
||||
/// </summary>
|
||||
public float symbolOffset { get { return m_SymbolOffset; } set { m_SymbolOffset = value; } }
|
||||
/// <summary>
|
||||
/// the dent of arrow symbol.
|
||||
/// 箭头的凹陷程度。
|
||||
/// </summary>
|
||||
public float symbolDent { get { return m_SymbolDent; } set { m_SymbolDent = value; } }
|
||||
|
||||
public static AxisLine defaultAxisLine
|
||||
@@ -29,6 +67,7 @@ namespace XCharts
|
||||
{
|
||||
m_Show = true,
|
||||
m_OnZero = true,
|
||||
m_Width = 0.7f,
|
||||
m_Symbol = false,
|
||||
m_SymbolWidth = 10,
|
||||
m_SymbolHeight = 15,
|
||||
|
||||
@@ -3,10 +3,17 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// the name of axis.
|
||||
/// 坐标轴名称。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AxisName
|
||||
{
|
||||
[Serializable]
|
||||
/// <summary>
|
||||
/// the location of axis name.
|
||||
/// 坐标轴名称显示位置。
|
||||
/// </summary>
|
||||
public enum Location
|
||||
{
|
||||
Start,
|
||||
@@ -22,13 +29,45 @@ namespace XCharts
|
||||
[SerializeField] private int m_FontSize;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show axis name.
|
||||
/// 是否显示坐标名称。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// the name of axis.
|
||||
/// 坐标轴名称。
|
||||
/// </summary>
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
/// <summary>
|
||||
/// Location of axis name.
|
||||
/// 坐标轴名称显示位置。
|
||||
/// </summary>
|
||||
public Location location { get { return m_Location; } set { m_Location = value; } }
|
||||
/// <summary>
|
||||
/// Gap between axis name and axis line.
|
||||
/// 坐标轴名称与轴线之间的距离。
|
||||
/// </summary>
|
||||
public float gap { get { return m_Gap; } set { m_Gap = value; } }
|
||||
/// <summary>
|
||||
/// Rotation of axis name.
|
||||
/// 坐标轴名字旋转,角度值。
|
||||
/// </summary>
|
||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
||||
/// <summary>
|
||||
/// Color of axis name.
|
||||
/// 坐标轴名称的文字颜色。
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// axis name font size.
|
||||
/// 坐标轴名称的文字大小。
|
||||
/// </summary>
|
||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||
/// <summary>
|
||||
/// axis name font style.
|
||||
/// 坐标轴名称的文字风格。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||
|
||||
public static AxisName defaultAxisName
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Split area of axis in grid area, not shown by default.
|
||||
/// 坐标轴在 grid 区域中的分隔区域,默认不显示。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AxisSplitArea
|
||||
@@ -15,15 +16,15 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Set this to true to show the splitArea.
|
||||
/// 是否显示分隔区域。
|
||||
/// </summary>
|
||||
/// <value>false</value>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// Color of split area. SplitArea color could also be set in color array,
|
||||
/// which the split lines would take as their colors in turns.
|
||||
/// Dark and light colors in turns are used by default.
|
||||
/// 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
||||
/// </summary>
|
||||
/// <value>['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)']</value>
|
||||
public List<Color> color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public static AxisSplitArea defaultSplitArea
|
||||
|
||||
@@ -3,6 +3,10 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to axis tick.
|
||||
/// 坐标轴刻度相关设置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AxisTick
|
||||
{
|
||||
@@ -11,9 +15,25 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Inside;
|
||||
[SerializeField] private float m_Length;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis tick from showing.
|
||||
/// 是否显示坐标轴刻度。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
|
||||
/// 类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
||||
/// </summary>
|
||||
public bool alignWithLabel { get { return m_AlignWithLabel; } set { m_AlignWithLabel = value; } }
|
||||
/// <summary>
|
||||
/// Set this to true so the axis labels face the inside direction.
|
||||
/// 坐标轴刻度是否朝内,默认朝外。
|
||||
/// </summary>
|
||||
public bool inside { get { return m_Inside; } set { m_Inside = value; } }
|
||||
/// <summary>
|
||||
/// The length of the axis tick.
|
||||
/// 坐标轴刻度的长度。
|
||||
/// </summary>
|
||||
public float length { get { return m_Length; } set { m_Length = value; } }
|
||||
|
||||
public static AxisTick defaultTick
|
||||
|
||||
@@ -6,9 +6,19 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// the layout is horizontal or vertical.
|
||||
/// 垂直还是水平布局方式。
|
||||
/// </summary>
|
||||
public enum Orient
|
||||
{
|
||||
/// <summary>
|
||||
/// 水平
|
||||
/// </summary>
|
||||
Horizonal,
|
||||
/// <summary>
|
||||
/// 垂直
|
||||
/// </summary>
|
||||
Vertical
|
||||
}
|
||||
|
||||
@@ -167,22 +177,22 @@ namespace XCharts
|
||||
ChartHelper.HideAllObject(titleObject, s_TitleObjectName);
|
||||
|
||||
Text titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform,
|
||||
m_ThemeInfo.font, m_ThemeInfo.textColor, anchor, anchorMin, anchorMax, pivot,
|
||||
m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot,
|
||||
new Vector2(titleWid, m_Title.textFontSize), m_Title.textFontSize);
|
||||
|
||||
titleText.alignment = anchor;
|
||||
titleText.gameObject.SetActive(m_Title.show);
|
||||
titleText.transform.localPosition = Vector2.zero;
|
||||
titleText.text = m_Title.text;
|
||||
titleText.text = m_Title.text.Replace("\\n", "\n");
|
||||
|
||||
Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform,
|
||||
m_ThemeInfo.font, m_ThemeInfo.textColor, anchor, anchorMin, anchorMax, pivot,
|
||||
m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot,
|
||||
new Vector2(titleWid, m_Title.subTextFontSize), m_Title.subTextFontSize);
|
||||
|
||||
subText.alignment = anchor;
|
||||
subText.gameObject.SetActive(m_Title.show && !string.IsNullOrEmpty(m_Title.subText));
|
||||
subText.transform.localPosition = subTitlePosition;
|
||||
subText.text = m_Title.subText;
|
||||
subText.text = m_Title.subText.Replace("\\n", "\n");
|
||||
}
|
||||
|
||||
private void InitLegend()
|
||||
@@ -221,7 +231,7 @@ namespace XCharts
|
||||
Button btn = ChartHelper.AddButtonObject(s_LegendObjectName + "_" + i + "_" + legendName, legendObject.transform,
|
||||
m_ThemeInfo.font, m_Legend.itemFontSize, m_ThemeInfo.legendTextColor, anchor,
|
||||
anchorMin, anchorMax, pivot, new Vector2(m_Legend.itemWidth, m_Legend.itemHeight));
|
||||
var bgColor = IsLegendActive(legendName) ? m_ThemeInfo.GetColor(i) : m_ThemeInfo.legendUnableColor;
|
||||
var bgColor = IsActiveByLegend(legendName) ? m_ThemeInfo.GetColor(i) : m_ThemeInfo.legendUnableColor;
|
||||
m_Legend.SetButton(legendName, btn, datas.Count);
|
||||
m_Legend.UpdateButtonColor(legendName, bgColor);
|
||||
btn.GetComponentInChildren<Text>().text = legendName;
|
||||
@@ -366,7 +376,7 @@ namespace XCharts
|
||||
|
||||
private void CheckTooltip()
|
||||
{
|
||||
if (!m_Tooltip.show || !m_Tooltip.isInited)
|
||||
if (!m_Tooltip.show || !m_Tooltip.inited)
|
||||
{
|
||||
|
||||
if (m_Tooltip.dataIndex[0] != 0 || m_Tooltip.dataIndex[1] != 0)
|
||||
|
||||
@@ -3,18 +3,47 @@ using System.Collections.Generic;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// The base class of all charts.
|
||||
/// 所有Chart的基类,不可直接使用。
|
||||
/// </summary>
|
||||
public partial class BaseChart
|
||||
{
|
||||
/// <summary>
|
||||
/// The title setting of chart.
|
||||
/// 标题组件
|
||||
/// </summary>
|
||||
public Title title { get { return m_Title; } }
|
||||
/// <summary>
|
||||
/// The legend setting of chart.
|
||||
/// 图例组件
|
||||
/// </summary>
|
||||
public Legend legend { get { return m_Legend; } }
|
||||
/// <summary>
|
||||
/// The tooltip setting of chart.
|
||||
/// 提示框组件
|
||||
/// </summary>
|
||||
public Tooltip tooltip { get { return m_Tooltip; } }
|
||||
/// <summary>
|
||||
/// The series setting of chart.
|
||||
/// 系列列表
|
||||
/// </summary>
|
||||
public Series series { get { return m_Series; } }
|
||||
|
||||
/// <summary>
|
||||
/// The width of chart.
|
||||
/// 图表的宽
|
||||
/// </summary>
|
||||
public float chartWidth { get { return m_ChartWidth; } }
|
||||
/// <summary>
|
||||
/// The height of chart.
|
||||
/// 图表的高
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float chartHeight { get { return m_ChartHeight; } }
|
||||
|
||||
/// <summary>
|
||||
/// The min number of data to show in chart.
|
||||
/// 图表所显示数据的最小索引
|
||||
/// </summary>
|
||||
public int minShowDataNumber
|
||||
{
|
||||
@@ -24,6 +53,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// The max number of data to show in chart.
|
||||
/// 图表所显示数据的最大索引
|
||||
/// </summary>
|
||||
public int maxShowDataNumber
|
||||
{
|
||||
@@ -35,6 +65,7 @@ namespace XCharts
|
||||
/// The max number of serie and axis data cache.
|
||||
/// The first data will be remove when the size of serie and axis data is larger then maxCacheDataNumber.
|
||||
/// default:0,unlimited.
|
||||
/// 图表每个系列中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||
/// </summary>
|
||||
public int maxCacheDataNumber
|
||||
{
|
||||
@@ -44,6 +75,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Set the size of chart.
|
||||
/// 设置图表的大小。
|
||||
/// </summary>
|
||||
/// <param name="width">width</param>
|
||||
/// <param name="height">height</param>
|
||||
@@ -60,6 +92,7 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// Remove all series and legend data.
|
||||
/// It just emptying all of serie's data without emptying the list of series.
|
||||
/// 清除所有数据,系列中只是移除数据,列表会保留。
|
||||
/// </summary>
|
||||
public virtual void ClearData()
|
||||
{
|
||||
@@ -68,8 +101,21 @@ namespace XCharts
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data from series and legend.
|
||||
/// The series list is also cleared.
|
||||
/// 清除所有系列和图例数据,系列的列表也会被清除。
|
||||
/// </summary>
|
||||
public virtual void RemoveData()
|
||||
{
|
||||
m_Legend.ClearData();
|
||||
m_Series.RemoveAll();
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove legend and serie by name.
|
||||
/// 清除指定系列名称的数据。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
public virtual void RemoveData(string serieName)
|
||||
@@ -79,19 +125,9 @@ namespace XCharts
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data from series and legend.
|
||||
/// The series list is also cleared.
|
||||
/// </summary>
|
||||
public virtual void RemoveData()
|
||||
{
|
||||
m_Legend.ClearData();
|
||||
m_Series.RemoveAll();
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a serie to serie list.
|
||||
/// 添加一个系列到系列列表中。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <param name="type">the type of serie</param>
|
||||
@@ -106,6 +142,7 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// Add a data to serie.
|
||||
/// If serieName doesn't exist in legend,will be add to legend.
|
||||
/// 添加一个数据到指定的系列中。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <param name="data">the data to add</param>
|
||||
@@ -121,6 +158,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Add a data to serie.
|
||||
/// 添加一个数据到指定的系列中。
|
||||
/// </summary>
|
||||
/// <param name="serieIndex">the index of serie</param>
|
||||
/// <param name="data">the data to add</param>
|
||||
@@ -135,6 +173,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Add an arbitray dimension data to serie,such as (x,y,z,...).
|
||||
/// 添加多维数据(x,y,z...)到指定的系列中。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
|
||||
@@ -149,6 +188,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Add an arbitray dimension data to serie,such as (x,y,z,...).
|
||||
/// 添加多维数据(x,y,z...)到指定的系列中。
|
||||
/// </summary>
|
||||
/// <param name="serieIndex">the index of serie,index starts at 0</param>
|
||||
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
|
||||
@@ -163,6 +203,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Add a (x,y) data to serie.
|
||||
/// 添加(x,y)数据到指定系列中。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <param name="xValue">x data</param>
|
||||
@@ -178,6 +219,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Add a (x,y) data to serie.
|
||||
/// 添加(x,y)数据到指定系列中。
|
||||
/// </summary>
|
||||
/// <param name="serieIndex">the index of serie</param>
|
||||
/// <param name="xValue">x data</param>
|
||||
@@ -193,6 +235,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Update serie data by serie name.
|
||||
/// 更新指定系列中的指定索引数据。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <param name="value">the data will be update</param>
|
||||
@@ -205,6 +248,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Update serie data by serie index.
|
||||
/// 更新指定系列中的指定索引数据。
|
||||
/// </summary>
|
||||
/// <param name="serieIndex">the index of serie</param>
|
||||
/// <param name="value">the data will be update</param>
|
||||
@@ -216,7 +260,8 @@ namespace XCharts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show serie and legend.
|
||||
/// Whether to show serie.
|
||||
/// 设置指定系列是否显示。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <param name="active">Active or not</param>
|
||||
@@ -230,7 +275,8 @@ namespace XCharts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show serie and legend.
|
||||
/// Whether to show serie.
|
||||
/// 设置指定系列是否显示。
|
||||
/// </summary>
|
||||
/// <param name="serieIndex">the index of serie</param>
|
||||
/// <param name="active">Active or not</param>
|
||||
@@ -247,6 +293,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Whether serie is activated.
|
||||
/// 获取指定系列是否显示。
|
||||
/// </summary>
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <returns>True when activated</returns>
|
||||
@@ -257,6 +304,7 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Whether serie is activated.
|
||||
/// 获取指定系列是否显示。
|
||||
/// </summary>
|
||||
/// <param name="serieIndex">the index of serie</param>
|
||||
/// <returns>True when activated</returns>
|
||||
@@ -265,13 +313,20 @@ namespace XCharts
|
||||
return m_Series.IsActive(serieIndex);
|
||||
}
|
||||
|
||||
public virtual bool IsLegendActive(string legendName)
|
||||
/// <summary>
|
||||
/// Whether serie is activated.
|
||||
/// 获得指定图例名字的系列是否显示。
|
||||
/// </summary>
|
||||
/// <param name="legendName"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool IsActiveByLegend(string legendName)
|
||||
{
|
||||
return IsActive(legendName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Redraw chart next frame.
|
||||
/// Redraw chart in next frame.
|
||||
/// 在下一帧刷新图表。
|
||||
/// </summary>
|
||||
public void RefreshChart()
|
||||
{
|
||||
@@ -279,7 +334,8 @@ namespace XCharts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update chart theme
|
||||
/// Update chart theme.
|
||||
/// 切换图表主题。
|
||||
/// </summary>
|
||||
/// <param name="theme">theme</param>
|
||||
public void UpdateTheme(Theme theme)
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class Coordinate : IEquatable<Coordinate>
|
||||
{
|
||||
[SerializeField] private float m_Left;
|
||||
[SerializeField] private float m_Right;
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
[SerializeField] private float m_Tickness;
|
||||
[SerializeField] private int m_FontSize;
|
||||
|
||||
public float left { get { return m_Left; } set { m_Left = value; } }
|
||||
public float right { get { return m_Right; } set { m_Right = value; } }
|
||||
public float top { get { return m_Top; } set { m_Top = value; } }
|
||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
||||
public float tickness { get { return m_Tickness; } set { m_Tickness = value; } }
|
||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||
|
||||
public static Coordinate defaultCoordinate
|
||||
{
|
||||
get
|
||||
{
|
||||
var coordinate = new Coordinate
|
||||
{
|
||||
m_Left = 50,
|
||||
m_Right = 30,
|
||||
m_Top = 50,
|
||||
m_Bottom = 30,
|
||||
m_Tickness = 0.6f,
|
||||
m_FontSize = 16,
|
||||
};
|
||||
return coordinate;
|
||||
}
|
||||
}
|
||||
public void Copy(Coordinate other)
|
||||
{
|
||||
m_Left = other.left;
|
||||
m_Right = other.right;
|
||||
m_Top = other.top;
|
||||
m_Bottom = other.bottom;
|
||||
m_Tickness = other.tickness;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (obj is Coordinate)
|
||||
{
|
||||
return Equals((Coordinate)obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(Coordinate other)
|
||||
{
|
||||
if (ReferenceEquals(null, other))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_Left == other.left &&
|
||||
m_Right == other.right &&
|
||||
m_Top == other.top &&
|
||||
m_Bottom == other.bottom &&
|
||||
m_Tickness == other.tickness &&
|
||||
m_FontSize == other.fontSize;
|
||||
}
|
||||
|
||||
public static bool operator ==(Coordinate left, Coordinate right)
|
||||
{
|
||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(Coordinate left, Coordinate right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class CoordinateChart : BaseChart
|
||||
public partial class CoordinateChart : BaseChart
|
||||
{
|
||||
private static readonly string s_DefaultAxisY = "axis_y";
|
||||
private static readonly string s_DefaultAxisX = "axis_x";
|
||||
private static readonly string s_DefaultDataZoom = "datazoom";
|
||||
|
||||
[SerializeField] protected Coordinate m_Coordinate = Coordinate.defaultCoordinate;
|
||||
[SerializeField] protected Grid m_Grid = Grid.defaultGrid;
|
||||
[SerializeField] protected List<XAxis> m_XAxises = new List<XAxis>();
|
||||
[SerializeField] protected List<YAxis> m_YAxises = new List<YAxis>();
|
||||
[SerializeField] protected DataZoom m_DataZoom = DataZoom.defaultDataZoom;
|
||||
@@ -22,85 +22,9 @@ namespace XCharts
|
||||
private bool m_DataZoomEndDrag;
|
||||
private float m_DataZoomLastStartIndex;
|
||||
private float m_DataZoomLastEndIndex;
|
||||
|
||||
private List<XAxis> m_CheckXAxises = new List<XAxis>();
|
||||
private List<YAxis> m_CheckYAxises = new List<YAxis>();
|
||||
private Coordinate m_CheckCoordinate = Coordinate.defaultCoordinate;
|
||||
|
||||
public float coordinateX { get { return m_Coordinate.left; } }
|
||||
public float coordinateY { get { return m_Coordinate.bottom; } }
|
||||
public float coordinateWid { get { return chartWidth - m_Coordinate.left - m_Coordinate.right; } }
|
||||
public float coordinateHig { get { return chartHeight - m_Coordinate.top - m_Coordinate.bottom; } }
|
||||
public List<XAxis> xAxises { get { return m_XAxises; } }
|
||||
public List<YAxis> yAxises { get { return m_YAxises; } }
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data from series,legend and axis.
|
||||
/// It just emptying all of serie's data without emptying the list of series.
|
||||
/// </summary>
|
||||
public override void ClearData()
|
||||
{
|
||||
base.ClearData();
|
||||
ClearAxisData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data from series,legend and axis.
|
||||
/// The series list is also cleared.
|
||||
/// </summary>
|
||||
public override void RemoveData()
|
||||
{
|
||||
base.RemoveData();
|
||||
ClearAxisData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data of axises.
|
||||
/// </summary>
|
||||
public void ClearAxisData()
|
||||
{
|
||||
foreach (var item in m_XAxises) item.data.Clear();
|
||||
foreach (var item in m_YAxises) item.data.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a category data to xAxis.
|
||||
/// </summary>
|
||||
/// <param name="category">the category data</param>
|
||||
/// <param name="xAxisIndex">which xAxis should category add to</param>
|
||||
public void AddXAxisData(string category, int xAxisIndex = 0)
|
||||
{
|
||||
m_XAxises[xAxisIndex].AddData(category, m_MaxCacheDataNumber);
|
||||
OnXAxisChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a category data to yAxis.
|
||||
/// </summary>
|
||||
/// <param name="category">the category data</param>
|
||||
/// <param name="yAxisIndex">which yAxis should category add to</param>
|
||||
public void AddYAxisData(string category, int yAxisIndex = 0)
|
||||
{
|
||||
m_YAxises[yAxisIndex].AddData(category, m_MaxCacheDataNumber);
|
||||
OnYAxisChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether is Cartesian coordinates, reutrn true when all the show axis is `Value` type.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsCartesian()
|
||||
{
|
||||
foreach (var axis in m_XAxises)
|
||||
{
|
||||
if (axis.show && !axis.IsValue()) return false;
|
||||
}
|
||||
foreach (var axis in m_YAxises)
|
||||
{
|
||||
if (axis.show && !axis.IsValue()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private Grid m_CheckCoordinate = Grid.defaultGrid;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -127,7 +51,7 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_Coordinate = Coordinate.defaultCoordinate;
|
||||
m_Grid = Grid.defaultGrid;
|
||||
m_XAxises.Clear();
|
||||
m_YAxises.Clear();
|
||||
Awake();
|
||||
@@ -151,7 +75,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var isCartesian = IsCartesian();
|
||||
var isCartesian = IsValue();
|
||||
for (int i = 0; i < m_XAxises.Count; i++)
|
||||
{
|
||||
var xAxis = m_XAxises[i];
|
||||
@@ -250,7 +174,7 @@ namespace XCharts
|
||||
base.RefreshTooltip();
|
||||
int index;
|
||||
Axis tempAxis;
|
||||
bool isCartesian = IsCartesian();
|
||||
bool isCartesian = IsValue();
|
||||
if (isCartesian)
|
||||
{
|
||||
index = m_Tooltip.dataIndex[0];
|
||||
@@ -440,14 +364,14 @@ namespace XCharts
|
||||
{
|
||||
txt = ChartHelper.AddTextObject(objName + i, axisObj.transform,
|
||||
m_ThemeInfo.font, labelColor, TextAnchor.MiddleLeft, Vector2.zero,
|
||||
Vector2.zero, new Vector2(0, 0.5f), new Vector2(m_Coordinate.left, 20),
|
||||
Vector2.zero, new Vector2(0, 0.5f), new Vector2(m_Grid.left, 20),
|
||||
yAxis.axisLabel.fontSize, yAxis.axisLabel.rotate, yAxis.axisLabel.fontStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
txt = ChartHelper.AddTextObject(objName + i, axisObj.transform,
|
||||
m_ThemeInfo.font, labelColor, TextAnchor.MiddleRight, Vector2.zero,
|
||||
Vector2.zero, new Vector2(1, 0.5f), new Vector2(m_Coordinate.left, 20),
|
||||
Vector2.zero, new Vector2(1, 0.5f), new Vector2(m_Grid.left, 20),
|
||||
yAxis.axisLabel.fontSize, yAxis.axisLabel.rotate, yAxis.axisLabel.fontStyle);
|
||||
}
|
||||
|
||||
@@ -667,9 +591,9 @@ namespace XCharts
|
||||
|
||||
private void CheckCoordinate()
|
||||
{
|
||||
if (m_CheckCoordinate != m_Coordinate)
|
||||
if (m_CheckCoordinate != m_Grid)
|
||||
{
|
||||
m_CheckCoordinate.Copy(m_Coordinate);
|
||||
m_CheckCoordinate.Copy(m_Grid);
|
||||
OnCoordinateChanged();
|
||||
}
|
||||
}
|
||||
@@ -780,6 +704,7 @@ namespace XCharts
|
||||
|
||||
private void DrawCoordinate(VertexHelper vh)
|
||||
{
|
||||
DrawGrid(vh);
|
||||
for (int i = 0; i < m_XAxises.Count; i++)
|
||||
{
|
||||
DrawXAxisTickAndSplit(vh, i, m_XAxises[i]);
|
||||
@@ -798,6 +723,18 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGrid(VertexHelper vh)
|
||||
{
|
||||
if (m_Grid.show && m_Grid.backgroundColor != Color.clear)
|
||||
{
|
||||
var p1 = new Vector2(coordinateX, coordinateY);
|
||||
var p2 = new Vector2(coordinateX, coordinateY + coordinateHig);
|
||||
var p3 = new Vector2(coordinateX + coordinateWid, coordinateY + coordinateHig);
|
||||
var p4 = new Vector2(coordinateX + coordinateWid, coordinateY);
|
||||
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_Grid.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawYAxisTickAndSplit(VertexHelper vh, int yAxisIndex, YAxis yAxis)
|
||||
{
|
||||
if (yAxis.show)
|
||||
@@ -834,11 +771,11 @@ namespace XCharts
|
||||
pX += startX - yAxis.axisTick.length;
|
||||
}
|
||||
ChartHelper.DrawLine(vh, new Vector3(startX, pY), new Vector3(pX, pY),
|
||||
m_Coordinate.tickness, m_ThemeInfo.axisLineColor);
|
||||
yAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
if (yAxis.showSplitLine)
|
||||
{
|
||||
DrawSplitLine(vh, true, yAxis.splitLineType, new Vector3(coordinateX, pY),
|
||||
DrawSplitLine(vh, yAxis, yAxis.splitLineType, new Vector3(coordinateX, pY),
|
||||
new Vector3(coordinateX + coordinateWid, pY), m_ThemeInfo.axisSplitLineColor);
|
||||
}
|
||||
}
|
||||
@@ -881,11 +818,11 @@ namespace XCharts
|
||||
pY += startY - xAxis.axisTick.length;
|
||||
}
|
||||
ChartHelper.DrawLine(vh, new Vector3(pX, startY), new Vector3(pX, pY),
|
||||
m_Coordinate.tickness, m_ThemeInfo.axisLineColor);
|
||||
xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
if (xAxis.showSplitLine)
|
||||
{
|
||||
DrawSplitLine(vh, false, xAxis.splitLineType, new Vector3(pX, coordinateY),
|
||||
DrawSplitLine(vh, xAxis, xAxis.splitLineType, new Vector3(pX, coordinateY),
|
||||
new Vector3(pX, coordinateY + coordinateHig), m_ThemeInfo.axisSplitLineColor);
|
||||
}
|
||||
}
|
||||
@@ -898,9 +835,9 @@ namespace XCharts
|
||||
{
|
||||
var lineY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].zeroYOffset : 0);
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) lineY += coordinateHig;
|
||||
var left = new Vector3(coordinateX - m_Coordinate.tickness, lineY);
|
||||
var top = new Vector3(coordinateX + coordinateWid + m_Coordinate.tickness, lineY);
|
||||
ChartHelper.DrawLine(vh, left, top, m_Coordinate.tickness, m_ThemeInfo.axisLineColor);
|
||||
var left = new Vector3(coordinateX - xAxis.axisLine.width, lineY);
|
||||
var top = new Vector3(coordinateX + coordinateWid + xAxis.axisLine.width, lineY);
|
||||
ChartHelper.DrawLine(vh, left, top, xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||
if (xAxis.axisLine.symbol)
|
||||
{
|
||||
var axisLine = xAxis.axisLine;
|
||||
@@ -920,9 +857,9 @@ namespace XCharts
|
||||
{
|
||||
var lineX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].zeroXOffset : 0);
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) lineX += coordinateWid;
|
||||
var top = new Vector3(lineX, coordinateY + coordinateHig + m_Coordinate.tickness);
|
||||
ChartHelper.DrawLine(vh, new Vector3(lineX, coordinateY - m_Coordinate.tickness),
|
||||
top, m_Coordinate.tickness, m_ThemeInfo.axisLineColor);
|
||||
var top = new Vector3(lineX, coordinateY + coordinateHig + yAxis.axisLine.width);
|
||||
ChartHelper.DrawLine(vh, new Vector3(lineX, coordinateY - yAxis.axisLine.width),
|
||||
top, yAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||
if (yAxis.axisLine.symbol)
|
||||
{
|
||||
var axisLine = yAxis.axisLine;
|
||||
@@ -943,10 +880,11 @@ namespace XCharts
|
||||
var p2 = new Vector2(coordinateX, m_DataZoom.bottom + m_DataZoom.height);
|
||||
var p3 = new Vector2(coordinateX + coordinateWid, m_DataZoom.bottom + m_DataZoom.height);
|
||||
var p4 = new Vector2(coordinateX + coordinateWid, m_DataZoom.bottom);
|
||||
ChartHelper.DrawLine(vh, p1, p2, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
|
||||
ChartHelper.DrawLine(vh, p2, p3, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
|
||||
ChartHelper.DrawLine(vh, p3, p4, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
|
||||
ChartHelper.DrawLine(vh, p4, p1, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
|
||||
var xAxis = xAxises[0];
|
||||
ChartHelper.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||
ChartHelper.DrawLine(vh, p2, p3, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||
ChartHelper.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||
ChartHelper.DrawLine(vh, p4, p1, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
|
||||
if (m_DataZoom.showDataShadow && m_Series.Count > 0)
|
||||
{
|
||||
Serie serie = m_Series.series[0];
|
||||
@@ -968,12 +906,12 @@ namespace XCharts
|
||||
if (i > 0)
|
||||
{
|
||||
Color color = m_ThemeInfo.dataZoomLineColor;
|
||||
ChartHelper.DrawLine(vh, lp, np, m_Coordinate.tickness, color);
|
||||
Vector3 alp = new Vector3(lp.x, lp.y - m_Coordinate.tickness);
|
||||
Vector3 anp = new Vector3(np.x, np.y - m_Coordinate.tickness);
|
||||
ChartHelper.DrawLine(vh, lp, np, xAxis.axisLine.width, color);
|
||||
Vector3 alp = new Vector3(lp.x, lp.y - xAxis.axisLine.width);
|
||||
Vector3 anp = new Vector3(np.x, np.y - xAxis.axisLine.width);
|
||||
Color areaColor = new Color(color.r, color.g, color.b, color.a * 0.75f);
|
||||
Vector3 tnp = new Vector3(np.x, m_DataZoom.bottom + m_Coordinate.tickness);
|
||||
Vector3 tlp = new Vector3(lp.x, m_DataZoom.bottom + m_Coordinate.tickness);
|
||||
Vector3 tnp = new Vector3(np.x, m_DataZoom.bottom + xAxis.axisLine.width);
|
||||
Vector3 tlp = new Vector3(lp.x, m_DataZoom.bottom + xAxis.axisLine.width);
|
||||
ChartHelper.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
|
||||
}
|
||||
lp = np;
|
||||
@@ -989,15 +927,16 @@ namespace XCharts
|
||||
p3 = new Vector2(end, m_DataZoom.bottom + m_DataZoom.height);
|
||||
p4 = new Vector2(end, m_DataZoom.bottom);
|
||||
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.dataZoomSelectedColor);
|
||||
ChartHelper.DrawLine(vh, p1, p2, m_Coordinate.tickness, m_ThemeInfo.dataZoomSelectedColor);
|
||||
ChartHelper.DrawLine(vh, p3, p4, m_Coordinate.tickness, m_ThemeInfo.dataZoomSelectedColor);
|
||||
ChartHelper.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
|
||||
ChartHelper.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawSplitLine(VertexHelper vh, bool isYAxis, Axis.SplitLineType type,
|
||||
protected void DrawSplitLine(VertexHelper vh, Axis axis, Axis.SplitLineType type,
|
||||
Vector3 startPos, Vector3 endPos, Color color)
|
||||
{
|
||||
bool isYAxis = axis is YAxis;
|
||||
switch (type)
|
||||
{
|
||||
case Axis.SplitLineType.Dashed:
|
||||
@@ -1013,21 +952,21 @@ namespace XCharts
|
||||
{
|
||||
var toX = startX + dashLen;
|
||||
ChartHelper.DrawLine(vh, new Vector3(startX, startY), new Vector3(toX, startY),
|
||||
m_Coordinate.tickness, color);
|
||||
axis.axisLine.width, color);
|
||||
startX += dashLen * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
var toY = startY + dashLen;
|
||||
ChartHelper.DrawLine(vh, new Vector3(startX, startY), new Vector3(startX, toY),
|
||||
m_Coordinate.tickness, color);
|
||||
axis.axisLine.width, color);
|
||||
startY += dashLen * 2;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case Axis.SplitLineType.Solid:
|
||||
ChartHelper.DrawLine(vh, startPos, endPos, m_Coordinate.tickness, color);
|
||||
ChartHelper.DrawLine(vh, startPos, endPos, axis.axisLine.width, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1052,12 +991,12 @@ namespace XCharts
|
||||
if (xAxis.IsValue()) pX = m_Tooltip.pointerPos.x;
|
||||
Vector2 sp = new Vector2(pX, coordinateY);
|
||||
Vector2 ep = new Vector2(pX, coordinateY + coordinateHig);
|
||||
DrawSplitLine(vh, false, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
DrawSplitLine(vh, xAxis, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(coordinateX, m_Tooltip.pointerPos.y);
|
||||
ep = new Vector2(coordinateX + coordinateWid, m_Tooltip.pointerPos.y);
|
||||
DrawSplitLine(vh, true, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
DrawSplitLine(vh, yAxis, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
}
|
||||
break;
|
||||
case Tooltip.Type.Shadow:
|
||||
@@ -1084,6 +1023,7 @@ namespace XCharts
|
||||
for (int i = 0; i < m_YAxises.Count; i++)
|
||||
{
|
||||
var yAxis = m_YAxises[i];
|
||||
var xAxis = m_XAxises[i];
|
||||
if (!yAxis.show) continue;
|
||||
float splitWidth = yAxis.GetDataWidth(coordinateHig, m_DataZoom);
|
||||
switch (m_Tooltip.type)
|
||||
@@ -1094,12 +1034,12 @@ namespace XCharts
|
||||
float pY = coordinateY + m_Tooltip.yValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||
Vector2 sp = new Vector2(coordinateX, pY);
|
||||
Vector2 ep = new Vector2(coordinateX + coordinateWid, pY);
|
||||
DrawSplitLine(vh, false, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
DrawSplitLine(vh, xAxis, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(coordinateX, m_Tooltip.pointerPos.y);
|
||||
ep = new Vector2(coordinateX + coordinateWid, m_Tooltip.pointerPos.y);
|
||||
DrawSplitLine(vh, true, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
DrawSplitLine(vh, yAxis, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||
}
|
||||
break;
|
||||
case Tooltip.Type.Shadow:
|
||||
|
||||
131
Scripts/UI/Internal/CoordinateChart_API.cs
Normal file
131
Scripts/UI/Internal/CoordinateChart_API.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// The basic class of rectangular coordinate chart,such as LineChart,BarChart and ScatterChart.
|
||||
/// 直角坐标系类型图表的基类,如折线图LineChart,柱状图BarChart,散点图ScatterChart都属于这类型的图表。
|
||||
/// 不可用直接将CoordinateChart绑定到GameObject上。
|
||||
/// </summary>
|
||||
public partial class CoordinateChart
|
||||
{
|
||||
/// <summary>
|
||||
/// The lower left position x of coordinate system.
|
||||
/// 坐标系的左下角坐标X。
|
||||
/// </summary>
|
||||
public float coordinateX { get { return m_Grid.left; } }
|
||||
/// <summary>
|
||||
/// The lower left position y of coordinate system.
|
||||
/// 坐标系的左下角坐标Y。
|
||||
/// </summary>
|
||||
public float coordinateY { get { return m_Grid.bottom; } }
|
||||
/// <summary>
|
||||
/// the width of coordinate system。
|
||||
/// 坐标系的宽。
|
||||
/// </summary>
|
||||
public float coordinateWid { get { return chartWidth - m_Grid.left - m_Grid.right; } }
|
||||
/// <summary>
|
||||
/// the height of coordinate system。
|
||||
/// 坐标系的高。
|
||||
/// </summary>
|
||||
public float coordinateHig { get { return chartHeight - m_Grid.top - m_Grid.bottom; } }
|
||||
/// <summary>
|
||||
/// grid component.
|
||||
/// 网格组件。
|
||||
/// </summary>
|
||||
public Grid grid { get { return m_Grid; } }
|
||||
/// <summary>
|
||||
/// the x axises,xAxises[0] is the first x axis, xAxises[1] is the second x axis.
|
||||
/// 两个x轴。
|
||||
/// </summary>
|
||||
public List<XAxis> xAxises { get { return m_XAxises; } }
|
||||
/// <summary>
|
||||
/// the y axises, yAxises[0] is the first y axis, yAxises[1] is the second y axis.
|
||||
/// 两个y轴。
|
||||
/// </summary>
|
||||
public List<YAxis> yAxises { get { return m_YAxises; } }
|
||||
/// <summary>
|
||||
/// dataZoom component.
|
||||
/// 区域缩放组件。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public DataZoom dataZoom { get { return m_DataZoom; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data from series,legend and axis.
|
||||
/// It just emptying all of serie's data without emptying the list of series.
|
||||
/// 清空所有图例,系列和坐标轴类目数据。系列中指示清空系列中的数据,会保留系列列表。
|
||||
/// </summary>
|
||||
public override void ClearData()
|
||||
{
|
||||
base.ClearData();
|
||||
ClearAxisData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data from series,legend and axis.
|
||||
/// The series list is also cleared.
|
||||
/// 清空所有图例,系列和坐标轴类目数据。系列的列表也会被清空。
|
||||
/// </summary>
|
||||
public override void RemoveData()
|
||||
{
|
||||
base.RemoveData();
|
||||
ClearAxisData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data of axises.
|
||||
/// 清除所有x轴和y轴的类目数据。
|
||||
/// </summary>
|
||||
public void ClearAxisData()
|
||||
{
|
||||
foreach (var item in m_XAxises) item.data.Clear();
|
||||
foreach (var item in m_YAxises) item.data.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a category data to xAxis.
|
||||
/// 添加一个类目数据到指定的x轴。
|
||||
/// </summary>
|
||||
/// <param name="category">the category data</param>
|
||||
/// <param name="xAxisIndex">which xAxis should category add to</param>
|
||||
public void AddXAxisData(string category, int xAxisIndex = 0)
|
||||
{
|
||||
m_XAxises[xAxisIndex].AddData(category, m_MaxCacheDataNumber);
|
||||
OnXAxisChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a category data to yAxis.
|
||||
/// 添加一个类目数据到指定的y轴。
|
||||
/// </summary>
|
||||
/// <param name="category">the category data</param>
|
||||
/// <param name="yAxisIndex">which yAxis should category add to</param>
|
||||
public void AddYAxisData(string category, int yAxisIndex = 0)
|
||||
{
|
||||
m_YAxises[yAxisIndex].AddData(category, m_MaxCacheDataNumber);
|
||||
OnYAxisChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reutrn true when all the show axis is `Value` type.
|
||||
/// 纯数值坐标。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsValue()
|
||||
{
|
||||
foreach (var axis in m_XAxises)
|
||||
{
|
||||
if (axis.show && !axis.IsValue()) return false;
|
||||
}
|
||||
foreach (var axis in m_YAxises)
|
||||
{
|
||||
if (axis.show && !axis.IsValue()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
11
Scripts/UI/Internal/CoordinateChart_API.cs.meta
Normal file
11
Scripts/UI/Internal/CoordinateChart_API.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbe51753d5fc64acfab72f95e03773c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,11 +3,18 @@ using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 支持从json格式的字符串中导入数据
|
||||
/// </summary>
|
||||
public class JsonDataSupport : IJsonData, ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField] protected string m_JsonData;
|
||||
[SerializeField] protected bool m_DataFromJson;
|
||||
|
||||
/// <summary>
|
||||
/// json格式的字符串数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
|
||||
@@ -3,9 +3,16 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Location type. Quick to set the general location.
|
||||
/// 位置类型。通过Align快速设置大体位置,再通过left,right,top,bottom微调具体位置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Location : IPropertyChanged, IEquatable<Location>
|
||||
{
|
||||
/// <summary>
|
||||
/// 对齐方式
|
||||
/// </summary>
|
||||
public enum Align
|
||||
{
|
||||
TopLeft,
|
||||
@@ -30,15 +37,54 @@ namespace XCharts
|
||||
private Vector2 m_AnchorMax;
|
||||
private Vector2 m_Pivot;
|
||||
|
||||
/// <summary>
|
||||
/// 对齐方式。
|
||||
/// </summary>
|
||||
public Align align { get { return m_Align; } set { m_Align = value; UpdateAlign(); } }
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// 离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left { get { return m_Left; } set { m_Left = value; UpdateAlign(); } }
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// 离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right { get { return m_Right; } set { m_Right = value; UpdateAlign(); } }
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// 离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top { get { return m_Top; } set { m_Top = value; UpdateAlign(); } }
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// 离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; UpdateAlign(); } }
|
||||
|
||||
/// <summary>
|
||||
/// the anchor of text.
|
||||
/// Location对应的Anchor锚点
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public TextAnchor textAnchor { get { return m_TextAnchor; } }
|
||||
/// <summary>
|
||||
/// the minimum achor.
|
||||
/// Location对应的anchorMin。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Vector2 anchorMin { get { return m_AnchorMin; } }
|
||||
/// <summary>
|
||||
/// the maximun achor.
|
||||
/// Location对应的anchorMax.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Vector2 anchorMax { get { return m_AnchorMax; } }
|
||||
/// <summary>
|
||||
/// the povot.
|
||||
/// Loation对应的中心点。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Vector2 pivot { get { return m_Pivot; } }
|
||||
|
||||
public static Location defaultLeft
|
||||
@@ -164,6 +210,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回在坐标系中的具体位置
|
||||
/// </summary>
|
||||
/// <param name="chartWidht"></param>
|
||||
/// <param name="chartHeight"></param>
|
||||
/// <returns></returns>
|
||||
public Vector2 GetPosition(float chartWidht, float chartHeight)
|
||||
{
|
||||
switch (align)
|
||||
@@ -252,6 +304,9 @@ namespace XCharts
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
||||
/// </summary>
|
||||
public void OnChanged()
|
||||
{
|
||||
UpdateAlign();
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Scatter
|
||||
{
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private float m_InsideRadius;
|
||||
[SerializeField] private float m_OutsideRadius;
|
||||
[SerializeField] private float m_TooltipExtraRadius;
|
||||
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
|
||||
public static Scatter defaultScatter
|
||||
{
|
||||
get
|
||||
{
|
||||
var scatter = new Scatter
|
||||
{
|
||||
};
|
||||
return scatter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,11 @@ using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
/// <summary>
|
||||
/// A data item of serie.系列中的一个数据项。
|
||||
/// A data item of serie.
|
||||
/// 系列中的一个数据项。可存储数据名和1-n维的数据。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieData
|
||||
{
|
||||
[SerializeField] private string m_Name;
|
||||
@@ -17,30 +18,34 @@ namespace XCharts
|
||||
private bool m_Show = true;
|
||||
|
||||
/// <summary>
|
||||
/// the name of data item.数据项名称。
|
||||
/// the name of data item.
|
||||
/// 数据项名称。
|
||||
/// </summary>
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
/// <summary>
|
||||
/// Whether the data item is selected.该数据项是否被选中。
|
||||
/// Whether the data item is selected.
|
||||
/// 该数据项是否被选中。
|
||||
/// </summary>
|
||||
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
|
||||
/// <summary>
|
||||
/// An arbitrary dimension data list of data item.可指定任意维数的数值列表。
|
||||
/// An arbitrary dimension data list of data item.
|
||||
/// 可指定任意维数的数值列表。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public List<float> data { get { return m_Data; } set { m_Data = value; } }
|
||||
/// <summary>
|
||||
/// Whether the data item is showed.该数据项是否要显示。
|
||||
/// [default:true] Whether the data item is showed.
|
||||
/// 该数据项是否要显示。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// Whether the data item is highlighted.该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
|
||||
/// Whether the data item is highlighted.
|
||||
/// 该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
|
||||
/// </summary>
|
||||
public bool highlighted { get; set; }
|
||||
/// <summary>
|
||||
/// the label of data item.该数据项的文本标签。
|
||||
/// the label of data item.
|
||||
/// 该数据项的文本标签。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Text label { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
/// <summary>
|
||||
/// Text label of chart, to explain some data information about graphic item like value, name and so on.
|
||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieLabel
|
||||
{
|
||||
/// <summary>
|
||||
/// The position of label.标签的位置。
|
||||
/// The position of label.
|
||||
/// 标签的位置。
|
||||
/// </summary>
|
||||
public enum Position
|
||||
{
|
||||
@@ -20,15 +21,34 @@ namespace XCharts
|
||||
/// </summary>
|
||||
Outside,
|
||||
/// <summary>
|
||||
/// Inside the sectors of pie chart.饼图扇区内部。
|
||||
/// Inside the sectors of pie chart.
|
||||
/// 饼图扇区内部。
|
||||
/// </summary>
|
||||
Inside,
|
||||
/// <summary>
|
||||
/// In the center of pie chart.在饼图中心位置。
|
||||
/// In the center of pie chart.
|
||||
/// 在饼图中心位置。
|
||||
/// </summary>
|
||||
Center,
|
||||
/// <summary>
|
||||
/// top of symbol.
|
||||
/// 图形标志的顶部。
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// the left of symbol.
|
||||
/// 图形标志的左边。
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// the right of symbol.
|
||||
/// 图形标志的右边。
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// the bottom of symbol.
|
||||
/// 图形标志的底部。
|
||||
/// </summary>
|
||||
Bottom,
|
||||
}
|
||||
[SerializeField] private bool m_Show = false;
|
||||
@@ -43,11 +63,13 @@ namespace XCharts
|
||||
[SerializeField] private float m_LineLength1 = 25f;
|
||||
[SerializeField] private float m_LineLength2 = 15f;
|
||||
/// <summary>
|
||||
/// Whether the label is showed.是否显示文本标签。
|
||||
/// Whether the label is showed.
|
||||
/// 是否显示文本标签。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// The position of label.标签的位置。
|
||||
/// The position of label.
|
||||
/// 标签的位置。
|
||||
/// </summary>
|
||||
public Position position { get { return m_Position; } set { m_Position = value; } }
|
||||
/// <summary>
|
||||
@@ -61,20 +83,39 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// Rotate label.标签旋转。
|
||||
/// Rotate label.
|
||||
/// 标签旋转。
|
||||
/// </summary>
|
||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
||||
/// <summary>
|
||||
/// font size.文字的字体大小。
|
||||
/// font size.
|
||||
/// 文字的字体大小。
|
||||
/// </summary>
|
||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||
/// <summary>
|
||||
/// font style.文字的字体风格。
|
||||
/// font style.
|
||||
/// 文字的字体风格。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show visual guide line.Will show when label position is set as 'outside'.
|
||||
/// 是否显示视觉引导线。在 label 位置 设置为'outside'的时候会显示视觉引导线。
|
||||
/// </summary>
|
||||
public bool line { get { return m_Line; } set { m_Line = value; } }
|
||||
/// <summary>
|
||||
/// the width of visual guild line.
|
||||
/// 视觉引导线的宽度。
|
||||
/// </summary>
|
||||
public float lineWidth { get { return m_LineWidth; } set { m_LineWidth = value; } }
|
||||
/// <summary>
|
||||
/// The length of the first segment of visual guide line.
|
||||
/// 视觉引导线第一段的长度。
|
||||
/// </summary>
|
||||
public float lineLength1 { get { return m_LineLength1; } set { m_LineLength1 = value; } }
|
||||
/// <summary>
|
||||
/// The length of the second segment of visual guide line.
|
||||
/// 视觉引导线第二段的长度。
|
||||
/// </summary>
|
||||
public float lineLength2 { get { return m_LineLength2; } set { m_LineLength2 = value; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,40 +3,71 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
/// 标记图形的类型。
|
||||
/// </summary>
|
||||
public enum SerieSymbolType
|
||||
{
|
||||
/// <summary>
|
||||
/// 空心圆。
|
||||
/// </summary>
|
||||
EmptyCircle,
|
||||
/// <summary>
|
||||
/// 圆形。
|
||||
/// </summary>
|
||||
Circle,
|
||||
/// <summary>
|
||||
/// 正方形。
|
||||
/// </summary>
|
||||
Rect,
|
||||
/// <summary>
|
||||
/// 三角形。
|
||||
/// </summary>
|
||||
Triangle,
|
||||
/// <summary>
|
||||
/// 菱形。
|
||||
/// </summary>
|
||||
Diamond,
|
||||
/// <summary>
|
||||
/// 不显示标记。
|
||||
/// </summary>
|
||||
None,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The way to get serie symbol size.
|
||||
/// <para> `Custom`:Specify constant for symbol size. </para>
|
||||
/// <para> `FromData`:Specify the dataIndex and dataScale to calculate symbol size,the formula:data[dataIndex]*dataScale. </para>
|
||||
/// <para> `Callback`:Specify callback function for symbol size. </para>
|
||||
/// 获取标记图形大小的方式。
|
||||
/// </summary>
|
||||
public enum SerieSymbolSizeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Specify constant for symbol size.
|
||||
/// 自定义大小。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// Specify the dataIndex and dataScale to calculate symbol size
|
||||
/// Specify the dataIndex and dataScale to calculate symbol size.
|
||||
/// 通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。
|
||||
/// </summary>
|
||||
FromData,
|
||||
/// <summary>
|
||||
/// Specify callback function for symbol size
|
||||
/// Specify callback function for symbol size.
|
||||
/// 通过回调函数获取。
|
||||
/// </summary>
|
||||
Callback,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取标记大小的回调。
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public delegate float SymbolSizeCallback(List<float> data);
|
||||
|
||||
/// <summary>
|
||||
/// 系列数据项的标记的图形
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieSymbol
|
||||
{
|
||||
@@ -50,19 +81,74 @@ namespace XCharts
|
||||
[SerializeField] private SymbolSizeCallback m_SizeCallback;
|
||||
[SerializeField] private SymbolSizeCallback m_SelectedSizeCallback;
|
||||
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
/// 标记类型。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SerieSymbolType type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// the type of symbol size.
|
||||
/// 标记图形的大小获取方式。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SerieSymbolSizeType sizeType { get { return m_SizeType; } set { m_SizeType = value; } }
|
||||
/// <summary>
|
||||
/// the size of symbol.
|
||||
/// 标记的大小。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float size { get { return m_Size; } set { m_Size = value; } }
|
||||
/// <summary>
|
||||
/// the size of selected symbol.
|
||||
/// 被选中的标记的大小。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float selectedSize { get { return m_SelectedSize; } set { m_SelectedSize = value; } }
|
||||
/// <summary>
|
||||
/// whitch data index is when the sizeType assined as FromData.
|
||||
/// 当sizeType指定为FromData时,指定的数据源索引。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public int dataIndex { get { return m_DataIndex; } set { m_DataIndex = value; } }
|
||||
/// <summary>
|
||||
/// the scale of data when sizeType assined as FromData.
|
||||
/// 当sizeType指定为FromData时,指定的倍数系数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float dataScale { get { return m_DataScale; } set { m_DataScale = value; } }
|
||||
/// <summary>
|
||||
/// the scale of selected data when sizeType assined as FromData.
|
||||
/// 当sizeType指定为FromData时,指定的高亮倍数系数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float selectedDataScale { get { return m_SelectedDataScale; } set { m_SelectedDataScale = value; } }
|
||||
/// <summary>
|
||||
/// the callback of size when sizeType assined as Callback.
|
||||
/// 当sizeType指定为Callback时,指定的回调函数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SymbolSizeCallback sizeCallback { get { return m_SizeCallback; } set { m_SizeCallback = value; } }
|
||||
/// <summary>
|
||||
/// the callback of size when sizeType assined as Callback.
|
||||
/// 当sizeType指定为Callback时,指定的高亮回调函数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SymbolSizeCallback selectedSizeCallback { get { return m_SelectedSizeCallback; } set { m_SelectedSizeCallback = value; } }
|
||||
|
||||
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
|
||||
/// <summary>
|
||||
/// the setting for effect scatter.
|
||||
/// 带有涟漪特效动画的散点图的动画参数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public List<float> animationSize { get { return m_AnimationSize; } }
|
||||
public Color animationColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 根据指定的sizeType获得标记的大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSize(List<float> data)
|
||||
{
|
||||
if (data == null) return size;
|
||||
@@ -86,6 +172,11 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据sizeType获得高亮时的标记大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSelectedSize(List<float> data)
|
||||
{
|
||||
if (data == null) return selectedSize;
|
||||
|
||||
@@ -102,13 +102,13 @@ namespace XCharts
|
||||
var dataIndex = i % dataCount;
|
||||
var serie = m_Series.GetSerie(pointSerieIndex[i]);
|
||||
float symbolSize = serie.symbol.size;
|
||||
if ((m_Tooltip.show && m_Tooltip.IsSelectedDataIndex(dataIndex))
|
||||
if ((m_Tooltip.show && m_Tooltip.IsSelected(dataIndex))
|
||||
|| serie.data[dataIndex].highlighted
|
||||
|| serie.highlighted)
|
||||
{
|
||||
if (IsCartesian())
|
||||
if (IsValue())
|
||||
{
|
||||
if (m_Series.IsTooltipSelected(serie.index))
|
||||
if (m_Series.IsHighlight(serie.index))
|
||||
{
|
||||
symbolSize = serie.symbol.selectedSize;
|
||||
}
|
||||
@@ -185,8 +185,8 @@ namespace XCharts
|
||||
if (xAxis.IsValue())
|
||||
{
|
||||
float xValue = i > xData.Count - 1 ? 0 : xData[i];
|
||||
float pX = coordinateX + m_Coordinate.tickness;
|
||||
float pY = seriesHig[i] + coordinateY + m_Coordinate.tickness;
|
||||
float pX = coordinateX + xAxis.axisLine.width;
|
||||
float pY = seriesHig[i] + coordinateY + xAxis.axisLine.width;
|
||||
float xDataHig = (xValue - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWid;
|
||||
yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHig;
|
||||
np = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
@@ -194,7 +194,7 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
float pX = startX + i * scaleWid;
|
||||
float pY = seriesHig[i] + coordinateY + m_Coordinate.tickness;
|
||||
float pY = seriesHig[i] + coordinateY + yAxis.axisLine.width;
|
||||
yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHig;
|
||||
np = new Vector3(pX, pY + yDataHig);
|
||||
}
|
||||
@@ -272,14 +272,14 @@ namespace XCharts
|
||||
lastSmoothPoints[lastSmoothPoints.Count - 1].y + m_Line.tickness) :
|
||||
new Vector3(lastSmoothPoints[smoothPointCount].x,
|
||||
lastSmoothPoints[smoothPointCount].y + m_Line.tickness)) :
|
||||
new Vector3(to.x, coordinateY + m_Coordinate.tickness);
|
||||
new Vector3(to.x, coordinateY + xAxis.axisLine.width);
|
||||
Vector3 tlp = serieIndex > 0 ?
|
||||
(smoothPointCount > lastSmoothPoints.Count - 1 ?
|
||||
new Vector3(lastSmoothPoints[lastSmoothPoints.Count - 2].x,
|
||||
lastSmoothPoints[lastSmoothPoints.Count - 2].y + m_Line.tickness) :
|
||||
new Vector3(lastSmoothPoints[smoothPointCount - 1].x,
|
||||
lastSmoothPoints[smoothPointCount - 1].y + m_Line.tickness)) :
|
||||
new Vector3(start.x, coordinateY + m_Coordinate.tickness);
|
||||
new Vector3(start.x, coordinateY + xAxis.axisLine.width);
|
||||
Color areaColor = new Color(color.r, color.g, color.b, color.a * 0.75f);
|
||||
ChartHelper.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
|
||||
}
|
||||
@@ -301,18 +301,18 @@ namespace XCharts
|
||||
{
|
||||
Vector3 tnp = serieIndex > 0 ?
|
||||
new Vector3(lastPoints[i].x, lastPoints[i].y + m_Line.tickness) :
|
||||
new Vector3(np.x, coordinateY + m_Coordinate.tickness);
|
||||
new Vector3(np.x, coordinateY + xAxis.axisLine.width);
|
||||
Vector3 tlp = serieIndex > 0 ?
|
||||
new Vector3(lastPoints[i - 1].x, lastPoints[i - 1].y + m_Line.tickness) :
|
||||
new Vector3(lp.x, coordinateY + m_Coordinate.tickness);
|
||||
new Vector3(lp.x, coordinateY + xAxis.axisLine.width);
|
||||
ChartHelper.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 cross1 = new Vector3(cross.x, cross.y + (alp.y > coordinateY ? m_Coordinate.tickness : -m_Coordinate.tickness));
|
||||
Vector3 cross2 = new Vector3(cross.x, cross.y + (anp.y > coordinateY ? m_Coordinate.tickness : -m_Coordinate.tickness));
|
||||
Vector3 xp1 = new Vector3(alp.x, coordinateY + (alp.y > coordinateY ? m_Coordinate.tickness : -m_Coordinate.tickness));
|
||||
Vector3 xp2 = new Vector3(anp.x, coordinateY + (anp.y > coordinateY ? m_Coordinate.tickness : -m_Coordinate.tickness));
|
||||
Vector3 cross1 = new Vector3(cross.x, cross.y + (alp.y > coordinateY ? xAxis.axisLine.width : -xAxis.axisLine.width));
|
||||
Vector3 cross2 = new Vector3(cross.x, cross.y + (anp.y > coordinateY ? xAxis.axisLine.width : -xAxis.axisLine.width));
|
||||
Vector3 xp1 = new Vector3(alp.x, coordinateY + (alp.y > coordinateY ? xAxis.axisLine.width : -xAxis.axisLine.width));
|
||||
Vector3 xp2 = new Vector3(anp.x, coordinateY + (anp.y > coordinateY ? xAxis.axisLine.width : -xAxis.axisLine.width));
|
||||
ChartHelper.DrawTriangle(vh, alp, cross1, xp1, areaColor);
|
||||
ChartHelper.DrawTriangle(vh, anp, cross2, xp2, areaColor);
|
||||
}
|
||||
@@ -382,7 +382,7 @@ namespace XCharts
|
||||
}
|
||||
float value = serie.yData[i];
|
||||
float pY = startY + i * scaleWid;
|
||||
float pX = seriesHig[i] + coordinateX + m_Coordinate.tickness;
|
||||
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
||||
float dataHig = (value - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWid;
|
||||
np = new Vector3(pX + dataHig, pY);
|
||||
if (i > 0)
|
||||
@@ -457,14 +457,14 @@ namespace XCharts
|
||||
lastSmoothPoints[lastSmoothPoints.Count - 1].y + m_Line.tickness) :
|
||||
new Vector3(lastSmoothPoints[smoothPointCount].x,
|
||||
lastSmoothPoints[smoothPointCount].y + m_Line.tickness)) :
|
||||
new Vector3(coordinateX + m_Coordinate.tickness, to.y);
|
||||
new Vector3(coordinateX + yAxis.axisLine.width, to.y);
|
||||
Vector3 tlp = serieIndex > 0 ?
|
||||
(smoothPointCount > lastSmoothPoints.Count - 1 ?
|
||||
new Vector3(lastSmoothPoints[lastSmoothPoints.Count - 2].x,
|
||||
lastSmoothPoints[lastSmoothPoints.Count - 2].y + m_Line.tickness) :
|
||||
new Vector3(lastSmoothPoints[smoothPointCount - 1].x,
|
||||
lastSmoothPoints[smoothPointCount - 1].y + m_Line.tickness)) :
|
||||
new Vector3(coordinateX + m_Coordinate.tickness, start.y);
|
||||
new Vector3(coordinateX + yAxis.axisLine.width, start.y);
|
||||
Color areaColor = new Color(color.r, color.g, color.b, color.a * 0.75f);
|
||||
ChartHelper.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
|
||||
}
|
||||
@@ -485,19 +485,19 @@ namespace XCharts
|
||||
if (cross == Vector3.zero)
|
||||
{
|
||||
Vector3 tnp = serieIndex > 0 ?
|
||||
new Vector3(lastPoints[i].x + m_Coordinate.tickness, lastPoints[i].y) :
|
||||
new Vector3(coordinateX + m_Coordinate.tickness, np.y);
|
||||
new Vector3(lastPoints[i].x + yAxis.axisLine.width, lastPoints[i].y) :
|
||||
new Vector3(coordinateX + yAxis.axisLine.width, np.y);
|
||||
Vector3 tlp = serieIndex > 0 ?
|
||||
new Vector3(lastPoints[i - 1].x + m_Coordinate.tickness, lastPoints[i - 1].y) :
|
||||
new Vector3(coordinateX + m_Coordinate.tickness, lp.y);
|
||||
new Vector3(lastPoints[i - 1].x + yAxis.axisLine.width, lastPoints[i - 1].y) :
|
||||
new Vector3(coordinateX + yAxis.axisLine.width, lp.y);
|
||||
ChartHelper.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 cross1 = new Vector3(cross.x + (alp.x > coordinateX ? m_Coordinate.tickness : -m_Coordinate.tickness), cross.y);
|
||||
Vector3 cross2 = new Vector3(cross.x + (anp.x > coordinateX ? m_Coordinate.tickness : -m_Coordinate.tickness), cross.y);
|
||||
Vector3 xp1 = new Vector3(coordinateX + (alp.x > coordinateX ? m_Coordinate.tickness : -m_Coordinate.tickness), alp.y);
|
||||
Vector3 xp2 = new Vector3(coordinateX + (anp.x > coordinateX ? m_Coordinate.tickness : -m_Coordinate.tickness), anp.y);
|
||||
Vector3 cross1 = new Vector3(cross.x + (alp.x > coordinateX ? yAxis.axisLine.width : -yAxis.axisLine.width), cross.y);
|
||||
Vector3 cross2 = new Vector3(cross.x + (anp.x > coordinateX ? yAxis.axisLine.width : -yAxis.axisLine.width), cross.y);
|
||||
Vector3 xp1 = new Vector3(coordinateX + (alp.x > coordinateX ? yAxis.axisLine.width : -yAxis.axisLine.width), alp.y);
|
||||
Vector3 xp2 = new Vector3(coordinateX + (anp.x > coordinateX ? yAxis.axisLine.width : -yAxis.axisLine.width), anp.y);
|
||||
ChartHelper.DrawTriangle(vh, alp, cross1, xp1, areaColor);
|
||||
ChartHelper.DrawTriangle(vh, anp, cross2, xp2, areaColor);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
/// <param name="legendName">the name of legend</param>
|
||||
/// <returns></returns>
|
||||
public override bool IsLegendActive(string legendName)
|
||||
public override bool IsActiveByLegend(string legendName)
|
||||
{
|
||||
foreach (var serie in m_Series.series)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace XCharts
|
||||
|
||||
public Radar radar { get { return m_Radar; } }
|
||||
|
||||
/// <summary>
|
||||
/// 移除所有数据,包含指示器数据。
|
||||
/// </summary>
|
||||
public override void RemoveData()
|
||||
{
|
||||
base.RemoveData();
|
||||
@@ -87,7 +90,7 @@ namespace XCharts
|
||||
pos = new Vector3(pos.x + txtWid / 2, y);
|
||||
}
|
||||
Text txt = ChartHelper.AddTextObject(INDICATOR_TEXT + i, transform, m_ThemeInfo.font,
|
||||
m_ThemeInfo.textColor, anchor, Vector2.zero, Vector2.zero, new Vector2(1, 0.5f),
|
||||
m_ThemeInfo.titleTextColor, anchor, Vector2.zero, Vector2.zero, new Vector2(1, 0.5f),
|
||||
new Vector2(txtWid, txtHig));
|
||||
txt.transform.localPosition = pos;
|
||||
txt.text = m_Radar.indicatorList[i].name;
|
||||
@@ -155,7 +158,7 @@ namespace XCharts
|
||||
InitIndicator();
|
||||
}
|
||||
|
||||
HashSet<string> serieNameSet = new HashSet<string>();
|
||||
HashSet<string> serieNameSet = new HashSet<string>();
|
||||
private void DrawData(VertexHelper vh)
|
||||
{
|
||||
int indicatorNum = m_Radar.indicatorList.Count;
|
||||
@@ -185,7 +188,7 @@ HashSet<string> serieNameSet = new HashSet<string>();
|
||||
var dataList = m_Series.series[i].yData;
|
||||
var color = m_ThemeInfo.GetColor(i);
|
||||
var areaColor = color;
|
||||
areaColor.a = (byte)m_Radar.areaAipha;
|
||||
areaColor.a = (byte)m_Radar.areaAlpha;
|
||||
|
||||
List<Vector3> pointList = new List<Vector3>(dataList.Count);
|
||||
dataPosList.Add(pointList);
|
||||
@@ -334,11 +337,7 @@ HashSet<string> serieNameSet = new HashSet<string>();
|
||||
{
|
||||
m_Tooltip.UpdateContentPos(new Vector2(local.x + 18, local.y - 25));
|
||||
RefreshTooltip();
|
||||
if (m_Tooltip.lastDataIndex != m_Tooltip.dataIndex)
|
||||
{
|
||||
RefreshChart();
|
||||
}
|
||||
m_Tooltip.lastDataIndex = m_Tooltip.dataIndex;
|
||||
RefreshChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -10,10 +10,6 @@ namespace XCharts
|
||||
[DisallowMultipleComponent]
|
||||
public class ScatterChart : CoordinateChart
|
||||
{
|
||||
[SerializeField] private Scatter m_Scatter = Scatter.defaultScatter;
|
||||
|
||||
public Scatter scatter { get { return m_Scatter; } }
|
||||
|
||||
private float m_EffectScatterSpeed = 15;
|
||||
private float m_EffectScatterSize;
|
||||
private float m_EffectScatterAplha;
|
||||
@@ -22,7 +18,6 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_Scatter = Scatter.defaultScatter;
|
||||
m_Title.text = "ScatterChart";
|
||||
m_Tooltip.type = Tooltip.Type.None;
|
||||
m_XAxises[0].type = Axis.AxisType.Value;
|
||||
@@ -94,8 +89,8 @@ namespace XCharts
|
||||
var serieData = serie.GetDataList(m_DataZoom)[n];
|
||||
float xValue = serieData.data[0];
|
||||
float yValue = serieData.data[1];
|
||||
float pX = coordinateX + m_Coordinate.tickness;
|
||||
float pY = coordinateY + m_Coordinate.tickness;
|
||||
float pX = coordinateX + xAxis.axisLine.width;
|
||||
float pY = coordinateY + yAxis.axisLine.width;
|
||||
float xDataHig = (xValue - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWid;
|
||||
float yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHig;
|
||||
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
|
||||
Reference in New Issue
Block a user