mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 07:20:08 +00:00
3.0 - polar chart
This commit is contained in:
37
Runtime/Chart/PolarChart.cs
Normal file
37
Runtime/Chart/PolarChart.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[AddComponentMenu("XCharts/PolarChart", 23)]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[DisallowMultipleComponent]
|
||||
public class PolarChart : BaseChart
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
AddChartComponentWhenNoExist<PolarCoord>();
|
||||
|
||||
var tooltip = GetChartComponent<Tooltip>();
|
||||
tooltip.type = Tooltip.Type.Corss;
|
||||
tooltip.trigger = Tooltip.Trigger.Axis;
|
||||
|
||||
RemoveData();
|
||||
var serie = Line.AddDefaultSerie(this, GenerateDefaultSerieName());
|
||||
serie.SetCoord<PolarCoord>();
|
||||
serie.ClearData();
|
||||
for (int i = 0; i <= 360; i++)
|
||||
{
|
||||
var t = i / 180f * Mathf.PI;
|
||||
var r = Mathf.Sin(2 * t) * Mathf.Cos(2 * t) * 2;
|
||||
AddData(0, Mathf.Abs(r), i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user