Compare commits

..

10 Commits

Author SHA1 Message Date
monitor1394
220b829279 v2.0.1 2021-02-26 01:03:47 +08:00
monitor1394
c507771cff 修复HeatmapChartTooltip指示的位置不准的问题 #123 2021-02-26 00:54:43 +08:00
monitor1394
09daa2f027 修复Unity版本兼容问题 2021-02-22 11:02:54 +08:00
monitor1394
4ea5168e9a 修复Unity版本兼容问题 2021-02-21 22:15:07 +08:00
monitor1394
2fdd554751 update doc 2021-02-21 03:43:32 +08:00
monitor1394
b96e1dcf4d 增加TooltipignoreDataShow参数 2021-02-21 02:42:45 +08:00
monitor1394
80b000ed32 修复创建图表时的空报错 2021-02-21 02:26:36 +08:00
monitor1394
f0c553b0b7 修复图表在LayoutGroup控制下时可能显示错乱的问题 #121 2021-02-19 22:01:56 +08:00
monitor1394
f7b8f2f76f Fixed an issue where the Radar could not refresh itself after parameter changing 2021-02-18 09:47:03 +08:00
monitor1394
04efcf3959 Fixed an issue where the Radar could not refresh itself after parameter changing #122 2021-02-18 09:24:01 +08:00
41 changed files with 512 additions and 679 deletions

View File

