diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a29b300..158b152e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 更新日志 +* (2019.12.06) 修复数据过小时`AxisLabel`直接科学计数法显示的问题 * (2019.12.04) 优化和完善数据更新`UpdateData`接口 * (2019.12.03) 增加圆环饼图的圆角支持,参数:`serie.arcShaped` * (2019.12.03) 增加数据更新动画,参数:`serie.animation.updateAnimation` diff --git a/Runtime/Component/Sub/AxisLabel.cs b/Runtime/Component/Sub/AxisLabel.cs index 1fbd86a4..408f7ffc 100644 --- a/Runtime/Component/Sub/AxisLabel.cs +++ b/Runtime/Component/Sub/AxisLabel.cs @@ -154,7 +154,8 @@ namespace XCharts { int minAcc = ChartHelper.GetFloatAccuracy(minValue); int maxAcc = ChartHelper.GetFloatAccuracy(maxValue); - int acc = Mathf.Max(minAcc, maxAcc); + int curAcc = ChartHelper.GetFloatAccuracy(value); + int acc = Mathf.Max(Mathf.Max(minAcc, maxAcc), curAcc); return ChartCached.FloatToStr(value, acc, m_ForceENotation); } else if (value - (int)value == 0) @@ -181,7 +182,9 @@ namespace XCharts content = content.Replace("\\n", "\n"); content = content.Replace("
", "\n"); return content; - } else { + } + else + { return value.ToString(m_Formatter); } } diff --git a/Runtime/Component/Sub/SerieAnimation.cs b/Runtime/Component/Sub/SerieAnimation.cs index 49d2f2e4..4a6b95a4 100644 --- a/Runtime/Component/Sub/SerieAnimation.cs +++ b/Runtime/Component/Sub/SerieAnimation.cs @@ -26,7 +26,7 @@ namespace XCharts [SerializeField] private float m_Duration = 1000; [SerializeField] private int m_Threshold = 2000; [SerializeField] private float m_Delay = 0; - [SerializeField] private bool m_UpdateAnimation = false; + [SerializeField] private bool m_UpdateAnimation = true; [SerializeField] private float m_UpdateDuration = 500; [SerializeField] private float m_ActualDuration; diff --git a/Runtime/Utility/ChartCached.cs b/Runtime/Utility/ChartCached.cs index 45e53098..abb63300 100644 --- a/Runtime/Utility/ChartCached.cs +++ b/Runtime/Utility/ChartCached.cs @@ -41,9 +41,9 @@ namespace XCharts } else { - if (f == 0) valueDic[value] = forceE ? value.ToString("E") : value.ToString(); - else if (f == 1) valueDic[value] = value.ToString("f1"); - else if (f == 2) valueDic[value] = value.ToString("f2"); + if (f == 0) valueDic[value] = forceE ? value.ToString("E0") : value.ToString(); + else if (f == 1) valueDic[value] = forceE ? value.ToString("E1") : value.ToString("f1"); + else if (f == 2) valueDic[value] = forceE ? value.ToString("E2") : value.ToString("f2"); else valueDic[value] = (f > 3 || forceE) ? value.ToString("E0") : value.ToString(GetFn(f)); return valueDic[value]; } @@ -103,9 +103,9 @@ namespace XCharts } } - internal static string GetAxisLabelName(string prefix, bool isYAxis,int axisIndex, int i) + internal static string GetAxisLabelName(string prefix, bool isYAxis, int axisIndex, int i) { - int key = (isYAxis?2:1) * 1000000 + (axisIndex+1) * 100000 + i; + int key = (isYAxis ? 2 : 1) * 1000000 + (axisIndex + 1) * 100000 + i; if (s_AxisLabelName.ContainsKey(key)) { return s_AxisLabelName[key]; diff --git a/Runtime/Utility/ChartHelper.cs b/Runtime/Utility/ChartHelper.cs index 08b1a7c9..0e791c45 100644 --- a/Runtime/Utility/ChartHelper.cs +++ b/Runtime/Utility/ChartHelper.cs @@ -513,7 +513,8 @@ namespace XCharts count++; intvalue = (int)(value * Mathf.Pow(10, count)); } - return count; + if (count == 12 && (value == 0 || value == 1)) return 1; + else return count; } public static void AddEventListener(GameObject obj, EventTriggerType type,