Ei kuvausta
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.

Example80_Polar.cs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using UnityEngine;
  2. using XCharts.Runtime;
  3. #if INPUT_SYSTEM_ENABLED
  4. using Input = XCharts.Runtime.InputHelper;
  5. #endif
  6. namespace XCharts.Example
  7. {
  8. [DisallowMultipleComponent]
  9. [ExecuteInEditMode]
  10. public class Example80_Polar : MonoBehaviour
  11. {
  12. private BaseChart chart;
  13. private float updateTime;
  14. void Awake()
  15. {
  16. chart = gameObject.GetComponent<BaseChart>();
  17. if (chart == null)
  18. {
  19. chart = gameObject.AddComponent<BaseChart>();
  20. }
  21. chart.GetOrAddChartComponent<PolarCoord>();
  22. }
  23. void Update()
  24. {
  25. if (Input.GetKeyDown(KeyCode.Space))
  26. {
  27. AddData();
  28. }
  29. }
  30. void AddData()
  31. {
  32. chart.RemoveData();
  33. chart.GetChartComponent<Tooltip>().type = Tooltip.Type.Corss;
  34. var angleAxis = chart.GetChartComponent<AngleAxis>();
  35. angleAxis.type = Axis.AxisType.Value;
  36. angleAxis.minMaxType = Axis.AxisMinMaxType.Custom;
  37. angleAxis.min = 0;
  38. angleAxis.max = 360;
  39. angleAxis.startAngle = Random.Range(0, 90);
  40. chart.AddSerie<Line>("line1");
  41. var rate = Random.Range(1, 4);
  42. for (int i = 0; i <= 360; i++)
  43. {
  44. var t = i / 180f * Mathf.PI;
  45. var r = Mathf.Sin(2 * t) * Mathf.Cos(2 * t) * rate;
  46. chart.AddData(0, Mathf.Abs(r), i);
  47. }
  48. }
  49. }
  50. }