AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
XCharts.Legend Class Reference

Legend component.The legend component shows different sets of tags, colors, and names. You can control which series are not displayed by clicking on the legend. 图例组件。 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。 More...

Inheritance diagram for XCharts.Legend:
Collaboration diagram for XCharts.Legend:

Public Types

enum  Type {
  Type.Auto, Type.Custom, Type.EmptyCircle, Type.Circle,
  Type.Rect, Type.Triangle, Type.Diamond
}
 
enum  SelectedMode { SelectedMode.Multiple, SelectedMode.Single, SelectedMode.None }
 Selected mode of legend, which controls whether series can be toggled displaying by clicking legends. 图例选择的模式,控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。 More...
 

Public Member Functions

override void ClearComponentDirty ()
 
void ClearData ()
 Clear legend data. 清空。 More...
 
bool ContainsData (string name)
 Whether include in legend data by the specified name. 是否包括由指定名字的图例 More...
 
void RemoveData (string name)
 Removes the legend with the specified name. 移除指定名字的图例。 More...
 
void AddData (string name)
 Add legend data. 添加图例。 More...
 
string GetData (int index)
 Gets the legend for the specified index. 获得指定索引的图例。 More...
 
int GetIndex (string legendName)
 Gets the index of the specified legend. 获得指定图例的索引。 More...
 
void RemoveButton ()
 Remove all legend buttons. 移除所有图例按钮。 More...
 
void SetButton (string name, LegendItem item, int total)
 Bind buttons to legends. 给图例绑定按钮。 More...
 
void UpdateButtonColor (string name, Color color)
 Update the legend button color. 更新图例按钮颜色。 More...
 
void UpdateContentColor (string name, Color color)
 Update the text color of legend. 更新图例文字颜色。 More...
 
Sprite GetIcon (int index)
 Gets the legend button for the specified index. 获得指定索引的图例按钮。 More...
 
void OnChanged ()
 Callback handling when parameters change. 参数变更时的回调处理。 More...
 
string GetFormatterContent (string category)
 获得图例格式化后的显示内容。 More...
 
- Public Member Functions inherited from XCharts.ChartComponent
virtual void SetVerticesDirty ()
 
virtual void ClearVerticesDirty ()
 
virtual void SetComponentDirty ()
 
virtual void ClearDirty ()
 
virtual void SetAllDirty ()
 

Properties

bool show [get, set]
 Whether to show legend component. 是否显示图例组件。 More...
 
Type iconType [get, set]
 Type of legend. 图例类型。 [default:Type.Auto] More...
 
SelectedMode selectedMode [get, set]
 Selected mode of legend, which controls whether series can be toggled displaying by clicking legends. 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。 [default:SelectedMode.Multiple] More...
 
Orient orient [get, set]
 Specify whether the layout of legend component is horizontal or vertical. 布局方式是横还是竖。 [default:Orient.Horizonal] More...
 
Location location [get, set]
 The location of legend. 图例显示的位置。 [default:Location.defaultTop] More...
 
float itemWidth [get, set]
 Image width of legend symbol. 图例标记的图形宽度。 [default:24f] More...
 
float itemHeight [get, set]
 Image height of legend symbol. 图例标记的图形高度。 [default:12f] More...
 
float itemGap [get, set]
 The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout. 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。 [default:10f] More...
 
bool itemAutoColor [get, set]
 Whether the legend symbol matches the color automatically. 图例标记的图形是否自动匹配颜色。 [default:true] More...
 
bool textAutoColor [get, set]
 Whether the legend text matches the color automatically. 图例标记的文本是否自动匹配颜色。 [default:false] More...
 
string formatter [get, set]
 Legend content string template formatter. Support for wrapping lines with
. Template:{name}. 图例内容字符串模版格式器。支持用
换行。 模板变量为图例名称 {name}。 [default:null] More...
 
TextStyle textStyle [get, set]
 the style of text. 文本样式。 More...
 