@@ -2,6 +2,7 @@
# 更新日志 # 更新日志
[Latest](#Latest) [Latest](#Latest)
[v2.0.1](#v2.0.1)
[v2.0.0](#v2.0.0) [v2.0.0](#v2.0.0)
[v2.0.0-preview.2](#v2.0.0-preview.2) [v2.0.0-preview.2](#v2.0.0-preview.2)
[v2.0.0-preview.1](#v2.0.0-preview.1) [v2.0.0-preview.1](#v2.0.0-preview.1)
@@ -31,6 +32,14 @@
## Latest ## Latest
## v2.0.1
* (2021.02.26) Fixed incorrect position of `Tooltip` in `HeatmapChart` #123
* (2021.02.22) Fixed compatibility issues with `Unity` version
* (2021.02.21) Added `Tooltip` parameter `ignoreDataShow`
* (2021.02.19) Fixed an issue where charts could appear abnormal when under `LayoutGroup` control #121
* (2021.02.18) Fixed an issue where the `Radar` could not refresh itself after parameter changing #122
## v2.0.0 ## v2.0.0
* (2021.02.05) Release `v2.0.0` version * (2021.02.05) Release `v2.0.0` version
@@ -44,7 +53,7 @@
* (2021.01.21) Release `v2.0.0-preview.2` version * (2021.01.21) Release `v2.0.0-preview.2` version
* (2021.01.21) Fixed an error about `AxisTick` in `Inpsector` * (2021.01.21) Fixed an error about `AxisTick` in `Inpsector`
* (2021.01.21) Fixed a build compatibility error * (2021.01.21) Fixed a build compatibility error
* (2021.01.19) Add `XChartsSettings` `editorShowAllListData` parameter to configure whether to display all the list's data in Inspector * (2021.01.19) Added `XChartsSettings` `editorShowAllListData` parameter to configure whether to display all the list's data in Inspector
## v2.0.0-preview.1 ## v2.0.0-preview.1

View File

@@ -2,6 +2,7 @@
# 更新日志 # 更新日志
[Latest](#Latest) [Latest](#Latest)
[v2.0.1](#v2.0.1)
[v2.0.0](#v2.0.0) [v2.0.0](#v2.0.0)
[v2.0.0-preview.2](#v2.0.0-preview.2) [v2.0.0-preview.2](#v2.0.0-preview.2)
[v2.0.0-preview.1](#v2.0.0-preview.1) [v2.0.0-preview.1](#v2.0.0-preview.1)
@@ -31,7 +32,15 @@
## Latest ## Latest
## 2.0.0 ## v2.0.1
* (2021.02.26) 修复`HeatmapChart``Tooltip`指示的位置不准的问题 #123
* (2021.02.22) 修复`Unity`版本兼容问题
* (2021.02.21) 增加`Tooltip``ignoreDataShow`参数
* (2021.02.19) 修复图表在`LayoutGroup`控制下时可能显示错乱的问题 #121
* (2021.02.18) 修复`Radar`参数变更后无法自刷新的问题 #122
## v2.0.0
* (2021.02.05) 发布`v2.0.0`版本 * (2021.02.05) 发布`v2.0.0`版本
* (2021.02.03) 修复`AxisLine``OnZero``YAxis`不生效的问题 #116 * (2021.02.03) 修复`AxisLine``OnZero``YAxis`不生效的问题 #116

View File

@@ -231,7 +231,8 @@
* `paddingLeftRight`:文字和边框的左右边距。 * `paddingLeftRight`:文字和边框的左右边距。
* `paddingTopBottom`:文字和边框的上下边距。 * `paddingTopBottom`:文字和边框的上下边距。
* `backgroundImage`:提示框的背景图。 * `backgroundImage`:提示框的背景图。
* `ignoreDataDefaultContent`:被忽略数据的默认显示字符信息 * `ignoreDataShow``(since v2.0.1)`是否显示忽略数据在`tooltip`上。 [defaut: `false`]
* `ignoreDataDefaultContent`:忽略数据的默认显示字符信息。
* `alwayShow`:是否触发后一直显示。 * `alwayShow`:是否触发后一直显示。
* `offset``(since v1.5.3)`提示框相对于鼠标位置的偏移。 * `offset``(since v1.5.3)`提示框相对于鼠标位置的偏移。

View File

@@ -235,6 +235,7 @@ Tooltip component.
* `paddingLeftRight`: the text padding of left and right. [defaut: `5f`]. * `paddingLeftRight`: the text padding of left and right. [defaut: `5f`].
* `paddingTopBottom`: the text padding of top and bottom. [defaut: `5f`]. * `paddingTopBottom`: the text padding of top and bottom. [defaut: `5f`].
* `backgroundImage`: The image of icon. * `backgroundImage`: The image of icon.
* `ignoreDataShow`: Whether to show ignored data on tooltip. [defaut: `false`].
* `ignoreDataDefaultContent`: The default display character information for ignored data. * `ignoreDataDefaultContent`: The default display character information for ignored data.
* `alwayShow`: Whether to trigger after always display. * `alwayShow`: Whether to trigger after always display.
* `offset`: `(since v1.5.3)`The position offset of tooltip relative to the mouse position. * `offset`: `(since v1.5.3)`The position offset of tooltip relative to the mouse position.

View File

@@ -18,10 +18,17 @@ namespace XCharts
[CustomEditor(typeof(BaseChart), false)] [CustomEditor(typeof(BaseChart), false)]
public class BaseChartEditor : Editor public class BaseChartEditor : Editor
{ {
#if UNITY_2019_3_OR_NEWER
private const float k_IconWidth = 14; private const float k_IconWidth = 14;
private const float k_IconGap = 0f; private const float k_IconGap = 0f;
private const float k_IconXOffset = 10f; private const float k_IconXOffset = 7f;
private const float k_IconYOffset = -5f; private const float k_IconYOffset = -1f;
#else
private const float k_IconWidth = 14;
private const float k_IconGap = 0f;
private const float k_IconXOffset = 4f;
private const float k_IconYOffset = -3f;
#endif
protected BaseChart m_Chart; protected BaseChart m_Chart;
protected SerializedProperty m_Script; protected SerializedProperty m_Script;
@@ -197,12 +204,13 @@ namespace XCharts
for (int i = 0; i < prop.arraySize; i++) for (int i = 0; i < prop.arraySize; i++)
{ {
EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(i), true); EditorGUILayout.PropertyField(prop.GetArrayElementAtIndex(i), true);
EditorGUILayout.Space(-EditorGUIUtility.singleLineHeight - EditorGUIUtility.standardVerticalSpacing); var currRect = EditorGUILayout.GetControlRect(GUILayout.Height(0));
var currRect = EditorGUILayout.GetControlRect(); currRect.y -= EditorGUI.GetPropertyHeight(prop.GetArrayElementAtIndex(i));
var rect1 = new Rect(currRect.width + k_IconXOffset, var rect1 = new Rect(currRect.width + k_IconXOffset,
currRect.y + k_IconYOffset, currRect.y + k_IconYOffset,
k_IconWidth, EditorGUIUtility.singleLineHeight); k_IconWidth, EditorGUIUtility.singleLineHeight);
var oldColor = GUI.contentColor;
GUI.contentColor = Color.black;
if (GUI.Button(rect1, ChartEditorHelper.Styles.iconRemove, ChartEditorHelper.Styles.invisibleButton)) if (GUI.Button(rect1, ChartEditorHelper.Styles.iconRemove, ChartEditorHelper.Styles.invisibleButton))
{ {
if (i < prop.arraySize && i >= 0) prop.DeleteArrayElementAtIndex(i); if (i < prop.arraySize && i >= 0) prop.DeleteArrayElementAtIndex(i);
@@ -221,7 +229,7 @@ namespace XCharts
{ {
if (i > 0) prop.MoveArrayElement(i, i - 1); if (i > 0) prop.MoveArrayElement(i, i - 1);
} }
GUI.contentColor = oldColor;
} }
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }

View File

@@ -22,7 +22,6 @@ namespace XCharts
{ {
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type"); SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
SerializedProperty m_LogBase = prop.FindPropertyRelative("m_LogBase"); SerializedProperty m_LogBase = prop.FindPropertyRelative("m_LogBase");
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType"); SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex; Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
var chart = prop.serializedObject.targetObject as BaseChart; var chart = prop.serializedObject.targetObject as BaseChart;

View File

@@ -86,6 +86,12 @@ namespace XCharts
m_DrawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; m_DrawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
protected void AddHeight(float height)
{
m_Heights[m_KeyName] += height;
m_DrawRect.y += height;
}
protected void PropertyListField(SerializedProperty prop, string relativePropName, bool showOrder = true) protected void PropertyListField(SerializedProperty prop, string relativePropName, bool showOrder = true)
{ {
if (IngorePropertys.Contains(relativePropName)) return; if (IngorePropertys.Contains(relativePropName)) return;
@@ -106,6 +112,25 @@ namespace XCharts
} }
} }
protected void PropertyFieldLimitMin(SerializedProperty prop, string relativePropName, float minValue)
{
if (IngorePropertys.Contains(relativePropName)) return;
if (!ChartEditorHelper.PropertyFieldWithMinValue(ref m_DrawRect, m_Heights, m_KeyName, prop,
relativePropName, minValue))
{
Debug.LogError("PropertyField ERROR:" + prop.displayName + ", " + relativePropName);
}
}
protected void PropertyFieldLimitMax(SerializedProperty prop, string relativePropName, float maxValue)
{
if (IngorePropertys.Contains(relativePropName)) return;
if (!ChartEditorHelper.PropertyFieldWithMaxValue(ref m_DrawRect, m_Heights, m_KeyName, prop,
relativePropName, maxValue))
{
Debug.LogError("PropertyField ERROR:" + prop.displayName + ", " + relativePropName);
}
}
protected void PropertyField(SerializedProperty prop, SerializedProperty relativeProp) protected void PropertyField(SerializedProperty prop, SerializedProperty relativeProp)
{ {
if (!ChartEditorHelper.PropertyField(ref m_DrawRect, m_Heights, m_KeyName, relativeProp)) if (!ChartEditorHelper.PropertyField(ref m_DrawRect, m_Heights, m_KeyName, relativeProp))
@@ -118,7 +143,8 @@ namespace XCharts
{ {
PropertyTwoFiled(prop, prop.FindPropertyRelative(relativeListProp), labelName); PropertyTwoFiled(prop, prop.FindPropertyRelative(relativeListProp), labelName);
} }
protected void PropertyTwoFiled(SerializedProperty prop, SerializedProperty relativeListProp, string labelName = null) protected void PropertyTwoFiled(SerializedProperty prop, SerializedProperty relativeListProp,
string labelName = null)
{ {
if (string.IsNullOrEmpty(labelName)) if (string.IsNullOrEmpty(labelName))
{ {
@@ -132,12 +158,14 @@ namespace XCharts
{ {
if (string.IsNullOrEmpty(relativePropName)) if (string.IsNullOrEmpty(relativePropName))
{ {
return ChartEditorHelper.MakeFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName, m_DisplayName, null); return ChartEditorHelper.MakeFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName,
m_DisplayName, null);
} }
else else
{ {
var relativeProp = prop.FindPropertyRelative(relativePropName); var relativeProp = prop.FindPropertyRelative(relativePropName);
return ChartEditorHelper.MakeFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName, m_DisplayName, relativeProp); return ChartEditorHelper.MakeFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName,
m_DisplayName, relativeProp);
} }
} }

View File

@@ -12,94 +12,24 @@ using UnityEngine;
namespace XCharts namespace XCharts
{ {
[CustomPropertyDrawer(typeof(Serie), true)] [CustomPropertyDrawer(typeof(Serie), true)]
public class SerieDrawer : PropertyDrawer public class SerieDrawer : BasePropertyDrawer
{ {
private Dictionary<string, bool> m_SerieModuleToggle = new Dictionary<string, bool>();
private List<bool> m_DataFoldout = new List<bool>();
private bool m_ShowJsonDataArea = false;
private string m_JsonDataAreaText;
private bool m_IsPolar = false; private bool m_IsPolar = false;
private List<bool> m_DataFoldout = new List<bool>();
public override string ClassName { get { return "Serie"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{ {
Rect drawRect = pos; pos.width -= 9;
drawRect.height = EditorGUIUtility.singleLineHeight; base.OnGUI(pos, prop, label);
SerializedProperty show = prop.FindPropertyRelative("m_Show"); var type = prop.FindPropertyRelative("m_Type");
SerializedProperty type = prop.FindPropertyRelative("m_Type"); if (!MakeFoldout(prop, "m_Show"))
SerializedProperty name = prop.FindPropertyRelative("m_Name");
SerializedProperty stack = prop.FindPropertyRelative("m_Stack");
SerializedProperty m_AxisIndex = prop.FindPropertyRelative("m_AxisIndex");
SerializedProperty m_XAxisIndex = prop.FindPropertyRelative("m_XAxisIndex");
SerializedProperty m_YAxisIndex = prop.FindPropertyRelative("m_YAxisIndex");
SerializedProperty m_RadarType = prop.FindPropertyRelative("m_RadarType");
SerializedProperty m_RadarIndex = prop.FindPropertyRelative("m_RadarIndex");
SerializedProperty m_VesselIndex = prop.FindPropertyRelative("m_VesselIndex");
SerializedProperty m_PolarIndex = prop.FindPropertyRelative("m_PolarIndex");
SerializedProperty m_MinShow = prop.FindPropertyRelative("m_MinShow");
SerializedProperty m_MaxShow = prop.FindPropertyRelative("m_MaxShow");
SerializedProperty m_MaxCache = prop.FindPropertyRelative("m_MaxCache");
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
SerializedProperty m_ItemStyle = prop.FindPropertyRelative("m_ItemStyle");
SerializedProperty m_LineArrow = prop.FindPropertyRelative("m_LineArrow");
SerializedProperty m_LineType = prop.FindPropertyRelative("m_LineType");
SerializedProperty m_SampleDist = prop.FindPropertyRelative("m_SampleDist");
SerializedProperty m_SampleType = prop.FindPropertyRelative("m_SampleType");
SerializedProperty m_SampleAverage = prop.FindPropertyRelative("m_SampleAverage");
SerializedProperty m_BarType = prop.FindPropertyRelative("m_BarType");
SerializedProperty m_BarPercentStack = prop.FindPropertyRelative("m_BarPercentStack");
SerializedProperty m_BarWidth = prop.FindPropertyRelative("m_BarWidth");
SerializedProperty m_BarGap = prop.FindPropertyRelative("m_BarGap");
SerializedProperty m_BarZebraWidth = prop.FindPropertyRelative("m_BarZebraWidth");
SerializedProperty m_BarZebraGap = prop.FindPropertyRelative("m_BarZebraGap");
SerializedProperty m_AreaStyle = prop.FindPropertyRelative("m_AreaStyle");
SerializedProperty m_Symbol = prop.FindPropertyRelative("m_Symbol");
SerializedProperty m_RoseType = prop.FindPropertyRelative("m_RoseType");
SerializedProperty m_Space = prop.FindPropertyRelative("m_Space");
SerializedProperty m_Center = prop.FindPropertyRelative("m_Center");
SerializedProperty m_Radius = prop.FindPropertyRelative("m_Radius");
SerializedProperty m_Label = prop.FindPropertyRelative("m_Label");
SerializedProperty m_Emphasis = prop.FindPropertyRelative("m_Emphasis");
SerializedProperty m_Animation = prop.FindPropertyRelative("m_Animation");
SerializedProperty m_DataDimension = prop.FindPropertyRelative("m_ShowDataDimension");
SerializedProperty m_ShowDataName = prop.FindPropertyRelative("m_ShowDataName");
SerializedProperty m_ShowDataIcon = prop.FindPropertyRelative("m_ShowDataIcon");
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
SerializedProperty m_StartAngle = prop.FindPropertyRelative("m_StartAngle");
SerializedProperty m_EndAngle = prop.FindPropertyRelative("m_EndAngle");
SerializedProperty m_RingGap = prop.FindPropertyRelative("m_RingGap");
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
SerializedProperty m_Clockwise = prop.FindPropertyRelative("m_Clockwise");
SerializedProperty m_RoundCap = prop.FindPropertyRelative("m_RoundCap");
SerializedProperty m_GaugeType = prop.FindPropertyRelative("m_GaugeType");
SerializedProperty m_GaugeAxis = prop.FindPropertyRelative("m_GaugeAxis");
SerializedProperty m_GaugePointer = prop.FindPropertyRelative("m_GaugePointer");
SerializedProperty m_TitleStyle = prop.FindPropertyRelative("m_TitleStyle");
SerializedProperty m_Clip = prop.FindPropertyRelative("m_Clip");
SerializedProperty m_Ignore = prop.FindPropertyRelative("m_Ignore");
SerializedProperty m_IgnoreValue = prop.FindPropertyRelative("m_IgnoreValue");
SerializedProperty m_ShowAsPositiveNumber = prop.FindPropertyRelative("m_ShowAsPositiveNumber");
SerializedProperty m_Large = prop.FindPropertyRelative("m_Large");
SerializedProperty m_LargeThreshold = prop.FindPropertyRelative("m_LargeThreshold");
SerializedProperty m_AvoidLabelOverlap = prop.FindPropertyRelative("m_AvoidLabelOverlap");
SerializedProperty m_WaveHeight = prop.FindPropertyRelative("m_WaveHeight");
SerializedProperty m_WaveLength = prop.FindPropertyRelative("m_WaveLength");
SerializedProperty m_WaveSpeed = prop.FindPropertyRelative("m_WaveSpeed");
SerializedProperty m_WaveOffset = prop.FindPropertyRelative("m_WaveOffset");
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
int index = InitToggle(prop);
string moduleName = "Serie " + index;
var toggle = ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieModuleToggle, prop, moduleName, show);
if (!toggle)
{ {
var orderButton = 48; var orderButton = 48;
var gap = 4; var gap = 4;
var drawRect = pos;
drawRect.x += EditorGUIUtility.labelWidth + gap; drawRect.x += EditorGUIUtility.labelWidth + gap;
drawRect.width = pos.width - drawRect.x + ChartEditorHelper.BOOL_WIDTH - orderButton; drawRect.width = pos.width - drawRect.x + ChartEditorHelper.BOOL_WIDTH - orderButton;
EditorGUI.PropertyField(drawRect, type, GUIContent.none); EditorGUI.PropertyField(drawRect, type, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
else else
{ {
@@ -107,351 +37,240 @@ namespace XCharts
m_IsPolar = chart is PolarChart; m_IsPolar = chart is PolarChart;
var serieType = (SerieType)type.enumValueIndex; var serieType = (SerieType)type.enumValueIndex;
++EditorGUI.indentLevel; ++EditorGUI.indentLevel;
drawRect.x = pos.x; PropertyField(prop, "m_Type");
drawRect.width = pos.width; PropertyField(prop, "m_Name");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, type);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, name);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
switch (serieType) switch (serieType)
{ {
case SerieType.Line: case SerieType.Line:
EditorGUI.PropertyField(drawRect, stack); PropertyField(prop, "m_Stack");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_IsPolar) if (m_IsPolar)
{ {
EditorGUI.PropertyField(drawRect, m_PolarIndex); PropertyField(prop, "m_PolarIndex");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
else else
{ {
EditorGUI.PropertyField(drawRect, m_XAxisIndex); PropertyField(prop, "m_XAxisIndex");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_YAxisIndex");
EditorGUI.PropertyField(drawRect, m_YAxisIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
EditorGUI.PropertyField(drawRect, m_MinShow); PropertyFieldLimitMin(prop, "m_MinShow", 0);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyFieldLimitMin(prop, "m_MaxShow", 0);
EditorGUI.PropertyField(drawRect, m_MaxShow); PropertyFieldLimitMin(prop, "m_MaxCache", 0);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_LineType");
EditorGUI.PropertyField(drawRect, m_MaxCache); PropertyField(prop, "m_SampleDist");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_SampleType");
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0; PropertyField(prop, "m_SampleAverage");
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0; PropertyField(prop, "m_Clip");
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0; PropertyField(prop, "m_Ignore");
EditorGUI.PropertyField(drawRect, m_LineType); PropertyField(prop, "m_IgnoreValue");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_ShowAsPositiveNumber");
EditorGUI.PropertyField(drawRect, m_SampleDist); PropertyField(prop, "m_Large");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_LargeThreshold");
EditorGUI.PropertyField(drawRect, m_SampleType); PropertyField(prop, "m_Symbol");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_LineStyle");
EditorGUI.PropertyField(drawRect, m_SampleAverage); PropertyField(prop, "m_LineArrow");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_ItemStyle");
EditorGUI.PropertyField(drawRect, m_Clip); PropertyField(prop, "m_AreaStyle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Label");
EditorGUI.PropertyField(drawRect, m_Ignore); PropertyField(prop, "m_Emphasis");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Large);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LargeThreshold);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Symbol);
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
EditorGUI.PropertyField(drawRect, m_LineArrow);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineArrow);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_AreaStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Bar: case SerieType.Bar:
EditorGUI.PropertyField(drawRect, stack); PropertyField(prop, "m_Stack");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_IsPolar) if (m_IsPolar)
{ {
EditorGUI.PropertyField(drawRect, m_PolarIndex); PropertyField(prop, "m_PolarIndex");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
else else
{ {
EditorGUI.PropertyField(drawRect, m_XAxisIndex); PropertyField(prop, "m_XAxisIndex");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_YAxisIndex");
EditorGUI.PropertyField(drawRect, m_YAxisIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
EditorGUI.PropertyField(drawRect, m_MinShow); PropertyFieldLimitMin(prop, "m_MinShow", 0);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyFieldLimitMin(prop, "m_MaxShow", 0);
EditorGUI.PropertyField(drawRect, m_MaxShow); PropertyFieldLimitMin(prop, "m_MaxCache", 0);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_BarType");
EditorGUI.PropertyField(drawRect, m_MaxCache); PropertyField(prop, "m_BarPercentStack");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_BarWidth");
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0; PropertyField(prop, "m_BarGap");
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0; PropertyField(prop, "m_BarZebraWidth");
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0; PropertyField(prop, "m_BarZebraGap");
EditorGUI.PropertyField(drawRect, m_BarType); PropertyField(prop, "m_Clip");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Ignore");
EditorGUI.PropertyField(drawRect, m_BarPercentStack); PropertyField(prop, "m_IgnoreValue");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_ShowAsPositiveNumber");
EditorGUI.PropertyField(drawRect, m_BarWidth); PropertyField(prop, "m_Large");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_LargeThreshold");
EditorGUI.PropertyField(drawRect, m_BarGap); PropertyField(prop, "m_ItemStyle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Label");
EditorGUI.PropertyField(drawRect, m_BarZebraWidth); PropertyField(prop, "m_Emphasis");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarZebraGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Clip);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Ignore);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Large);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LargeThreshold);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Pie: case SerieType.Pie:
EditorGUI.PropertyField(drawRect, m_RoseType); PropertyField(prop, "m_RoseType");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Space");
EditorGUI.PropertyField(drawRect, m_Space); PropertyTwoFiled(prop, "m_Center");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyTwoFiled(prop, "m_Radius");
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center"); PropertyField(prop, "m_RoundCap");
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius"); PropertyField(prop, "m_Ignore");
EditorGUI.PropertyField(drawRect, m_RoundCap); PropertyField(prop, "m_IgnoreValue");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_AvoidLabelOverlap");
EditorGUI.PropertyField(drawRect, m_Ignore); PropertyField(prop, "m_ItemStyle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Label");
EditorGUI.PropertyField(drawRect, m_IgnoreValue); PropertyField(prop, "m_Emphasis");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_AvoidLabelOverlap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Ring: case SerieType.Ring:
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center"); PropertyTwoFiled(prop, "m_Center");
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius"); PropertyTwoFiled(prop, "m_Radius");
EditorGUI.PropertyField(drawRect, m_StartAngle); PropertyField(prop, "m_StartAngle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_RingGap");
EditorGUI.PropertyField(drawRect, m_RingGap); PropertyField(prop, "m_RoundCap");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Clockwise");
EditorGUI.PropertyField(drawRect, m_RoundCap); PropertyField(prop, "m_TitleStyle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_ItemStyle");
EditorGUI.PropertyField(drawRect, m_Clockwise); PropertyField(prop, "m_Label");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Emphasis");
EditorGUI.PropertyField(drawRect, m_TitleStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TitleStyle);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Radar: case SerieType.Radar:
EditorGUI.PropertyField(drawRect, m_RadarType); PropertyField(prop, "m_RadarType");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_RadarIndex");
EditorGUI.PropertyField(drawRect, m_RadarIndex); PropertyField(prop, "m_Symbol");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_LineStyle");
EditorGUI.PropertyField(drawRect, m_Symbol); PropertyField(prop, "m_ItemStyle");
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol); PropertyField(prop, "m_AreaStyle");
EditorGUI.PropertyField(drawRect, m_LineStyle); PropertyField(prop, "m_Label");
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle); PropertyField(prop, "m_Emphasis");
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_AreaStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Scatter: case SerieType.Scatter:
case SerieType.EffectScatter: case SerieType.EffectScatter:
EditorGUI.PropertyField(drawRect, m_Clip); PropertyField(prop, "m_Clip");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Symbol");
EditorGUI.PropertyField(drawRect, m_Symbol); PropertyField(prop, "m_ItemStyle");
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol); PropertyField(prop, "m_Label");
EditorGUI.PropertyField(drawRect, m_ItemStyle); PropertyField(prop, "m_Emphasis");
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Heatmap: case SerieType.Heatmap:
EditorGUI.PropertyField(drawRect, m_Ignore); PropertyField(prop, "m_Ignore");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_IgnoreValue");
EditorGUI.PropertyField(drawRect, m_IgnoreValue); PropertyField(prop, "m_ItemStyle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Label");
EditorGUI.PropertyField(drawRect, m_ItemStyle); PropertyField(prop, "m_Emphasis");
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Gauge: case SerieType.Gauge:
EditorGUI.PropertyField(drawRect, m_GaugeType); PropertyField(prop, "m_GaugeType");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyTwoFiled(prop, "m_Center");
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center"); PropertyTwoFiled(prop, "m_Radius");
//ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius"); PropertyField(prop, "m_Min");
EditorGUI.PropertyField(drawRect, m_Radius.GetArrayElementAtIndex(0), new GUIContent("Radius")); PropertyField(prop, "m_Max");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_StartAngle");
EditorGUI.PropertyField(drawRect, m_Min); PropertyField(prop, "m_EndAngle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyFieldLimitMax(prop, "m_SplitNumber", 36);
EditorGUI.PropertyField(drawRect, m_Max); PropertyField(prop, "m_RoundCap");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_TitleStyle");
EditorGUI.PropertyField(drawRect, m_StartAngle); PropertyField(prop, "m_GaugeAxis");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_GaugePointer");
EditorGUI.PropertyField(drawRect, m_EndAngle); PropertyField(prop, "m_ItemStyle");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Label");
EditorGUI.PropertyField(drawRect, m_SplitNumber); PropertyField(prop, "m_Emphasis");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_SplitNumber.intValue > 36)
{
m_SplitNumber.intValue = 36;
}
EditorGUI.PropertyField(drawRect, m_RoundCap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TitleStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TitleStyle);
EditorGUI.PropertyField(drawRect, m_GaugeAxis);
drawRect.y += EditorGUI.GetPropertyHeight(m_GaugeAxis);
EditorGUI.PropertyField(drawRect, m_GaugePointer);
drawRect.y += EditorGUI.GetPropertyHeight(m_GaugePointer);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break; break;
case SerieType.Liquid: case SerieType.Liquid:
EditorGUI.PropertyField(drawRect, m_VesselIndex); PropertyField(prop, "m_VesselIndex");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_Min");
EditorGUI.PropertyField(drawRect, m_Min); PropertyField(prop, "m_Max");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_WaveLength");
EditorGUI.PropertyField(drawRect, m_Max); PropertyField(prop, "m_WaveHeight");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_WaveSpeed");
EditorGUI.PropertyField(drawRect, m_WaveLength); PropertyField(prop, "m_WaveOffset");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; PropertyField(prop, "m_ItemStyle");
EditorGUI.PropertyField(drawRect, m_WaveHeight); PropertyField(prop, "m_Label");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_WaveSpeed);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_WaveOffset);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
break; break;
} }
EditorGUI.PropertyField(drawRect, m_Animation); PropertyField(prop, "m_Animation");
drawRect.y += EditorGUI.GetPropertyHeight(m_Animation); //PropertyListField(prop, "m_Data");
drawRect.width = EditorGUIUtility.labelWidth + 10; DrawData(pos, prop, serieType, ref m_DrawRect);
m_DataFoldout[index] = EditorGUI.Foldout(drawRect, m_DataFoldout[index], "Data"); --EditorGUI.indentLevel;
drawRect.width = pos.width; }
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; }
if (m_DataFoldout[index])
{
EditorGUI.indentLevel++;
float nameWid = 45; private void DrawData(Rect pos, SerializedProperty prop, SerieType serieType, ref Rect drawRect)
{
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
SerializedProperty m_DataDimension = prop.FindPropertyRelative("m_ShowDataDimension");
SerializedProperty m_ShowDataName = prop.FindPropertyRelative("m_ShowDataName");
SerializedProperty m_ShowDataIcon = prop.FindPropertyRelative("m_ShowDataIcon");
int index = InitToggle(prop);
drawRect.width = EditorGUIUtility.labelWidth + 10;
m_DataFoldout[index] = EditorGUI.Foldout(drawRect, m_DataFoldout[index], "Data");
drawRect.width = pos.width;
AddSingleLineHeight();
if (m_DataFoldout[index])
{
EditorGUI.indentLevel++;
float nameWid = 45;
#if UNITY_2019_3_OR_NEWER #if UNITY_2019_3_OR_NEWER
var gap = 2; var gap = 2;
var namegap = 3; var namegap = 3;
#else #else
var gap = 0; var gap = 0;
var namegap = 0; var namegap = 0;
#endif #endif
EditorGUI.PropertyField(new Rect(drawRect.x, drawRect.y, pos.width - 2 * nameWid - 2, pos.height), m_DataDimension); EditorGUI.PropertyField(new Rect(drawRect.x, drawRect.y, pos.width - 2 * nameWid - 2, pos.height), m_DataDimension);
var nameRect = new Rect(pos.width - 2 * nameWid + 14 + gap, drawRect.y, nameWid - gap, pos.height); var nameRect = new Rect(pos.width - 2 * nameWid + 14 + gap, drawRect.y, nameWid - gap, pos.height);
if (XChartsSettings.editorBlockEnable) if (XChartsSettings.editorBlockEnable)
{ {
nameRect.x += ChartEditorHelper.BLOCK_WIDTH; nameRect.x += ChartEditorHelper.BLOCK_WIDTH;
}
if (GUI.Button(nameRect, new GUIContent("Name")))
{
m_ShowDataName.boolValue = !m_ShowDataName.boolValue;
}
var iconRect = new Rect(pos.width - nameWid + 14, drawRect.y, nameWid + namegap, pos.height);
if (XChartsSettings.editorBlockEnable)
{
iconRect.x += ChartEditorHelper.BLOCK_WIDTH;
}
if (GUI.Button(iconRect, new GUIContent("More...")))
{
m_ShowDataIcon.boolValue = !m_ShowDataIcon.boolValue;
}
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
var listSize = m_Datas.arraySize;
listSize = EditorGUI.IntField(drawRect, "Size", listSize);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (listSize < 0) listSize = 0;
if (m_DataDimension.intValue < 1) m_DataDimension.intValue = 1;
int dimension = m_DataDimension.intValue;
bool showName = m_ShowDataName.boolValue;
bool showIcon = m_ShowDataIcon.boolValue;
bool showSelected = (serieType == SerieType.Pie);
if (listSize != m_Datas.arraySize)
{
while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
}
if (listSize > 30 && !XChartsSettings.editorShowAllListData)
{
int num = listSize > 10 ? 10 : listSize;
for (int i = 0; i < num; i++)
{
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
}
if (num >= 10)
{
EditorGUI.LabelField(drawRect, "...");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, listSize - 1, pos.width);
}
}
else
{
for (int i = 0; i < m_Datas.arraySize; i++)
{
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
}
}
drawRect.y += EditorGUIUtility.standardVerticalSpacing;
EditorGUI.indentLevel--;
} }
--EditorGUI.indentLevel; if (GUI.Button(nameRect, new GUIContent("Name")))
{
m_ShowDataName.boolValue = !m_ShowDataName.boolValue;
}
var iconRect = new Rect(pos.width - nameWid + 14, drawRect.y, nameWid + namegap, pos.height);
if (XChartsSettings.editorBlockEnable)
{
iconRect.x += ChartEditorHelper.BLOCK_WIDTH;
}
if (GUI.Button(iconRect, new GUIContent("More...")))
{
m_ShowDataIcon.boolValue = !m_ShowDataIcon.boolValue;
}
AddSingleLineHeight();
var listSize = m_Datas.arraySize;
listSize = EditorGUI.IntField(drawRect, "Size", listSize);
AddSingleLineHeight();
if (listSize < 0) listSize = 0;
if (m_DataDimension.intValue < 1) m_DataDimension.intValue = 1;
int dimension = m_DataDimension.intValue;
bool showName = m_ShowDataName.boolValue;
bool showIcon = m_ShowDataIcon.boolValue;
bool showSelected = (serieType == SerieType.Pie);
if (listSize != m_Datas.arraySize)
{
while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
}
if (listSize > 30 && !XChartsSettings.editorShowAllListData)
{
int num = listSize > 10 ? 10 : listSize;
for (int i = 0; i < num; i++)
{
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
}
if (num >= 10)
{
EditorGUI.LabelField(drawRect, "...");
AddSingleLineHeight();
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, listSize - 1, pos.width);
}
}
else
{
for (int i = 0; i < m_Datas.arraySize; i++)
{
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
}
}
AddHeight(EditorGUIUtility.standardVerticalSpacing);
EditorGUI.indentLevel--;
} }
} }
@@ -491,7 +310,7 @@ namespace XCharts
{ {
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index)); EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index));
} }
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; AddHeight(EditorGUI.GetPropertyHeight(element));
} }
else else
{ {
@@ -527,8 +346,7 @@ namespace XCharts
drawRect.width = dataWid + 40 + dimension * namegap; drawRect.width = dataWid + 40 + dimension * namegap;
EditorGUI.PropertyField(drawRect, sereName, GUIContent.none); EditorGUI.PropertyField(drawRect, sereName, GUIContent.none);
} }
AddSingleLineHeight();
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.x = lastX; drawRect.x = lastX;
drawRect.width = lastWid; drawRect.width = lastWid;
EditorGUIUtility.fieldWidth = lastFieldWid; EditorGUIUtility.fieldWidth = lastFieldWid;
@@ -547,149 +365,23 @@ namespace XCharts
var m_EnableSymbol = serieData.FindPropertyRelative("m_EnableSymbol"); var m_EnableSymbol = serieData.FindPropertyRelative("m_EnableSymbol");
var m_Symbol = serieData.FindPropertyRelative("m_Symbol"); var m_Symbol = serieData.FindPropertyRelative("m_Symbol");
EditorGUI.PropertyField(drawRect, m_Icon); EditorGUI.PropertyField(drawRect, m_Icon);
drawRect.y += EditorGUI.GetPropertyHeight(m_Icon); AddHeight(EditorGUI.GetPropertyHeight(m_Icon));
EditorGUI.PropertyField(drawRect, m_Symbol); EditorGUI.PropertyField(drawRect, m_Symbol);
ChartEditorHelper.MakeBool(drawRect, m_EnableSymbol, 1, "(enable)"); ChartEditorHelper.MakeBool(drawRect, m_EnableSymbol, 1, "(enable)");
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol); AddHeight(EditorGUI.GetPropertyHeight(m_Symbol));
EditorGUI.PropertyField(drawRect, m_Label); EditorGUI.PropertyField(drawRect, m_Label);
ChartEditorHelper.MakeBool(drawRect, m_EnableLabel, 1, "(enable)"); ChartEditorHelper.MakeBool(drawRect, m_EnableLabel, 1, "(enable)");
drawRect.y += EditorGUI.GetPropertyHeight(m_Label); AddHeight(EditorGUI.GetPropertyHeight(m_Label));
EditorGUI.PropertyField(drawRect, m_ItemStyle); EditorGUI.PropertyField(drawRect, m_ItemStyle);
ChartEditorHelper.MakeBool(drawRect, m_EnableItemStyle, 1, "(enable)"); ChartEditorHelper.MakeBool(drawRect, m_EnableItemStyle, 1, "(enable)");
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle); AddHeight(EditorGUI.GetPropertyHeight(m_ItemStyle));
EditorGUI.PropertyField(drawRect, m_Emphasis); EditorGUI.PropertyField(drawRect, m_Emphasis);
ChartEditorHelper.MakeBool(drawRect, m_EnableEmphasis, 1, "(enable)"); ChartEditorHelper.MakeBool(drawRect, m_EnableEmphasis, 1, "(enable)");
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis); AddHeight(EditorGUI.GetPropertyHeight(m_Emphasis));
EditorGUI.indentLevel -= 2; EditorGUI.indentLevel -= 2;
} }
} }
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
int index = InitToggle(prop);
if (!m_SerieModuleToggle.ContainsKey(prop.propertyPath) || !m_SerieModuleToggle[prop.propertyPath])
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
else
{
SerializedProperty type = prop.FindPropertyRelative("m_Type");
var serieType = (SerieType)type.enumValueIndex;
switch (serieType)
{
case SerieType.Line:
height += 20 * EditorGUIUtility.singleLineHeight + 19 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Bar:
height += 22 * EditorGUIUtility.singleLineHeight + 21 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Pie:
height += 12 * EditorGUIUtility.singleLineHeight + 11 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Ring:
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TitleStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Radar:
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Scatter:
case SerieType.EffectScatter:
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Heatmap:
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Gauge:
height += 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TitleStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_GaugeAxis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_GaugePointer"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Liquid:
height += 11 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
}
if (m_DataFoldout[index])
{
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
int num = m_Data.arraySize;
if (num > 30)
{
num = 11;
height += (num + 1) * EditorGUIUtility.singleLineHeight + (num) * EditorGUIUtility.standardVerticalSpacing;
}
else
{
height += (num) * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
}
height += EditorGUIUtility.standardVerticalSpacing;
if (prop.FindPropertyRelative("m_ShowDataIcon").boolValue)
{
for (int i = 0; i < num; i++)
{
var item = m_Data.GetArrayElementAtIndex(i);
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_IconStyle"));
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Symbol"));
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Emphasis"));
}
}
}
if (m_ShowJsonDataArea)
{
height += EditorGUIUtility.singleLineHeight * 4 + EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
}
private int InitToggle(SerializedProperty prop) private int InitToggle(SerializedProperty prop)
{ {
int index = 0; int index = 0;

View File

@@ -165,13 +165,13 @@ namespace XCharts
else if (IsAssetsExist(XChartsMgr.GetThemeAssetPath(m_ChartName))) else if (IsAssetsExist(XChartsMgr.GetThemeAssetPath(m_ChartName)))
{ {
ShowNotification(new GUIContent("ERROR:The asset is exist! \npath=" ShowNotification(new GUIContent("ERROR:The asset is exist! \npath="
+ XChartsMgr.GetThemeAssetPath(m_ChartName)), 5); + XChartsMgr.GetThemeAssetPath(m_ChartName)));
} }
else else
{ {
XChartsMgr.ExportTheme(target.theme, m_ChartName); XChartsMgr.ExportTheme(target.theme, m_ChartName);
ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath=" ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath="
+ XChartsMgr.GetThemeAssetPath(m_ChartName)), 5); + XChartsMgr.GetThemeAssetPath(m_ChartName)));
} }
} }
} }

