ScatterChart.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using UnityEngine;
  2. namespace XCharts.Runtime
  3. {
  4. /// <summary>
  5. /// Scatter chart is mainly used to show the relationship between two data dimensions.
  6. /// || 散点图主要用于展现两个数据维度之间的关系。
  7. /// </summary>
  8. [AddComponentMenu("XCharts/ScatterChart", 17)]
  9. [ExecuteInEditMode]
  10. [RequireComponent(typeof(RectTransform))]
  11. [DisallowMultipleComponent]
  12. [HelpURL("https://xcharts-team.github.io/docs/configuration")]
  13. public class ScatterChart : BaseChart
  14. {
  15. protected override void DefaultChart()
  16. {
  17. EnsureChartComponent<GridCoord>();
  18. var xAxis = EnsureChartComponent<XAxis>();
  19. xAxis.type = Axis.AxisType.Value;
  20. xAxis.boundaryGap = false;
  21. var yAxis = EnsureChartComponent<YAxis>();
  22. yAxis.type = Axis.AxisType.Value;
  23. yAxis.boundaryGap = false;
  24. RemoveData();
  25. Scatter.AddDefaultSerie(this, GenerateDefaultSerieName());
  26. }
  27. /// <summary>
  28. /// default bubble chart.
  29. /// || 默认气泡图。
  30. /// </summary>
  31. public void DefaultBubbleChart()
  32. {
  33. CheckChartInit();
  34. var serie = GetSerie(0);
  35. serie.itemStyle.borderWidth = 2f;
  36. serie.itemStyle.borderColor = theme.GetColor(0);
  37. serie.itemStyle.opacity = 0.35f;
  38. serie.symbol.sizeType = SymbolSizeType.FromData;
  39. serie.symbol.dataScale = 0.3f;
  40. serie.symbol.maxSize = 30f;
  41. }
  42. }
  43. }