List< string > data [get, set]
 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匹配时才会生效。 More...
 
List< Sprite > icons [get, set]
 自定义的图例标记图形。 More...
 
int index [get, set]
 
override bool vertsDirty [get]
 图表是否需要刷新(图例组件不需要刷新图表) More...
 
override bool componentDirty [get]
 组件是否需要刷新 More...
 
Dictionary< string, LegendItembuttonList [get]
 the button list of legend. 图例按钮列表。 More...
 
float runtimeWidth [get, set]
 运行时图例的总宽度 More...
 
float runtimeHeight [get, set]
 运行时图例的总高度 More...
 
Dictionary< int, float > runtimeEachWidth [get]
 多列时每列的宽度 More...
 
float runtimeEachHeight [get, set]
 单列高度 More...
 
static Legend defaultLegend [get]
 一个在顶部居中显示的默认图例。 More...
 
- Properties inherited from XCharts.ChartComponent
virtual bool vertsDirty [get]
 图表重绘标记。 More...
 
virtual bool componentDirty [get]
 组件重新初始化标记。 More...
 
bool anyDirty [get]
 需要重绘图表或重新初始化组件。 More...
 
Painter painter [get, set]
 
Action refreshComponent [get, set]
 
GameObject gameObject [get, set]
 

Additional Inherited Members

- Protected Attributes inherited from XCharts.ChartComponent
bool m_VertsDirty
 
bool m_ComponentDirty
 
Painter m_Painter
 

Detailed Description

Legend component.The legend component shows different sets of tags, colors, and names. You can control which series are not displayed by clicking on the legend. 图例组件。 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。

Definition at line 20 of file Legend.cs.

Member Enumeration Documentation

◆ SelectedMode

Selected mode of legend, which controls whether series can be toggled displaying by clicking legends. 图例选择的模式,控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。

Enumerator
Multiple 

多选。

Single 

单选。

None 

无法选择。

Definition at line 57 of file Legend.cs.

58  {
62  Multiple,
66  Single,
70  None
71  }

◆ Type

enum XCharts.Legend.Type
strong
Enumerator
Auto 

自动匹配。

Custom 

自定义图标。

EmptyCircle 

空心圆。

Circle 

圆形。

Rect 

正方形。可通过Setting的legendIconCornerRadius参数调整圆角。

Triangle 

三角形。

Diamond 

菱形。

Definition at line 22 of file Legend.cs.

23  {
27  Auto,
31  Custom,
39  Circle,
43  Rect,
47  Triangle,
51  Diamond,
52  }

Member Function Documentation

◆ AddData()

void XCharts.Legend.AddData ( string  name)
inline

Add legend data. 添加图例。

Parameters
name

Definition at line 337 of file Legend.cs.

338  {
339  if (!m_Data.Contains(name) && !string.IsNullOrEmpty(name))
340  {
341  m_Data.Add(name);
342  SetComponentDirty();
343  }
344  }

◆ ClearData()

void XCharts.Legend.ClearData ( )
inline

Clear legend data. 清空。

Definition at line 301 of file Legend.cs.

302  {
303  m_Data.Clear();
304  SetComponentDirty();
305  }

◆ ContainsData()

bool XCharts.Legend.ContainsData ( string  name)
inline

Whether include in legend data by the specified name. 是否包括由指定名字的图例

Parameters
name
Returns

Definition at line 313 of file Legend.cs.

314  {
315  return m_Data.Contains(name);
316  }

◆ GetData()

string XCharts.Legend.GetData ( int  index)
inline

Gets the legend for the specified index. 获得指定索引的图例。

Parameters
index
Returns

Definition at line 352 of file Legend.cs.

353  {
354  if (index >= 0 && index < m_Data.Count)
355  {
356  return m_Data[index];
357  }
358  return null;
359  }

◆ GetFormatterContent()