View File

@@ -14,7 +14,8 @@ public class ChartEditorHelper
#else #else
public const float INDENT_WIDTH = 15; public const float INDENT_WIDTH = 15;
public const float BOOL_WIDTH = 15; public const float BOOL_WIDTH = 15;
public const float ARROW_WIDTH = 13; public const float ARROW_WIDTH = 17.2f;
public const float BLOCK_WIDTH = 0;
public const float GAP_WIDTH = 0; public const float GAP_WIDTH = 0;
#endif #endif
@@ -26,8 +27,8 @@ public class ChartEditorHelper
font = headerStyle.font, font = headerStyle.font,
fontStyle = headerStyle.fontStyle, fontStyle = headerStyle.fontStyle,
}; };
public static readonly GUIContent iconAdd = EditorGUIUtility.TrIconContent("Toolbar Plus", "Add"); public static readonly GUIContent iconAdd = new GUIContent("+", "Add");
public static readonly GUIContent iconRemove = EditorGUIUtility.TrIconContent("Toolbar Minus", "Remove"); public static readonly GUIContent iconRemove = new GUIContent("-", "Remove");
public static readonly GUIContent iconUp = new GUIContent("↑", "Up"); public static readonly GUIContent iconUp = new GUIContent("↑", "Up");
public static readonly GUIContent iconDown = new GUIContent("↓", "Down"); public static readonly GUIContent iconDown = new GUIContent("↓", "Down");
public static readonly GUIStyle invisibleButton = "InvisibleButton"; public static readonly GUIStyle invisibleButton = "InvisibleButton";
@@ -41,13 +42,17 @@ public class ChartEditorHelper
drawRect = offset.Remove(drawRect); drawRect = offset.Remove(drawRect);
} }
public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp, string name) public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp,
string name)
{ {
while (arrayProp.arraySize < 2) arrayProp.arraySize++; while (arrayProp.arraySize < 2) arrayProp.arraySize++;
MakeTwoField(ref drawRect, rectWidth, arrayProp.GetArrayElementAtIndex(0), arrayProp.GetArrayElementAtIndex(1), name); var prop1 = arrayProp.GetArrayElementAtIndex(0);
var prop2 = arrayProp.GetArrayElementAtIndex(1);
MakeTwoField(ref drawRect, rectWidth, prop1, prop2, name);
} }
public static void MakeDivideList(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp, string name, int showNum) public static void MakeDivideList(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp,
string name, int showNum)
{ {
while (arrayProp.arraySize < showNum) arrayProp.arraySize++; while (arrayProp.arraySize < showNum) arrayProp.arraySize++;
EditorGUI.LabelField(drawRect, name); EditorGUI.LabelField(drawRect, name);
@@ -70,7 +75,8 @@ public class ChartEditorHelper
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty prop1, SerializedProperty prop2, string name) public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty prop1,
SerializedProperty prop2, string name)
{ {
EditorGUI.LabelField(drawRect, name); EditorGUI.LabelField(drawRect, name);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH; var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
@@ -134,21 +140,23 @@ public class ChartEditorHelper
{ {
float defaultWidth = drawRect.width; float defaultWidth = drawRect.width;
float defaultX = drawRect.x; float defaultX = drawRect.x;
var style = bold ? Styles.foldoutStyle : EditorStyles.foldout;
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH; drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH;
moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? Styles.foldoutStyle : EditorStyles.foldout); moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, style);
MakeBool(drawRect, prop); MakeBool(drawRect, prop);
drawRect.width = defaultWidth; drawRect.width = defaultWidth;
drawRect.x = defaultX; drawRect.x = defaultX;
return moduleToggle; return moduleToggle;
} }
public static bool MakeFoldout(ref Rect drawRect, Dictionary<string, float> heights, Dictionary<string, bool> moduleToggle, public static bool MakeFoldout(ref Rect drawRect, Dictionary<string, float> heights,
string key, string content, SerializedProperty prop, bool bold = false) Dictionary<string, bool> moduleToggle, string key, string content, SerializedProperty prop, bool bold = false)
{ {
float defaultWidth = drawRect.width; float defaultWidth = drawRect.width;
float defaultX = drawRect.x; float defaultX = drawRect.x;
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH; var style = bold ? Styles.foldoutStyle : EditorStyles.foldout;
moduleToggle[key] = EditorGUI.Foldout(drawRect, moduleToggle[key], content, bold ? Styles.foldoutStyle : EditorStyles.foldout); drawRect.width = EditorGUIUtility.labelWidth;
moduleToggle[key] = EditorGUI.Foldout(drawRect, moduleToggle[key], content, style);
if (prop != null) if (prop != null)
{ {
if (prop.propertyType == SerializedPropertyType.Boolean) if (prop.propertyType == SerializedPropertyType.Boolean)
@@ -200,10 +208,11 @@ public class ChartEditorHelper
drawRect.x = defaultX; drawRect.x = defaultX;
} }
public static bool MakeFoldout(ref Rect drawRect, ref float height, ref Dictionary<string, bool> moduleToggle, SerializedProperty prop, public static bool MakeFoldout(ref Rect drawRect, ref float height, ref Dictionary<string, bool> moduleToggle,
string moduleName, string showPropName, bool bold = false) SerializedProperty prop, string moduleName, string showPropName, bool bold = false)
{ {
var flag = MakeFoldout(ref drawRect, ref moduleToggle, prop, moduleName, prop.FindPropertyRelative(showPropName), bold); var relativeProp = prop.FindPropertyRelative(showPropName);
var flag = MakeFoldout(ref drawRect, ref moduleToggle, prop, moduleName, relativeProp, bold);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
return flag; return flag;
@@ -255,13 +264,15 @@ public class ChartEditorHelper
return toggle; return toggle;
} }
public static bool MakeListWithFoldout(ref Rect drawRect, SerializedProperty listProp, bool foldout, bool showOrder = false, bool showSize = true) public static bool MakeListWithFoldout(ref Rect drawRect, SerializedProperty listProp, bool foldout,
bool showOrder = false, bool showSize = true)
{ {
var height = 0f; var height = 0f;
return MakeListWithFoldout(ref drawRect, ref height, listProp, foldout, showOrder, showSize); return MakeListWithFoldout(ref drawRect, ref height, listProp, foldout, showOrder, showSize);
} }
public static bool MakeListWithFoldout(ref Rect drawRect, ref float height, SerializedProperty listProp, bool foldout, bool showOrder = false, bool showSize = true) public static bool MakeListWithFoldout(ref Rect drawRect, ref float height, SerializedProperty listProp,
bool foldout, bool showOrder = false, bool showSize = true)
{ {
var rawWidth = drawRect.width; var rawWidth = drawRect.width;
drawRect.width = EditorGUIUtility.labelWidth + 10; drawRect.width = EditorGUIUtility.labelWidth + 10;
@@ -276,13 +287,15 @@ public class ChartEditorHelper
return flag; return flag;
} }
public static void MakeList(ref Rect drawRect, SerializedProperty listProp, bool showOrder = false, bool showSize = true) public static void MakeList(ref Rect drawRect, SerializedProperty listProp, bool showOrder = false,
bool showSize = true)
{ {
var height = 0f; var height = 0f;
MakeList(ref drawRect, ref height, listProp, showOrder, showSize); MakeList(ref drawRect, ref height, listProp, showOrder, showSize);
} }
public static void MakeList(ref Rect drawRect, ref float height, SerializedProperty listProp, bool showOrder = false, bool showSize = true) public static void MakeList(ref Rect drawRect, ref float height, SerializedProperty listProp,
bool showOrder = false, bool showSize = true)
{ {
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
var listSize = listProp.arraySize; var listSize = listProp.arraySize;
@@ -293,12 +306,14 @@ public class ChartEditorHelper
if (showOrder) if (showOrder)
{ {
var temp = INDENT_WIDTH + GAP_WIDTH + iconGap; var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth - 1, drawRect.height); var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth + 2, drawRect.height);
var iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height); var iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
if (XChartsSettings.editorBlockEnable) if (XChartsSettings.editorBlockEnable)
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
var oldColor = GUI.contentColor;
GUI.contentColor = Color.black;
if (GUI.Button(iconRect, Styles.iconAdd, Styles.invisibleButton)) if (GUI.Button(iconRect, Styles.iconAdd, Styles.invisibleButton))
{ {
if (listProp.displayName.Equals("Series")) if (listProp.displayName.Equals("Series"))
@@ -311,6 +326,7 @@ public class ChartEditorHelper
listProp.arraySize++; listProp.arraySize++;
} }
} }
GUI.contentColor = oldColor;
listSize = listProp.arraySize; listSize = listProp.arraySize;
listSize = EditorGUI.IntField(elementRect, "Size", listSize); listSize = EditorGUI.IntField(elementRect, "Size", listSize);
} }
@@ -357,11 +373,10 @@ public class ChartEditorHelper
SerializedProperty element = listProp.GetArrayElementAtIndex(i); SerializedProperty element = listProp.GetArrayElementAtIndex(i);
if (showOrder) if (showOrder)
{ {
var temp = INDENT_WIDTH + GAP_WIDTH + iconGap; var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
var isSerie = "Serie".Equals(element.type); var isSerie = "Serie".Equals(element.type);
var elementRect = isSerie var elementRect = isSerie
? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH, drawRect.height) ? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * iconGap, drawRect.height)
: new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height); : new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height);
EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i)); EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i));
var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
@@ -369,6 +384,8 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
var oldColor = GUI.contentColor;
GUI.contentColor = Color.black;
if (GUI.Button(iconRect, Styles.iconUp, Styles.invisibleButton)) if (GUI.Button(iconRect, Styles.iconUp, Styles.invisibleButton))
{ {
if (i > 0) listProp.MoveArrayElement(i, i - 1); if (i > 0) listProp.MoveArrayElement(i, i - 1);
@@ -396,6 +413,7 @@ public class ChartEditorHelper
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing; height += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
} }
GUI.contentColor = oldColor;
} }
else else
{ {
@@ -408,23 +426,62 @@ public class ChartEditorHelper
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key, SerializedProperty prop) public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty prop)
{ {
if (prop == null) if (prop == null) return false;
{
return false;
}
EditorGUI.PropertyField(drawRect, prop, true); EditorGUI.PropertyField(drawRect, prop, true);
var hig = EditorGUI.GetPropertyHeight(prop); var hig = EditorGUI.GetPropertyHeight(prop);
// var hig = prop.hasVisibleChildren
// ? EditorGUI.GetPropertyHeight(prop)
// : EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.y += hig; drawRect.y += hig;
heights[key] += hig; heights[key] += hig;
return true; return true;
} }
public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key, SerializedProperty parentProp, string relativeName)
public static bool PropertyFieldWithMinValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty prop, float minValue)
{
if (prop == null) return false;
EditorGUI.PropertyField(drawRect, prop, true);
if (prop.propertyType == SerializedPropertyType.Float && prop.floatValue < minValue)
prop.floatValue = minValue;
if (prop.propertyType == SerializedPropertyType.Integer && prop.intValue < minValue)
prop.intValue = (int)minValue;
var hig = EditorGUI.GetPropertyHeight(prop);
drawRect.y += hig;
heights[key] += hig;
return true;
}
public static bool PropertyFieldWithMaxValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty prop, float maxValue)
{
if (prop == null) return false;
EditorGUI.PropertyField(drawRect, prop, true);
if (prop.propertyType == SerializedPropertyType.Float && prop.floatValue > maxValue)
prop.floatValue = maxValue;
if (prop.propertyType == SerializedPropertyType.Integer && prop.intValue > maxValue)
prop.intValue = (int)maxValue;
var hig = EditorGUI.GetPropertyHeight(prop);
drawRect.y += hig;
heights[key] += hig;
return true;
}
public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty parentProp, string relativeName)
{ {
return PropertyField(ref drawRect, heights, key, parentProp.FindPropertyRelative(relativeName)); return PropertyField(ref drawRect, heights, key, parentProp.FindPropertyRelative(relativeName));
} }
public static bool PropertyFieldWithMinValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty parentProp, string relativeName, float minValue)
{
var relativeProp = parentProp.FindPropertyRelative(relativeName);
return PropertyFieldWithMinValue(ref drawRect, heights, key, relativeProp, minValue);
}
public static bool PropertyFieldWithMaxValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty parentProp, string relativeName, float maxValue)
{
var relativeProp = parentProp.FindPropertyRelative(relativeName);
return PropertyFieldWithMaxValue(ref drawRect, heights, key, relativeProp, maxValue);
}
} }

