2019-07-21 22:58:51 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-07-13 16:38:38 +08:00
|
|
|
|
using System.ComponentModel;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of serie.
|
|
|
|
|
|
/// 系列类型。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public enum SerieType
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 折线图。折线图是用折线将各个数据点标志连接起来的图表,用于展现数据的变化趋势。可用于直角坐标系和极坐标系上。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
Line,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 柱状图。柱状/条形图 通过 柱形的高度/条形的宽度 来表现数据的大小,用于有至少一个类目轴或时间轴的直角坐标系上。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
Bar,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 饼图。饼图主要用于表现不同类目的数据在总和中的占比。每个的弧度表示数据数量的比例。
|
|
|
|
|
|
/// 饼图更适合表现数据相对于总数的百分比等关系。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
Pie,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 雷达图。雷达图主要用于表现多变量的数据,例如球员的各个属性分析。依赖 radar 组件。
|
|
|
|
|
|
/// </summary>
|
2019-07-20 12:18:07 +08:00
|
|
|
|
Radar,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 散点图。直角坐标系上的散点图可以用来展现数据的 x,y 之间的关系,如果数据项有多个维度,
|
|
|
|
|
|
/// 其它维度的值可以通过不同大小的 symbol 展现成气泡图,也可以用颜色来表现。
|
|
|
|
|
|
/// </summary>
|
2019-07-20 12:18:07 +08:00
|
|
|
|
Scatter,
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 带有涟漪特效动画的散点图。利用动画特效可以将某些想要突出的数据进行视觉突出。
|
|
|
|
|
|
/// </summary>
|
2019-10-14 07:45:56 +08:00
|
|
|
|
EffectScatter,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 热力图。主要通过颜色去表现数值的大小,必须要配合 visualMap 组件使用。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Heatmap,
|
2019-07-20 12:18:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether to show as Nightingale chart, which distinguishs data through radius.
|
|
|
|
|
|
/// 是否展示成南丁格尔图,通过半径区分数据大小。
|
|
|
|
|
|
/// </summary>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
public enum RoseType
|
2019-07-20 12:18:07 +08:00
|
|
|
|
{
|
2019-07-29 08:01:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Don't show as Nightingale chart.不展示成南丁格尔玫瑰图
|
|
|
|
|
|
/// </summary>
|
2019-07-20 12:18:07 +08:00
|
|
|
|
None,
|
2019-07-29 08:01:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Use central angle to show the percentage of data, radius to show data size.
|
|
|
|
|
|
/// 扇区圆心角展现数据的百分比,半径展现数据的大小。
|
|
|
|
|
|
/// </summary>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
Radius,
|
2019-07-29 08:01:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// All the sectors will share the same central angle, the data size is shown only through radiuses.
|
|
|
|
|
|
/// 所有扇区圆心角相同,仅通过半径展现数据大小。
|
|
|
|
|
|
/// </summary>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
Area
|
2019-07-14 14:34:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-15 21:44:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the type of line chart.
|
|
|
|
|
|
/// 折线图样式类型
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum LineType
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the normal line chart,
|
2019-09-25 09:44:53 +08:00
|
|
|
|
/// 普通折线图。
|
2019-08-15 21:44:30 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
Normal,
|
|
|
|
|
|
/// <summary>
|
2019-10-01 09:36:24 +08:00
|
|
|
|
/// the smooth line chart,
|
2019-08-15 21:44:30 +08:00
|
|
|
|
/// 平滑曲线。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Smooth,
|
|
|
|
|
|
/// <summary>
|
2019-10-01 09:36:24 +08:00
|
|
|
|
/// the smooth-dash line chart,
|
|
|
|
|
|
/// 平滑虚线。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
SmoothDash,
|
|
|
|
|
|
/// <summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
/// step line.
|
|
|
|
|
|
/// 阶梯线图:当前点。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
StepStart,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// step line.
|
|
|
|
|
|
/// 阶梯线图:当前点和下一个点的中间。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
StepMiddle,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// step line.
|
|
|
|
|
|
/// 阶梯线图:下一个拐点。
|
|
|
|
|
|
/// </summary>
|
2019-09-18 18:23:37 +08:00
|
|
|
|
StepEnd,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 虚线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Dash,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 点线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Dot,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 点划线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
DashDot,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 双点划线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
DashDotDot
|
2019-08-15 21:44:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-30 12:43:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 采样类型
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum SampleType
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取峰值。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Peak,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取过滤点的平均值。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Average,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取过滤点的最大值。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Max,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取过滤点的最小值。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Min,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取过滤点的和。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Sum
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 系列。每个系列通过 type 决定自己的图表类型。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[System.Serializable]
|
2019-10-14 18:13:08 +08:00
|
|
|
|
public class Serie : MainComponent
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-20 12:18:07 +08:00
|
|
|
|
[SerializeField] [DefaultValue("true")] private bool m_Show = true;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[SerializeField] private SerieType m_Type;
|
|
|
|
|
|
[SerializeField] private string m_Name;
|
|
|
|
|
|
[SerializeField] private string m_Stack;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
[SerializeField] [Range(0, 1)] private int m_AxisIndex = 0;
|
|
|
|
|
|
[SerializeField] private int m_RadarIndex = 0;
|
2019-09-29 07:37:53 +08:00
|
|
|
|
[SerializeField] protected int m_MinShow;
|
|
|
|
|
|
[SerializeField] protected int m_MaxShow;
|
|
|
|
|
|
[SerializeField] protected int m_MaxCache;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
[SerializeField] private AreaStyle m_AreaStyle = AreaStyle.defaultAreaStyle;
|
2019-07-21 22:58:51 +08:00
|
|
|
|
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
|
2019-08-15 21:44:30 +08:00
|
|
|
|
[SerializeField] private LineType m_LineType = LineType.Normal;
|
2019-09-29 08:43:49 +08:00
|
|
|
|
[SerializeField] private float m_SampleDist = 0;
|
2019-09-30 12:43:26 +08:00
|
|
|
|
[SerializeField] private SampleType m_SampleType = SampleType.Average;
|
|
|
|
|
|
[SerializeField] private float m_SampleAverage = 0;
|
|
|
|
|
|
|
2019-08-15 21:44:30 +08:00
|
|
|
|
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
|
|
|
|
|
[SerializeField] private float m_BarWidth = 0.6f;
|
|
|
|
|
|
[SerializeField] private float m_BarGap = 0.3f; // 30%
|
|
|
|
|
|
[SerializeField] private float m_BarCategoryGap = 0.2f; // 20%
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
#region PieChart field
|
2019-07-28 00:44:53 +08:00
|
|
|
|
[SerializeField] private bool m_ClickOffset = true;
|
|
|
|
|
|
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
|
|
|
|
|
[SerializeField] private float m_Space;
|
|
|
|
|
|
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
|
|
|
|
|
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
|
|
|
|
|
|
#endregion
|
2019-07-29 00:25:10 +08:00
|
|
|
|
[SerializeField] private SerieLabel m_Label = new SerieLabel();
|
2019-09-02 08:43:52 +08:00
|
|
|
|
[SerializeField] private Animation m_Animation = new Animation();
|
2019-09-19 19:26:05 +08:00
|
|
|
|
[SerializeField] private LineArrow m_LineArrow = new LineArrow();
|
2019-10-14 07:45:56 +08:00
|
|
|
|
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
|
|
|
|
|
[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
2019-08-04 15:24:31 +08:00
|
|
|
|
[SerializeField] [Range(1, 10)] private int m_ShowDataDimension;
|
2019-07-21 22:58:51 +08:00
|
|
|
|
[SerializeField] private bool m_ShowDataName;
|
2019-09-24 18:47:43 +08:00
|
|
|
|
[SerializeField] private bool m_ShowDataIcon;
|
|
|
|
|
|
|
2019-07-21 22:58:51 +08:00
|
|
|
|
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2019-08-07 07:59:00 +08:00
|
|
|
|
[NonSerialized] private int m_FilterStart;
|
|
|
|
|
|
[NonSerialized] private int m_FilterEnd;
|
|
|
|
|
|
[NonSerialized] private List<SerieData> m_FilterData;
|
2019-08-15 21:44:30 +08:00
|
|
|
|
[NonSerialized] private Dictionary<int, List<Vector3>> m_UpSmoothPoints = new Dictionary<int, List<Vector3>>();
|
|
|
|
|
|
[NonSerialized] private Dictionary<int, List<Vector3>> m_DownSmoothPoints = new Dictionary<int, List<Vector3>>();
|
2019-08-07 07:59:00 +08:00
|
|
|
|
[NonSerialized] private List<Vector3> m_DataPoints = new List<Vector3>();
|
2019-10-09 02:37:05 +08:00
|
|
|
|
[NonSerialized] private bool m_NeedUpdateFilterData;
|
2019-08-07 07:59:00 +08:00
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether to show serie in chart.
|
|
|
|
|
|
/// 系列是否显示在图表上。
|
|
|
|
|
|
/// </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 chart type of serie.
|
|
|
|
|
|
/// 系列的图表类型。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public SerieType type { get { return m_Type; } set { m_Type = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Series name used for displaying in tooltip and filtering with legend.
|
|
|
|
|
|
/// 系列名称,用于 tooltip 的显示,legend 的图例筛选。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public string name { get { return m_Name; } set { m_Name = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-10-03 09:42:03 +08:00
|
|
|
|
/// 图例名称。当系列名称不为空时,图例名称即为系列名称;反之则为索引index。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string legendName { get { return string.IsNullOrEmpty(name) ? ChartCached.IntToStr(index) : name; } }
|
|
|
|
|
|
/// <summary>
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// 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>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public string stack { get { return m_Stack; } set { m_Stack = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Index of axis to combine with, which is useful for multiple x axes in one chart.
|
|
|
|
|
|
/// 使用的坐标轴轴的 index,在单个图表实例中存在多个坐标轴轴的时候有用。
|
|
|
|
|
|
/// </summary>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public int axisIndex { get { return m_AxisIndex; } set { m_AxisIndex = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// Index of radar component that radar chart uses.
|
|
|
|
|
|
/// 雷达图所使用的 radar 组件的 index。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int radarIndex { get { return m_RadarIndex; } set { m_RadarIndex = value; } }
|
|
|
|
|
|
/// <summary>
|
2019-09-29 07:37:53 +08:00
|
|
|
|
/// The min number of data to show in chart.
|
|
|
|
|
|
/// 系列所显示数据的最小索引
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int minShow
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_MinShow; }
|
|
|
|
|
|
set { m_MinShow = value; if (m_MinShow < 0) m_MinShow = 0; }
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The max number of data to show in chart.
|
|
|
|
|
|
/// 系列所显示数据的最大索引
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int maxShow
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_MaxShow; }
|
|
|
|
|
|
set { m_MaxShow = value; if (m_MaxShow < 0) m_MaxShow = 0; }
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The max number of serie data cache.
|
|
|
|
|
|
/// The first data will be remove when the size of serie data is larger then maxCache.
|
|
|
|
|
|
/// default:0,unlimited.
|
|
|
|
|
|
/// 系列中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int maxCache
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_MaxCache; }
|
|
|
|
|
|
set { m_MaxCache = value; if (m_MaxCache < 0) m_MaxCache = 0; }
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// The style of area.
|
|
|
|
|
|
/// 区域填充样式。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
|
|
|
|
|
public AreaStyle areaStyle { get { return m_AreaStyle; } set { m_AreaStyle = value; } }
|
|
|
|
|
|
/// <summary>
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// the symbol of serie data item.
|
|
|
|
|
|
/// 标记的图形。
|
|
|
|
|
|
/// </summary>
|
2019-07-21 22:58:51 +08:00
|
|
|
|
public SerieSymbol symbol { get { return m_Symbol; } set { m_Symbol = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
/// The type of line chart.
|
|
|
|
|
|
/// 折线图样式类型。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
|
|
|
|
|
public LineType lineType { get { return m_LineType; } set { m_LineType = value; } }
|
|
|
|
|
|
/// <summary>
|
2019-09-29 06:58:26 +08:00
|
|
|
|
/// the min pixel dist of sample.
|
2019-09-29 08:43:49 +08:00
|
|
|
|
/// 采样的最小像素距离,默认为0时不采样。当两个数据点间的水平距离小于改值时,开启采样,保证两点间的水平距离不小于改值。
|
2019-09-29 06:58:26 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
2019-09-29 08:43:49 +08:00
|
|
|
|
public float sampleDist { get { return m_SampleDist; } set { m_SampleDist = value < 0 ? 0 : value; } }
|
2019-09-29 06:58:26 +08:00
|
|
|
|
/// <summary>
|
2019-09-30 12:43:26 +08:00
|
|
|
|
/// the type of sample.
|
|
|
|
|
|
/// 采样类型。当sampleDist大于0时有效。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public SampleType sampleType { get { return m_SampleType; } set { m_SampleType = value; } }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设定的采样平均值。当sampleType 为 Peak 时,用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
|
|
|
|
|
public float sampleAverage { get { return m_SampleAverage; } set { m_SampleAverage = value; } }
|
|
|
|
|
|
/// <summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
/// The style of line.
|
|
|
|
|
|
/// 线条样式。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
|
|
|
|
|
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The width of the bar. Adaptive when default 0.
|
|
|
|
|
|
/// 柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
|
|
|
|
|
public float barWidth { get { return m_BarWidth; } set { m_BarWidth = value; } }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The gap between bars between different series, is a percent value like '0.3f' , which means 30% of the bar width, can be set as a fixed value.
|
|
|
|
|
|
/// <para>Set barGap as '-1' can overlap bars that belong to different series, which is useful when making a series of bar be background.
|
|
|
|
|
|
/// In a single coodinate system, this attribute is shared by multiple 'bar' series.
|
|
|
|
|
|
/// This attribute should be set on the last 'bar' series in the coodinate system,
|
|
|
|
|
|
/// then it will be adopted by all 'bar' series in the coordinate system.</para>
|
|
|
|
|
|
/// 不同系列的柱间距离。为百分比(如 '0.3f',表示柱子宽度的 30%)
|
|
|
|
|
|
/// 如果想要两个系列的柱子重叠,可以设置 barGap 为 '-1f'。这在用柱子做背景的时候有用。
|
|
|
|
|
|
/// 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
|
|
|
|
|
public float barGap { get { return m_BarGap; } set { m_BarGap = value; } }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The bar gap of a single series, defaults to be 20% of the category gap, can be set as a fixed value.
|
|
|
|
|
|
/// In a single coodinate system, this attribute is shared by multiple 'bar' series.
|
|
|
|
|
|
/// This attribute should be set on the last 'bar' series in the coodinate system,
|
|
|
|
|
|
/// then it will be adopted by all 'bar' series in the coordinate system.
|
|
|
|
|
|
/// 同一系列的柱间距离,默认为类目间距的20%,可设固定值。
|
|
|
|
|
|
/// 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
|
|
|
|
|
public float barCategoryGap { get { return m_BarCategoryGap; } set { m_BarCategoryGap = value; } }
|
|
|
|
|
|
/// <summary>
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// Whether offset when mouse click pie chart item.
|
|
|
|
|
|
/// 鼠标点击时是否开启偏移,一般用在PieChart图表中。
|
|
|
|
|
|
/// </summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public bool pieClickOffset { get { return m_ClickOffset; } set { m_ClickOffset = value; } }
|
2019-07-29 08:01:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether to show as Nightingale chart.
|
|
|
|
|
|
/// 是否展示成南丁格尔图,通过半径区分数据大小。
|
|
|
|
|
|
/// </summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public RoseType pieRoseType { get { return m_RoseType; } set { m_RoseType = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the space of pie chart item.
|
|
|
|
|
|
/// 饼图项间的空隙留白。
|
|
|
|
|
|
/// </summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public float pieSpace { get { return m_Space; } set { m_Space = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the center of pie chart.
|
|
|
|
|
|
/// 饼图的中心点。
|
|
|
|
|
|
/// </summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public float[] pieCenter { get { return m_Center; } set { m_Center = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the radius of pie chart.
|
|
|
|
|
|
/// 饼图的半径。radius[0]表示内径,radius[1]表示外径。
|
|
|
|
|
|
/// </summary>
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public float[] pieRadius { get { return m_Radius; } set { m_Radius = value; } }
|
2019-07-29 00:25:10 +08:00
|
|
|
|
/// <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; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-09-19 19:26:05 +08:00
|
|
|
|
/// The start animation.
|
|
|
|
|
|
/// 起始动画。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
2019-09-02 08:43:52 +08:00
|
|
|
|
public Animation animation { get { return m_Animation; } set { m_Animation = value; } }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-09-19 19:26:05 +08:00
|
|
|
|
/// The arrow of line.
|
2019-10-14 07:45:56 +08:00
|
|
|
|
/// 折线图的箭头。
|
2019-09-19 19:26:05 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public LineArrow lineArrow { get { return m_LineArrow; } set { m_LineArrow = value; } }
|
2019-10-14 07:45:56 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The style of data item.
|
|
|
|
|
|
/// 图形样式。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ItemStyle itemStyle { get { return m_ItemStyle; } set { m_ItemStyle = value; } }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 高亮的图形样式和文本标签样式。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Emphasis emphasis { get { return m_Emphasis; } set { m_Emphasis = value; } }
|
|
|
|
|
|
|
2019-09-19 19:26:05 +08:00
|
|
|
|
/// <summary>
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
|
|
|
|
|
/// </summary>
|
2019-07-29 00:25:10 +08:00
|
|
|
|
public List<SerieData> data { get { return m_Data; } }
|
2019-07-28 00:44:53 +08:00
|
|
|
|
|
2019-07-29 00:25:10 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The index of serie,start at 0.
|
|
|
|
|
|
/// 系列的索引,从0开始。
|
|
|
|
|
|
/// </summary>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
public int index { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether the serie is highlighted.
|
|
|
|
|
|
/// 该系列是否高亮,一般由图例悬停触发。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool highlighted { get; set; }
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the count of data list.
|
|
|
|
|
|
/// 数据项个数。
|
|
|
|
|
|
/// </summary>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
public int dataCount { get { return m_Data.Count; } }
|
2019-10-05 18:23:06 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 数据项位置坐标。
|
|
|
|
|
|
/// </summary>
|
2019-08-07 07:59:00 +08:00
|
|
|
|
public List<Vector3> dataPoints { get { return m_DataPoints; } }
|
2019-10-05 18:23:06 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 饼图的中心点位置。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Vector3 pieCenterPos { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 饼图的内径
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float pieInsideRadius { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 饼图的外径
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float pieOutsideRadius { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 饼图的数据项最大值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float pieDataMax { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 饼图的数据项之和
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float pieDataTotal { get; set; }
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public List<Vector3> GetUpSmoothList(int dataIndex, int size = 100)
|
2019-08-07 07:59:00 +08:00
|
|
|
|
{
|
2019-08-15 21:44:30 +08:00
|
|
|
|
if (m_UpSmoothPoints.ContainsKey(dataIndex))
|
2019-08-07 07:59:00 +08:00
|
|
|
|
{
|
2019-08-15 21:44:30 +08:00
|
|
|
|
return m_UpSmoothPoints[dataIndex];
|
2019-08-07 07:59:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = new List<Vector3>(size);
|
2019-08-15 21:44:30 +08:00
|
|
|
|
m_UpSmoothPoints[dataIndex] = list;
|
2019-08-07 07:59:00 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-07-14 14:34:18 +08:00
|
|
|
|
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public List<Vector3> GetDownSmoothList(int dataIndex, int size = 100)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_DownSmoothPoints.ContainsKey(dataIndex))
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_DownSmoothPoints[dataIndex];
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = new List<Vector3>(size);
|
|
|
|
|
|
m_DownSmoothPoints[dataIndex] = list;
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ClearSmoothList(int dataIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_UpSmoothPoints.ContainsKey(dataIndex))
|
|
|
|
|
|
{
|
|
|
|
|
|
m_UpSmoothPoints[dataIndex].Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_DownSmoothPoints.ContainsKey(dataIndex))
|
|
|
|
|
|
{
|
|
|
|
|
|
m_DownSmoothPoints[dataIndex].Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 维度Y对应数据中最大值。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public float yMax
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
float max = int.MinValue;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
foreach (var sdata in data)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
if (sdata.show && sdata.data[1] > max)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
max = sdata.data[1];
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return max;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 维度X对应数据中的最大值。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public float xMax
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
float max = int.MinValue;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
foreach (var sdata in data)
|
2019-07-14 14:34:18 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
if (sdata.show && sdata.data[0] > max)
|
2019-07-14 14:34:18 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
max = sdata.data[0];
|
2019-07-14 14:34:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return max;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 维度Y对应数据的最小值。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public float yMin
|
2019-05-13 09:48:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
float min = int.MaxValue;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
foreach (var sdata in data)
|
2019-05-13 09:48:47 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
if (sdata.show && sdata.data[1] < min)
|
2019-05-13 09:48:47 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
min = sdata.data[1];
|
2019-05-13 09:48:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return min;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 维度X对应数据的最小值。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public float xMin
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
float min = int.MaxValue;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
foreach (var sdata in data)
|
2019-07-14 14:34:18 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
if (sdata.show && sdata.data[0] < min)
|
2019-07-14 14:34:18 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
min = sdata.data[0];
|
2019-07-14 14:34:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return min;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 维度Y数据的总和。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public float yTotal
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
float total = 0;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
foreach (var sdata in data)
|
2019-07-14 14:34:18 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
if (sdata.show)
|
|
|
|
|
|
total += sdata.data[1];
|
2019-07-14 14:34:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
return total;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 维度X数据的总和。
|
|
|
|
|
|
/// </summary>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public float xTotal
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
float total = 0;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
foreach (var sdata in data)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
if (sdata.show)
|
|
|
|
|
|
total += sdata.data[0];
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
return total;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清空所有数据
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public void ClearData()
|
|
|
|
|
|
{
|
2019-07-21 22:58:51 +08:00
|
|
|
|
m_Data.Clear();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 移除指定索引的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public void RemoveData(int index)
|
|
|
|
|
|
{
|
2019-07-21 22:58:51 +08:00
|
|
|
|
m_Data.RemoveAt(index);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加一个数据到维度Y(此时维度X对应的数据是索引)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
|
/// <param name="dataName"></param>
|
2019-09-29 07:37:53 +08:00
|
|
|
|
public void AddYData(float value, string dataName = null)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-09-29 07:37:53 +08:00
|
|
|
|
if (m_MaxCache > 0)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-10-09 02:37:05 +08:00
|
|
|
|
while (m_Data.Count > m_MaxCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_NeedUpdateFilterData = true;
|
|
|
|
|
|
m_Data.RemoveAt(0);
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
2019-09-16 18:17:49 +08:00
|
|
|
|
int xValue = m_Data.Count;
|
2019-07-21 22:58:51 +08:00
|
|
|
|
m_Data.Add(new SerieData() { data = new List<float>() { xValue, value }, name = dataName });
|
2019-07-15 00:24:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加(x,y)数据到维度X和维度Y
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="xValue"></param>
|
|
|
|
|
|
/// <param name="yValue"></param>
|
|
|
|
|
|
/// <param name="dataName"></param>
|
|
|
|
|
|
/// <param name="maxDataNumber"></param>
|
2019-09-29 07:37:53 +08:00
|
|
|
|
public void AddXYData(float xValue, float yValue, string dataName = null)
|
2019-07-15 00:24:04 +08:00
|
|
|
|
{
|
2019-09-29 07:37:53 +08:00
|
|
|
|
if (m_MaxCache > 0)
|
2019-07-15 00:24:04 +08:00
|
|
|
|
{
|
2019-10-09 02:37:05 +08:00
|
|
|
|
while (m_Data.Count > m_MaxCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_NeedUpdateFilterData = true;
|
|
|
|
|
|
m_Data.RemoveAt(0);
|
|
|
|
|
|
}
|
2019-07-15 00:24:04 +08:00
|
|
|
|
}
|
2019-07-21 22:58:51 +08:00
|
|
|
|
m_Data.Add(new SerieData() { data = new List<float>() { xValue, yValue }, name = dataName });
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将一组数据添加到系列中。
|
|
|
|
|
|
/// 如果数据只有一个,默认添加到维度Y中。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="valueList"></param>
|
|
|
|
|
|
/// <param name="dataName"></param>
|
|
|
|
|
|
/// <param name="maxDataNumber"></param>
|
2019-09-29 07:37:53 +08:00
|
|
|
|
public void AddData(List<float> valueList, string dataName = null)
|
2019-07-25 09:42:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (valueList == null || valueList.Count == 0) return;
|
|
|
|
|
|
if (valueList.Count == 1)
|
|
|
|
|
|
{
|
2019-09-29 07:37:53 +08:00
|
|
|
|
AddYData(valueList[0], dataName);
|
2019-07-25 09:42:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (valueList.Count == 2)
|
|
|
|
|
|
{
|
2019-09-29 07:37:53 +08:00
|
|
|
|
AddXYData(valueList[0], valueList[1], dataName);
|
2019-07-25 09:42:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-09-29 07:37:53 +08:00
|
|
|
|
if (m_MaxCache > 0)
|
2019-07-25 09:42:00 +08:00
|
|
|
|
{
|
2019-10-09 02:37:05 +08:00
|
|
|
|
while (m_Data.Count > m_MaxCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_NeedUpdateFilterData = true;
|
|
|
|
|
|
m_Data.RemoveAt(0);
|
|
|
|
|
|
}
|
2019-07-25 09:42:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
var serieData = new SerieData();
|
|
|
|
|
|
serieData.name = dataName;
|
|
|
|
|
|
for (int i = 0; i < valueList.Count; i++)
|
|
|
|
|
|
{
|
2019-08-04 15:24:31 +08:00
|
|
|
|
serieData.data.Add(valueList[i]);
|
2019-07-25 09:42:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
m_Data.Add(serieData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得维度Y索引对应的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public float GetYData(int index, DataZoom dataZoom = null)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-25 09:42:00 +08:00
|
|
|
|
if (index < 0) return 0;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
var serieData = GetDataList(dataZoom);
|
|
|
|
|
|
if (index < serieData.Count)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
return serieData[index].data[1];
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
2019-07-28 00:44:53 +08:00
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得维度Y索引对应的数据和数据名
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index">索引</param>
|
|
|
|
|
|
/// <param name="yData">对应的数据值</param>
|
|
|
|
|
|
/// <param name="dataName">对应的数据名</param>
|
|
|
|
|
|
/// <param name="dataZoom">区域缩放</param>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
public void GetYData(int index, out float yData, out string dataName, DataZoom dataZoom = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
yData = 0;
|
|
|
|
|
|
dataName = null;
|
|
|
|
|
|
if (index < 0) return;
|
|
|
|
|
|
var serieData = GetDataList(dataZoom);
|
|
|
|
|
|
if (index < serieData.Count)
|
2019-07-25 09:42:00 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
yData = serieData[index].data[1];
|
|
|
|
|
|
dataName = serieData[index].name;
|
2019-07-25 09:42:00 +08:00
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得指定索引的数据项
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-07-24 23:38:23 +08:00
|
|
|
|
public SerieData GetSerieData(int index, DataZoom dataZoom = null)
|
|
|
|
|
|
{
|
2019-07-22 19:02:28 +08:00
|
|
|
|
var data = GetDataList(dataZoom);
|
|
|
|
|
|
if (index >= 0 && index <= data.Count - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return data[index];
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得指定索引的维度X和维度Y的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <param name="xValue"></param>
|
|
|
|
|
|
/// <param name="yVlaue"></param>
|
2019-07-15 00:24:04 +08:00
|
|
|
|
public void GetXYData(int index, DataZoom dataZoom, out float xValue, out float yVlaue)
|
|
|
|
|
|
{
|
|
|
|
|
|
xValue = 0;
|
|
|
|
|
|
yVlaue = 0;
|
2019-07-25 09:42:00 +08:00
|
|
|
|
if (index < 0) return;
|
2019-07-28 00:44:53 +08:00
|
|
|
|
var showData = GetDataList(dataZoom);
|
|
|
|
|
|
if (index < showData.Count)
|
2019-07-25 09:42:00 +08:00
|
|
|
|
{
|
2019-07-28 00:44:53 +08:00
|
|
|
|
var serieData = showData[index];
|
|
|
|
|
|
xValue = serieData.data[0];
|
|
|
|
|
|
yVlaue = serieData.data[1];
|
2019-07-25 09:42:00 +08:00
|
|
|
|
}
|
2019-07-15 00:24:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得系列的数据列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-10-14 07:45:56 +08:00
|
|
|
|
public List<SerieData> GetDataList(DataZoom dataZoom = null)
|
2019-07-21 22:58:51 +08:00
|
|
|
|
{
|
2019-10-09 02:37:05 +08:00
|
|
|
|
if (dataZoom != null && dataZoom.enable)
|
2019-07-21 22:58:51 +08:00
|
|
|
|
{
|
2019-10-09 02:37:05 +08:00
|
|
|
|
UpdateFilterData(dataZoom);
|
2019-08-07 07:59:00 +08:00
|
|
|
|
return m_FilterData;
|
2019-07-21 22:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_Data;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得指定维数的最大最小值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dimension"></param>
|
|
|
|
|
|
/// <param name="dataZoom"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public void GetMinMaxData(int dimension, out float minValue, out float maxValue, DataZoom dataZoom = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var dataList = GetDataList(dataZoom);
|
|
|
|
|
|
float max = float.MinValue;
|
|
|
|
|
|
float min = float.MaxValue;
|
|
|
|
|
|
for (int i = 0; i < dataList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var serieData = dataList[i];
|
|
|
|
|
|
if (serieData.data.Count > dimension)
|
|
|
|
|
|
{
|
|
|
|
|
|
var value = serieData.data[dimension];
|
|
|
|
|
|
if (value > max) max = value;
|
|
|
|
|
|
if (value < min) min = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
maxValue = max;
|
|
|
|
|
|
minValue = min;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-10-09 02:37:05 +08:00
|
|
|
|
private List<SerieData> emptyFilter = new List<SerieData>();
|
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)
|
|
|
|
|
|
{
|
2019-10-09 02:37:05 +08:00
|
|
|
|
if (dataZoom != null && dataZoom.enable)
|
2019-06-13 09:53:03 +08:00
|
|
|
|
{
|
2019-08-04 23:01:34 +08:00
|
|
|
|
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
|
|
|
|
|
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
2019-10-09 02:37:05 +08:00
|
|
|
|
if (startIndex != m_FilterStart || endIndex != m_FilterEnd || m_NeedUpdateFilterData)
|
2019-06-13 09:53:03 +08:00
|
|
|
|
{
|
2019-08-07 07:59:00 +08:00
|
|
|
|
m_FilterStart = startIndex;
|
|
|
|
|
|
m_FilterEnd = endIndex;
|
2019-10-09 02:37:05 +08:00
|
|
|
|
m_NeedUpdateFilterData = false;
|
2019-07-21 22:58:51 +08:00
|
|
|
|
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
|
|
|
|
|
if (m_Data.Count > 0)
|
|
|
|
|
|
{
|
2019-08-07 07:59:00 +08:00
|
|
|
|
m_FilterData = m_Data.GetRange(startIndex, count);
|
2019-07-21 22:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-08-07 07:59:00 +08:00
|
|
|
|
m_FilterData = m_Data;
|
2019-07-21 22:58:51 +08:00
|
|
|
|
}
|
2019-06-13 09:53:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (endIndex == 0)
|
|
|
|
|
|
{
|
2019-10-09 02:37:05 +08:00
|
|
|
|
m_FilterData = emptyFilter;
|
2019-06-13 09:53:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新指定索引的维度Y数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <param name="value"></param>
|
2019-07-14 14:34:18 +08:00
|
|
|
|
public void UpdateYData(int index, float value)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-08-13 10:20:15 +08:00
|
|
|
|
UpdateData(index, 1, value);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新指定索引的维度X和维度Y的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <param name="xValue"></param>
|
|
|
|
|
|
/// <param name="yValue"></param>
|
2019-07-15 00:24:04 +08:00
|
|
|
|
public void UpdateXYData(int index, float xValue, float yValue)
|
|
|
|
|
|
{
|
2019-08-13 10:20:15 +08:00
|
|
|
|
UpdateData(index, 0, xValue);
|
|
|
|
|
|
UpdateData(index, 1, yValue);
|
2019-07-25 09:42:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新指定索引指定维数的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index">要更新数据的索引</param>
|
|
|
|
|
|
/// <param name="dimension">要更新数据的维数</param>
|
|
|
|
|
|
/// <param name="value">新的数据值</param>
|
2019-07-25 09:42:00 +08:00
|
|
|
|
public void UpdateData(int index, int dimension, float value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index < 0) return;
|
|
|
|
|
|
if (index < m_Data.Count && dimension < m_Data[index].data.Count)
|
2019-07-15 00:24:04 +08:00
|
|
|
|
{
|
2019-07-25 09:42:00 +08:00
|
|
|
|
m_Data[index].data[dimension] = value;
|
2019-07-15 00:24:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-14 08:52:28 +08:00
|
|
|
|
public void UpdateDataName(int index, string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index >= 0 && index < m_Data.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
var serieData = m_Data[index];
|
|
|
|
|
|
serieData.name = name;
|
2019-08-20 09:40:19 +08:00
|
|
|
|
if (serieData.labelText != null)
|
2019-08-14 08:52:28 +08:00
|
|
|
|
{
|
2019-08-20 09:40:19 +08:00
|
|
|
|
serieData.labelText.text = name == null ? "" : name;
|
2019-08-14 08:52:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清除所有数据的高亮标志
|
|
|
|
|
|
/// </summary>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
public void ClearHighlight()
|
|
|
|
|
|
{
|
|
|
|
|
|
highlighted = false;
|
|
|
|
|
|
foreach (var sd in m_Data)
|
|
|
|
|
|
{
|
|
|
|
|
|
sd.highlighted = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置指定索引的数据为高亮状态
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
public void SetHighlight(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index <= 0) return;
|
|
|
|
|
|
for (int i = 0; i < m_Data.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Data[i].highlighted = index == i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-04 15:24:31 +08:00
|
|
|
|
public Color GetAreaColor(ThemeInfo theme, int index, bool highlight)
|
|
|
|
|
|
{
|
2019-10-09 18:54:58 +08:00
|
|
|
|
var color = areaStyle.color != Color.clear ? areaStyle.color : (Color)theme.GetColor(index);
|
|
|
|
|
|
if (highlight)
|
2019-08-04 15:24:31 +08:00
|
|
|
|
{
|
2019-10-09 18:54:58 +08:00
|
|
|
|
if (areaStyle.highlightColor != Color.clear) color = areaStyle.highlightColor;
|
|
|
|
|
|
else color *= color;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
}
|
2019-10-09 18:54:58 +08:00
|
|
|
|
color.a *= areaStyle.opacity;
|
|
|
|
|
|
return color;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public Color GetAreaToColor(ThemeInfo theme, int index, bool highlight)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (areaStyle.toColor != Color.clear)
|
|
|
|
|
|
{
|
|
|
|
|
|
var color = areaStyle.toColor;
|
2019-10-09 18:54:58 +08:00
|
|
|
|
if (highlight)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (areaStyle.highlightToColor != Color.clear) color = areaStyle.highlightToColor;
|
|
|
|
|
|
else color *= color;
|
|
|
|
|
|
}
|
2019-08-15 21:44:30 +08:00
|
|
|
|
color.a *= areaStyle.opacity;
|
|
|
|
|
|
return color;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetAreaColor(theme, index, highlight);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-04 15:24:31 +08:00
|
|
|
|
public Color GetLineColor(ThemeInfo theme, int index, bool highlight)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (lineStyle.color != Color.clear)
|
|
|
|
|
|
{
|
|
|
|
|
|
var color = lineStyle.color;
|
|
|
|
|
|
if (highlight) color *= color;
|
2019-08-15 21:44:30 +08:00
|
|
|
|
color.a *= lineStyle.opacity;
|
|
|
|
|
|
return color;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var color = (Color)theme.GetColor(index);
|
|
|
|
|
|
if (highlight) color *= color;
|
|
|
|
|
|
color.a *= lineStyle.opacity;
|
|
|
|
|
|
return color;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Color GetSymbolColor(ThemeInfo theme, int index, bool highlight)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (symbol.color != Color.clear)
|
|
|
|
|
|
{
|
|
|
|
|
|
var color = symbol.color;
|
|
|
|
|
|
if (highlight) color *= color;
|
|
|
|
|
|
color.a *= symbol.opacity;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
return color;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var color = (Color)theme.GetColor(index);
|
|
|
|
|
|
if (highlight) color *= color;
|
2019-08-15 21:44:30 +08:00
|
|
|
|
color.a *= symbol.opacity;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
return color;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-15 21:44:30 +08:00
|
|
|
|
public float GetBarWidth(float categoryWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_BarWidth > 1) return m_BarWidth;
|
|
|
|
|
|
else return m_BarWidth * categoryWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public float GetBarGap(float categoryWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_BarGap == -1) return 0;
|
|
|
|
|
|
else if (m_BarGap <= 1) return GetBarWidth(categoryWidth) * m_BarGap;
|
|
|
|
|
|
else return m_BarGap;
|
|
|
|
|
|
}
|
2019-09-24 18:47:43 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置所有数据的图标是否显示
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="flag"></param>
|
|
|
|
|
|
public void SetDataIconActive(bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var data in m_Data)
|
|
|
|
|
|
{
|
|
|
|
|
|
data.showIcon = flag;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置指定index的数据图标是否显示
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataIndex"></param>
|
|
|
|
|
|
/// <param name="flag"></param>
|
|
|
|
|
|
public void SetDataIconActive(int dataIndex, bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = m_Data[dataIndex];
|
|
|
|
|
|
data.showIcon = flag;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 统一设置图标的尺寸
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="width"></param>
|
|
|
|
|
|
/// <param name="height"></param>
|
|
|
|
|
|
public void SetDataIconSize(float width, float height)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var data in m_Data)
|
|
|
|
|
|
{
|
|
|
|
|
|
data.iconWidth = width;
|
|
|
|
|
|
data.iconHeight = height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置指定index的数据图标的图片
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataIndex"></param>
|
|
|
|
|
|
/// <param name="image"></param>
|
|
|
|
|
|
public void SetDataIcon(int dataIndex, Sprite image)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = m_Data[dataIndex];
|
|
|
|
|
|
data.iconImage = image;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-25 09:44:53 +08:00
|
|
|
|
public bool IsNeedShowDataIcon()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var data in m_Data)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (data.showIcon) return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-24 18:47:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置指定index的数据图标的尺寸
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataIndex"></param>
|
|
|
|
|
|
/// <param name="width"></param>
|
|
|
|
|
|
/// <param name="height"></param>
|
|
|
|
|
|
public void SetDataIconSize(int dataIndex, float width, float height)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = m_Data[dataIndex];
|
|
|
|
|
|
data.iconWidth = width;
|
|
|
|
|
|
data.iconHeight = height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置指定index的数据图标的颜色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dataIndex"></param>
|
|
|
|
|
|
/// <param name="color"></param>
|
|
|
|
|
|
public void SetDataIconColor(int dataIndex, Color color)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = m_Data[dataIndex];
|
|
|
|
|
|
data.iconColor = color;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从json中导入数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="jsonData"></param>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public override void ParseJsonData(string jsonData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
2019-07-21 22:58:51 +08:00
|
|
|
|
jsonData = jsonData.Replace("\r\n", "");
|
|
|
|
|
|
jsonData = jsonData.Replace(" ", "");
|
|
|
|
|
|
jsonData = jsonData.Replace("\n", "");
|
|
|
|
|
|
int startIndex = jsonData.IndexOf("[");
|
|
|
|
|
|
int endIndex = jsonData.LastIndexOf("]");
|
2019-07-25 09:42:00 +08:00
|
|
|
|
if (startIndex == -1 || endIndex == -1)
|
|
|
|
|
|
{
|
2019-07-24 23:38:23 +08:00
|
|
|
|
Debug.LogError("json data need include in [ ]");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
ClearData();
|
2019-07-21 22:58:51 +08:00
|
|
|
|
string temp = jsonData.Substring(startIndex + 1, endIndex - startIndex - 1);
|
|
|
|
|
|
if (temp.IndexOf("],") > -1 || temp.IndexOf("] ,") > -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] datas = temp.Split(new string[] { "],", "] ," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
for (int i = 0; i < datas.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = datas[i].Split(new char[] { '[', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
var serieData = new SerieData();
|
|
|
|
|
|
for (int j = 0; j < data.Length; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var txt = data[j].Trim().Replace("]", "");
|
|
|
|
|
|
float value;
|
|
|
|
|
|
var flag = float.TryParse(txt, out value);
|
|
|
|
|
|
if (flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
serieData.data.Add(value);
|
|
|
|
|
|
}
|
|
|
|
|
|
else serieData.name = txt.Replace("\"", "").Trim();
|
|
|
|
|
|
}
|
|
|
|
|
|
m_Data.Add(serieData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-07-28 00:44:53 +08:00
|
|
|
|
else if (temp.IndexOf("value") > -1 && temp.IndexOf("name") > -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] datas = temp.Split(new string[] { "},", "} ,", "}" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
for (int i = 0; i < datas.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var arr = datas[i].Replace("{", "").Split(',');
|
|
|
|
|
|
var serieData = new SerieData();
|
|
|
|
|
|
foreach (var a in arr)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (a.StartsWith("value:"))
|
|
|
|
|
|
{
|
|
|
|
|
|
float value = float.Parse(a.Substring(6, a.Length - 6));
|
|
|
|
|
|
serieData.data = new List<float>() { i, value };
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (a.StartsWith("name:"))
|
|
|
|
|
|
{
|
|
|
|
|
|
string name = a.Substring(6, a.Length - 6 - 1);
|
|
|
|
|
|
serieData.name = name;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (a.StartsWith("selected:"))
|
|
|
|
|
|
{
|
|
|
|
|
|
string selected = a.Substring(9, a.Length - 9);
|
|
|
|
|
|
serieData.selected = bool.Parse(selected);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
m_Data.Add(serieData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-07-21 22:58:51 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] datas = temp.Split(',');
|
|
|
|
|
|
for (int i = 0; i < datas.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
float value;
|
|
|
|
|
|
var flag = float.TryParse(datas[i].Trim(), out value);
|
|
|
|
|
|
if (flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
var serieData = new SerieData();
|
2019-07-28 00:44:53 +08:00
|
|
|
|
serieData.data = new List<float>() { i, value };
|
2019-07-21 22:58:51 +08:00
|
|
|
|
m_Data.Add(serieData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|