string XCharts.Legend.GetFormatterContent ( string  category)
inline

获得图例格式化后的显示内容。

Parameters
category
Returns

Definition at line 456 of file Legend.cs.

457  {
458  if (string.IsNullOrEmpty(m_Formatter))
459  return category;
460  else
461  {
462  var content = m_Formatter.Replace("{name}", category);
463  content = content.Replace("\\n", "\n");
464  content = content.Replace("<br/>", "\n");
465  return content;
466  }
467  }

◆ GetIcon()

Sprite XCharts.Legend.GetIcon ( int  index)
inline

Gets the legend button for the specified index. 获得指定索引的图例按钮。

Parameters
index
Returns

Definition at line 430 of file Legend.cs.

431  {
432  if (index >= 0 && index < m_Icons.Count)
433  {
434  return m_Icons[index];
435  }
436  else
437  {
438  return null;
439  }
440  }

◆ GetIndex()

int XCharts.Legend.GetIndex ( string  legendName)
inline

Gets the index of the specified legend. 获得指定图例的索引。

Parameters
legendName
Returns

Definition at line 367 of file Legend.cs.

368  {
369  return m_Data.IndexOf(legendName);
370  }

◆ OnChanged()

void XCharts.Legend.OnChanged ( )
inline

Callback handling when parameters change. 参数变更时的回调处理。

Implements XCharts.IPropertyChanged.

Definition at line 446 of file Legend.cs.

447  {
448  m_Location.OnChanged();
449  }

◆ RemoveButton()

void XCharts.Legend.RemoveButton ( )
inline

Remove all legend buttons. 移除所有图例按钮。

Definition at line 376 of file Legend.cs.

377  {
378  m_DataBtnList.Clear();
379  }

◆ RemoveData()

void XCharts.Legend.RemoveData ( string  name)
inline

Removes the legend with the specified name. 移除指定名字的图例。

Parameters
name

Definition at line 323 of file Legend.cs.

324  {
325  if (m_Data.Contains(name))
326  {
327  m_Data.Remove(name);
328  SetComponentDirty();
329  }
330  }

◆ SetButton()

void XCharts.Legend.SetButton ( string  name,
LegendItem  item,
int  total 
)
inline

Bind buttons to legends. 给图例绑定按钮。

Parameters
name
btn
total

Definition at line 388 of file Legend.cs.

389  {
390  m_DataBtnList[name] = item;
391  int index = m_DataBtnList.Values.Count;
392  item.SetIconActive(iconType == Type.Custom);
393  item.SetActive(show);
394  }

◆ UpdateButtonColor()

void XCharts.Legend.UpdateButtonColor ( string  name,
Color  color 
)
inline

Update the legend button color. 更新图例按钮颜色。

Parameters
name
color

Definition at line 402 of file Legend.cs.

403  {
404  if (m_DataBtnList.ContainsKey(name))
405  {
406  m_DataBtnList[name].SetIconColor(color);
407  }
408  }

◆ UpdateContentColor()

void XCharts.Legend.UpdateContentColor ( string  name,
Color  color 
)
inline

Update the text color of legend. 更新图例文字颜色。

Parameters
name
color

Definition at line 416 of file Legend.cs.

417  {
418  if (m_DataBtnList.ContainsKey(name))
419  {
420  m_DataBtnList[name].SetContentColor(color);
421  }
422  }

Property Documentation

◆ buttonList

Dictionary<string, LegendItem> XCharts.Legend.buttonList
get

the button list of legend. 图例按钮列表。

Definition at line 254 of file Legend.cs.

254 { get { return m_DataBtnList; } }

◆ componentDirty

override bool XCharts.Legend.componentDirty
get

组件是否需要刷新

Definition at line 238 of file Legend.cs.

238  {
239  get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty; }
240  }

◆ data

List<string> XCharts.Legend.data
getset

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匹配时才会生效。

Definition at line 217 of file Legend.cs.