View File

@@ -1,8 +1,7 @@
{ {
"name": "XCharts.Editor", "name": "XCharts.Editor",
"references": [ "references": [
"XCharts.Runtime", "XCharts.Runtime"
"Unity.TextMeshPro"
], ],
"includePlatforms": [ "includePlatforms": [
"Editor" "Editor"

View File

@@ -38,6 +38,7 @@ MonoBehaviour:
m_SerieScatterSymbolSize: 20 m_SerieScatterSymbolSize: 20
m_SerieScatterSymbolSelectedSize: 30 m_SerieScatterSymbolSelectedSize: 30
m_EditorBlockEnable: 1 m_EditorBlockEnable: 1
m_EditorShowAllListData: 0
m_MaxPainter: 10 m_MaxPainter: 10
m_LineSmoothStyle: 3 m_LineSmoothStyle: 3
m_LineSmoothness: 2 m_LineSmoothness: 2

View File

@@ -26,6 +26,17 @@ namespace XCharts
m_Radars.Clear(); m_Radars.Clear();
} }
/// <summary>
/// 移除指定Radar的所有Indicator。
/// </summary>
/// <param name="radarIndex"></param>
public void RemoveIndicator(int radarIndex)
{
var radar = GetRadar(radarIndex);
if (radar == null) return;
radar.indicatorList.Clear();
}
/// <summary> /// <summary>
/// 添加雷达坐标系组件。 /// 添加雷达坐标系组件。
/// </summary> /// </summary>
@@ -61,6 +72,14 @@ namespace XCharts
return radar; return radar;
} }
public bool AddIndicator(int radarIndex, Radar.Indicator indicator)
{
var radar = GetRadar(radarIndex);
if (radar == null) return false;
radar.AddIndicator(indicator);
return true;
}
/// <summary> /// <summary>
/// 添加指示器。 /// 添加指示器。
/// </summary> /// </summary>

