mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 22:10:11 +00:00
增加PolarChart的clockwise是否顺时针支持
This commit is contained in:
@@ -16,11 +16,11 @@ namespace XCharts
|
||||
protected override void DrawExtended(ref Rect drawRect, SerializedProperty prop)
|
||||
{
|
||||
SerializedProperty m_StartAngle = prop.FindPropertyRelative("m_StartAngle");
|
||||
//SerializedProperty m_Clockwise = prop.FindPropertyRelative("m_Clockwise");
|
||||
SerializedProperty m_Clockwise = prop.FindPropertyRelative("m_Clockwise");
|
||||
EditorGUI.PropertyField(drawRect, m_StartAngle);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
//EditorGUI.PropertyField(drawRect, m_Clockwise);
|
||||
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Clockwise);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
protected override string GetDisplayName(string displayName)
|
||||
@@ -34,7 +34,7 @@ namespace XCharts
|
||||
|
||||
protected override float GetExtendedHeight()
|
||||
{
|
||||
return 1 * EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
return 2 * EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,7 @@ namespace XCharts
|
||||
[SerializeField] protected bool m_LogBaseE = false;
|
||||
[SerializeField] protected int m_CeilRate = 0;
|
||||
[SerializeField] protected bool m_Inverse = false;
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
||||
@@ -206,6 +207,15 @@ namespace XCharts
|
||||
set { if (m_Type == AxisType.Value && PropertyUtility.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the positive position of axis is in clockwise. True for clockwise by default.
|
||||
/// 刻度增长是否按顺时针,默认顺时针。
|
||||
/// </summary>
|
||||
public bool clockwise
|
||||
{
|
||||
get { return m_Clockwise; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Category data, available in type: 'Category' axis.
|
||||
/// 类目数据,在类目轴(type: 'category')中有效。
|
||||
/// </summary>
|
||||
@@ -843,7 +853,7 @@ namespace XCharts
|
||||
public class AngleAxis : Axis
|
||||
{
|
||||
[SerializeField] private float m_StartAngle = 90;
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
|
||||
/// <summary>
|
||||
/// Starting angle of axis. 90 degrees by default, standing for top position of center. 0 degree stands for right position of center.
|
||||
/// 起始刻度的角度,默认为 90 度,即圆心的正上方。0 度为圆心的正右方。
|
||||
@@ -853,16 +863,7 @@ namespace XCharts
|
||||
get { return m_StartAngle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the positive position of axis is in clockwise. True for clockwise by default.
|
||||
/// 刻度增长是否按顺时针,默认顺时针。
|
||||
/// </summary>
|
||||
public bool clockWise
|
||||
{
|
||||
get { return m_Clockwise; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
|
||||
public float runtimeStartAngle { get; set; }
|
||||
|
||||
public static AngleAxis defaultAngleAxis
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
value = (minValue + (maxValue - minValue) * index / (split - 1));
|
||||
if (!axis.clockwise && value != minValue) value = maxValue - value;
|
||||
}
|
||||
if (axis.inverse)
|
||||
{
|
||||
|
||||
@@ -181,13 +181,14 @@ namespace XCharts
|
||||
tooltip.UpdateContentPos(pos);
|
||||
}
|
||||
|
||||
public static string GetPolarFormatterContent(Tooltip tooltip, Series series, ThemeInfo themeInfo)
|
||||
public static string GetPolarFormatterContent(Tooltip tooltip, Series series, ThemeInfo themeInfo, AngleAxis angleAxis)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tooltip.formatter))
|
||||
{
|
||||
var sb = ChartHelper.sb;
|
||||
sb.Length = 0;
|
||||
sb.Append(tooltip.runtimeAngle).Append("\n");
|
||||
var angle = angleAxis.clockwise ? tooltip.runtimeAngle : 360 - tooltip.runtimeAngle;
|
||||
sb.Append(angle).Append("\n");
|
||||
foreach (var serie in series.list)
|
||||
{
|
||||
if (serie.show && IsSelectedSerie(tooltip, serie.index))
|
||||
|
||||
@@ -486,10 +486,19 @@ namespace XCharts
|
||||
|
||||
private Vector3 GetPolarPos(SerieData serieData, float min, float max, float polarRadius)
|
||||
{
|
||||
var angle = m_AngleAxis.runtimeStartAngle + serieData.GetData(1);
|
||||
var angle = 0f;
|
||||
if (!m_AngleAxis.clockwise)
|
||||
{
|
||||
angle = m_AngleAxis.runtimeStartAngle - serieData.GetData(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = m_AngleAxis.runtimeStartAngle + serieData.GetData(1);
|
||||
}
|
||||
angle = (angle + 360) % 360;
|
||||
var value = serieData.GetData(0);
|
||||
var radius = (value - min) / (max - min) * polarRadius;
|
||||
serieData.runtimeAngle = (angle + 360) % 360;
|
||||
serieData.runtimeAngle = angle;
|
||||
serieData.runtimePosition = ChartHelper.GetPos(m_Polar.runtimeCenterPos, radius, angle, true);
|
||||
return serieData.runtimePosition;
|
||||
}
|
||||
@@ -583,7 +592,7 @@ namespace XCharts
|
||||
var showTooltip = m_Tooltip.isAnySerieDataIndex();
|
||||
if (showTooltip)
|
||||
{
|
||||
var content = TooltipHelper.GetPolarFormatterContent(m_Tooltip, m_Series, m_ThemeInfo);
|
||||
var content = TooltipHelper.GetPolarFormatterContent(m_Tooltip, m_Series, m_ThemeInfo, m_AngleAxis);
|
||||
TooltipHelper.SetContentAndPosition(tooltip, content, chartRect);
|
||||
}
|
||||
m_Tooltip.SetActive(showTooltip);
|
||||
|
||||
Reference in New Issue
Block a user