217  {
218  get { return m_Data; }
219  set { if (value != null) { m_Data = value; SetComponentDirty(); } }
220  }

◆ defaultLegend

Legend XCharts.Legend.defaultLegend
staticget

一个在顶部居中显示的默认图例。

Definition at line 276 of file Legend.cs.

276  {
277  get
278  {
279  var legend = new Legend
280  {
281  m_IconType = Type.Auto,
282  m_Show = false,
283  m_SelectedMode = SelectedMode.Multiple,
284  m_Orient = Orient.Horizonal,
285  m_Location = Location.defaultTop,
286  m_ItemWidth = 25.0f,
287  m_ItemHeight = 12.0f,
288  m_ItemGap = 10f,
289  };
290  legend.location.top = 35;
291  legend.textStyle.offset = new Vector2(2, 0);
292  legend.textStyle.fontSize = 0;
293  return legend;
294  }
295  }

◆ formatter

string XCharts.Legend.formatter
getset

Legend content string template formatter. Support for wrapping lines with
. Template:{name}. 图例内容字符串模版格式器。支持用
换行。 模板变量为图例名称 {name}。 [default:null]

Definition at line 196 of file Legend.cs.

196  {
197  get { return m_Formatter; }
198  set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
199  }

◆ icons

List<Sprite> XCharts.Legend.icons
getset

自定义的图例标记图形。

Definition at line 225 of file Legend.cs.

225  {
226  get { return m_Icons; }
227  set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
228  }

◆ iconType

Type XCharts.Legend.iconType
getset

Type of legend. 图例类型。 [default:Type.Auto]

Definition at line 105 of file Legend.cs.

105  {
106  get { return m_IconType; }
107  set { if (PropertyUtil.SetStruct(ref m_IconType, value)) SetAllDirty(); }
108  }

◆ itemAutoColor

bool XCharts.Legend.itemAutoColor
getset

Whether the legend symbol matches the color automatically. 图例标记的图形是否自动匹配颜色。 [default:true]

Definition at line 175 of file Legend.cs.