View File

@@ -340,6 +340,12 @@ namespace XCharts
return new Vector3(x, y); return new Vector3(x, y);
} }
public void AddIndicator(Radar.Indicator indicator)
{
indicatorList.Add(indicator);
SetAllDirty();
}
public Radar.Indicator AddIndicator(string name, float min, float max) public Radar.Indicator AddIndicator(string name, float min, float max)
{ {
var indicator = new Radar.Indicator(); var indicator = new Radar.Indicator();

View File

@@ -60,6 +60,7 @@ namespace XCharts
[SerializeField] private string m_NumericFormatter = ""; [SerializeField] private string m_NumericFormatter = "";
[SerializeField] private float m_PaddingLeftRight = 5f; [SerializeField] private float m_PaddingLeftRight = 5f;
[SerializeField] private float m_PaddingTopBottom = 5f; [SerializeField] private float m_PaddingTopBottom = 5f;
[SerializeField] private bool m_IgnoreDataShow = false;
[SerializeField] private string m_IgnoreDataDefaultContent = "-"; [SerializeField] private string m_IgnoreDataDefaultContent = "-";
[SerializeField] private bool m_AlwayShow = false; [SerializeField] private bool m_AlwayShow = false;
[SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f); [SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f);
@@ -185,6 +186,11 @@ namespace XCharts
/// </summary> /// </summary>
public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } } public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } }
/// <summary> /// <summary>
/// Whether to show ignored data on tooltip.
/// 是否显示忽略数据在tooltip上。
/// </summary>
public bool ignoreDataShow { get { return m_IgnoreDataShow; } set { m_IgnoreDataShow = value; } }
/// <summary>
/// The default display character information for ignored data. /// The default display character information for ignored data.
/// 被忽略数据的默认显示字符信息。 /// 被忽略数据的默认显示字符信息。
/// </summary> /// </summary>

