Brak opisu
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.

LineHandler.cs 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System.Collections.Generic;
  2. using System.Text;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using XUGL;
  6. namespace XCharts.Runtime
  7. {
  8. /// <summary>
  9. /// For grid coord
  10. /// </summary>
  11. [UnityEngine.Scripting.Preserve]
  12. internal sealed partial class LineHandler : SerieHandler<Line>
  13. {
  14. public override void Update()
  15. {
  16. base.Update();
  17. if (serie.IsUseCoord<GridCoord>())
  18. UpdateSerieGridContext();
  19. else if (serie.IsUseCoord<PolarCoord>())
  20. UpdateSeriePolarContext();
  21. }
  22. public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
  23. string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
  24. ref List<SerieParams> paramList, ref string title)
  25. {
  26. UpdateCoordSerieParams(ref paramList, ref title, dataIndex, showCategory, category,
  27. marker, itemFormatter, numericFormatter, ignoreDataDefaultContent);
  28. }
  29. public override void DrawSerie(VertexHelper vh)
  30. {
  31. if (serie.IsUseCoord<PolarCoord>())
  32. {
  33. DrawPolarLine(vh, serie);
  34. DrawPolarLineSymbol(vh);
  35. DrawPolarLineArrow(vh, serie);
  36. }
  37. else if (serie.IsUseCoord<GridCoord>())
  38. {
  39. DrawLineSerie(vh, serie);
  40. if (!SeriesHelper.IsStack(chart.series))
  41. {
  42. DrawLinePoint(vh, serie);
  43. DrawLineArrow(vh, serie);
  44. }
  45. }
  46. }
  47. public override void DrawUpper(VertexHelper vh)
  48. {
  49. if (serie.IsUseCoord<GridCoord>())
  50. {
  51. if (SeriesHelper.IsStack(chart.series))
  52. {
  53. DrawLinePoint(vh, serie);
  54. DrawLineArrow(vh, serie);
  55. }
  56. }
  57. }
  58. public override void RefreshEndLabelInternal()
  59. {
  60. base.RefreshEndLabelInternal();
  61. if (m_SerieGrid == null) return;
  62. if (!serie.animation.IsFinish()) return;
  63. var endLabelList = m_SerieGrid.context.endLabelList;
  64. if (endLabelList.Count <= 1) return;
  65. endLabelList.Sort(delegate(ChartLabel a, ChartLabel b)
  66. {
  67. if (a == null || b == null) return 1;
  68. return b.transform.position.y.CompareTo(a.transform.position.y);
  69. });
  70. var lastY = float.NaN;
  71. for (int i = 0; i < endLabelList.Count; i++)
  72. {
  73. var label = endLabelList[i];
  74. if (label == null) continue;
  75. if (!label.isAnimationEnd) continue;
  76. var labelPosition = label.transform.localPosition;
  77. if (float.IsNaN(lastY))
  78. {
  79. lastY = labelPosition.y;
  80. }
  81. else
  82. {
  83. var labelHeight = label.GetTextHeight();
  84. if (labelPosition.y + labelHeight > lastY)
  85. {
  86. label.SetPosition(new Vector3(labelPosition.x, lastY - labelHeight, labelPosition.z));
  87. }
  88. lastY = label.transform.localPosition.y;
  89. }
  90. }
  91. }
  92. }
  93. }