175  {
176  get { return m_ItemAutoColor; }
177  set { if (PropertyUtil.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
178  }

◆ itemGap

float XCharts.Legend.itemGap
getset

The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout. 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。 [default:10f]

Definition at line 165 of file Legend.cs.

165  {
166  get { return m_ItemGap; }
167  set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
168  }

◆ itemHeight

float XCharts.Legend.itemHeight
getset

Image height of legend symbol. 图例标记的图形高度。 [default:12f]

Definition at line 155 of file Legend.cs.

155  {
156  get { return m_ItemHeight; }
157  set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
158  }

◆ itemWidth

float XCharts.Legend.itemWidth
getset

Image width of legend symbol. 图例标记的图形宽度。 [default:24f]

Definition at line 145 of file Legend.cs.

145  {
146  get { return m_ItemWidth; }
147  set { if (PropertyUtil.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
148  }

◆ location

Location XCharts.Legend.location
getset

The location of legend. 图例显示的位置。 [default:Location.defaultTop]

Definition at line 135 of file Legend.cs.

135  {
136  get { return m_Location; }
137  set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
138  }

◆ orient

Orient XCharts.Legend.orient
getset

Specify whether the layout of legend component is horizontal or vertical. 布局方式是横还是竖。 [default:Orient.Horizonal]

Definition at line 125 of file Legend.cs.

125  {
126  get { return m_Orient; }
127  set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
128  }

◆ runtimeEachHeight

float XCharts.Legend.runtimeEachHeight
getset

单列高度

Definition at line 270 of file Legend.cs.

270 { get; internal set; }

◆ runtimeEachWidth

Dictionary<int, float> XCharts.Legend.runtimeEachWidth
get

多列时每列的宽度

Definition at line 266 of file Legend.cs.

266 { get { return m_RuntimeEachWidth; } }

◆ runtimeHeight

float XCharts.Legend.runtimeHeight
getset

运行时图例的总高度

Definition at line 262 of file Legend.cs.

262 { get; internal set; }

◆ runtimeWidth

float XCharts.Legend.runtimeWidth
getset

运行时图例的总宽度

Definition at line 258 of file Legend.cs.

258 { get; internal set; }

◆ selectedMode

SelectedMode XCharts.Legend.selectedMode
getset

Selected mode of legend, which controls whether series can be toggled displaying by clicking legends. 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。 [default:SelectedMode.Multiple]

Definition at line 115 of file Legend.cs.

115  {
116  get { return m_SelectedMode; }
117  set { if (PropertyUtil.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
118  }

◆ show

bool XCharts.Legend.show
getset

Whether to show legend component. 是否显示图例组件。

Definition at line 95 of file Legend.cs.

95  {
96  get { return m_Show; }
97  set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
98  }

◆ textAutoColor

bool XCharts.Legend.textAutoColor
getset

Whether the legend text matches the color automatically. 图例标记的文本是否自动匹配颜色。 [default:false]

Definition at line 185 of file Legend.cs.

185  {
186  get { return m_TextAutoColor; }
187  set { if (PropertyUtil.SetStruct(ref m_TextAutoColor, value)) SetComponentDirty(); }
188  }

◆ textStyle

TextStyle XCharts.Legend.textStyle
getset

the style of text. 文本样式。

Definition at line 205 of file Legend.cs.

205  {
206  get { return m_TextStyle; }
207  set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
208  }

◆ vertsDirty

override bool XCharts.Legend.vertsDirty
get

图表是否需要刷新(图例组件不需要刷新图表)

Definition at line 233 of file Legend.cs.

233 { get { return false; } }

The documentation for this class was generated from the following file:
XCharts.Orient
Orient
the layout is horizontal or vertical. 垂直还是水平布局方式。
Definition: BaseChart.cs:22
XCharts.RadarType.Single
@ Single
单圈雷达图。此时一个雷达只能绘制一个圈,多个serieData组成一个圈,数据取自data[1]。
XCharts.Legend.SelectedMode
SelectedMode
Selected mode of legend, which controls whether series can be toggled displaying by clicking legends....
Definition: Legend.cs:57
XCharts.SerieType.Custom
@ Custom
自定义。
XCharts.RadarType.Multiple
@ Multiple
多圈雷达图。此时可一个雷达里绘制多个圈,一个serieData就可组成一个圈(多维数据)。
XCharts.Legend.Type
Type
Definition: Legend.cs:22
XCharts.SerieSymbolType.Circle
@ Circle
圆形。
XCharts.RoseType.None
@ None
Don't show as Nightingale chart.不展示成南丁格尔玫瑰图
XCharts.ChartComponent.componentDirty
virtual bool componentDirty
组件重新初始化标记。
Definition: ChartComponent.cs:25
XCharts.Legend.show
bool show
Whether to show legend component. 是否显示图例组件。
Definition: Legend.cs:95
XCharts.Legend.location
Location location
The location of legend. 图例显示的位置。 [default:Location.defaultTop]
Definition: Legend.cs:135
XCharts.SerieSymbolType.Diamond
@ Diamond
菱形。
XCharts.Location.OnChanged
void OnChanged()
属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
Definition: Location.cs:313
XCharts.SerieSymbolType.Triangle
@ Triangle
三角形。
XCharts.SerieSymbolType.Rect
@ Rect
正方形。可通过设置itemStyle的cornerRadius变成圆角矩形。
XCharts.SerieSymbolType.EmptyCircle
@ EmptyCircle
空心圆。
XCharts.Legend.iconType
Type iconType
Type of legend. 图例类型。 [default:Type.Auto]
Definition: Legend.cs:105
XCharts.Legend.textStyle
TextStyle textStyle
the style of text. 文本样式。
Definition: Legend.cs:205