From 5fb86e4e5bce1986a8b9b9e30598239051e77564 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 24 Sep 2020 09:36:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=B9=E6=95=B0=E8=BD=B4lo?= =?UTF-8?q?gBase=E8=AE=BE=E7=BD=AE=E4=B8=BA0=E6=97=B6=E4=BC=9A=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/PropertyDrawers/AxisDrawer.cs | 6 ++++++ Runtime/Component/Main/Axis.cs | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Editor/PropertyDrawers/AxisDrawer.cs b/Editor/PropertyDrawers/AxisDrawer.cs index eaa80b80..8107432c 100644 --- a/Editor/PropertyDrawers/AxisDrawer.cs +++ b/Editor/PropertyDrawers/AxisDrawer.cs @@ -66,7 +66,13 @@ namespace XCharts { EditorGUI.PropertyField(drawRect, m_LogBaseE); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(drawRect, m_LogBase); + if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1) + { + m_LogBase.floatValue = 10; + } + EditorGUI.EndChangeCheck(); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } if (type == Axis.AxisType.Value) diff --git a/Runtime/Component/Main/Axis.cs b/Runtime/Component/Main/Axis.cs index 18bd4c56..aac96e45 100644 --- a/Runtime/Component/Main/Axis.cs +++ b/Runtime/Component/Main/Axis.cs @@ -169,7 +169,11 @@ namespace XCharts public float logBase { get { return m_LogBase; } - set { if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty(); } + set + { + if (value <= 0 || value == 1) value = 10; + if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty(); + } } /// /// On the log axis, if base e is the natural number, and is true, logBase fails. @@ -745,7 +749,7 @@ namespace XCharts public float GetLogValue(float value) { - if (value <= 0) return 0; + if (value <= 0 || value == 1) return 0; return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase); }