mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 18:00:26 +00:00
3.0 - bar chart
This commit is contained in:
@@ -10,7 +10,7 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SerieAnimation), true)]
|
||||
[CustomPropertyDrawer(typeof(AnimationStyle), true)]
|
||||
public class AnimationDrawer : BasePropertyDrawer
|
||||
{
|
||||
public override string ClassName { get { return "Animation"; } }
|
||||
|
||||
@@ -111,8 +111,6 @@ namespace XCharts
|
||||
|
||||
protected void PropertyTwoFiled(string relativePropName)
|
||||
{
|
||||
//TODO:
|
||||
//PropertyField(relativePropName);
|
||||
var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f);
|
||||
var prop = FindProperty(relativePropName);
|
||||
ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName);
|
||||
|
||||
@@ -22,21 +22,29 @@ namespace XCharts
|
||||
PropertyField("m_XAxisIndex");
|
||||
PropertyField("m_YAxisIndex");
|
||||
}
|
||||
PropertyFieldLimitMin("m_MinShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxCache", 0);
|
||||
PropertyField("m_BarType");
|
||||
PropertyField("m_BarPercentStack");
|
||||
PropertyField("m_BarWidth");
|
||||
PropertyField("m_BarGap");
|
||||
PropertyField("m_BarZebraWidth");
|
||||
PropertyField("m_BarZebraGap");
|
||||
PropertyField("m_Clip");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_ShowAsPositiveNumber");
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
if (serie.barType == BarType.Zebra)
|
||||
{
|
||||
PropertyField("m_BarZebraWidth");
|
||||
PropertyField("m_BarZebraGap");
|
||||
}
|
||||
|
||||
PropertyFiledMore(() =>
|
||||
{
|
||||
PropertyFieldLimitMin("m_MinShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxCache", 0);
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_IgnoreLineBreak");
|
||||
PropertyField("m_ShowAsPositiveNumber");
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
PropertyField("m_Clip");
|
||||
});
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[SerieEditor(typeof(Line))]
|
||||
@@ -22,20 +24,23 @@ namespace XCharts
|
||||
PropertyField("m_XAxisIndex");
|
||||
PropertyField("m_YAxisIndex");
|
||||
}
|
||||
PropertyFieldLimitMin("m_MinShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxCache", 0);
|
||||
PropertyField("m_LineType");
|
||||
PropertyField("m_SampleDist");
|
||||
PropertyField("m_SampleType");
|
||||
PropertyField("m_SampleAverage");
|
||||
PropertyField("m_Clip");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_IgnoreLineBreak");
|
||||
PropertyField("m_ShowAsPositiveNumber");
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
PropertyFiledMore(() =>
|
||||
{
|
||||
PropertyFieldLimitMin("m_MinShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxShow", 0);
|
||||
PropertyFieldLimitMin("m_MaxCache", 0);
|
||||
PropertyField("m_SampleDist");
|
||||
PropertyField("m_SampleType");
|
||||
PropertyField("m_SampleAverage");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_IgnoreLineBreak");
|
||||
PropertyField("m_ShowAsPositiveNumber");
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
PropertyField("m_Clip");
|
||||
});
|
||||
PropertyField("m_Symbol");
|
||||
PropertyField("m_LineStyle");
|
||||
PropertyField("m_LineArrow");
|
||||
|
||||
@@ -16,11 +16,15 @@ namespace XCharts
|
||||
PropertyField("m_Space");
|
||||
PropertyTwoFiled("m_Center");
|
||||
PropertyTwoFiled("m_Radius");
|
||||
PropertyField("m_MinAngle");
|
||||
PropertyField("m_RoundCap");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_AvoidLabelOverlap");
|
||||
|
||||
PropertyFiledMore(() =>
|
||||
{
|
||||
PropertyField("m_MinAngle");
|
||||
PropertyField("m_RoundCap");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_AvoidLabelOverlap");
|
||||
});
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_IconStyle");
|
||||
|
||||
@@ -97,13 +97,14 @@ namespace XCharts
|
||||
return baseProperty.FindPropertyRelative(path);
|
||||
}
|
||||
|
||||
protected void PropertyField(string path)
|
||||
protected SerializedProperty PropertyField(string path)
|
||||
{
|
||||
Assert.IsNotNull(path);
|
||||
var property = FindProperty(path);
|
||||
Assert.IsNotNull(property, "Can't find:" + path);
|
||||
var title = ChartEditorHelper.GetContent(property.displayName);
|
||||
PropertyField(property, title);
|
||||
return property;
|
||||
}
|
||||
|
||||
protected void PropertyField(SerializedProperty property)
|
||||
@@ -126,18 +127,40 @@ namespace XCharts
|
||||
|
||||
protected void PropertyTwoFiled(string relativePropName)
|
||||
{
|
||||
//TODO:
|
||||
PropertyField(relativePropName);
|
||||
var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f);
|
||||
var prop = FindProperty(relativePropName);
|
||||
ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName);
|
||||
}
|
||||
protected void PropertyFieldLimitMin(string relativePropName, double value)
|
||||
protected void PropertyFieldLimitMin(string relativePropName, double min)
|
||||
{
|
||||
//TODO:
|
||||
PropertyField(relativePropName);
|
||||
var prop = PropertyField(relativePropName);
|
||||
switch (prop.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Float:
|
||||
if (prop.floatValue < min)
|
||||
prop.floatValue = (float)min;
|
||||
break;
|
||||
case SerializedPropertyType.Integer:
|
||||
if (prop.intValue < min)
|
||||
prop.intValue = (int)min;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
protected void PropertyFieldLimitMax(string relativePropName, double value)
|
||||
protected void PropertyFieldLimitMax(string relativePropName, int max)
|
||||
{
|
||||
//TODO:
|
||||
PropertyField(relativePropName);
|
||||
var prop = PropertyField(relativePropName);
|
||||
switch (prop.propertyType)
|
||||
{
|
||||
case SerializedPropertyType.Float:
|
||||
if (prop.floatValue > max)
|
||||
prop.floatValue = (float)max;
|
||||
break;
|
||||
case SerializedPropertyType.Integer:
|
||||
if (prop.intValue > max)
|
||||
prop.intValue = (int)max;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ namespace XCharts
|
||||
{
|
||||
public class SerieEditor<T> : SerieBaseEditor where T : Serie
|
||||
{
|
||||
protected const string MORE = "More";
|
||||
protected bool m_MoreFoldout = false;
|
||||
private bool m_DataFoldout = false;
|
||||
private bool m_DataComponentFoldout = true;
|
||||
private Dictionary<int, bool> m_DataElementFoldout = new Dictionary<int, bool>();
|
||||
@@ -90,6 +92,15 @@ namespace XCharts
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
protected void PropertyFiledMore(System.Action action)
|
||||
{
|
||||
m_MoreFoldout = ChartEditorHelper.DrawHeader(MORE, m_MoreFoldout, false, null, null);
|
||||
if (m_MoreFoldout)
|
||||
{
|
||||
if (action != null) action();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSerieData(int dimension, SerializedProperty m_Datas, int index, bool showName)
|
||||
{
|
||||
bool flag;
|
||||
|
||||
@@ -103,11 +103,11 @@ namespace XCharts
|
||||
{
|
||||
EditorGUI.LabelField(drawRect, name);
|
||||
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
|
||||
var diff = 14 + EditorGUI.indentLevel * 14;
|
||||
var diff = 13 + EditorGUI.indentLevel * 14;
|
||||
var offset = diff - INDENT_WIDTH;
|
||||
var tempWidth = (rectWidth - startX + diff) / 2;
|
||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
||||
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height);
|
||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
|
||||
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
|
||||
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
|
||||
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
Reference in New Issue
Block a user