View File

@@ -28,9 +28,9 @@ namespace XCharts
grid.bottom = 60; grid.bottom = 60;
m_XAxes[0].type = Axis.AxisType.Category; m_XAxes[0].type = Axis.AxisType.Category;
m_XAxes[0].boundaryGap = false; m_XAxes[0].boundaryGap = true;
m_YAxes[0].type = Axis.AxisType.Category; m_YAxes[0].type = Axis.AxisType.Category;
m_YAxes[0].boundaryGap = false; m_YAxes[0].boundaryGap = true;
m_XAxes[0].splitNumber = 10; m_XAxes[0].splitNumber = 10;
m_YAxes[0].splitNumber = 10; m_YAxes[0].splitNumber = 10;
RemoveData(); RemoveData();

View File

@@ -249,16 +249,19 @@ namespace XCharts
m_Theme.ClearDirty(); m_Theme.ClearDirty();
} }
CheckComponentDirty(tooltip); CheckComponentDirty(tooltip);
foreach (var title in m_Titles) CheckComponentDirty(title); foreach (var component in m_Titles) CheckComponentDirty(component);
foreach (var legend in m_Legends) CheckComponentDirty(legend); foreach (var component in m_Legends) CheckComponentDirty(component);
foreach (var dataZoom in m_DataZooms) CheckComponentDirty(dataZoom); foreach (var component in m_Tooltips) CheckComponentDirty(component);
foreach (var visualMap in m_VisualMaps) CheckComponentDirty(visualMap); foreach (var component in m_DataZooms) CheckComponentDirty(component);
foreach (var grid in m_Grids) CheckComponentDirty(grid); foreach (var component in m_VisualMaps) CheckComponentDirty(component);
foreach (var axis in m_XAxes) CheckComponentDirty(axis); foreach (var component in m_Grids) CheckComponentDirty(component);
foreach (var axis in m_YAxes) CheckComponentDirty(axis); foreach (var component in m_XAxes) CheckComponentDirty(component);
foreach (var polar in m_Polars) CheckComponentDirty(polar); foreach (var component in m_YAxes) CheckComponentDirty(component);
foreach (var axis in m_AngleAxes) CheckComponentDirty(axis); foreach (var component in m_Vessels) CheckComponentDirty(component);
foreach (var axis in m_RadiusAxes) CheckComponentDirty(axis); foreach (var component in m_Polars) CheckComponentDirty(component);
foreach (var component in m_AngleAxes) CheckComponentDirty(component);
foreach (var component in m_RadiusAxes) CheckComponentDirty(component);
foreach (var component in m_Radars) CheckComponentDirty(component);
foreach (var drawSerie in m_DrawSeries) drawSerie.CheckComponent(); foreach (var drawSerie in m_DrawSeries) drawSerie.CheckComponent();
} }
@@ -278,9 +281,19 @@ namespace XCharts
{ {
base.SetAllComponentDirty(); base.SetAllComponentDirty();
m_Theme.SetAllDirty(); m_Theme.SetAllDirty();
foreach (var title in m_Titles) title.SetAllDirty(); foreach (var component in m_Titles) component.SetAllDirty();
foreach (var legend in m_Legends) legend.SetAllDirty(); foreach (var component in m_Legends) component.SetAllDirty();
tooltip.SetAllDirty(); foreach (var component in m_Tooltips) component.SetAllDirty();
foreach (var component in m_Grids) component.SetAllDirty();
foreach (var component in m_XAxes) component.SetAllDirty();
foreach (var component in m_YAxes) component.SetAllDirty();
foreach (var component in m_DataZooms) component.SetAllDirty();
foreach (var component in m_VisualMaps) component.SetAllDirty();
foreach (var component in m_Vessels) component.SetAllDirty();
foreach (var component in m_Polars) component.SetAllDirty();
foreach (var component in m_RadiusAxes) component.SetAllDirty();
foreach (var component in m_AngleAxes) component.SetAllDirty();
foreach (var component in m_Radars) component.SetAllDirty();
m_ReinitLabel = true; m_ReinitLabel = true;
m_ReinitTitle = true; m_ReinitTitle = true;
} }
@@ -337,18 +350,16 @@ namespace XCharts
} }
private void InitTitle(Title title) private void InitTitle(Title title)
{ {
title.OnChanged();
var anchorMin = title.location.runtimeAnchorMin;
var anchorMax = title.location.runtimeAnchorMax;
var pivot = title.location.runtimePivot;
var titleObject = ChartHelper.AddObject(s_TitleObjectName + title.index, transform, anchorMin, anchorMax,
pivot, m_ChartSizeDelta);
title.gameObject = titleObject;
title.painter = null; title.painter = null;
title.refreshComponent = delegate () title.refreshComponent = delegate ()
{ {
if (titleObject == null) return;
title.OnChanged(); title.OnChanged();
var anchorMin = title.location.runtimeAnchorMin;
var anchorMax = title.location.runtimeAnchorMax;
var pivot = title.location.runtimePivot;
var titleObject = ChartHelper.AddObject(s_TitleObjectName + title.index, transform, anchorMin, anchorMax,
pivot, m_ChartSizeDelta);
title.gameObject = titleObject;
anchorMin = title.location.runtimeAnchorMin; anchorMin = title.location.runtimeAnchorMin;
anchorMax = title.location.runtimeAnchorMax; anchorMax = title.location.runtimeAnchorMax;
pivot = title.location.runtimePivot; pivot = title.location.runtimePivot;
@@ -392,15 +403,13 @@ namespace XCharts
private void InitLegend(Legend legend) private void InitLegend(Legend legend)
{ {
legend.OnChanged();
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, transform, m_ChartMinAnchor,
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
legend.gameObject = legendObject;
legend.painter = null; // legend component does not need to paint legend.painter = null; // legend component does not need to paint
legend.refreshComponent = delegate () legend.refreshComponent = delegate ()
{ {
if (legendObject == null) return;
legend.OnChanged(); legend.OnChanged();
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, transform, m_ChartMinAnchor,
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
legend.gameObject = legendObject;
legendObject.hideFlags = chartHideFlags; legendObject.hideFlags = chartHideFlags;
SeriesHelper.UpdateSerieNameList(m_Series, ref m_LegendRealShowName); SeriesHelper.UpdateSerieNameList(m_Series, ref m_LegendRealShowName);
List<string> datas; List<string> datas;
@@ -583,12 +592,11 @@ namespace XCharts
private void InitTooltip() private void InitTooltip()
{ {
tooltip.gameObject = ChartHelper.AddObject("tooltip", transform, m_ChartMinAnchor,
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
tooltip.painter = m_PainterTop; tooltip.painter = m_PainterTop;
tooltip.refreshComponent = delegate () tooltip.refreshComponent = delegate ()
{ {
if (tooltip.gameObject == null) return; tooltip.gameObject = ChartHelper.AddObject("tooltip", transform, m_ChartMinAnchor,
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
var tooltipObject = tooltip.gameObject; var tooltipObject = tooltip.gameObject;
tooltipObject.transform.localPosition = Vector3.zero; tooltipObject.transform.localPosition = Vector3.zero;
tooltipObject.hideFlags = chartHideFlags; tooltipObject.hideFlags = chartHideFlags;
@@ -678,7 +686,7 @@ namespace XCharts
{ {
m_Painter.Refresh(); m_Painter.Refresh();
foreach (var painter in m_PainterList) painter.Refresh(); foreach (var painter in m_PainterList) painter.Refresh();
m_PainterTop.Refresh(); if (m_PainterTop != null) m_PainterTop.Refresh();
m_RefreshChart = false; m_RefreshChart = false;
} }
} }
@@ -688,7 +696,7 @@ namespace XCharts
if (m_Painter == null) return; if (m_Painter == null) return;
m_Painter.CheckRefresh(); m_Painter.CheckRefresh();
foreach (var painter in m_PainterList) painter.CheckRefresh(); foreach (var painter in m_PainterList) painter.CheckRefresh();
m_PainterTop.CheckRefresh(); if (m_PainterTop != null) m_PainterTop.CheckRefresh();
} }
protected void CheckRefreshLabel() protected void CheckRefreshLabel()
@@ -739,10 +747,7 @@ namespace XCharts
m_ChartSizeDelta = m_GraphSizeDelta; m_ChartSizeDelta = m_GraphSizeDelta;
m_ChartRect = m_GraphRect; m_ChartRect = m_GraphRect;
m_Background.SetAllDirty(); SetAllComponentDirty();
foreach (var title in m_Titles) title.SetAllDirty();
foreach (var legend in m_Legends) legend.SetAllDirty();
tooltip.SetAllDirty();
m_Series.SetLabelDirty(); m_Series.SetLabelDirty();
m_ReinitLabel = true; m_ReinitLabel = true;
RefreshChart(); RefreshChart();

View File

@@ -34,6 +34,7 @@ namespace XCharts
protected Vector2 m_GraphMaxAnchor; protected Vector2 m_GraphMaxAnchor;
protected Vector2 m_GraphPivot; protected Vector2 m_GraphPivot;
protected Vector2 m_GraphSizeDelta; protected Vector2 m_GraphSizeDelta;
protected Vector2 m_GraphAnchoredPosition;
protected Rect m_GraphRect = new Rect(0, 0, 0, 0); protected Rect m_GraphRect = new Rect(0, 0, 0, 0);
protected bool m_RefreshChart = false; protected bool m_RefreshChart = false;
protected bool m_ForceOpenRaycastTarget; protected bool m_ForceOpenRaycastTarget;
@@ -197,13 +198,12 @@ namespace XCharts
private void InitBackground() private void InitBackground()
{ {
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, m_GraphSizeDelta);
m_Background.gameObject = backgroundObj;
m_Background.painter = m_Painter; m_Background.painter = m_Painter;
m_Background.refreshComponent = delegate () m_Background.refreshComponent = delegate ()
{ {
if (backgroundObj == null) return; var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, m_GraphSizeDelta);
m_Background.gameObject = backgroundObj;
backgroundObj.hideFlags = chartHideFlags; backgroundObj.hideFlags = chartHideFlags;
var backgroundImage = ChartHelper.GetOrAddComponent<Image>(backgroundObj); var backgroundImage = ChartHelper.GetOrAddComponent<Image>(backgroundObj);
ChartHelper.UpdateRectTransform(backgroundObj, m_GraphMinAnchor, ChartHelper.UpdateRectTransform(backgroundObj, m_GraphMinAnchor,
@@ -235,8 +235,11 @@ namespace XCharts
Awake(); Awake();
} }
if (m_GraphWidth != currWidth || m_GraphHeight != currHeight || if (m_GraphWidth != currWidth
m_GraphMinAnchor != rectTransform.anchorMin || m_GraphMaxAnchor != rectTransform.anchorMax) || m_GraphHeight != currHeight
|| m_GraphMinAnchor != rectTransform.anchorMin
|| m_GraphMaxAnchor != rectTransform.anchorMax
|| m_GraphAnchoredPosition != rectTransform.anchoredPosition)
{ {
UpdateSize(); UpdateSize();
} }
@@ -255,6 +258,7 @@ namespace XCharts
m_GraphMaxAnchor = rectTransform.anchorMax; m_GraphMaxAnchor = rectTransform.anchorMax;
m_GraphMinAnchor = rectTransform.anchorMin; m_GraphMinAnchor = rectTransform.anchorMin;
m_GraphSizeDelta = rectTransform.sizeDelta; m_GraphSizeDelta = rectTransform.sizeDelta;
m_GraphAnchoredPosition = rectTransform.anchoredPosition;
rectTransform.pivot = LayerHelper.ResetChartPositionAndPivot(m_GraphMinAnchor, m_GraphMaxAnchor, rectTransform.pivot = LayerHelper.ResetChartPositionAndPivot(m_GraphMinAnchor, m_GraphMaxAnchor,
m_GraphWidth, m_GraphHeight, ref m_GraphX, ref m_GraphY); m_GraphWidth, m_GraphHeight, ref m_GraphX, ref m_GraphY);

View File

@@ -26,7 +26,6 @@ namespace XCharts
private float m_DataZoomLastStartIndex; private float m_DataZoomLastStartIndex;
private float m_DataZoomLastEndIndex; private float m_DataZoomLastEndIndex;
private bool m_CheckDataZoomLabel; private bool m_CheckDataZoomLabel;
private Dictionary<int, List<Serie>> m_StackSeries = new Dictionary<int, List<Serie>>();
protected override void InitComponent() protected override void InitComponent()
{ {
@@ -61,15 +60,6 @@ namespace XCharts
Awake(); Awake();
} }
#endif #endif
protected override void SetAllComponentDirty()
{
base.SetAllComponentDirty();
foreach (var dataZoom in m_DataZooms) dataZoom.SetAllDirty();
foreach (var visualMap in m_VisualMaps) visualMap.SetAllDirty();
foreach (var grid in m_Grids) grid.SetAllDirty();
foreach (var axis in m_XAxes) axis.SetAllDirty();
foreach (var axis in m_YAxes) axis.SetAllDirty();
}
private void RefreshSeriePainterByGridIndex(int gridIndex) private void RefreshSeriePainterByGridIndex(int gridIndex)
{ {
@@ -499,14 +489,13 @@ namespace XCharts
private void InitYAxis(int yAxisIndex, YAxis yAxis) private void InitYAxis(int yAxisIndex, YAxis yAxis)
{ {
string objName = ChartCached.GetYAxisName(yAxisIndex);
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
yAxis.gameObject = axisObj;
yAxis.painter = m_Painter; yAxis.painter = m_Painter;
yAxis.refreshComponent = delegate () yAxis.refreshComponent = delegate ()
{ {
if (axisObj == null) return; string objName = ChartCached.GetYAxisName(yAxisIndex);
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
yAxis.gameObject = axisObj;
yAxis.axisLabelTextList.Clear(); yAxis.axisLabelTextList.Clear();
axisObj.SetActive(yAxis.show && yAxis.axisLabel.show); axisObj.SetActive(yAxis.show && yAxis.axisLabel.show);
axisObj.hideFlags = chartHideFlags; axisObj.hideFlags = chartHideFlags;
@@ -610,14 +599,13 @@ namespace XCharts
private void InitXAxis(int xAxisIndex, XAxis xAxis) private void InitXAxis(int xAxisIndex, XAxis xAxis)
{ {
string objName = ChartCached.GetXAxisName(xAxisIndex);
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
xAxis.gameObject = axisObj;
xAxis.painter = m_Painter; xAxis.painter = m_Painter;
xAxis.refreshComponent = delegate () xAxis.refreshComponent = delegate ()
{ {
if (axisObj == null) return; string objName = ChartCached.GetXAxisName(xAxisIndex);
var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin,
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
xAxis.gameObject = axisObj;
xAxis.axisLabelTextList.Clear(); xAxis.axisLabelTextList.Clear();
axisObj.SetActive(xAxis.show && xAxis.axisLabel.show); axisObj.SetActive(xAxis.show && xAxis.axisLabel.show);
axisObj.hideFlags = chartHideFlags; axisObj.hideFlags = chartHideFlags;
@@ -716,13 +704,12 @@ namespace XCharts
{ {
var dataZoom = m_DataZooms[i]; var dataZoom = m_DataZooms[i];
dataZoom.index = i; dataZoom.index = i;
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + i, transform, graphAnchorMin,
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
dataZoom.gameObject = dataZoomObject;
dataZoom.painter = m_PainterTop; dataZoom.painter = m_PainterTop;
dataZoom.refreshComponent = delegate () dataZoom.refreshComponent = delegate ()
{ {
if (dataZoomObject == null) return; var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + i, transform, graphAnchorMin,
graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
dataZoom.gameObject = dataZoomObject;
dataZoomObject.hideFlags = chartHideFlags; dataZoomObject.hideFlags = chartHideFlags;
ChartHelper.HideAllObject(dataZoomObject); ChartHelper.HideAllObject(dataZoomObject);
var startLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "start", dataZoomObject.transform, var startLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "start", dataZoomObject.transform,
@@ -1381,7 +1368,8 @@ namespace XCharts
private void CheckRaycastTarget() private void CheckRaycastTarget()
{ {
var ray = dataZoom.enable || (visualMap.enable && visualMap.show && visualMap.calculable); var ray = (dataZoom != null && dataZoom.enable)
|| (visualMap != null && visualMap.enable && visualMap.show && visualMap.calculable);
if (raycastTarget != ray) if (raycastTarget != ray)
{ {
raycastTarget = ray; raycastTarget = ray;
@@ -1390,7 +1378,7 @@ namespace XCharts
private void CheckDataZoom() private void CheckDataZoom()
{ {
if (!dataZoom.enable) return; if (dataZoom == null || !dataZoom.enable) return;
CheckDataZoomScale(); CheckDataZoomScale();
CheckDataZoomLabel(); CheckDataZoomLabel();
} }

View File

@@ -18,7 +18,7 @@ namespace XCharts
protected void CheckVisualMap() protected void CheckVisualMap()
{ {
if (!visualMap.enable || !visualMap.show) return; if (visualMap == null || !visualMap.enable || !visualMap.show) return;
Vector2 local; Vector2 local;
if (canvas == null) return; if (canvas == null) return;
@@ -120,6 +120,8 @@ namespace XCharts
if (serie.animation.HasFadeOut()) return; if (serie.animation.HasFadeOut()) return;
var yAxis = m_YAxes[serie.yAxisIndex]; var yAxis = m_YAxes[serie.yAxisIndex];
var xAxis = m_XAxes[serie.xAxisIndex]; var xAxis = m_XAxes[serie.xAxisIndex];
xAxis.boundaryGap = true;
yAxis.boundaryGap = true;
var grid = GetSerieGridOrDefault(serie); var grid = GetSerieGridOrDefault(serie);
var xCount = xAxis.data.Count; var xCount = xAxis.data.Count;
var yCount = yAxis.data.Count; var yCount = yAxis.data.Count;
@@ -153,9 +155,11 @@ namespace XCharts
serie.dataPoints.Add(Vector3.zero); serie.dataPoints.Add(Vector3.zero);
continue; continue;
} }
var value = serieData.GetCurrData(dimension, dataChangeDuration, yAxis.inverse, yAxis.runtimeMinValue, yAxis.runtimeMaxValue); var value = serieData.GetCurrData(dimension, dataChangeDuration, yAxis.inverse,
yAxis.runtimeMinValue, yAxis.runtimeMaxValue);
if (serieData.IsDataChanged()) dataChanging = true; if (serieData.IsDataChanged()) dataChanging = true;
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth, zeroY + (j + 0.5f) * yWidth); var pos = new Vector3(zeroX + (i + (xAxis.boundaryGap ? 0.5f : 0)) * xWidth,
zeroY + (j + (yAxis.boundaryGap ? 0.5f : 0)) * yWidth);
serie.dataPoints.Add(pos); serie.dataPoints.Add(pos);
serieData.canShowLabel = false; serieData.canShowLabel = false;
if (value == 0) continue; if (value == 0) continue;
@@ -171,7 +175,9 @@ namespace XCharts
} }
if (animationIndex >= 0 && i > animationIndex) continue; if (animationIndex >= 0 && i > animationIndex) continue;
serieData.canShowLabel = true; serieData.canShowLabel = true;
var emphasis = (tooltip.show && i == (int)tooltip.runtimeXValues[0] && j == (int)tooltip.runtimeYValues[0]) var emphasis = (tooltip.show
&& i == (int)tooltip.runtimeXValues[0]
&& j == (int)tooltip.runtimeYValues[0])
|| visualMap.runtimeSelectedIndex > 0; || visualMap.runtimeSelectedIndex > 0;
var rectWid = xWidth - 2 * borderWidth; var rectWid = xWidth - 2 * borderWidth;
var rectHig = yWidth - 2 * borderWidth; var rectHig = yWidth - 2 * borderWidth;
@@ -180,10 +186,12 @@ namespace XCharts
{ {
UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor); UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor);
} }
if (visualMap.hoverLink && emphasis && serie.emphasis.show && serie.emphasis.itemStyle.borderWidth > 0) if (visualMap.hoverLink && emphasis && serie.emphasis.show
&& serie.emphasis.itemStyle.borderWidth > 0)
{ {
var emphasisBorderWidth = serie.emphasis.itemStyle.borderWidth; var emphasisBorderWidth = serie.emphasis.itemStyle.borderWidth;
var emphasisBorderColor = serie.emphasis.itemStyle.opacity > 0 ? serie.emphasis.itemStyle.borderColor : ChartConst.clearColor32; var emphasisBorderColor = serie.emphasis.itemStyle.opacity > 0
? serie.emphasis.itemStyle.borderColor : ChartConst.clearColor32;
UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor); UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor);
} }
} }

View File

@@ -18,7 +18,6 @@ namespace XCharts
public BaseChart chart; public BaseChart chart;
private const string INDICATOR_TEXT = "indicator"; private const string INDICATOR_TEXT = "indicator";
private bool m_IsEnterLegendButtom; private bool m_IsEnterLegendButtom;
private bool m_RadarsDirty;
Dictionary<string, int> serieNameSet = new Dictionary<string, int>(); Dictionary<string, int> serieNameSet = new Dictionary<string, int>();
public DrawSerieRadar(BaseChart chart) public DrawSerieRadar(BaseChart chart)
@@ -28,26 +27,11 @@ namespace XCharts
public void InitComponent() public void InitComponent()
{ {
InitIndicator(); InitRadars();
} }
public void CheckComponent() public void CheckComponent()
{ {
var anyDirty = IsAnyRadarDirty();
if (m_RadarsDirty || anyDirty)
{
InitIndicator();
chart.RefreshBasePainter();
chart.tooltip.UpdateToTop();
if (anyDirty)
{
foreach (var radar in chart.radars)
{
radar.ClearDirty();
}
}
m_RadarsDirty = false;
}
} }
public void Update() public void Update()
@@ -244,22 +228,31 @@ namespace XCharts
{ {
} }
private void InitIndicator() private void InitRadars()
{ {
ChartHelper.HideAllObject(chart.transform, INDICATOR_TEXT);
for (int n = 0; n < chart.radars.Count; n++) for (int n = 0; n < chart.radars.Count; n++)
{ {
Radar radar = chart.radars[n]; Radar radar = chart.radars[n];
radar.index = n;
InitRadar(radar);
}
}
private void InitRadar(Radar radar)
{
float txtWid = 100;
float txtHig = 20;
radar.painter = chart.GetPainter(radar.index);
radar.refreshComponent = delegate ()
{
ChartHelper.HideAllObject(chart.transform, INDICATOR_TEXT + "_" + radar.index);
radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight); radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
int indicatorNum = radar.indicatorList.Count; for (int i = 0; i < radar.indicatorList.Count; i++)
float txtWid = 100;
float txtHig = 20;
for (int i = 0; i < indicatorNum; i++)
{ {
var indicator = radar.indicatorList[i]; var indicator = radar.indicatorList[i];
var pos = radar.GetIndicatorPosition(i); var pos = radar.GetIndicatorPosition(i);
var textStyle = indicator.textStyle; var textStyle = indicator.textStyle;
var objName = INDICATOR_TEXT + "_" + n + "_" + i; var objName = INDICATOR_TEXT + "_" + radar.index + "_" + i;
var txt = ChartHelper.AddTextObject(objName, chart.transform, new Vector2(0.5f, 0.5f), var txt = ChartHelper.AddTextObject(objName, chart.transform, new Vector2(0.5f, 0.5f),
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(txtWid, txtHig), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(txtWid, txtHig),
textStyle, chart.theme.radar); textStyle, chart.theme.radar);
@@ -270,7 +263,9 @@ namespace XCharts
var offset = new Vector3(textStyle.offset.x, textStyle.offset.y); var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset); AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
} }
} chart.RefreshBasePainter();
};
radar.refreshComponent?.Invoke();
} }
private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i) private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i)

View File

@@ -228,7 +228,6 @@ namespace XCharts
labelRadius = serie.runtimeOutsideRadius + serieLabel.lineLength1; labelRadius = serie.runtimeOutsideRadius + serieLabel.lineLength1;
labelCenter = new Vector2(serie.runtimeCenterPos.x + labelRadius * Mathf.Sin(currRad), labelCenter = new Vector2(serie.runtimeCenterPos.x + labelRadius * Mathf.Sin(currRad),
serie.runtimeCenterPos.y + labelRadius * Mathf.Cos(currRad)); serie.runtimeCenterPos.y + labelRadius * Mathf.Cos(currRad));
float labelWidth = serieData.labelObject.label.GetPreferredWidth();
serieData.labelPosition = labelCenter; serieData.labelPosition = labelCenter;
} }
break; break;

View File

@@ -106,7 +106,7 @@ namespace XCharts
public static void InitRadarTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, Radar radar, public static void InitRadarTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, Radar radar,
ChartTheme theme) ChartTheme theme)
{ {
if(radar == null) return; if (radar == null) return;
if (!serie.show) return; if (!serie.show) return;
if (tooltip.runtimeGridIndex >= 0) return; if (tooltip.runtimeGridIndex >= 0) return;
if (serie.radarIndex != radar.index) return; if (serie.radarIndex != radar.index) return;
@@ -206,7 +206,7 @@ namespace XCharts
.Append(ChartCached.FloatToStr(yValue, numericFormatter)).Append("]"); .Append(ChartCached.FloatToStr(yValue, numericFormatter)).Append("]");
} }
} }
else else if (!isIngore || (isIngore && tooltip.ignoreDataShow))
{ {
var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent : var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent :
ChartCached.FloatToStr(yValue, numericFormatter); ChartCached.FloatToStr(yValue, numericFormatter);

View File

@@ -100,7 +100,6 @@ namespace XCharts
public static void DrawLineStyle(VertexHelper vh, LineStyle.Type lineType, float lineWidth, public static void DrawLineStyle(VertexHelper vh, LineStyle.Type lineType, float lineWidth,
Vector3 startPos, Vector3 endPos, Color32 color) Vector3 startPos, Vector3 endPos, Color32 color)
{ {
var type = lineType;
switch (lineType) switch (lineType)
{ {
case LineStyle.Type.Dashed: case LineStyle.Type.Dashed:

View File

@@ -1,7 +1,6 @@
{ {
"name": "XCharts.Runtime", "name": "XCharts.Runtime",
"references": [ "references": [
"Unity.TextMeshPro"
], ],
"optionalUnityReferences": [], "optionalUnityReferences": [],
"includePlatforms": [], "includePlatforms": [],

View File

@@ -35,8 +35,8 @@ namespace XCharts
[ExecuteInEditMode] [ExecuteInEditMode]
public class XChartsMgr : MonoBehaviour public class XChartsMgr : MonoBehaviour
{ {
internal static string _version = "2.0.0"; internal static string _version = "2.0.1";
internal static int _versionDate = 20210205; internal static int _versionDate = 20210226;
public static string version { get { return _version; } } public static string version { get { return _version; } }
public static int versionDate { get { return _versionDate; } } public static int versionDate { get { return _versionDate; } }
public static string fullVersion { get { return version + "-" + versionDate; } } public static string fullVersion { get { return version + "-" + versionDate; } }

View File

@@ -12,7 +12,6 @@ namespace XCharts
public class XChartsPackageResourceImporter public class XChartsPackageResourceImporter
{ {
bool m_EssentialResourcesImported; bool m_EssentialResourcesImported;
bool m_ExamplesAndExtrasResourcesImported;
public XChartsPackageResourceImporter() { } public XChartsPackageResourceImporter() { }
@@ -23,7 +22,6 @@ namespace XCharts
public void OnGUI() public void OnGUI()
{ {
m_EssentialResourcesImported = File.Exists("Assets/XCharts/Resources/XChartsSettings.asset"); m_EssentialResourcesImported = File.Exists("Assets/XCharts/Resources/XChartsSettings.asset");
m_ExamplesAndExtrasResourcesImported = Directory.Exists("Assets/XCharts/Examples & Extras");
GUILayout.BeginVertical(); GUILayout.BeginVertical();
{ {

View File

@@ -14,7 +14,10 @@ using TMPro;
namespace XCharts namespace XCharts
{ {
[Serializable] [Serializable]
#if UNITY_2018_3
[ExcludeFromPresetAttribute] [ExcludeFromPresetAttribute]
#endif
public class XChartsSettings : ScriptableObject public class XChartsSettings : ScriptableObject
{ {

View File

@@ -1,9 +1,9 @@
{ {
"name": "com.monitor1394.xcharts", "name": "com.monitor1394.xcharts",
"displayName": "XCharts", "displayName": "XCharts",
"version": "2.0.0", "version": "2.0.1",
"date": "20210205", "date": "20210226",
"checkdate": "20210205", "checkdate": "20210226",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!", "desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"unity": "2018.3", "unity": "2018.3",
"description": "A charting and data visualization library for Unity.", "description": "A charting and data visualization library for Unity.",

View File

@@ -1,7 +1,7 @@
{ {
"version": "2.0.0", "version": "2.0.1",
"date": "20210205", "date": "20210226",
"checkdate": "20210205", "checkdate": "20210226",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!", "desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts" "homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 KiB

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 632 KiB

After

Width:  |  Height:  |  Size: 1014 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

After

Width:  |  Height:  |  Size: 446 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 KiB

After

Width:  |  Height:  |  Size: 571 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 307 KiB