diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 1604a648..b3f6472b 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -75,6 +75,7 @@ slug: /changelog ## master +* (2024.07.29) 修复`Tooltip`在微信小游戏平台上报错的兼容问题 (#326) * (2024.07.27) 调整`Axis`的`AxisName`的默认位置 * (2024.07.22) 优化`Pie`的`Label`在`Tooltip`触发时的表现 * (2024.07.21) 修复`Tooltip`在开启`DataZoom`时指示内容不准确的问题 diff --git a/Runtime/Internal/Utilities/ChartCached.cs b/Runtime/Internal/Utilities/ChartCached.cs index cda8bbb8..1a07f332 100644 --- a/Runtime/Internal/Utilities/ChartCached.cs +++ b/Runtime/Internal/Utilities/ChartCached.cs @@ -12,7 +12,7 @@ namespace XCharts.Runtime private const string NUMERIC_FORMATTER_X = "X"; private const string NUMERIC_FORMATTER_x = "x"; private static readonly string s_DefaultAxis = "axis_"; - private static CultureInfo ci = new CultureInfo("en-us"); // "en-us", "zh-cn", "ar-iq", "de-de" + private static CultureInfo ci = GetDefaultCultureInfo(); // "en-us", "zh-cn", "ar-iq", "de-de" private static Dictionary s_ColorToStr = new Dictionary(100); private static Dictionary s_SerieLabelName = new Dictionary(1000); private static Dictionary s_ColorDotStr = new Dictionary(100); @@ -24,6 +24,18 @@ namespace XCharts.Runtime private static Dictionary> s_PrecisionToStr = new Dictionary>(); private static Dictionary> s_StringIntDict = new Dictionary>(); + private static CultureInfo GetDefaultCultureInfo() + { + try + { + return new CultureInfo("en-us"); + } + catch (Exception) + { + return CultureInfo.InvariantCulture; + } + } + public static string FloatToStr(double value, string numericFormatter = "F", int precision = 0) { if (precision > 0 && numericFormatter.Length == 1)