Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace XCharts.Runtime
  5. {
  6. /// <summary>
  7. /// Whether to show as Nightingale chart, which distinguishs data through radius.
  8. /// 是否展示成南丁格尔图,通过半径区分数据大小。
  9. /// </summary>
  10. public enum RoseType
  11. {
  12. /// <summary>
  13. /// Don't show as Nightingale chart.
  14. /// |不展示成南丁格尔玫瑰图。
  15. /// </summary>
  16. None,
  17. /// <summary>
  18. /// Use central angle to show the percentage of data, radius to show data size.
  19. /// |扇区圆心角展现数据的百分比,半径展现数据的大小。
  20. /// </summary>
  21. Radius,
  22. /// <summary>
  23. /// All the sectors will share the same central angle, the data size is shown only through radiuses.
  24. /// |所有扇区圆心角相同,仅通过半径展现数据大小。
  25. /// </summary>
  26. Area
  27. }
  28. /// <summary>
  29. /// the type of line chart.
  30. /// |折线图样式类型
  31. /// </summary>
  32. public enum LineType
  33. {
  34. /// <summary>
  35. /// the normal line chart,
  36. /// |普通折线图。
  37. /// </summary>
  38. Normal,
  39. /// <summary>
  40. /// the smooth line chart,
  41. /// |平滑曲线。
  42. /// </summary>
  43. Smooth,
  44. /// <summary>
  45. /// step line.
  46. /// |阶梯线图:当前点。
  47. /// </summary>
  48. StepStart,
  49. /// <summary>
  50. /// step line.
  51. /// |阶梯线图:当前点和下一个点的中间。
  52. /// </summary>
  53. StepMiddle,
  54. /// <summary>
  55. /// step line.
  56. /// |阶梯线图:下一个拐点。
  57. /// </summary>
  58. StepEnd
  59. }
  60. /// <summary>
  61. /// the type of bar. |柱状图类型。
  62. /// </summary>
  63. public enum BarType
  64. {
  65. /// <summary>
  66. /// normal bar.
  67. /// |普通柱形图。
  68. /// </summary>
  69. Normal,
  70. /// <summary>
  71. /// zebra bar.
  72. /// |斑马柱形图。
  73. /// </summary>
  74. Zebra,
  75. /// <summary>
  76. /// capsule bar.
  77. /// |胶囊柱形图。
  78. /// </summary>
  79. Capsule
  80. }
  81. /// <summary>
  82. /// the type of radar. |雷达图类型。
  83. /// </summary>
  84. public enum RadarType
  85. {
  86. /// <summary>
  87. /// multiple radar.
  88. /// |多圈雷达图。此时可一个雷达里绘制多个圈,一个serieData就可组成一个圈(多维数据)。
  89. /// </summary>
  90. Multiple,
  91. /// <summary>
  92. /// single radar.
  93. /// |单圈雷达图。此时一个雷达只能绘制一个圈,多个serieData组成一个圈,数据取自`data[1]`。
  94. /// </summary>
  95. Single
  96. }
  97. /// <summary>
  98. /// 采样类型
  99. /// </summary>
  100. public enum SampleType
  101. {
  102. /// <summary>
  103. /// Take a peak. When the average value of the filter point is greater than or equal to 'sampleAverage',
  104. /// take the maximum value; If you do it the other way around, you get the minimum.
  105. /// |取峰值。
  106. /// </summary>
  107. Peak,
  108. /// <summary>
  109. /// Take the average of the filter points.
  110. /// |取过滤点的平均值。
  111. /// </summary>
  112. Average,
  113. /// <summary>
  114. /// Take the maximum value of the filter point.
  115. /// |取过滤点的最大值。
  116. /// </summary>
  117. Max,
  118. /// <summary>
  119. /// Take the minimum value of the filter point.
  120. /// |取过滤点的最小值。
  121. /// </summary>
  122. Min,
  123. /// <summary>
  124. /// Take the sum of the filter points.
  125. /// |取过滤点的和。
  126. /// </summary>
  127. Sum
  128. }
  129. /// <summary>
  130. /// 数据排序方式
  131. /// </summary>
  132. public enum SerieDataSortType
  133. {
  134. /// <summary>
  135. /// 按 data 的顺序
  136. /// </summary>
  137. None,
  138. /// <summary>
  139. /// 升序
  140. /// </summary>
  141. Ascending,
  142. /// <summary>
  143. /// 降序
  144. /// </summary>
  145. Descending,
  146. }
  147. /// <summary>
  148. /// 对齐方式
  149. /// </summary>
  150. public enum Align
  151. {
  152. Center,
  153. Left,
  154. Right
  155. }
  156. /// <summary>
  157. /// Serie state. Supports normal, emphasis, blur, and select states.
  158. /// |Serie状态。支持正常、高亮、淡出、选中四种状态。
  159. /// </summary>
  160. public enum SerieState
  161. {
  162. /// <summary>
  163. /// Normal state.
  164. /// |正常状态。
  165. /// </summary>
  166. Normal,
  167. /// <summary>
  168. /// Emphasis state.
  169. /// |高亮状态。
  170. /// </summary>
  171. Emphasis,
  172. /// <summary>
  173. /// Blur state.
  174. /// |淡出状态。
  175. /// </summary>
  176. Blur,
  177. /// <summary>
  178. /// Select state.
  179. /// |选中状态。
  180. /// </summary>
  181. Select,
  182. /// <summary>
  183. /// Auto state.
  184. /// |自动保持和父节点一致。一般用在SerieData。
  185. /// </summary>
  186. Auto
  187. }
  188. /// <summary>
  189. /// The policy to take color from theme.
  190. /// |从主题中取色策略。
  191. /// </summary>
  192. public enum SerieColorBy
  193. {
  194. /// <summary>
  195. /// Select state.
  196. /// |默认策略。每种Serie都有自己的默认的取颜色策略。比如Line默认是Series策略,Pie默认是Data策略
  197. /// </summary>
  198. Default,
  199. /// <summary>
  200. /// assigns the colors in the palette by serie, so that all data in the same series are in the same color;.
  201. /// |按照系列分配调色盘中的颜色,同一系列中的所有数据都是用相同的颜色。
  202. /// </summary>
  203. Serie,
  204. /// <summary>
  205. /// assigns colors in the palette according to data items, with each data item using a different color..
  206. /// |按照数据项分配调色盘中的颜色,每个数据项都使用不同的颜色。
  207. /// </summary>
  208. Data
  209. }
  210. /// <summary>
  211. /// 系列。
  212. /// </summary>
  213. [System.Serializable]
  214. public partial class Serie : BaseSerie, IComparable
  215. {
  216. [SerializeField] private int m_Index;
  217. [SerializeField] private bool m_Show = true;
  218. [SerializeField] private string m_CoordSystem = "GridCoord";
  219. [SerializeField] private string m_SerieType = "";
  220. [SerializeField] private string m_SerieName;
  221. [SerializeField][Since("v3.2.0")] private SerieState m_State = SerieState.Normal;
  222. [SerializeField][Since("v3.2.0")] private SerieColorBy m_ColorBy = SerieColorBy.Default;
  223. [SerializeField] private string m_Stack;
  224. [SerializeField] private int m_XAxisIndex = 0;
  225. [SerializeField] private int m_YAxisIndex = 0;
  226. [SerializeField] private int m_RadarIndex = 0;
  227. [SerializeField] private int m_VesselIndex = 0;
  228. [SerializeField] private int m_PolarIndex = 0;
  229. [SerializeField] private int m_SingleAxisIndex = 0;
  230. [SerializeField] private int m_ParallelIndex = 0;
  231. [SerializeField] protected int m_MinShow;
  232. [SerializeField] protected int m_MaxShow;
  233. [SerializeField] protected int m_MaxCache;
  234. [SerializeField] private float m_SampleDist = 0;
  235. [SerializeField] private SampleType m_SampleType = SampleType.Average;
  236. [SerializeField] private float m_SampleAverage = 0;
  237. [SerializeField] private LineType m_LineType = LineType.Normal;
  238. [SerializeField][Since("v3.4.0")] private bool m_SmoothLimit = false;
  239. [SerializeField] private BarType m_BarType = BarType.Normal;
  240. [SerializeField] private bool m_BarPercentStack = false;
  241. [SerializeField] private float m_BarWidth = 0;
  242. [SerializeField][Since("v3.5.0")] private float m_BarMaxWidth = 0;
  243. [SerializeField] private float m_BarGap = 0.1f;
  244. [SerializeField] private float m_BarZebraWidth = 4f;
  245. [SerializeField] private float m_BarZebraGap = 2f;
  246. [SerializeField] private float m_Min;
  247. [SerializeField] private float m_Max;
  248. [SerializeField] private float m_MinSize = 0f;
  249. [SerializeField] private float m_MaxSize = 1f;
  250. [SerializeField] private float m_StartAngle;
  251. [SerializeField] private float m_EndAngle;
  252. [SerializeField] private float m_MinAngle;
  253. [SerializeField] private bool m_Clockwise = true;
  254. [SerializeField] private bool m_RoundCap;
  255. [SerializeField] private int m_SplitNumber;
  256. [SerializeField] private bool m_ClickOffset = true;
  257. [SerializeField] private RoseType m_RoseType = RoseType.None;
  258. [SerializeField] private float m_Gap;
  259. [SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.48f };
  260. [SerializeField] private float[] m_Radius = new float[2] { 0, 0.28f };
  261. [SerializeField][Range(2, 10)] private int m_ShowDataDimension;
  262. [SerializeField] private bool m_ShowDataName;
  263. [SerializeField] private bool m_Clip = false;
  264. [SerializeField] private bool m_Ignore = false;
  265. [SerializeField] private double m_IgnoreValue = 0;
  266. [SerializeField] private bool m_IgnoreLineBreak = false;
  267. [SerializeField] private bool m_ShowAsPositiveNumber = false;
  268. [SerializeField] private bool m_Large = true;
  269. [SerializeField] private int m_LargeThreshold = 200;
  270. [SerializeField] private bool m_AvoidLabelOverlap = false;
  271. [SerializeField] private RadarType m_RadarType = RadarType.Multiple;
  272. [SerializeField] private bool m_PlaceHolder = false;
  273. [SerializeField] private SerieDataSortType m_DataSortType = SerieDataSortType.Descending;
  274. [SerializeField] private Orient m_Orient = Orient.Vertical;
  275. [SerializeField] private Align m_Align = Align.Center;
  276. [SerializeField] private float m_Left;
  277. [SerializeField] private float m_Right;
  278. [SerializeField] private float m_Top;
  279. [SerializeField] private float m_Bottom;
  280. [SerializeField] private bool m_InsertDataToHead;
  281. [SerializeField] private LineStyle m_LineStyle = new LineStyle();
  282. [SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
  283. [SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
  284. [SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
  285. [SerializeField] private List<SerieData> m_Data = new List<SerieData>();
  286. [NonSerialized] internal int m_FilterStart;
  287. [NonSerialized] internal int m_FilterEnd;
  288. [NonSerialized] internal double m_FilterStartValue;
  289. [NonSerialized] internal double m_FilterEndValue;
  290. [NonSerialized] internal int m_FilterMinShow;
  291. [NonSerialized] internal bool m_NeedUpdateFilterData;
  292. [NonSerialized] public List<SerieData> m_FilterData = new List<SerieData>();
  293. [NonSerialized] private bool m_NameDirty;
  294. /// <summary>
  295. /// event callback when click serie.
  296. /// |点击系列时的回调。
  297. /// </summary>
  298. public Action<SerieEventData> onClick { get; set; }
  299. /// <summary>
  300. /// event callback when mouse down on serie.
  301. /// |鼠标按下时的回调。
  302. /// </summary>
  303. public Action<SerieEventData> onDown { get; set; }
  304. /// <summary>
  305. /// event callback when mouse enter serie.
  306. /// |鼠标进入时的回调。
  307. /// </summary>
  308. public Action<SerieEventData> onEnter { get; set; }
  309. /// <summary>
  310. /// event callback when mouse leave serie.
  311. /// |鼠标离开时的回调。
  312. /// </summary>
  313. public Action<SerieEventData> onExit { get; set; }
  314. /// <summary>
  315. /// The index of serie.
  316. /// |系列索引。
  317. /// </summary>
  318. public int index { get { return m_Index; } internal set { m_Index = value; } }
  319. /// <summary>
  320. /// Whether to show serie in chart.
  321. /// |系列是否显示在图表上。
  322. /// </summary>
  323. public bool show
  324. {
  325. get { return m_Show; }
  326. set { if (PropertyUtil.SetStruct(ref m_Show, value)) { SetVerticesDirty(); SetSerieNameDirty(); } }
  327. }
  328. /// <summary>
  329. /// the chart coord system of serie.
  330. /// |使用的坐标系。
  331. /// </summary>
  332. public string coordSystem
  333. {
  334. get { return m_CoordSystem; }
  335. set { if (PropertyUtil.SetClass(ref m_CoordSystem, value, true)) SetVerticesDirty(); }
  336. }
  337. /// <summary>
  338. /// the type of serie.
  339. /// |系列类型。
  340. /// </summary>
  341. public string serieType
  342. {
  343. get { return m_SerieType; }
  344. set { if (PropertyUtil.SetClass(ref m_SerieType, value, true)) SetVerticesDirty(); }
  345. }
  346. /// <summary>
  347. /// Series name used for displaying in tooltip and filtering with legend.
  348. /// |系列名称,用于 tooltip 的显示,legend 的图例筛选。
  349. /// </summary>
  350. public string serieName
  351. {
  352. get { return m_SerieName; }
  353. set { if (PropertyUtil.SetClass(ref m_SerieName, value)) { SetVerticesDirty(); SetSerieNameDirty(); } }
  354. }
  355. /// <summary>
  356. /// Legend name. When the serie name is not empty, the legend name is the series name; Otherwise, it is index.
  357. /// |图例名称。当系列名称不为空时,图例名称即为系列名称;反之则为索引index。
  358. /// </summary>
  359. public string legendName { get { return string.IsNullOrEmpty(serieName) ? ChartCached.IntToStr(index) : serieName; } }
  360. /// <summary>
  361. /// The default state of a serie.
  362. /// |系列的默认状态。
  363. /// </summary>
  364. public SerieState state
  365. {
  366. get { return m_State; }
  367. set { if (PropertyUtil.SetStruct(ref m_State, value)) { SetAllDirty(); } }
  368. }
  369. /// <summary>
  370. /// The policy to take color from theme.
  371. /// |从主题中取色的策略。
  372. /// </summary>
  373. public SerieColorBy colorBy
  374. {
  375. //get { return m_ColorBy; }
  376. get { return m_ColorBy == SerieColorBy.Default ? defaultColorBy : m_ColorBy; }
  377. set { if (PropertyUtil.SetStruct(ref m_ColorBy, value)) { SetAllDirty(); } }
  378. }
  379. /// <summary>
  380. /// If stack the value. On the same category axis, the series with the same stack name would be put on top of each other.
  381. /// |数据堆叠,同个类目轴上系列配置相同的stack值后,后一个系列的值会在前一个系列的值上相加。
  382. /// </summary>
  383. public string stack
  384. {
  385. get { return m_Stack; }
  386. set { if (PropertyUtil.SetClass(ref m_Stack, value)) SetVerticesDirty(); }
  387. }
  388. /// <summary>
  389. /// the index of XAxis.
  390. /// |使用X轴的index。
  391. /// </summary>
  392. public int xAxisIndex
  393. {
  394. get { return m_XAxisIndex; }
  395. set { if (PropertyUtil.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
  396. }
  397. /// <summary>
  398. /// the index of YAxis.
  399. /// |使用Y轴的index。
  400. /// </summary>
  401. public int yAxisIndex
  402. {
  403. get { return m_YAxisIndex; }
  404. set { if (PropertyUtil.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
  405. }
  406. /// <summary>
  407. /// Index of radar component that radar chart uses.
  408. /// |雷达图所使用的 radar 组件的 index。
  409. /// </summary>
  410. public int radarIndex
  411. {
  412. get { return m_RadarIndex; }
  413. set { if (PropertyUtil.SetStruct(ref m_RadarIndex, value)) SetVerticesDirty(); }
  414. }
  415. /// <summary>
  416. /// Index of vesel component that liquid chart uses.
  417. /// |水位图所使用的 vessel 组件的 index。
  418. /// </summary>
  419. public int vesselIndex
  420. {
  421. get { return m_VesselIndex; }
  422. set { if (PropertyUtil.SetStruct(ref m_VesselIndex, value)) SetVerticesDirty(); }
  423. }
  424. /// <summary>
  425. /// Index of polar component that serie uses.
  426. /// |所使用的 polar 组件的 index。
  427. /// </summary>
  428. public int polarIndex
  429. {
  430. get { return m_PolarIndex; }
  431. set { if (PropertyUtil.SetStruct(ref m_PolarIndex, value)) SetVerticesDirty(); }
  432. }
  433. /// <summary>s
  434. /// Index of single axis component that serie uses.
  435. /// |所使用的 singleAxis 组件的 index。
  436. /// </summary>
  437. public int singleAxisIndex
  438. {
  439. get { return m_SingleAxisIndex; }
  440. set { if (PropertyUtil.SetStruct(ref m_SingleAxisIndex, value)) SetAllDirty(); }
  441. }
  442. /// <summary>s
  443. /// Index of parallel coord component that serie uses.
  444. /// |所使用的 parallel coord 组件的 index。
  445. /// </summary>
  446. public int parallelIndex
  447. {
  448. get { return m_ParallelIndex; }
  449. set { if (PropertyUtil.SetStruct(ref m_ParallelIndex, value)) SetAllDirty(); }
  450. }
  451. /// <summary>
  452. /// The min number of data to show in chart.
  453. /// |系列所显示数据的最小索引
  454. /// </summary>
  455. public int minShow
  456. {
  457. get { return m_MinShow; }
  458. set { if (PropertyUtil.SetStruct(ref m_MinShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
  459. }
  460. /// <summary>
  461. /// The max number of data to show in chart.
  462. /// |系列所显示数据的最大索引
  463. /// </summary>
  464. public int maxShow
  465. {
  466. get { return m_MaxShow; }
  467. set { if (PropertyUtil.SetStruct(ref m_MaxShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
  468. }
  469. /// <summary>
  470. /// The max number of serie data cache.
  471. /// The first data will be remove when the size of serie data is larger then maxCache.
  472. /// |系列中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
  473. /// </summary>
  474. public int maxCache
  475. {
  476. get { return m_MaxCache; }
  477. set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
  478. }
  479. /// <summary>
  480. /// the symbol of serie data item.
  481. /// |标记的图形。
  482. /// </summary>
  483. public SerieSymbol symbol
  484. {
  485. get { return m_Symbol; }
  486. set { if (PropertyUtil.SetClass(ref m_Symbol, value, true)) SetVerticesDirty(); }
  487. }
  488. /// <summary>
  489. /// The type of line chart.
  490. /// |折线图样式类型。
  491. /// </summary>
  492. public LineType lineType
  493. {
  494. get { return m_LineType; }
  495. set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
  496. }
  497. /// <summary>
  498. /// Whether to restrict the curve. When true, the curve between two continuous data of the same value
  499. /// is restricted to not exceed the data point, and is flat to the data point.
  500. /// |是否限制曲线。当为true时,两个连续相同数值的数据间的曲线会限制为不超出数据点,和数据点是平直的。
  501. /// </summary>
  502. public bool smoothLimit
  503. {
  504. get { return m_SmoothLimit; }
  505. set { if (PropertyUtil.SetStruct(ref m_SmoothLimit, value)) { SetVerticesDirty(); } }
  506. }
  507. /// <summary>
  508. /// the min pixel dist of sample.
  509. /// |采样的最小像素距离,默认为0时不采样。当两个数据点间的水平距离小于改值时,开启采样,保证两点间的水平距离不小于改值。
  510. /// </summary>
  511. public float sampleDist
  512. {
  513. get { return m_SampleDist; }
  514. set { if (PropertyUtil.SetStruct(ref m_SampleDist, value < 0 ? 0 : value)) SetVerticesDirty(); }
  515. }
  516. /// <summary>
  517. /// the type of sample.
  518. /// |采样类型。当sampleDist大于0时有效。
  519. /// </summary>
  520. public SampleType sampleType
  521. {
  522. get { return m_SampleType; }
  523. set { if (PropertyUtil.SetStruct(ref m_SampleType, value)) SetVerticesDirty(); }
  524. }
  525. /// <summary>
  526. /// 设定的采样平均值。当sampleType 为 Peak 时,用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。
  527. /// </summary>
  528. public float sampleAverage
  529. {
  530. get { return m_SampleAverage; }
  531. set { if (PropertyUtil.SetStruct(ref m_SampleAverage, value)) SetVerticesDirty(); }
  532. }
  533. /// <summary>
  534. /// The style of line.
  535. /// |线条样式。
  536. /// </summary>
  537. public LineStyle lineStyle
  538. {
  539. get { return m_LineStyle; }
  540. set { if (PropertyUtil.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); }
  541. }
  542. /// <summary>
  543. /// 柱形图类型。
  544. /// </summary>
  545. public BarType barType
  546. {
  547. get { return m_BarType; }
  548. set { if (PropertyUtil.SetStruct(ref m_BarType, value)) SetVerticesDirty(); }
  549. }
  550. /// <summary>
  551. /// 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true,则就显示成百分比堆叠柱状图。
  552. /// </summary>
  553. public bool barPercentStack
  554. {
  555. get { return m_BarPercentStack; }
  556. set { if (PropertyUtil.SetStruct(ref m_BarPercentStack, value)) SetVerticesDirty(); }
  557. }
  558. /// <summary>
  559. /// The width of the bar. Adaptive when default 0.
  560. /// |柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。
  561. /// </summary>
  562. public float barWidth
  563. {
  564. get { return m_BarWidth; }
  565. set { if (PropertyUtil.SetStruct(ref m_BarWidth, value)) SetVerticesDirty(); }
  566. }
  567. /// <summary>
  568. /// The max width of the bar. Adaptive when default 0.
  569. /// |柱条的最大宽度,默认为0为不限制最大宽度。支持设置成相对于类目宽度的百分比。
  570. /// </summary>
  571. public float barMaxWidth
  572. {
  573. get { return m_BarMaxWidth; }
  574. set { if (PropertyUtil.SetStruct(ref m_BarMaxWidth, value)) SetVerticesDirty(); }
  575. }
  576. /// <summary>
  577. /// 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.
  578. /// Set barGap as '-1' can overlap bars that belong to different series, which is useful when making a series of bar be background.
  579. /// In a single coodinate system, this attribute is shared by multiple 'bar' series.
  580. /// This attribute should be set on the last 'bar' series in the coodinate system,
  581. /// then it will be adopted by all 'bar' series in the coordinate system.
  582. /// |不同系列的柱间距离。为百分比(如 '0.3f',表示柱子宽度的 30%)
  583. /// 如果想要两个系列的柱子重叠,可以设置 barGap 为 '-1f'。这在用柱子做背景的时候有用。
  584. /// 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。
  585. /// </summary>
  586. public float barGap
  587. {
  588. get { return m_BarGap; }
  589. set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
  590. }
  591. /// <summary>
  592. /// 斑马线的粗细。
  593. /// </summary>
  594. public float barZebraWidth
  595. {
  596. get { return m_BarZebraWidth; }
  597. set { if (PropertyUtil.SetStruct(ref m_BarZebraWidth, value < 0 ? 0 : value)) SetVerticesDirty(); }
  598. }
  599. /// <summary>
  600. /// 斑马线的间距。
  601. /// </summary>
  602. public float barZebraGap
  603. {
  604. get { return m_BarZebraGap; }
  605. set { if (PropertyUtil.SetStruct(ref m_BarZebraGap, value < 0 ? 0 : value)) SetVerticesDirty(); }
  606. }
  607. /// <summary>
  608. /// Whether offset when mouse click pie chart item.
  609. /// |鼠标点击时是否开启偏移,一般用在PieChart图表中。
  610. /// </summary>
  611. public bool pieClickOffset
  612. {
  613. get { return m_ClickOffset; }
  614. set { if (PropertyUtil.SetStruct(ref m_ClickOffset, value)) SetVerticesDirty(); }
  615. }
  616. /// <summary>
  617. /// Whether to show as Nightingale chart.
  618. /// |是否展示成南丁格尔图,通过半径区分数据大小。
  619. /// </summary>
  620. public RoseType pieRoseType
  621. {
  622. get { return m_RoseType; }
  623. set { if (PropertyUtil.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
  624. }
  625. /// <summary>
  626. /// gap of item.
  627. /// |间距。
  628. /// </summary>
  629. public float gap
  630. {
  631. get { return m_Gap; }
  632. set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
  633. }
  634. /// <summary>
  635. /// the center of chart.
  636. /// |中心点。
  637. /// </summary>
  638. public float[] center
  639. {
  640. get { return m_Center; }
  641. set { if (value != null && value.Length == 2) { m_Center = value; SetVerticesDirty(); } }
  642. }
  643. /// <summary>
  644. /// the radius of chart.
  645. /// |半径。radius[0]表示内径,radius[1]表示外径。
  646. /// </summary>
  647. public float[] radius
  648. {
  649. get { return m_Radius; }
  650. set { if (value != null && value.Length == 2) { m_Radius = value; SetVerticesDirty(); } }
  651. }
  652. /// <summary>
  653. /// 最小值。
  654. /// </summary>
  655. public float min
  656. {
  657. get { return m_Min; }
  658. set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
  659. }
  660. /// <summary>
  661. /// 最大值。
  662. /// </summary>
  663. public float max
  664. {
  665. get { return m_Max; }
  666. set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetVerticesDirty(); }
  667. }
  668. /// <summary>
  669. /// 数据最小值 min 映射的宽度。
  670. /// </summary>
  671. public float minSize
  672. {
  673. get { return m_MinSize; }
  674. set { if (PropertyUtil.SetStruct(ref m_MinSize, value)) SetVerticesDirty(); }
  675. }
  676. /// <summary>
  677. /// 数据最大值 max 映射的宽度。
  678. /// </summary>
  679. public float maxSize
  680. {
  681. get { return m_MaxSize; }
  682. set { if (PropertyUtil.SetStruct(ref m_MaxSize, value)) SetVerticesDirty(); }
  683. }
  684. /// <summary>
  685. /// 起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
  686. /// </summary>
  687. public float startAngle
  688. {
  689. get { return m_StartAngle; }
  690. set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
  691. }
  692. /// <summary>
  693. /// 结束角度。和时钟一样,12点钟位置是0度,顺时针到360度。
  694. /// </summary>
  695. public float endAngle
  696. {
  697. get { return m_EndAngle; }
  698. set { if (PropertyUtil.SetStruct(ref m_EndAngle, value)) SetVerticesDirty(); }
  699. }
  700. /// <summary>
  701. /// The minimum angle of sector(0-360). It prevents some sector from being too small when value is small.
  702. /// |最小的扇区角度(0-360)。用于防止某个值过小导致扇区太小影响交互。
  703. /// </summary>
  704. public float minAngle
  705. {
  706. get { return m_MinAngle; }
  707. set { if (PropertyUtil.SetStruct(ref m_MinAngle, value)) SetVerticesDirty(); }
  708. }
  709. /// <summary>
  710. /// 是否顺时针。
  711. /// </summary>
  712. public bool clockwise
  713. {
  714. get { return m_Clockwise; }
  715. set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
  716. }
  717. /// <summary>
  718. /// 刻度分割段数。最大可设置36。
  719. /// </summary>
  720. public int splitNumber
  721. {
  722. get { return m_SplitNumber; }
  723. set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value > 36 ? 36 : value)) SetVerticesDirty(); }
  724. }
  725. /// <summary>
  726. /// 是否开启圆弧效果。
  727. /// </summary>
  728. public bool roundCap
  729. {
  730. get { return m_RoundCap; }
  731. set { if (PropertyUtil.SetStruct(ref m_RoundCap, value)) SetVerticesDirty(); }
  732. }
  733. /// <summary>
  734. /// 是否开启忽略数据。当为 true 时,数据值为 ignoreValue 时不进行绘制。
  735. /// </summary>
  736. public bool ignore
  737. {
  738. get { return m_Ignore; }
  739. set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
  740. }
  741. /// <summary>
  742. /// 忽略数据的默认值。当ignore为true才有效。
  743. /// </summary>
  744. public double ignoreValue
  745. {
  746. get { return m_IgnoreValue; }
  747. set { if (PropertyUtil.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
  748. }
  749. /// <summary>
  750. /// 忽略数据时折线是断开还是连接。默认false为连接。
  751. /// </summary>
  752. /// <value></value>
  753. public bool ignoreLineBreak
  754. {
  755. get { return m_IgnoreLineBreak; }
  756. set { if (PropertyUtil.SetStruct(ref m_IgnoreLineBreak, value)) SetVerticesDirty(); }
  757. }
  758. /// <summary>
  759. /// 雷达图类型。
  760. /// </summary>
  761. public RadarType radarType
  762. {
  763. get { return m_RadarType; }
  764. set { if (PropertyUtil.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); }
  765. }
  766. /// <summary>
  767. /// The start animation.
  768. /// |起始动画。
  769. /// </summary>
  770. public AnimationStyle animation
  771. {
  772. get { return m_Animation; }
  773. set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
  774. }
  775. /// <summary>
  776. /// The style of data item.
  777. /// |图形样式。
  778. /// </summary>
  779. public ItemStyle itemStyle
  780. {
  781. get { return m_ItemStyle; }
  782. set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
  783. }
  784. /// <summary>
  785. /// 数据项里的数据维数。
  786. /// </summary>
  787. public int showDataDimension { get { return m_ShowDataDimension; } set { m_ShowDataDimension = Mathf.Clamp(2, 10, value); } }
  788. /// <summary>
  789. /// 在Editor的inpsector上是否显示name参数
  790. /// </summary>
  791. public bool showDataName { get { return m_ShowDataName; } set { m_ShowDataName = value; } }
  792. /// <summary>
  793. /// If clip the overflow on the coordinate system.
  794. /// |是否裁剪超出坐标系部分的图形。
  795. /// </summary>
  796. public bool clip
  797. {
  798. get { return m_Clip; }
  799. set { if (PropertyUtil.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
  800. }
  801. /// <summary>
  802. /// Show negative number as positive number.
  803. /// |将负数数值显示为正数。一般和`AxisLabel`的`showAsPositiveNumber`配合使用。仅在折线图和柱状图中有效。
  804. /// </summary>
  805. public bool showAsPositiveNumber
  806. {
  807. get { return m_ShowAsPositiveNumber; }
  808. set { if (PropertyUtil.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
  809. }
  810. /// <summary>
  811. /// 是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。
  812. /// 开启后配合 largeThreshold 在数据量大于指定阈值的时候对绘制进行优化。
  813. /// 缺点:优化后不能自定义设置单个数据项的样式,不能显示Label。
  814. /// </summary>
  815. public bool large
  816. {
  817. get { return m_Large; }
  818. set { if (PropertyUtil.SetStruct(ref m_Large, value)) SetAllDirty(); }
  819. }
  820. /// <summary>
  821. /// 开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
  822. /// </summary>
  823. public int largeThreshold
  824. {
  825. get { return m_LargeThreshold; }
  826. set { if (PropertyUtil.SetStruct(ref m_LargeThreshold, value)) SetAllDirty(); }
  827. }
  828. /// <summary>
  829. /// 在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。
  830. /// </summary>
  831. public bool avoidLabelOverlap
  832. {
  833. get { return m_AvoidLabelOverlap; }
  834. set { if (PropertyUtil.SetStruct(ref m_AvoidLabelOverlap, value)) SetVerticesDirty(); }
  835. }
  836. /// <summary>
  837. /// Distance between component and the left side of the container.
  838. /// |组件离容器左侧的距离。
  839. /// </summary>
  840. public float left
  841. {
  842. get { return m_Left; }
  843. set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); }
  844. }
  845. /// <summary>
  846. /// Distance between component and the right side of the container.
  847. /// |组件离容器右侧的距离。
  848. /// </summary>
  849. public float right
  850. {
  851. get { return m_Right; }
  852. set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); }
  853. }
  854. /// <summary>
  855. /// Distance between component and the top side of the container.
  856. /// |组件离容器上侧的距离。
  857. /// </summary>
  858. public float top
  859. {
  860. get { return m_Top; }
  861. set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); }
  862. }
  863. /// <summary>
  864. /// Distance between component and the bottom side of the container.
  865. /// |组件离容器下侧的距离。
  866. /// </summary>
  867. public float bottom
  868. {
  869. get { return m_Bottom; }
  870. set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
  871. }
  872. /// <summary>
  873. /// Whether to add new data at the head or at the end of the list.
  874. /// |添加新数据时是在列表的头部还是尾部加入。
  875. /// </summary>
  876. public bool insertDataToHead
  877. {
  878. get { return m_InsertDataToHead; }
  879. set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); }
  880. }
  881. /// <summary>
  882. /// 组件的数据排序。
  883. /// </summary>
  884. public SerieDataSortType dataSortType
  885. {
  886. get { return m_DataSortType; }
  887. set { if (PropertyUtil.SetStruct(ref m_DataSortType, value)) SetVerticesDirty(); }
  888. }
  889. /// <summary>
  890. /// 组件的朝向。
  891. /// </summary>
  892. public Orient orient
  893. {
  894. get { return m_Orient; }
  895. set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
  896. }
  897. /// <summary>
  898. /// 组件水平方向对齐方式。
  899. /// </summary>
  900. public Align align
  901. {
  902. get { return m_Align; }
  903. set { if (PropertyUtil.SetStruct(ref m_Align, value)) SetVerticesDirty(); }
  904. }
  905. /// <summary>
  906. /// 占位模式。占位模式时,数据有效但不参与渲染和显示。
  907. /// </summary>
  908. public bool placeHolder
  909. {
  910. get { return m_PlaceHolder; }
  911. set { if (PropertyUtil.SetStruct(ref m_PlaceHolder, value)) SetAllDirty(); }
  912. }
  913. /// <summary>
  914. /// 系列中的数据内容数组。SerieData可以设置1到n维数据。
  915. /// </summary>
  916. public List<SerieData> data { get { return m_Data; } }
  917. /// <summary>
  918. /// 取色策略是否为按数据项分配。
  919. /// </summary>
  920. public bool colorByData { get { return colorBy == SerieColorBy.Data; } }
  921. public override bool vertsDirty
  922. {
  923. get
  924. {
  925. return m_VertsDirty ||
  926. symbol.vertsDirty ||
  927. lineStyle.vertsDirty ||
  928. itemStyle.vertsDirty ||
  929. IsVertsDirty(lineArrow) ||
  930. IsVertsDirty(areaStyle) ||
  931. IsVertsDirty(label) ||
  932. IsVertsDirty(labelLine) ||
  933. IsVertsDirty(titleStyle) ||
  934. IsVertsDirty(emphasisStyle) ||
  935. IsVertsDirty(blurStyle) ||
  936. IsVertsDirty(selectStyle) ||
  937. AnySerieDataVerticesDirty();
  938. }
  939. }
  940. public override bool componentDirty
  941. {
  942. get
  943. {
  944. return m_ComponentDirty ||
  945. symbol.componentDirty ||
  946. IsComponentDirty(titleStyle) ||
  947. IsComponentDirty(label) ||
  948. IsComponentDirty(labelLine) ||
  949. IsComponentDirty(emphasisStyle) ||
  950. IsComponentDirty(blurStyle) ||
  951. IsComponentDirty(selectStyle);
  952. }
  953. }
  954. public override void ClearVerticesDirty()
  955. {
  956. base.ClearVerticesDirty();
  957. if (!IsPerformanceMode())
  958. {
  959. foreach (var serieData in m_Data)
  960. serieData.ClearVerticesDirty();
  961. }
  962. symbol.ClearVerticesDirty();
  963. lineStyle.ClearVerticesDirty();
  964. itemStyle.ClearVerticesDirty();
  965. ClearVerticesDirty(areaStyle);
  966. ClearVerticesDirty(label);
  967. ClearVerticesDirty(emphasisStyle);
  968. ClearVerticesDirty(blurStyle);
  969. ClearVerticesDirty(selectStyle);
  970. ClearVerticesDirty(lineArrow);
  971. ClearVerticesDirty(titleStyle);
  972. }
  973. public override void ClearComponentDirty()
  974. {
  975. base.ClearComponentDirty();
  976. if (!IsPerformanceMode())
  977. {
  978. foreach (var serieData in m_Data)
  979. serieData.ClearComponentDirty();
  980. }
  981. symbol.ClearComponentDirty();
  982. lineStyle.ClearComponentDirty();
  983. itemStyle.ClearComponentDirty();
  984. ClearComponentDirty(areaStyle);
  985. ClearComponentDirty(label);
  986. ClearComponentDirty(emphasisStyle);
  987. ClearComponentDirty(blurStyle);
  988. ClearComponentDirty(selectStyle);
  989. ClearComponentDirty(lineArrow);
  990. ClearComponentDirty(titleStyle);
  991. }
  992. public override void SetAllDirty()
  993. {
  994. base.SetAllDirty();
  995. labelDirty = true;
  996. titleDirty = true;
  997. }
  998. private bool AnySerieDataVerticesDirty()
  999. {
  1000. if (IsPerformanceMode())
  1001. return false;
  1002. if (this is ISimplifiedSerie)
  1003. return false;
  1004. foreach (var serieData in m_Data)
  1005. if (serieData.vertsDirty) return true;
  1006. return false;
  1007. }
  1008. private bool AnySerieDataComponentDirty()
  1009. {
  1010. if (IsPerformanceMode())
  1011. return false;
  1012. if (this is ISimplifiedSerie)
  1013. return false;
  1014. foreach (var serieData in m_Data)
  1015. if (serieData.componentDirty) return true;
  1016. return false;
  1017. }
  1018. /// <summary>
  1019. /// Whether the serie is highlighted.
  1020. /// |该系列是否高亮,一般由图例悬停触发。
  1021. /// </summary>
  1022. public bool highlight { get; internal set; }
  1023. /// <summary>
  1024. /// the count of data list.
  1025. /// |数据项个数。
  1026. /// </summary>
  1027. public int dataCount { get { return m_Data.Count; } }
  1028. public bool nameDirty { get { return m_NameDirty; } }
  1029. public bool labelDirty { get; set; }
  1030. public bool titleDirty { get; set; }
  1031. public bool dataDirty { get; set; }
  1032. private void SetSerieNameDirty()
  1033. {
  1034. m_NameDirty = true;
  1035. }
  1036. public void ClearSerieNameDirty()
  1037. {
  1038. m_NameDirty = false;
  1039. }
  1040. public override void ClearDirty()
  1041. {
  1042. base.ClearDirty();
  1043. }
  1044. /// <summary>
  1045. /// 维度Y对应数据中最大值。
  1046. /// </summary>
  1047. public double yMax
  1048. {
  1049. get
  1050. {
  1051. var max = double.MinValue;
  1052. foreach (var sdata in data)
  1053. {
  1054. if (sdata.show && !IsIgnoreValue(sdata, sdata.data[1]) && sdata.data[1] > max)
  1055. {
  1056. max = sdata.data[1];
  1057. }
  1058. }
  1059. return max;
  1060. }
  1061. }
  1062. /// <summary>
  1063. /// 维度X对应数据中的最大值。
  1064. /// </summary>
  1065. public double xMax
  1066. {
  1067. get
  1068. {
  1069. var max = double.MinValue;
  1070. foreach (var sdata in data)
  1071. {
  1072. if (sdata.show && !IsIgnoreValue(sdata, sdata.data[0]) && sdata.data[0] > max)
  1073. {
  1074. max = sdata.data[0];
  1075. }
  1076. }
  1077. return max;
  1078. }
  1079. }
  1080. /// <summary>
  1081. /// 维度Y对应数据的最小值。
  1082. /// </summary>
  1083. public double yMin
  1084. {
  1085. get
  1086. {
  1087. var min = double.MaxValue;
  1088. foreach (var sdata in data)
  1089. {
  1090. if (sdata.show && !IsIgnoreValue(sdata, sdata.data[1]) && sdata.data[1] < min)
  1091. {
  1092. min = sdata.data[1];
  1093. }
  1094. }
  1095. return min;
  1096. }
  1097. }
  1098. /// <summary>
  1099. /// 维度X对应数据的最小值。
  1100. /// </summary>
  1101. public double xMin
  1102. {
  1103. get
  1104. {
  1105. var min = double.MaxValue;
  1106. foreach (var sdata in data)
  1107. {
  1108. if (sdata.show && !IsIgnoreValue(sdata, sdata.data[0]) && sdata.data[0] < min)
  1109. {
  1110. min = sdata.data[0];
  1111. }
  1112. }
  1113. return min;
  1114. }
  1115. }
  1116. /// <summary>
  1117. /// 维度Y数据的总和。
  1118. /// </summary>
  1119. public double yTotal
  1120. {
  1121. get
  1122. {
  1123. double total = 0;
  1124. if (IsPerformanceMode())
  1125. {
  1126. foreach (var sdata in data)
  1127. {
  1128. if (sdata.show && !IsIgnoreValue(sdata, sdata.data[1]))
  1129. total += sdata.data[1];
  1130. }
  1131. }
  1132. else
  1133. {
  1134. var duration = animation.GetUpdateAnimationDuration();
  1135. var unscaledTime = animation.unscaledTime;
  1136. foreach (var sdata in data)
  1137. {
  1138. if (sdata.show && !IsIgnoreValue(sdata, sdata.data[1]))
  1139. total += sdata.GetCurrData(1, duration, unscaledTime);
  1140. }
  1141. }
  1142. return total;
  1143. }
  1144. }
  1145. /// <summary>
  1146. /// 维度X数据的总和。
  1147. /// </summary>
  1148. public double xTotal
  1149. {
  1150. get
  1151. {
  1152. double total = 0;
  1153. foreach (var sdata in data)
  1154. {
  1155. if (sdata.show && !IsIgnoreValue(sdata, sdata.data[1]))
  1156. total += sdata.data[0];
  1157. }
  1158. return total;
  1159. }
  1160. }
  1161. public void ResetInteract()
  1162. {
  1163. interact.Reset();
  1164. foreach (var serieData in m_Data)
  1165. serieData.interact.Reset();
  1166. }
  1167. /// <summary>
  1168. /// 重置数据项索引。避免部分数据项的索引异常。
  1169. /// </summary>
  1170. public bool ResetDataIndex()
  1171. {
  1172. var flag = false;
  1173. for (int i = 0; i < m_Data.Count; i++)
  1174. {
  1175. if (m_Data[i].index != i)
  1176. {
  1177. m_Data[i].index = i;
  1178. flag = true;
  1179. }
  1180. }
  1181. return flag;
  1182. }
  1183. /// <summary>
  1184. /// 清空所有数据
  1185. /// </summary>
  1186. public override void ClearData()
  1187. {
  1188. while (m_Data.Count > 0)
  1189. {
  1190. RemoveData(0);
  1191. }
  1192. m_Data.Clear();
  1193. m_NeedUpdateFilterData = true;
  1194. dataDirty = true;
  1195. SetVerticesDirty();
  1196. }
  1197. /// <summary>
  1198. /// 移除指定索引的数据
  1199. /// </summary>
  1200. /// <param name="index"></param>
  1201. public void RemoveData(int index)
  1202. {
  1203. if (index >= 0 && index < m_Data.Count)
  1204. {
  1205. if (!string.IsNullOrEmpty(m_Data[index].name))
  1206. {
  1207. SetSerieNameDirty();
  1208. }
  1209. SetVerticesDirty();
  1210. var serieData = m_Data[index];
  1211. SerieDataPool.Release(serieData);
  1212. if (serieData.labelObject != null)
  1213. {
  1214. SerieLabelPool.Release(serieData.labelObject.gameObject);
  1215. }
  1216. m_Data.RemoveAt(index);
  1217. m_NeedUpdateFilterData = true;
  1218. labelDirty = true;
  1219. dataDirty = true;
  1220. }
  1221. }
  1222. /// <summary>
  1223. /// 添加一个数据到维度Y(此时维度X对应的数据是索引)
  1224. /// </summary>
  1225. /// <param name="value"></param>
  1226. /// <param name="dataName"></param>
  1227. /// <param name="dataId">the unique id of data</param>
  1228. public SerieData AddYData(double value, string dataName = null, string dataId = null)
  1229. {
  1230. CheckMaxCache();
  1231. int xValue = m_Data.Count;
  1232. var serieData = SerieDataPool.Get();
  1233. serieData.data.Add(xValue);
  1234. serieData.data.Add(value);
  1235. serieData.name = dataName;
  1236. serieData.index = xValue;
  1237. serieData.id = dataId;
  1238. AddSerieData(serieData);
  1239. m_ShowDataDimension = 2;
  1240. SetVerticesDirty();
  1241. CheckDataName(dataName);
  1242. labelDirty = true;
  1243. dataDirty = true;
  1244. return serieData;
  1245. }
  1246. public void AddSerieData(SerieData serieData)
  1247. {
  1248. if (m_InsertDataToHead)
  1249. m_Data.Insert(0, serieData);
  1250. else
  1251. m_Data.Add(serieData);
  1252. SetVerticesDirty();
  1253. dataDirty = true;
  1254. m_NeedUpdateFilterData = true;
  1255. }
  1256. private void CheckDataName(string dataName)
  1257. {
  1258. if (string.IsNullOrEmpty(dataName))
  1259. SetSerieNameDirty();
  1260. else
  1261. m_ShowDataName = true;
  1262. }
  1263. /// <summary>
  1264. /// 添加(x,y)数据到维度X和维度Y
  1265. /// </summary>
  1266. /// <param name="xValue"></param>
  1267. /// <param name="yValue"></param>
  1268. /// <param name="dataName"></param>
  1269. /// <param name="dataId">the unique id of data</param>
  1270. public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)
  1271. {
  1272. CheckMaxCache();
  1273. var serieData = SerieDataPool.Get();
  1274. serieData.data.Clear();
  1275. serieData.data.Add(xValue);
  1276. serieData.data.Add(yValue);
  1277. serieData.name = dataName;
  1278. serieData.index = m_Data.Count;
  1279. serieData.id = dataId;
  1280. AddSerieData(serieData);
  1281. m_ShowDataDimension = 2;
  1282. SetVerticesDirty();
  1283. CheckDataName(dataName);
  1284. labelDirty = true;
  1285. return serieData;
  1286. }
  1287. /// <summary>
  1288. /// 添加 (open, close, lowest, heighest) 数据
  1289. /// </summary>
  1290. /// <param name="open"></param>
  1291. /// <param name="close"></param>
  1292. /// <param name="lowest"></param>
  1293. /// <param name="heighest"></param>
  1294. /// <param name="dataName"></param>
  1295. /// <param name="dataId">the unique id of data</param>
  1296. /// <returns></returns>
  1297. public SerieData AddData(double indexOrTimestamp, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null)
  1298. {
  1299. CheckMaxCache();
  1300. var serieData = SerieDataPool.Get();
  1301. serieData.data.Clear();
  1302. serieData.data.Add(indexOrTimestamp);
  1303. serieData.data.Add(open);
  1304. serieData.data.Add(close);
  1305. serieData.data.Add(lowest);
  1306. serieData.data.Add(heighest);
  1307. serieData.name = dataName;
  1308. serieData.index = m_Data.Count;
  1309. serieData.id = dataId;
  1310. AddSerieData(serieData);
  1311. m_ShowDataDimension = 5;
  1312. SetVerticesDirty();
  1313. CheckDataName(dataName);
  1314. labelDirty = true;
  1315. return serieData;
  1316. }
  1317. /// <summary>
  1318. /// 将一组数据添加到系列中。
  1319. /// 如果数据只有一个,默认添加到维度Y中。
  1320. /// </summary>
  1321. /// <param name="valueList"></param>
  1322. /// <param name="dataName"></param>
  1323. /// <param name="dataId">the unique id of data</param>
  1324. public SerieData AddData(List<double> valueList, string dataName = null, string dataId = null)
  1325. {
  1326. if (valueList == null || valueList.Count == 0) return null;
  1327. if (valueList.Count == 1)
  1328. return AddYData(valueList[0], dataName, dataId);
  1329. else if (valueList.Count == 2)
  1330. return AddXYData(valueList[0], valueList[1], dataName, dataId);
  1331. else
  1332. {
  1333. CheckMaxCache();
  1334. m_ShowDataDimension = valueList.Count;
  1335. var serieData = SerieDataPool.Get();
  1336. serieData.name = dataName;
  1337. serieData.index = m_Data.Count;
  1338. serieData.id = dataId;
  1339. for (int i = 0; i < valueList.Count; i++)
  1340. {
  1341. serieData.data.Add(valueList[i]);
  1342. }
  1343. AddSerieData(serieData);
  1344. SetVerticesDirty();
  1345. CheckDataName(dataName);
  1346. labelDirty = true;
  1347. return serieData;
  1348. }
  1349. }
  1350. /// <summary>
  1351. /// 添加任意维数据到系列中。
  1352. /// </summary>
  1353. /// <param name="values">任意维数据</param>
  1354. /// <returns></returns>
  1355. public SerieData AddData(params double[] values)
  1356. {
  1357. if (values == null || values.Length == 0) return null;
  1358. string dataName = null;
  1359. string dataId = null;
  1360. if (values.Length == 1)
  1361. return AddYData(values[0], dataName, dataId);
  1362. else if (values.Length == 2)
  1363. return AddXYData(values[0], values[1], dataName, dataId);
  1364. else
  1365. {
  1366. CheckMaxCache();
  1367. m_ShowDataDimension = values.Length;
  1368. var serieData = SerieDataPool.Get();
  1369. serieData.name = dataName;
  1370. serieData.index = m_Data.Count;
  1371. serieData.id = dataId;
  1372. for (int i = 0; i < values.Length; i++)
  1373. {
  1374. serieData.data.Add(values[i]);
  1375. }
  1376. AddSerieData(serieData);
  1377. SetVerticesDirty();
  1378. CheckDataName(dataName);
  1379. labelDirty = true;
  1380. return serieData;
  1381. }
  1382. }
  1383. public SerieData AddChildData(SerieData parent, double value, string name, string id)
  1384. {
  1385. var serieData = new SerieData();
  1386. serieData.name = name;
  1387. serieData.index = m_Data.Count;
  1388. serieData.id = id;
  1389. serieData.data = new List<double>() { m_Data.Count, value };
  1390. AddChildData(parent, serieData);
  1391. return serieData;
  1392. }
  1393. public SerieData AddChildData(SerieData parent, List<double> value, string name, string id)
  1394. {
  1395. var serieData = new SerieData();
  1396. serieData.name = name;
  1397. serieData.index = m_Data.Count;
  1398. serieData.id = id;
  1399. serieData.data = new List<double>(value);
  1400. AddChildData(parent, serieData);
  1401. return serieData;
  1402. }
  1403. public void AddChildData(SerieData parent, SerieData serieData)
  1404. {
  1405. serieData.parentId = parent.id;
  1406. serieData.context.parent = parent;
  1407. if (!m_Data.Contains(serieData))
  1408. AddSerieData(serieData);
  1409. if (!parent.context.children.Contains(serieData))
  1410. {
  1411. parent.context.children.Add(serieData);
  1412. }
  1413. }
  1414. private void CheckMaxCache()
  1415. {
  1416. if (m_MaxCache <= 0) return;
  1417. while (m_Data.Count >= m_MaxCache)
  1418. {
  1419. m_NeedUpdateFilterData = true;
  1420. if (m_InsertDataToHead) RemoveData(m_Data.Count - 1);
  1421. else RemoveData(0);
  1422. }
  1423. }
  1424. /// <summary>
  1425. /// 获得指定index指定维数的数据
  1426. /// </summary>
  1427. /// <param name="index"></param>
  1428. /// <param name="dimension"></param>
  1429. /// <param name="dataZoom"></param>
  1430. /// <returns></returns>
  1431. public double GetData(int index, int dimension, DataZoom dataZoom = null)
  1432. {
  1433. if (index < 0 || dimension < 0) return 0;
  1434. var serieData = GetSerieData(index, dataZoom);
  1435. if (serieData != null && dimension < serieData.data.Count)
  1436. {
  1437. var value = serieData.GetData(dimension);
  1438. if (showAsPositiveNumber)
  1439. value = Math.Abs(value);
  1440. return value;
  1441. }
  1442. else
  1443. {
  1444. return 0;
  1445. }
  1446. }
  1447. /// <summary>
  1448. /// 获得维度Y索引对应的数据
  1449. /// </summary>
  1450. /// <param name="index"></param>
  1451. /// <param name="dataZoom"></param>
  1452. /// <returns></returns>
  1453. public double GetYData(int index, DataZoom dataZoom = null)
  1454. {
  1455. if (index < 0) return 0;
  1456. var serieData = GetDataList(dataZoom);
  1457. if (index < serieData.Count)
  1458. {
  1459. var value = serieData[index].data[1];
  1460. if (showAsPositiveNumber)
  1461. value = Math.Abs(value);
  1462. return value;
  1463. }
  1464. return 0;
  1465. }
  1466. public double GetYCurrData(int index, DataZoom dataZoom = null)
  1467. {
  1468. if (index < 0) return 0;
  1469. var serieData = GetDataList(dataZoom);
  1470. if (index < serieData.Count)
  1471. {
  1472. var value = serieData[index].GetCurrData(1, animation.GetUpdateAnimationDuration(), animation.unscaledTime);
  1473. if (showAsPositiveNumber)
  1474. value = Math.Abs(value);
  1475. return value;
  1476. }
  1477. return 0;
  1478. }
  1479. /// <summary>
  1480. /// 获得维度Y索引对应的数据和数据名
  1481. /// </summary>
  1482. /// <param name="index">索引</param>
  1483. /// <param name="yData">对应的数据值</param>
  1484. /// <param name="dataName">对应的数据名</param>
  1485. /// <param name="dataZoom">区域缩放</param>
  1486. public void GetYData(int index, out double yData, out string dataName, DataZoom dataZoom = null)
  1487. {
  1488. yData = 0;
  1489. dataName = null;
  1490. if (index < 0) return;
  1491. var serieData = GetDataList(dataZoom);
  1492. if (index < serieData.Count)
  1493. {
  1494. yData = serieData[index].data[1];
  1495. if (showAsPositiveNumber)
  1496. yData = Math.Abs(yData);
  1497. dataName = serieData[index].name;
  1498. }
  1499. }
  1500. /// <summary>
  1501. /// 获得指定索引的数据项
  1502. /// </summary>
  1503. /// <param name="index"></param>
  1504. /// <param name="dataZoom"></param>
  1505. /// <returns></returns>
  1506. public SerieData GetSerieData(int index, DataZoom dataZoom = null)
  1507. {
  1508. var data = GetDataList(dataZoom);
  1509. if (index >= 0 && index <= data.Count - 1)
  1510. return data[index];
  1511. return null;
  1512. }
  1513. public SerieData GetSerieData(string id, DataZoom dataZoom = null)
  1514. {
  1515. var data = GetDataList(dataZoom);
  1516. foreach (var serieData in data)
  1517. {
  1518. var target = GetSerieData(serieData, id);
  1519. if (target != null) return target;
  1520. }
  1521. return null;
  1522. }
  1523. public SerieData GetSerieData(SerieData parent, string id)
  1524. {
  1525. if (id.Equals(parent.id)) return parent;
  1526. foreach (var child in parent.context.children)
  1527. {
  1528. var data = GetSerieData(child, id);
  1529. if (data != null)
  1530. {
  1531. return data;
  1532. }
  1533. }
  1534. return null;
  1535. }
  1536. /// <summary>
  1537. /// 获得指定索引的维度X和维度Y的数据
  1538. /// </summary>
  1539. /// <param name="index"></param>
  1540. /// <param name="dataZoom"></param>
  1541. /// <param name="xValue"></param>
  1542. /// <param name="yVlaue"></param>
  1543. public void GetXYData(int index, DataZoom dataZoom, out double xValue, out double yVlaue)
  1544. {
  1545. xValue = 0;
  1546. yVlaue = 0;
  1547. if (index < 0) return;
  1548. var showData = GetDataList(dataZoom);
  1549. if (index < showData.Count)
  1550. {
  1551. var serieData = showData[index];
  1552. xValue = serieData.data[0];
  1553. yVlaue = serieData.data[1];
  1554. if (showAsPositiveNumber)
  1555. {
  1556. xValue = Math.Abs(xValue);
  1557. yVlaue = Math.Abs(yVlaue);
  1558. }
  1559. }
  1560. }
  1561. public virtual double GetDataTotal(int dimension, SerieData serieData = null)
  1562. {
  1563. if (m_Max > 0) return m_Max;
  1564. double total = 0;
  1565. foreach (var sdata in data)
  1566. {
  1567. if (sdata.show)
  1568. total += sdata.GetData(dimension);
  1569. }
  1570. return total;
  1571. }
  1572. /// <summary>
  1573. /// 获得系列的数据列表
  1574. /// </summary>
  1575. /// <param name="dataZoom"></param>
  1576. /// <returns></returns>
  1577. public List<SerieData> GetDataList(DataZoom dataZoom = null)
  1578. {
  1579. if (dataZoom != null && dataZoom.enable &&
  1580. (dataZoom.IsContainsXAxis(xAxisIndex) || dataZoom.IsContainsYAxis(yAxisIndex)))
  1581. {
  1582. SerieHelper.UpdateFilterData(this, dataZoom);
  1583. return m_FilterData;
  1584. }
  1585. else
  1586. {
  1587. return useSortData && context.sortedData.Count > 0 ? context.sortedData : m_Data;
  1588. }
  1589. }
  1590. /// <summary>
  1591. /// 更新指定索引的维度Y数据
  1592. /// </summary>
  1593. /// <param name="index"></param>
  1594. /// <param name="value"></param>
  1595. public bool UpdateYData(int index, double value)
  1596. {
  1597. UpdateData(index, 1, value);
  1598. return true;
  1599. }
  1600. /// <summary>
  1601. /// 更新指定索引的维度X和维度Y的数据
  1602. /// </summary>
  1603. /// <param name="index"></param>
  1604. /// <param name="xValue"></param>
  1605. /// <param name="yValue"></param>
  1606. public bool UpdateXYData(int index, double xValue, double yValue)
  1607. {
  1608. var flag1 = UpdateData(index, 0, xValue);
  1609. var flag2 = UpdateData(index, 1, yValue);
  1610. return flag1 || flag2;
  1611. }
  1612. /// <summary>
  1613. /// 更新指定索引指定维数的数据
  1614. /// </summary>
  1615. /// <param name="index">要更新数据的索引</param>
  1616. /// <param name="dimension">要更新数据的维数</param>
  1617. /// <param name="value">新的数据值</param>
  1618. public bool UpdateData(int index, int dimension, double value)
  1619. {
  1620. if (index >= 0 && index < m_Data.Count)
  1621. {
  1622. var animationOpen = animation.enable;
  1623. var animationDuration = animation.GetUpdateAnimationDuration();
  1624. var unscaledTime = animation.unscaledTime;
  1625. var flag = m_Data[index].UpdateData(dimension, value, animationOpen, unscaledTime, animationDuration);
  1626. if (flag)
  1627. {
  1628. SetVerticesDirty();
  1629. dataDirty = true;
  1630. }
  1631. return flag;
  1632. }
  1633. else
  1634. {
  1635. return false;
  1636. }
  1637. }
  1638. /// <summary>
  1639. /// 更新指定索引的数据项数据列表
  1640. /// </summary>
  1641. /// <param name="index"></param>
  1642. /// <param name="values"></param>
  1643. public bool UpdateData(int index, List<double> values)
  1644. {
  1645. if (index >= 0 && index < m_Data.Count && values != null)
  1646. {
  1647. var serieData = m_Data[index];
  1648. var animationOpen = animation.enable;
  1649. var animationDuration = animation.GetUpdateAnimationDuration();
  1650. var unscaledTime = animation.unscaledTime;
  1651. for (int i = 0; i < values.Count; i++)
  1652. serieData.UpdateData(i, values[i], animationOpen, unscaledTime, animationDuration);
  1653. SetVerticesDirty();
  1654. dataDirty = true;
  1655. return true;
  1656. }
  1657. return false;
  1658. }
  1659. public bool UpdateDataName(int index, string name)
  1660. {
  1661. if (index >= 0 && index < m_Data.Count)
  1662. {
  1663. var serieData = m_Data[index];
  1664. serieData.name = name;
  1665. SetSerieNameDirty();
  1666. if (serieData.labelObject != null)
  1667. {
  1668. serieData.labelObject.SetText(name == null ? "" : name);
  1669. }
  1670. return true;
  1671. }
  1672. return false;
  1673. }
  1674. /// <summary>
  1675. /// 清除所有数据的高亮标志
  1676. /// </summary>
  1677. public void ClearHighlight()
  1678. {
  1679. highlight = false;
  1680. foreach (var serieData in m_Data)
  1681. serieData.context.highlight = false;
  1682. }
  1683. /// <summary>
  1684. /// 设置指定索引的数据为高亮状态
  1685. /// </summary>
  1686. public void SetHighlight(int index, bool flag)
  1687. {
  1688. var serieData = GetSerieData(index);
  1689. if (serieData != null)
  1690. serieData.context.highlight = flag;
  1691. }
  1692. public float GetBarWidth(float categoryWidth, int barCount = 0)
  1693. {
  1694. var realWidth = 0f;
  1695. if (categoryWidth < 2)
  1696. {
  1697. realWidth = categoryWidth;
  1698. }
  1699. else if (m_BarWidth == 0)
  1700. {
  1701. var width = ChartHelper.GetActualValue(0.6f, categoryWidth);
  1702. if (barCount == 0)
  1703. realWidth = width < 1 ? categoryWidth : width;
  1704. else
  1705. realWidth = width / barCount;
  1706. }
  1707. else
  1708. {
  1709. realWidth = ChartHelper.GetActualValue(m_BarWidth, categoryWidth);
  1710. }
  1711. if (m_BarMaxWidth == 0)
  1712. {
  1713. return realWidth;
  1714. }
  1715. else
  1716. {
  1717. var maxWidth = ChartHelper.GetActualValue(m_BarMaxWidth, categoryWidth);
  1718. return realWidth > maxWidth ? maxWidth : realWidth;
  1719. }
  1720. }
  1721. public bool IsIgnoreIndex(int index, int dimension = 1)
  1722. {
  1723. var serieData = GetSerieData(index);
  1724. if (serieData != null)
  1725. return IsIgnoreValue(serieData, dimension);
  1726. return false;
  1727. }
  1728. public bool IsIgnoreValue(SerieData serieData, int dimension = 1)
  1729. {
  1730. return IsIgnoreValue(serieData, serieData.GetData(dimension));
  1731. }
  1732. public bool IsIgnoreValue(double value)
  1733. {
  1734. return m_Ignore && MathUtil.Approximately(value, m_IgnoreValue);
  1735. }
  1736. public bool IsIgnoreValue(SerieData serieData, double value)
  1737. {
  1738. return serieData.ignore || IsIgnoreValue(value);
  1739. }
  1740. public bool IsIgnorePoint(int index)
  1741. {
  1742. if (index >= 0 && index < dataCount)
  1743. {
  1744. return ChartHelper.IsIngore(data[index].context.position);
  1745. }
  1746. return false;
  1747. }
  1748. public bool IsSerie<T>() where T : Serie
  1749. {
  1750. return this is T;
  1751. }
  1752. public bool IsUseCoord<T>() where T : CoordSystem
  1753. {
  1754. return ChartCached.GetTypeName<T>().Equals(m_CoordSystem);
  1755. }
  1756. public bool SetCoord<T>() where T : CoordSystem
  1757. {
  1758. if (GetType().IsDefined(typeof(CoordOptionsAttribute), false))
  1759. {
  1760. var attribute = GetType().GetAttribute<CoordOptionsAttribute>();
  1761. if (attribute.Contains<T>())
  1762. {
  1763. m_CoordSystem = typeof(T).Name;
  1764. return true;
  1765. }
  1766. }
  1767. Debug.LogError("not support coord system:" + typeof(T));
  1768. return false;
  1769. }
  1770. /// <summary>
  1771. /// 是否为性能模式。性能模式下不绘制Symbol,不刷新Label,不单独设置数据项配置。
  1772. /// </summary>
  1773. public bool IsPerformanceMode()
  1774. {
  1775. return m_Large && m_Data.Count >= m_LargeThreshold;
  1776. }
  1777. public bool IsLegendName(string legendName)
  1778. {
  1779. if (colorBy == SerieColorBy.Data)
  1780. {
  1781. return IsSerieDataLegendName(legendName) || IsSerieLegendName(legendName);
  1782. }
  1783. else
  1784. {
  1785. return IsSerieLegendName(legendName);
  1786. }
  1787. }
  1788. public bool IsSerieLegendName(string legendName)
  1789. {
  1790. return legendName.Equals(this.legendName);
  1791. }
  1792. public bool IsSerieDataLegendName(string legendName)
  1793. {
  1794. foreach (var serieData in m_Data)
  1795. {
  1796. if (legendName.Equals(serieData.legendName))
  1797. return true;
  1798. }
  1799. return false;
  1800. }
  1801. /// <summary>
  1802. /// 启用或取消初始动画
  1803. /// </summary>
  1804. public void AnimationEnable(bool flag)
  1805. {
  1806. if (animation.enable) animation.enable = flag;
  1807. SetVerticesDirty();
  1808. }
  1809. /// <summary>
  1810. /// 渐入动画
  1811. /// </summary>
  1812. public void AnimationFadeIn()
  1813. {
  1814. if (animation.enable) animation.FadeIn();
  1815. SetVerticesDirty();
  1816. }
  1817. /// <summary>
  1818. /// 渐出动画
  1819. /// </summary>
  1820. public void AnimationFadeOut()
  1821. {
  1822. if (animation.enable) animation.FadeOut();
  1823. SetVerticesDirty();
  1824. }
  1825. /// <summary>
  1826. /// 暂停动画
  1827. /// </summary>
  1828. public void AnimationPause()
  1829. {
  1830. if (animation.enable) animation.Pause();
  1831. SetVerticesDirty();
  1832. }
  1833. /// <summary>
  1834. /// 继续动画
  1835. /// </summary>
  1836. public void AnimationResume()
  1837. {
  1838. if (animation.enable) animation.Resume();
  1839. SetVerticesDirty();
  1840. }
  1841. /// <summary>
  1842. /// 重置动画
  1843. /// </summary>
  1844. public void AnimationReset()
  1845. {
  1846. if (animation.enable) animation.Reset();
  1847. SetVerticesDirty();
  1848. }
  1849. /// <summary>
  1850. /// 重置动画
  1851. /// </summary>
  1852. public void AnimationRestart()
  1853. {
  1854. if (animation.enable) animation.Restart();
  1855. SetVerticesDirty();
  1856. }
  1857. public int CompareTo(object obj)
  1858. {
  1859. return index.CompareTo((obj as Serie).index);
  1860. }
  1861. public T Clone<T>() where T : Serie
  1862. {
  1863. var newSerie = Activator.CreateInstance<T>();
  1864. SerieHelper.CopySerie(this, newSerie);
  1865. return newSerie;
  1866. }
  1867. public Serie Clone()
  1868. {
  1869. var newSerie = Activator.CreateInstance(GetType()) as Serie;
  1870. SerieHelper.CopySerie(this, newSerie);
  1871. return newSerie;
  1872. }
  1873. }
  1874. }