Heatmap.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using UnityEngine;
  2. namespace XCharts.Runtime
  3. {
  4. /// <summary>
  5. /// The mapping type of heatmap.
  6. /// ||热力图类型。通过颜色映射划分。
  7. /// </summary>
  8. public enum HeatmapType
  9. {
  10. /// <summary>
  11. /// Data mapping type.By default, the second dimension data is used as the color map.
  12. /// ||数据映射型。默认用第2维数据作为颜色映射。要求数据至少有3个维度数据。
  13. /// </summary>
  14. Data,
  15. /// <summary>
  16. /// Number mapping type.The number of occurrences of a statistic in a divided grid, as a color map.
  17. /// ||个数映射型。统计数据在划分的格子中出现的次数,作为颜色映射。要求数据至少有2个维度数据。
  18. /// </summary>
  19. Count
  20. }
  21. [System.Serializable]
  22. [SerieHandler(typeof(HeatmapHandler), true)]
  23. [DefaultAnimation(AnimationType.LeftToRight, false)]
  24. [DefaultTooltip(Tooltip.Type.None, Tooltip.Trigger.Axis)]
  25. [RequireChartComponent(typeof(VisualMap))]
  26. [CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
  27. [SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
  28. [SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
  29. [SerieDataExtraField()]
  30. public class Heatmap : Serie, INeedSerieContainer
  31. {
  32. [SerializeField][Since("v3.3.0")] private HeatmapType m_HeatmapType = HeatmapType.Data;
  33. /// <summary>
  34. /// The mapping type of heatmap.
  35. /// ||热力图类型。通过颜色映射划分。
  36. /// </summary>
  37. public HeatmapType heatmapType
  38. {
  39. get { return m_HeatmapType; }
  40. set { if (PropertyUtil.SetStruct(ref m_HeatmapType, value)) { SetVerticesDirty(); } }
  41. }
  42. public int containerIndex { get; internal set; }
  43. public int containterInstanceId { get; internal set; }
  44. public static Serie AddDefaultSerie(BaseChart chart, string serieName)
  45. {
  46. var serie = chart.AddSerie<Heatmap>(serieName);
  47. serie.itemStyle.show = true;
  48. serie.itemStyle.borderWidth = 2;
  49. serie.itemStyle.borderColor = Color.clear;
  50. return serie;
  51. }
  52. }
  53. }