2019-07-13 16:38:38 +08:00
|
|
|
|
using System.Net.Mime;
|
|
|
|
|
|
using System;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
using UnityEngine.UI;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The axis in rectangular coordinate.
|
|
|
|
|
|
/// 直角坐标系的坐标轴组件。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[System.Serializable]
|
2019-06-13 09:53:03 +08:00
|
|
|
|
public class Axis : JsonDataSupport, IEquatable<Axis>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of axis.
|
|
|
|
|
|
/// 坐标轴类型。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public enum AxisType
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Numerical axis, suitable for continuous data.
|
|
|
|
|
|
/// 数值轴,适用于连续数据。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
Value,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Category axis, suitable for discrete category data. Data should only be set via data for this type.
|
|
|
|
|
|
/// 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Category
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of axis min and max value.
|
|
|
|
|
|
/// 坐标轴最大最小刻度显示类型。
|
|
|
|
|
|
/// </summary>
|
2019-05-16 09:39:58 +08:00
|
|
|
|
public enum AxisMinMaxType
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 0 - maximum.
|
|
|
|
|
|
/// 0-最大值。
|
|
|
|
|
|
/// </summary>
|
2019-05-16 09:39:58 +08:00
|
|
|
|
Default,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// minimum - maximum.
|
|
|
|
|
|
/// 最小值-最大值。
|
|
|
|
|
|
/// </summary>
|
2019-05-16 09:39:58 +08:00
|
|
|
|
MinMax,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Customize the minimum and maximum.
|
|
|
|
|
|
/// 自定义最小值最大值。
|
|
|
|
|
|
/// </summary>
|
2019-05-16 09:39:58 +08:00
|
|
|
|
Custom
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of split line.
|
|
|
|
|
|
/// 分割线类型
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public enum SplitLineType
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 不显示分割线
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
None,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 实线
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
Solid,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-09-18 18:23:37 +08:00
|
|
|
|
/// 虚线
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
Dashed,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-09-18 18:23:37 +08:00
|
|
|
|
/// 点线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Dotted,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 点划线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
DashDot,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 双点划线
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// </summary>
|
2019-09-18 18:23:37 +08:00
|
|
|
|
DashDotDot
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] protected bool m_Show = true;
|
|
|
|
|
|
[SerializeField] protected AxisType m_Type;
|
2019-05-16 09:39:58 +08:00
|
|
|
|
[SerializeField] protected AxisMinMaxType m_MinMaxType;
|
|
|
|
|
|
[SerializeField] protected int m_Min;
|
|
|
|
|
|
[SerializeField] protected int m_Max;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[SerializeField] protected int m_SplitNumber = 5;
|
2019-09-17 18:30:45 +08:00
|
|
|
|
[SerializeField] protected float m_Interval = 0;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[SerializeField] protected bool m_ShowSplitLine = false;
|
|
|
|
|
|
[SerializeField] protected SplitLineType m_SplitLineType = SplitLineType.Dashed;
|
|
|
|
|
|
[SerializeField] protected bool m_BoundaryGap = true;
|
|
|
|
|
|
[SerializeField] protected List<string> m_Data = new List<string>();
|
2019-07-09 22:20:50 +08:00
|
|
|
|
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
2019-06-29 07:22:57 +08:00
|
|
|
|
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[SerializeField] protected AxisTick m_AxisTick = AxisTick.defaultTick;
|
2019-07-03 18:45:48 +08:00
|
|
|
|
[SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2019-09-17 18:30:45 +08:00
|
|
|
|
[NonSerialized] private float m_ValueRange;
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set this to false to prevent the axis from showing.
|
|
|
|
|
|
/// 是否显示坐标轴。
|
|
|
|
|
|
/// </summary>
|
2019-06-13 09:53:03 +08:00
|
|
|
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of axis.
|
|
|
|
|
|
/// 坐标轴类型。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public AxisType type { get { return m_Type; } set { m_Type = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of axis minmax.
|
|
|
|
|
|
/// 坐标轴刻度最大最小值显示类型。
|
|
|
|
|
|
/// </summary>
|
2019-05-16 09:39:58 +08:00
|
|
|
|
public AxisMinMaxType minMaxType { get { return m_MinMaxType; } set { m_MinMaxType = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The minimun value of axis.
|
|
|
|
|
|
/// 设定的坐标轴刻度最小值,当minMaxType为Custom时有效。
|
|
|
|
|
|
/// </summary>
|
2019-05-16 09:39:58 +08:00
|
|
|
|
public int min { get { return m_Min; } set { m_Min = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The maximum value of axis.
|
|
|
|
|
|
/// 设定的坐标轴刻度最大值,当minMaxType为Custom时有效。
|
|
|
|
|
|
/// </summary>
|
2019-05-16 09:39:58 +08:00
|
|
|
|
public int max { get { return m_Max; } set { m_Max = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Number of segments that the axis is split into.
|
|
|
|
|
|
/// 坐标轴的分割段数。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-09-17 18:30:45 +08:00
|
|
|
|
/// 强制设置坐标轴分割间隔。无法在类目轴中使用。
|
|
|
|
|
|
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float interval { get { return m_Interval; } set { m_Interval = value; } }
|
|
|
|
|
|
/// <summary>
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// showSplitLineSet this to false to prevent the splitLine from showing. value type axes are shown by default, while category type axes are hidden.
|
|
|
|
|
|
/// 是否显示分隔线。默认数值轴显示,类目轴不显示。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public bool showSplitLine { get { return m_ShowSplitLine; } set { m_ShowSplitLine = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of split line.
|
|
|
|
|
|
/// 分割线类型。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public SplitLineType splitLineType { get { return m_SplitLineType; } set { m_SplitLineType = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The boundary gap on both sides of a coordinate axis.
|
|
|
|
|
|
/// 坐标轴两边是否留白。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Category data, available in type: 'Category' axis.
|
|
|
|
|
|
/// 类目数据,在类目轴(type: 'category')中有效。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public List<string> data { get { return m_Data; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// axis Line.
|
|
|
|
|
|
/// 坐标轴轴线。
|
|
|
|
|
|
/// </summary>
|
2019-07-09 22:20:50 +08:00
|
|
|
|
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// axis name.
|
|
|
|
|
|
/// 坐标轴名称。
|
|
|
|
|
|
/// </summary>
|
2019-06-29 07:22:57 +08:00
|
|
|
|
public AxisName axisName { get { return m_AxisName; } set { m_AxisName = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// axis tick.
|
|
|
|
|
|
/// 坐标轴刻度。
|
|
|
|
|
|
/// </summary>
|
2019-06-13 09:53:03 +08:00
|
|
|
|
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// axis label.
|
|
|
|
|
|
/// 坐标轴刻度标签。
|
|
|
|
|
|
/// </summary>
|
2019-07-03 18:45:48 +08:00
|
|
|
|
public AxisLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// axis split area.
|
|
|
|
|
|
/// 坐标轴分割区域。
|
|
|
|
|
|
/// </summary>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <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>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public float minValue { get; set; }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the current maximum value.
|
|
|
|
|
|
/// 当前最大值。
|
|
|
|
|
|
/// </summary>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public float maxValue { get; set; }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the x offset of zero position.
|
|
|
|
|
|
/// 坐标轴原点在X轴的偏移。
|
|
|
|
|
|
/// </summary>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public float zeroXOffset { get; set; }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the y offset of zero position.
|
|
|
|
|
|
/// 坐标轴原点在Y轴的偏移。
|
|
|
|
|
|
/// </summary>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public float zeroYOffset { get; set; }
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
private int filterStart;
|
|
|
|
|
|
private int filterEnd;
|
|
|
|
|
|
private List<string> filterData;
|
|
|
|
|
|
private List<Text> m_AxisLabelTextList = new List<Text>();
|
2019-07-13 16:38:38 +08:00
|
|
|
|
private GameObject m_TooltipLabel;
|
|
|
|
|
|
private Text m_TooltipLabelText;
|
|
|
|
|
|
private RectTransform m_TooltipLabelRect;
|
|
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public void Copy(Axis other)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Show = other.show;
|
|
|
|
|
|
m_Type = other.type;
|
2019-05-16 09:39:58 +08:00
|
|
|
|
m_Min = other.min;
|
|
|
|
|
|
m_Max = other.max;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_SplitNumber = other.splitNumber;
|
2019-09-17 18:30:45 +08:00
|
|
|
|
m_Interval = other.interval;
|
2019-07-03 18:45:48 +08:00
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_ShowSplitLine = other.showSplitLine;
|
|
|
|
|
|
m_SplitLineType = other.splitLineType;
|
|
|
|
|
|
m_BoundaryGap = other.boundaryGap;
|
2019-06-29 07:22:57 +08:00
|
|
|
|
m_AxisName.Copy(other.axisName);
|
2019-07-03 18:45:48 +08:00
|
|
|
|
m_AxisLabel.Copy(other.axisLabel);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_Data.Clear();
|
2019-08-06 18:21:16 +08:00
|
|
|
|
m_Data.Capacity = m_Data.Count;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
foreach (var d in other.data) m_Data.Add(d);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清空类目数据
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public void ClearData()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Data.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前坐标轴是否时类目轴
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public bool IsCategory()
|
|
|
|
|
|
{
|
|
|
|
|
|
return type == AxisType.Category;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当前坐标轴是否时数值轴
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public bool IsValue()
|
|
|
|
|
|
{
|
|
|
|
|
|
return type == AxisType.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加一个类目到类目数据列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="category"></param>
|
|
|
|
|
|
/// <param name="maxDataNumber"></param>
|
2019-06-13 09:53:03 +08:00
|
|
|
|
public void AddData(string category, int maxDataNumber)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (maxDataNumber > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
while (m_Data.Count > maxDataNumber) m_Data.RemoveAt(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
m_Data.Add(category);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得在dataZoom范围内指定索引的类目数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index">类目数据索引</param>
|
|
|
|
|
|
/// <param name="dataZoom">区域缩放</param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-06-21 09:34:33 +08:00
|
|
|
|
public string GetData(int index, DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-15 00:24:04 +08:00
|
|
|
|
var showData = GetDataList(dataZoom);
|
2019-06-13 09:53:03 +08:00
|
|
|
|
if (index >= 0 && index < showData.Count)
|
|
|
|
|
|
return showData[index];
|
2019-05-11 04:33:54 +08:00
|
|
|
|
else
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得指定区域缩放的类目数据列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataZoom">区域缩放</param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-07-15 00:24:04 +08:00
|
|
|
|
public List<string> GetDataList(DataZoom dataZoom)
|
2019-06-13 09:53:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (dataZoom != null && dataZoom.show)
|
|
|
|
|
|
{
|
2019-06-21 09:34:33 +08:00
|
|
|
|
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
2019-06-13 09:53:03 +08:00
|
|
|
|
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
|
|
|
|
|
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
2019-06-21 09:34:33 +08:00
|
|
|
|
if (filterData == null || filterData.Count != count)
|
2019-06-13 09:53:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
UpdateFilterData(dataZoom);
|
|
|
|
|
|
}
|
|
|
|
|
|
return filterData;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新dataZoom对应的类目数据列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
2019-06-13 09:53:03 +08:00
|
|
|
|
public void UpdateFilterData(DataZoom dataZoom)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataZoom != null && dataZoom.show)
|
|
|
|
|
|
{
|
|
|
|
|
|
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
|
|
|
|
|
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
2019-06-21 09:34:33 +08:00
|
|
|
|
if (startIndex != filterStart || endIndex != filterEnd)
|
2019-06-13 09:53:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
filterStart = startIndex;
|
|
|
|
|
|
filterEnd = endIndex;
|
|
|
|
|
|
if (m_Data.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
|
|
|
|
|
filterData = m_Data.GetRange(startIndex, count);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
filterData = m_Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-06-21 09:34:33 +08:00
|
|
|
|
else if (endIndex == 0)
|
2019-06-13 09:53:03 +08:00
|
|
|
|
{
|
|
|
|
|
|
filterData = new List<string>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得分割段数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-09-17 18:30:45 +08:00
|
|
|
|
public int GetSplitNumber(float coordinateWid, DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
if (type == AxisType.Value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_Interval > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (coordinateWid <= 0) return 0;
|
|
|
|
|
|
int num = Mathf.CeilToInt(m_ValueRange / m_Interval) + 1;
|
|
|
|
|
|
int maxNum = Mathf.CeilToInt(coordinateWid / 15);
|
|
|
|
|
|
if (num > maxNum)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Interval = m_ValueRange / (maxNum - 1);
|
|
|
|
|
|
num = Mathf.CeilToInt(m_ValueRange / m_Interval) + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return num;
|
|
|
|
|
|
}
|
|
|
|
|
|
else return m_SplitNumber;
|
|
|
|
|
|
}
|
2019-07-15 00:24:04 +08:00
|
|
|
|
int dataCount = GetDataList(dataZoom).Count;
|
2019-06-13 09:53:03 +08:00
|
|
|
|
if (dataCount > 2 * m_SplitNumber || dataCount <= 0)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
return m_SplitNumber;
|
|
|
|
|
|
else
|
2019-06-13 09:53:03 +08:00
|
|
|
|
return dataCount;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得分割段的宽度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="coordinateWidth"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-06-21 09:34:33 +08:00
|
|
|
|
public float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
2019-09-18 19:10:43 +08:00
|
|
|
|
int segment = (m_BoundaryGap ? split : split - 1);
|
|
|
|
|
|
segment = segment <= 0 ? 1 : segment;
|
|
|
|
|
|
return coordinateWidth / segment;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得类目数据个数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-06-13 09:53:03 +08:00
|
|
|
|
public int GetDataNumber(DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-15 00:24:04 +08:00
|
|
|
|
return GetDataList(dataZoom).Count;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得一个类目数据在坐标系中代表的宽度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="coordinateWidth"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-06-13 09:53:03 +08:00
|
|
|
|
public float GetDataWidth(float coordinateWidth, DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-06-13 09:53:03 +08:00
|
|
|
|
var dataCount = GetDataNumber(dataZoom);
|
2019-09-18 19:10:43 +08:00
|
|
|
|
int segment = (m_BoundaryGap ? dataCount : dataCount - 1);
|
|
|
|
|
|
segment = segment <= 0 ? 1 : segment;
|
|
|
|
|
|
return coordinateWidth / segment;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-07-23 21:43:01 +08:00
|
|
|
|
private Dictionary<float, string> _cacheValue2str = new Dictionary<float, string>();
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得标签显示的名称
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <param name="minValue"></param>
|
|
|
|
|
|
/// <param name="maxValue"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-09-17 18:30:45 +08:00
|
|
|
|
public string GetLabelName(float coordinateWidth, int index, float minValue, float maxValue, DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
if (m_Type == AxisType.Value)
|
|
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
float value = 0;
|
|
|
|
|
|
if (m_Interval > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index == split - 1) value = maxValue;
|
|
|
|
|
|
else value = minValue + index * m_Interval;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
value = (minValue + (maxValue - minValue) * index / (split - 1));
|
|
|
|
|
|
}
|
2019-09-23 19:09:56 +08:00
|
|
|
|
return m_AxisLabel.GetFormatterContent(value);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
2019-07-15 00:24:04 +08:00
|
|
|
|
var showData = GetDataList(dataZoom);
|
2019-06-13 09:53:03 +08:00
|
|
|
|
int dataCount = showData.Count;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
if (dataCount <= 0) return "";
|
2019-06-13 09:53:03 +08:00
|
|
|
|
|
2019-09-17 18:30:45 +08:00
|
|
|
|
if (index == split - 1 && !m_BoundaryGap)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-09-23 19:09:56 +08:00
|
|
|
|
return m_AxisLabel.GetFormatterContent(showData[dataCount - 1]);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
float rate = dataCount / split;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
if (rate < 1) rate = 1;
|
|
|
|
|
|
int offset = m_BoundaryGap ? (int)(rate / 2) : 0;
|
2019-06-13 09:53:03 +08:00
|
|
|
|
int newIndex = (int)(index * rate >= dataCount - 1 ?
|
|
|
|
|
|
dataCount - 1 : offset + index * rate);
|
2019-09-23 19:09:56 +08:00
|
|
|
|
return m_AxisLabel.GetFormatterContent(showData[newIndex]);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得分割线条数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-09-17 18:30:45 +08:00
|
|
|
|
public int GetScaleNumber(float coordinateWidth, DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-06-13 09:53:03 +08:00
|
|
|
|
if (type == AxisType.Value)
|
2019-05-14 05:24:13 +08:00
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
int splitNum = GetSplitNumber(coordinateWidth, dataZoom);
|
|
|
|
|
|
return m_BoundaryGap ? splitNum + 1 : splitNum;
|
2019-05-14 05:24:13 +08:00
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
else
|
2019-06-13 09:53:03 +08:00
|
|
|
|
{
|
2019-07-15 00:24:04 +08:00
|
|
|
|
var showData = GetDataList(dataZoom);
|
2019-06-13 09:53:03 +08:00
|
|
|
|
int dataCount = showData.Count;
|
|
|
|
|
|
if (dataCount > 2 * splitNumber || dataCount <= 0)
|
|
|
|
|
|
return m_BoundaryGap ? m_SplitNumber + 1 : m_SplitNumber;
|
|
|
|
|
|
else
|
|
|
|
|
|
return m_BoundaryGap ? dataCount + 1 : dataCount;
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得分割段宽度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="coordinateWidth"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-09-17 18:30:45 +08:00
|
|
|
|
public float GetScaleWidth(float coordinateWidth, int index, DataZoom dataZoom)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
int num = GetScaleNumber(coordinateWidth, dataZoom) - 1;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
if (num <= 0) num = 1;
|
2019-09-17 18:30:45 +08:00
|
|
|
|
if (type == AxisType.Value && m_Interval > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index == num - 1) return coordinateWidth - (num - 1) * m_Interval * coordinateWidth / m_ValueRange;
|
|
|
|
|
|
else return m_Interval * coordinateWidth / m_ValueRange;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return coordinateWidth / num;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新刻度标签文字
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
2019-09-17 18:30:45 +08:00
|
|
|
|
public void UpdateLabelText(float coordinateWidth, DataZoom dataZoom)
|
2019-07-13 16:38:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < axisLabelTextList.Count; i++)
|
|
|
|
|
|
{
|
2019-07-15 00:24:04 +08:00
|
|
|
|
if (axisLabelTextList[i] != null)
|
|
|
|
|
|
{
|
2019-09-17 18:30:45 +08:00
|
|
|
|
axisLabelTextList[i].text = GetLabelName(coordinateWidth, i, minValue, maxValue, dataZoom);
|
2019-07-15 00:24:04 +08:00
|
|
|
|
}
|
2019-07-13 16:38:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetTooltipLabel(GameObject label)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_TooltipLabel = label;
|
|
|
|
|
|
m_TooltipLabelRect = label.GetComponent<RectTransform>();
|
|
|
|
|
|
m_TooltipLabelText = label.GetComponentInChildren<Text>();
|
|
|
|
|
|
m_TooltipLabel.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetTooltipLabelColor(Color bgColor, Color textColor)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_TooltipLabel.GetComponent<Image>().color = bgColor;
|
|
|
|
|
|
m_TooltipLabelText.color = textColor;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetTooltipLabelActive(bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_TooltipLabel.SetActive(flag);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateTooptipLabelText(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_TooltipLabelText)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_TooltipLabelText.text = text;
|
|
|
|
|
|
m_TooltipLabelRect.sizeDelta = new Vector2(m_TooltipLabelText.preferredWidth + 8,
|
|
|
|
|
|
m_TooltipLabelText.preferredHeight + 8);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateTooltipLabelPos(Vector2 pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_TooltipLabel)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_TooltipLabel.transform.localPosition = pos;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 调整最大最小值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="minValue"></param>
|
|
|
|
|
|
/// <param name="maxValue"></param>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public void AdjustMinMaxValue(ref int minValue, ref int maxValue)
|
2019-07-13 16:38:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (minMaxType == Axis.AxisMinMaxType.Custom)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (min != 0 || max != 0)
|
|
|
|
|
|
{
|
2019-07-14 14:34:18 +08:00
|
|
|
|
minValue = min;
|
|
|
|
|
|
maxValue = max;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (minMaxType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Axis.AxisMinMaxType.Default:
|
|
|
|
|
|
if (minValue > 0 && maxValue > 0)
|
|
|
|
|
|
{
|
2019-07-14 14:34:18 +08:00
|
|
|
|
minValue = 0;
|
|
|
|
|
|
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
|
2019-07-13 16:38:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (minValue < 0 && maxValue < 0)
|
|
|
|
|
|
{
|
2019-07-14 14:34:18 +08:00
|
|
|
|
minValue = ChartHelper.GetMinDivisibleValue(minValue);
|
|
|
|
|
|
maxValue = 0;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-07-14 14:34:18 +08:00
|
|
|
|
minValue = ChartHelper.GetMinDivisibleValue(minValue);
|
|
|
|
|
|
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
|
2019-07-13 16:38:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Axis.AxisMinMaxType.MinMax:
|
2019-07-14 14:34:18 +08:00
|
|
|
|
minValue = ChartHelper.GetMinDivisibleValue(minValue);
|
|
|
|
|
|
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
|
2019-07-13 16:38:38 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-09-17 18:30:45 +08:00
|
|
|
|
m_ValueRange = maxValue - minValue;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
if (ReferenceEquals(null, obj))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (obj is Axis)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Equals((Axis)obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(Axis other)
|
|
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
if (ReferenceEquals(null, other))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
return show == other.show &&
|
|
|
|
|
|
type == other.type &&
|
2019-05-16 09:39:58 +08:00
|
|
|
|
min == other.min &&
|
|
|
|
|
|
max == other.max &&
|
2019-05-11 04:33:54 +08:00
|
|
|
|
splitNumber == other.splitNumber &&
|
2019-09-17 18:30:45 +08:00
|
|
|
|
interval == other.interval &&
|
2019-05-11 04:33:54 +08:00
|
|
|
|
showSplitLine == other.showSplitLine &&
|
2019-07-03 18:45:48 +08:00
|
|
|
|
m_AxisLabel.Equals(other.axisLabel) &&
|
2019-05-11 04:33:54 +08:00
|
|
|
|
splitLineType == other.splitLineType &&
|
|
|
|
|
|
boundaryGap == other.boundaryGap &&
|
2019-06-29 07:22:57 +08:00
|
|
|
|
axisName.Equals(other.axisName) &&
|
2019-05-11 04:33:54 +08:00
|
|
|
|
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-06-17 04:29:19 +08:00
|
|
|
|
public static bool operator ==(Axis left, Axis right)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return Equals(left, right);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-06-17 04:29:19 +08:00
|
|
|
|
public static bool operator !=(Axis left, Axis right)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
return !(left == right);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ParseJsonData(string jsonData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
|
|
|
|
|
m_Data = ChartHelper.ParseStringFromString(jsonData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <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>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public class XAxis : Axis
|
|
|
|
|
|
{
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public XAxis Clone()
|
|
|
|
|
|
{
|
2019-08-15 21:44:30 +08:00
|
|
|
|
var axis = XAxisPool.Get();
|
2019-07-13 16:38:38 +08:00
|
|
|
|
axis.show = show;
|
|
|
|
|
|
axis.type = type;
|
|
|
|
|
|
axis.min = min;
|
|
|
|
|
|
axis.max = max;
|
|
|
|
|
|
axis.splitNumber = splitNumber;
|
2019-09-17 18:30:45 +08:00
|
|
|
|
axis.interval = interval;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
|
|
|
|
|
|
axis.showSplitLine = showSplitLine;
|
|
|
|
|
|
axis.splitLineType = splitLineType;
|
|
|
|
|
|
axis.boundaryGap = boundaryGap;
|
|
|
|
|
|
axis.axisName.Copy(axisName);
|
|
|
|
|
|
axis.axisLabel.Copy(axisLabel);
|
|
|
|
|
|
axis.data.Clear();
|
2019-08-15 21:44:30 +08:00
|
|
|
|
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
foreach (var d in data) axis.data.Add(d);
|
|
|
|
|
|
return axis;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public static XAxis defaultXAxis
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var axis = new XAxis
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Show = true,
|
|
|
|
|
|
m_Type = AxisType.Category,
|
2019-05-16 09:39:58 +08:00
|
|
|
|
m_Min = 0,
|
|
|
|
|
|
m_Max = 0,
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_SplitNumber = 5,
|
|
|
|
|
|
m_ShowSplitLine = false,
|
|
|
|
|
|
m_SplitLineType = SplitLineType.Dashed,
|
|
|
|
|
|
m_BoundaryGap = true,
|
|
|
|
|
|
m_Data = new List<string>()
|
|
|
|
|
|
{
|
|
|
|
|
|
"x1","x2","x3","x4","x5"
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
return axis;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <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>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
public class YAxis : Axis
|
|
|
|
|
|
{
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public YAxis Clone()
|
|
|
|
|
|
{
|
2019-08-15 21:44:30 +08:00
|
|
|
|
var axis = YAxisPool.Get();
|
2019-07-13 16:38:38 +08:00
|
|
|
|
axis.show = show;
|
|
|
|
|
|
axis.type = type;
|
|
|
|
|
|
axis.min = min;
|
|
|
|
|
|
axis.max = max;
|
|
|
|
|
|
axis.splitNumber = splitNumber;
|
2019-09-17 18:30:45 +08:00
|
|
|
|
axis.interval = interval;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
|
|
|
|
|
|
axis.showSplitLine = showSplitLine;
|
|
|
|
|
|
axis.splitLineType = splitLineType;
|
|
|
|
|
|
axis.boundaryGap = boundaryGap;
|
|
|
|
|
|
axis.axisName.Copy(axisName);
|
|
|
|
|
|
axis.axisLabel.Copy(axisLabel);
|
|
|
|
|
|
axis.data.Clear();
|
2019-08-15 21:44:30 +08:00
|
|
|
|
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
foreach (var d in data) axis.data.Add(d);
|
|
|
|
|
|
return axis;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public static YAxis defaultYAxis
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var axis = new YAxis
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Show = true,
|
|
|
|
|
|
m_Type = AxisType.Value,
|
2019-05-16 09:39:58 +08:00
|
|
|
|
m_Min = 0,
|
|
|
|
|
|
m_Max = 0,
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_SplitNumber = 5,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
m_ShowSplitLine = true,
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_SplitLineType = SplitLineType.Dashed,
|
|
|
|
|
|
m_BoundaryGap = false,
|
|
|
|
|
|
m_Data = new List<string>(5),
|
|
|
|
|
|
};
|
|
|
|
|
|
return axis;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|