mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 07:20:08 +00:00
重构LineChart和BarChart,移除Line和Bar组件,参数统一放到Serie中配置。
This commit is contained in:
@@ -9,13 +9,10 @@ namespace XCharts
|
||||
[CustomEditor(typeof(BarChart), false)]
|
||||
public class BarChartEditor : CoordinateChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Bar;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (BarChart)target;
|
||||
m_Bar = serializedObject.FindProperty("m_Bar");
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
@@ -25,7 +22,6 @@ namespace XCharts
|
||||
{
|
||||
return;
|
||||
}
|
||||
EditorGUILayout.PropertyField(m_Bar, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ namespace XCharts
|
||||
protected SerializedProperty m_MinShowDataNumber;
|
||||
protected SerializedProperty m_MaxShowDataNumber;
|
||||
protected SerializedProperty m_MaxCacheDataNumber;
|
||||
protected SerializedProperty m_LineSmoothStyle;
|
||||
|
||||
protected float m_DefaultLabelWidth;
|
||||
protected float m_DefaultFieldWidth;
|
||||
@@ -48,6 +49,7 @@ namespace XCharts
|
||||
m_MinShowDataNumber = serializedObject.FindProperty("m_MinShowDataNumber");
|
||||
m_MaxShowDataNumber = serializedObject.FindProperty("m_MaxShowDataNumber");
|
||||
m_MaxCacheDataNumber = serializedObject.FindProperty("m_MaxCacheDataNumber");
|
||||
m_LineSmoothStyle = serializedObject.FindProperty("m_LineSmoothStyle");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@@ -93,6 +95,7 @@ namespace XCharts
|
||||
EditorGUILayout.PropertyField(m_MinShowDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_MaxShowDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_MaxCacheDataNumber, true);
|
||||
EditorGUILayout.PropertyField(m_LineSmoothStyle,true);
|
||||
if (m_MinShowDataNumber.intValue < 0) m_MinShowDataNumber.intValue = 0;
|
||||
if (m_MaxShowDataNumber.intValue < 0) m_MaxShowDataNumber.intValue = 0;
|
||||
if (m_MaxCacheDataNumber.intValue < 0) m_MaxCacheDataNumber.intValue = 0;
|
||||
|
||||
@@ -9,19 +9,10 @@ namespace XCharts
|
||||
[CustomEditor(typeof(LineChart), false)]
|
||||
public class LineChartEditor : CoordinateChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Line;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (LineChart)target;
|
||||
m_Line = serializedObject.FindProperty("m_Line");
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_Line, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Bar), true)]
|
||||
public class BarDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty m_InSameBar;
|
||||
SerializedProperty m_BarWidth;
|
||||
SerializedProperty m_Space;
|
||||
bool m_BarModuleToggle = true;
|
||||
|
||||
private void InitProperty(SerializedProperty prop)
|
||||
{
|
||||
m_InSameBar = prop.FindPropertyRelative("m_InSameBar");
|
||||
m_BarWidth = prop.FindPropertyRelative("m_BarWidth");
|
||||
m_Space = prop.FindPropertyRelative("m_Space");
|
||||
}
|
||||
|
||||
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_BarModuleToggle, "Bar");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
if (m_BarModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_InSameBar);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BarWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Space);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_BarModuleToggle)
|
||||
return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
else
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a443d39bebe073645a240a745feb9fc5
|
||||
timeCreated: 1554768582
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,94 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Line), true)]
|
||||
public class LineDrawer : PropertyDrawer
|
||||
{
|
||||
SerializedProperty m_Tickness;
|
||||
SerializedProperty m_Smooth;
|
||||
SerializedProperty m_SmoothStyle;
|
||||
SerializedProperty m_Area;
|
||||
SerializedProperty m_Step;
|
||||
SerializedProperty m_StepType;
|
||||
|
||||
private bool m_LineModuleToggle = false;
|
||||
|
||||
private void InitProperty(SerializedProperty prop)
|
||||
{
|
||||
m_Tickness = prop.FindPropertyRelative("m_Tickness");
|
||||
m_Smooth = prop.FindPropertyRelative("m_Smooth");
|
||||
m_SmoothStyle = prop.FindPropertyRelative("m_SmoothStyle");
|
||||
m_Area = prop.FindPropertyRelative("m_Area");
|
||||
m_Step = prop.FindPropertyRelative("m_Step");
|
||||
m_StepType = prop.FindPropertyRelative("m_StepType");
|
||||
}
|
||||
|
||||
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_LineModuleToggle, "Line");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_LineModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Tickness);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
EditorGUI.PropertyField(drawRect, m_Smooth);
|
||||
if (m_Smooth.boolValue)
|
||||
{
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 15;
|
||||
EditorGUI.LabelField(drawRect, "Style");
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 65;
|
||||
float tempWidth = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 70;
|
||||
if (tempWidth < 20) tempWidth = 20;
|
||||
drawRect.width = tempWidth;
|
||||
EditorGUI.PropertyField(drawRect, m_SmoothStyle, GUIContent.none);
|
||||
drawRect.x = pos.x;
|
||||
drawRect.width = pos.width;
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||
EditorGUI.PropertyField(drawRect, m_Step);
|
||||
if (m_Step.boolValue)
|
||||
{
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 15;
|
||||
EditorGUI.LabelField(drawRect, "Type");
|
||||
drawRect.x = EditorGUIUtility.labelWidth + 65;
|
||||
float tempWidth = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 70;
|
||||
if (tempWidth < 20) tempWidth = 20;
|
||||
drawRect.width = tempWidth;
|
||||
EditorGUI.PropertyField(drawRect, m_StepType, GUIContent.none);
|
||||
drawRect.x = pos.x;
|
||||
drawRect.width = pos.width;
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_Area);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (m_LineModuleToggle)
|
||||
{
|
||||
height = 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return height;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0eeb8c12e86239b4e93a6c75d766cb15
|
||||
timeCreated: 1554720052
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -24,6 +24,10 @@ namespace XCharts
|
||||
SerializedProperty m_AxisIndex = prop.FindPropertyRelative("m_AxisIndex");
|
||||
SerializedProperty m_RadarIndex = prop.FindPropertyRelative("m_RadarIndex");
|
||||
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||
SerializedProperty m_LineType = prop.FindPropertyRelative("m_LineType");
|
||||
SerializedProperty m_BarWidth = prop.FindPropertyRelative("m_BarWidth");
|
||||
SerializedProperty m_BarGap = prop.FindPropertyRelative("m_BarGap");
|
||||
SerializedProperty m_BarCategoryGap = prop.FindPropertyRelative("m_BarCategoryGap");
|
||||
SerializedProperty m_AreaStyle = prop.FindPropertyRelative("m_AreaStyle");
|
||||
SerializedProperty m_Symbol = prop.FindPropertyRelative("m_Symbol");
|
||||
SerializedProperty m_RoseType = prop.FindPropertyRelative("m_RoseType");
|
||||
@@ -71,6 +75,11 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_AxisIndex);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Line)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_LineType);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Line
|
||||
|| serieType == SerieType.Scatter
|
||||
|| serieType == SerieType.EffectScatter
|
||||
@@ -79,6 +88,13 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
}
|
||||
if (serieType == SerieType.Bar)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_BarWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BarGap);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Pie)
|
||||
{
|
||||
EditorGUI.PropertyField(drawRect, m_RoseType);
|
||||
@@ -112,6 +128,7 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_ClickOffset);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||
EditorGUI.PropertyField(drawRect, m_AreaStyle);
|
||||
@@ -276,6 +293,14 @@ namespace XCharts
|
||||
{
|
||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Line)
|
||||
{
|
||||
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (serieType == SerieType.Bar)
|
||||
{
|
||||
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
if (m_DataFoldout[index])
|
||||
{
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
|
||||
Reference in New Issue
Block a user