mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 18:30:14 +00:00
移除Pie组件,相关参数放到Settings中配置
This commit is contained in:
@@ -15,13 +15,11 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
base.OnEnable();
|
base.OnEnable();
|
||||||
m_Target = (PieChart)target;
|
m_Target = (PieChart)target;
|
||||||
m_Pie = serializedObject.FindProperty("m_Pie");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEndInspectorGUI()
|
protected override void OnEndInspectorGUI()
|
||||||
{
|
{
|
||||||
base.OnEndInspectorGUI();
|
base.OnEndInspectorGUI();
|
||||||
EditorGUILayout.PropertyField(m_Pie, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace XCharts
|
|
||||||
{
|
|
||||||
[CustomPropertyDrawer(typeof(Pie), true)]
|
|
||||||
public class PieInfoDrawer : PropertyDrawer
|
|
||||||
{
|
|
||||||
SerializedProperty m_Name;
|
|
||||||
SerializedProperty m_InsideRadius;
|
|
||||||
SerializedProperty m_OutsideRadius;
|
|
||||||
SerializedProperty m_TooltipExtraRadius;
|
|
||||||
SerializedProperty m_Rose;
|
|
||||||
SerializedProperty m_Space;
|
|
||||||
SerializedProperty m_Left;
|
|
||||||
SerializedProperty m_Right;
|
|
||||||
SerializedProperty m_Top;
|
|
||||||
SerializedProperty m_Bottom;
|
|
||||||
SerializedProperty m_Selected;
|
|
||||||
SerializedProperty m_SelectedIndex;
|
|
||||||
SerializedProperty m_SelectedOffset;
|
|
||||||
bool m_PieModuleToggle = true;
|
|
||||||
|
|
||||||
private void InitProperty(SerializedProperty prop)
|
|
||||||
{
|
|
||||||
m_TooltipExtraRadius = prop.FindPropertyRelative("m_TooltipExtraRadius");
|
|
||||||
m_SelectedOffset = prop.FindPropertyRelative("m_SelectedOffset");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
||||||
{
|
|
||||||
InitProperty(prop);
|
|
||||||
Rect drawRect = pos;
|
|
||||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_PieModuleToggle, "Pie");
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
if (m_PieModuleToggle)
|
|
||||||
{
|
|
||||||
++EditorGUI.indentLevel;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_TooltipExtraRadius);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_SelectedOffset);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
|
|
||||||
--EditorGUI.indentLevel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
||||||
{
|
|
||||||
if (m_PieModuleToggle)
|
|
||||||
return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
else
|
|
||||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 019eadbd43e952945925f357ae8ef74b
|
|
||||||
timeCreated: 1554773154
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -18,6 +18,8 @@ namespace XCharts
|
|||||||
SerializedProperty m_LineSegmentDistance = prop.FindPropertyRelative("m_LineSegmentDistance");
|
SerializedProperty m_LineSegmentDistance = prop.FindPropertyRelative("m_LineSegmentDistance");
|
||||||
SerializedProperty m_CicleSmoothness = prop.FindPropertyRelative("m_CicleSmoothness");
|
SerializedProperty m_CicleSmoothness = prop.FindPropertyRelative("m_CicleSmoothness");
|
||||||
SerializedProperty m_VisualMapTriangeLen = prop.FindPropertyRelative("m_VisualMapTriangeLen");
|
SerializedProperty m_VisualMapTriangeLen = prop.FindPropertyRelative("m_VisualMapTriangeLen");
|
||||||
|
SerializedProperty m_PieTooltipExtraRadius = prop.FindPropertyRelative("m_PieTooltipExtraRadius");
|
||||||
|
SerializedProperty m_PieSelectedOffset = prop.FindPropertyRelative("m_PieSelectedOffset");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SettingsModuleToggle, "Settings");
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SettingsModuleToggle, "Settings");
|
||||||
EditorGUI.LabelField(drawRect, "Settings", EditorStyles.boldLabel);
|
EditorGUI.LabelField(drawRect, "Settings", EditorStyles.boldLabel);
|
||||||
@@ -35,6 +37,10 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_VisualMapTriangeLen);
|
EditorGUI.PropertyField(drawRect, m_VisualMapTriangeLen);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_PieTooltipExtraRadius);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_PieSelectedOffset);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,7 +50,7 @@ namespace XCharts
|
|||||||
int num = 1;
|
int num = 1;
|
||||||
if (m_SettingsModuleToggle)
|
if (m_SettingsModuleToggle)
|
||||||
{
|
{
|
||||||
num = 6;
|
num = 8;
|
||||||
}
|
}
|
||||||
return num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
return num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace XCharts
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// the global setting of pie chart.
|
|
||||||
/// 饼图的全局设置。
|
|
||||||
/// </summary>
|
|
||||||
[System.Serializable]
|
|
||||||
public class Pie : MainComponent
|
|
||||||
{
|
|
||||||
[SerializeField] private float m_TooltipExtraRadius;
|
|
||||||
[SerializeField] private float m_SelectedOffset;
|
|
||||||
/// <summary>
|
|
||||||
/// the extra dadius of pie chart when the tooltip indicatored pie.
|
|
||||||
/// 提示框指示时的额外半径。
|
|
||||||
/// </summary>
|
|
||||||
public float tooltipExtraRadius { get { return m_TooltipExtraRadius; } set { m_TooltipExtraRadius = value; } }
|
|
||||||
/// <summary>
|
|
||||||
/// the offset of pie when the pie item is selected.
|
|
||||||
/// 饼图项被选中时的偏移。
|
|
||||||
/// </summary>
|
|
||||||
public float selectedOffset { get { return m_SelectedOffset; } set { m_SelectedOffset = value; } }
|
|
||||||
|
|
||||||
public static Pie defaultPie
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var pie = new Pie
|
|
||||||
{
|
|
||||||
m_TooltipExtraRadius = 10f,
|
|
||||||
m_SelectedOffset = 10f,
|
|
||||||
};
|
|
||||||
return pie;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ca364d90ce5fe4605a382e9af984757f
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -15,6 +15,8 @@ namespace XCharts
|
|||||||
[SerializeField] [Range(1f, 20)] protected float m_LineSegmentDistance = 3f;
|
[SerializeField] [Range(1f, 20)] protected float m_LineSegmentDistance = 3f;
|
||||||
[SerializeField] [Range(1, 10)] protected float m_CicleSmoothness = 2f;
|
[SerializeField] [Range(1, 10)] protected float m_CicleSmoothness = 2f;
|
||||||
[SerializeField] [Range(10, 50)] protected float m_VisualMapTriangeLen = 20f;
|
[SerializeField] [Range(10, 50)] protected float m_VisualMapTriangeLen = 20f;
|
||||||
|
[SerializeField] [Range(1, 20)] protected float m_PieTooltipExtraRadius = 8f;
|
||||||
|
[SerializeField] [Range(1, 20)] protected float m_PieSelectedOffset = 8f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Curve smoothing factor. By adjusting the smoothing coefficient, the curvature of the curve can be changed,
|
/// Curve smoothing factor. By adjusting the smoothing coefficient, the curvature of the curve can be changed,
|
||||||
@@ -47,6 +49,14 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public float visualMapTriangeLen { get { return m_VisualMapTriangeLen; } set { m_VisualMapTriangeLen = value <= 0 ? 1f : value; } }
|
public float visualMapTriangeLen { get { return m_VisualMapTriangeLen; } set { m_VisualMapTriangeLen = value <= 0 ? 1f : value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 饼图鼠标移到高亮时的额外半径
|
||||||
|
/// </summary>
|
||||||
|
public float pieTooltipExtraRadius { get { return m_PieTooltipExtraRadius; } set { m_PieTooltipExtraRadius = value <= 0 ? 0 : value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 饼图选中时的中心点偏移
|
||||||
|
/// </summary>
|
||||||
|
public float pieSelectedOffset { get { return m_PieSelectedOffset; } set { m_PieSelectedOffset = value <= 0 ? 0 : value; } }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,14 +12,10 @@ namespace XCharts
|
|||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
public class PieChart : BaseChart
|
public class PieChart : BaseChart
|
||||||
{
|
{
|
||||||
[SerializeField] private Pie m_Pie = Pie.defaultPie;
|
|
||||||
|
|
||||||
private bool isDrawPie;
|
private bool isDrawPie;
|
||||||
private bool m_IsEnterLegendButtom;
|
private bool m_IsEnterLegendButtom;
|
||||||
private bool m_RefreshLabel;
|
private bool m_RefreshLabel;
|
||||||
|
|
||||||
public Pie pie { get { return m_Pie; } }
|
|
||||||
|
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
@@ -30,7 +26,6 @@ namespace XCharts
|
|||||||
protected override void Reset()
|
protected override void Reset()
|
||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
m_Pie = Pie.defaultPie;
|
|
||||||
m_Title.text = "PieChart";
|
m_Title.text = "PieChart";
|
||||||
RemoveData();
|
RemoveData();
|
||||||
AddSerie(SerieType.Pie, "serie1");
|
AddSerie(SerieType.Pie, "serie1");
|
||||||
@@ -103,12 +98,12 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
isDataHighlight = true;
|
isDataHighlight = true;
|
||||||
color *= 1.2f;
|
color *= 1.2f;
|
||||||
serieData.pieOutsideRadius += m_Pie.tooltipExtraRadius;
|
serieData.pieOutsideRadius += m_Settings.pieTooltipExtraRadius;
|
||||||
}
|
}
|
||||||
var offset = serie.pieSpace;
|
var offset = serie.pieSpace;
|
||||||
if (serie.pieClickOffset && serieData.selected)
|
if (serie.pieClickOffset && serieData.selected)
|
||||||
{
|
{
|
||||||
offset += m_Pie.selectedOffset;
|
offset += m_Settings.pieSelectedOffset;
|
||||||
}
|
}
|
||||||
var halfDegree = (serieData.pieToAngle - startDegree) / 2;
|
var halfDegree = (serieData.pieToAngle - startDegree) / 2;
|
||||||
serieData.pieHalfAngle = startDegree + halfDegree;
|
serieData.pieHalfAngle = startDegree + halfDegree;
|
||||||
@@ -132,9 +127,9 @@ namespace XCharts
|
|||||||
serieData.pieOutsideRadius -= serieData.pieOffsetRadius;
|
serieData.pieOutsideRadius -= serieData.pieOffsetRadius;
|
||||||
if (serie.pieClickOffset && serieData.selected)
|
if (serie.pieClickOffset && serieData.selected)
|
||||||
{
|
{
|
||||||
serieData.pieOffsetRadius += m_Pie.selectedOffset;
|
serieData.pieOffsetRadius += m_Settings.pieSelectedOffset;
|
||||||
if (serieData.pieInsideRadius > 0) serieData.pieInsideRadius += m_Pie.selectedOffset;
|
if (serieData.pieInsideRadius > 0) serieData.pieInsideRadius += m_Settings.pieSelectedOffset;
|
||||||
serieData.pieOutsideRadius += m_Pie.selectedOffset;
|
serieData.pieOutsideRadius += m_Settings.pieSelectedOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
serieData.pieOffsetCenter = new Vector3(center.x + serieData.pieOffsetRadius * currSin,
|
serieData.pieOffsetCenter = new Vector3(center.x + serieData.pieOffsetRadius * currSin,
|
||||||
|
|||||||
Reference in New Issue
Block a user