2019-10-22 04:09:04 +08:00
|
|
|
|
/******************************************/
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Copyright (c) 2018 monitor1394 */
|
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 图例组件。
|
|
|
|
|
|
/// 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[System.Serializable]
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public class Legend : MainComponent, IPropertyChanged
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
|
|
|
|
|
/// It is enabled by default, and you may set it to be false to disabled it.
|
|
|
|
|
|
/// 图例选择的模式,控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public enum SelectedMode
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 多选。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Multiple,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 单选。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Single,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 无法选择。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
None
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[SerializeField] private bool m_Show = true;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
[SerializeField] private SelectedMode m_SelectedMode;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[SerializeField] private Orient m_Orient = Orient.Horizonal;
|
|
|
|
|
|
[SerializeField] private Location m_Location = Location.defaultRight;
|
2020-02-26 22:52:57 +08:00
|
|
|
|
[SerializeField] private float m_ItemWidth = 24.0f;
|
|
|
|
|
|
[SerializeField] private float m_ItemHeight = 12.0f;
|
|
|
|
|
|
[SerializeField] private float m_ItemGap = 10f;
|
|
|
|
|
|
[SerializeField] private bool m_ItemAutoColor = true;
|
2019-09-20 12:38:45 +08:00
|
|
|
|
[SerializeField] private string m_Formatter;
|
2020-02-26 22:52:57 +08:00
|
|
|
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
[SerializeField] private List<string> m_Data = new List<string>();
|
2020-02-26 22:52:57 +08:00
|
|
|
|
[SerializeField] private List<Sprite> m_Icons = new List<Sprite>();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2020-02-26 22:52:57 +08:00
|
|
|
|
private Dictionary<string, LegendItem> m_DataBtnList = new Dictionary<string, LegendItem>();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether to show legend component.
|
|
|
|
|
|
/// 是否显示图例组件。
|
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public bool show
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Show; }
|
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
|
|
|
|
|
/// 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public SelectedMode selectedMode
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_SelectedMode; }
|
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// Specify whether the layout of legend component is horizontal or vertical.
|
|
|
|
|
|
/// 布局方式是横还是竖。
|
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public Orient orient
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Orient; }
|
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The location of legend.
|
|
|
|
|
|
/// 图例显示的位置。
|
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public Location location
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Location; }
|
|
|
|
|
|
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// Image width of legend symbol.
|
|
|
|
|
|
/// 图例标记的图形宽度。
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public float itemWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_ItemWidth; }
|
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// Image height of legend symbol.
|
|
|
|
|
|
/// 图例标记的图形高度。
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public float itemHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_ItemHeight; }
|
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
|
|
|
|
|
|
/// 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
|
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public float itemGap
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_ItemGap; }
|
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// Whether the legend symbol matches the color automatically.
|
|
|
|
|
|
/// 图例标记的图形是否自动匹配颜色。
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public bool itemAutoColor
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_ItemAutoColor; }
|
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
2019-09-20 12:38:45 +08:00
|
|
|
|
/// 图例内容字符串模版格式器。支持用 \n 换行。
|
|
|
|
|
|
/// 模板变量为图例名称 {name}
|
2019-09-23 19:09:56 +08:00
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public string formatter
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Formatter; }
|
|
|
|
|
|
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2019-09-20 12:38:45 +08:00
|
|
|
|
/// <summary>
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// the style of text.
|
|
|
|
|
|
/// 文本样式。
|
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public TextStyle textStyle
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_TextStyle; }
|
|
|
|
|
|
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
|
|
|
|
|
}
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// <summary>
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// 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>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public List<string> data
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Data; }
|
|
|
|
|
|
set { if (value != null) { m_Data = value; SetComponentDirty(); } }
|
|
|
|
|
|
}
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// <summary>
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// 自定义的图例标记图形。
|
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
|
public List<Sprite> icons
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Icons; }
|
|
|
|
|
|
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 图表是否需要刷新(图例组件不需要刷新图表)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public override bool vertsDirty { get { return false; } }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 组件是否需要刷新
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public override bool componentDirty
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal override void ClearComponentDirty()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.ClearComponentDirty();
|
|
|
|
|
|
location.ClearComponentDirty();
|
|
|
|
|
|
textStyle.ClearComponentDirty();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// <summary>
|
2019-08-04 15:24:31 +08:00
|
|
|
|
/// the button list of legend.
|
|
|
|
|
|
/// 图例按钮列表。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value></value>
|
2020-02-26 22:52:57 +08:00
|
|
|
|
public Dictionary<string, LegendItem> buttonList { get { return m_DataBtnList; } }
|
|
|
|
|
|
|
|
|
|
|
|
public float runtimeWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var width = 0f;
|
|
|
|
|
|
foreach (var kv in buttonList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (orient == Orient.Horizonal)
|
|
|
|
|
|
width += kv.Value.width + m_ItemGap;
|
|
|
|
|
|
else if (kv.Value.width > width)
|
|
|
|
|
|
width = kv.Value.width;
|
|
|
|
|
|
}
|
|
|
|
|
|
return orient == Orient.Horizonal ? width - m_ItemGap : width;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public float runtimeHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var height = 0f;
|
|
|
|
|
|
foreach (var kv in buttonList)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (orient == Orient.Vertical)
|
|
|
|
|
|
height += kv.Value.height + m_ItemGap;
|
|
|
|
|
|
else if (kv.Value.height > height)
|
|
|
|
|
|
height = kv.Value.height;
|
|
|
|
|
|
}
|
|
|
|
|
|
return orient == Orient.Vertical ? height - m_ItemGap : height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 一个在顶部居中显示的默认图例。
|
|
|
|
|
|
/// </summary>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public static Legend defaultLegend
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var legend = new Legend
|
|
|
|
|
|
{
|
2019-07-15 19:21:22 +08:00
|
|
|
|
m_Show = false,
|
2019-08-04 15:24:31 +08:00
|
|
|
|
m_SelectedMode = SelectedMode.Multiple,
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_Orient = Orient.Horizonal,
|
2019-07-15 00:24:04 +08:00
|
|
|
|
m_Location = Location.defaultTop,
|
2020-02-26 22:52:57 +08:00
|
|
|
|
m_ItemWidth = 24.0f,
|
|
|
|
|
|
m_ItemHeight = 12.0f,
|
|
|
|
|
|
m_ItemGap = 10f,
|
2019-05-11 04:33:54 +08:00
|
|
|
|
};
|
2019-07-15 00:24:04 +08:00
|
|
|
|
legend.location.top = 30;
|
2020-02-26 22:52:57 +08:00
|
|
|
|
legend.textStyle.offset = new Vector2(2, 0);
|
|
|
|
|
|
legend.textStyle.fontSize = 18;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
return legend;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清空
|
|
|
|
|
|
/// </summary>
|
2019-05-15 09:44:18 +08:00
|
|
|
|
public void ClearData()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Data.Clear();
|
2020-03-05 20:25:19 +08:00
|
|
|
|
SetComponentDirty();
|
2019-05-15 09:44:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否包括由指定名字的图例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-05-15 09:44:18 +08:00
|
|
|
|
public bool ContainsData(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_Data.Contains(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 移除指定名字的图例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
2019-05-15 09:44:18 +08:00
|
|
|
|
public void RemoveData(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_Data.Contains(name))
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-05-15 09:44:18 +08:00
|
|
|
|
m_Data.Remove(name);
|
2020-03-05 20:25:19 +08:00
|
|
|
|
SetComponentDirty();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加图例项
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
2019-05-15 09:44:18 +08:00
|
|
|
|
public void AddData(string name)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-25 09:42:00 +08:00
|
|
|
|
if (!m_Data.Contains(name) && !string.IsNullOrEmpty(name))
|
2019-05-15 09:44:18 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_Data.Add(name);
|
2020-03-05 20:25:19 +08:00
|
|
|
|
SetComponentDirty();
|
2019-05-15 09:44:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得指定索引的图例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-07-13 16:38:38 +08:00
|
|
|
|
public string GetData(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index >= 0 && index < m_Data.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_Data[index];
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得指定图例的索引
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="legendName"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2019-07-28 00:44:53 +08:00
|
|
|
|
public int GetIndex(string legendName)
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_Data.IndexOf(legendName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 移除所有图例按钮
|
|
|
|
|
|
/// </summary>
|
2019-07-19 21:55:22 +08:00
|
|
|
|
public void RemoveButton()
|
2019-05-15 09:44:18 +08:00
|
|
|
|
{
|
2019-07-19 21:55:22 +08:00
|
|
|
|
m_DataBtnList.Clear();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 给图例绑定按钮
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
/// <param name="btn"></param>
|
|
|
|
|
|
/// <param name="total"></param>
|
2020-02-26 22:52:57 +08:00
|
|
|
|
public void SetButton(string name, LegendItem item, int total)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2020-02-26 22:52:57 +08:00
|
|
|
|
m_DataBtnList[name] = item;
|
2019-07-19 21:55:22 +08:00
|
|
|
|
int index = m_DataBtnList.Values.Count;
|
2020-02-26 22:52:57 +08:00
|
|
|
|
item.SetActive(show);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新图例按钮颜色
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
/// <param name="color"></param>
|
2019-07-19 21:55:22 +08:00
|
|
|
|
public void UpdateButtonColor(string name, Color color)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-07-19 21:55:22 +08:00
|
|
|
|
if (m_DataBtnList.ContainsKey(name))
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2020-02-26 22:52:57 +08:00
|
|
|
|
m_DataBtnList[name].SetIconColor(color);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-26 22:52:57 +08:00
|
|
|
|
public void UpdateContentColor(string name, Color color)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2020-02-26 22:52:57 +08:00
|
|
|
|
if (m_DataBtnList.ContainsKey(name))
|
|
|
|
|
|
{
|
|
|
|
|
|
m_DataBtnList[name].SetContentColor(color);
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-26 22:52:57 +08:00
|
|
|
|
public Sprite GetIcon(int index)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2020-02-26 22:52:57 +08:00
|
|
|
|
if (index >= 0 && index < m_Icons.Count)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2020-02-26 22:52:57 +08:00
|
|
|
|
return m_Icons[index];
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-26 22:52:57 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 参数变更时的回调处理
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void OnChanged()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Location.OnChanged();
|
|
|
|
|
|
}
|
2020-03-05 20:25:19 +08:00
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从json字符串解析数据,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;
|
|
|
|
|
|
m_Data = ChartHelper.ParseStringFromString(jsonData);
|
2020-03-05 20:25:19 +08:00
|
|
|
|
SetComponentDirty();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
2019-09-20 12:38:45 +08:00
|
|
|
|
|
|
|
|
|
|
public string GetFormatterContent(string category)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(m_Formatter))
|
|
|
|
|
|
return category;
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var content = m_Formatter.Replace("{name}", category);
|
2019-09-23 09:23:51 +08:00
|
|
|
|
content = content.Replace("\\n", "\n");
|
|
|
|
|
|
content = content.Replace("<br/>", "\n");
|
2019-09-20 12:38:45 +08:00
|
|
|
|
return content;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|