diff --git a/CHANGELOG.md b/CHANGELOG.md index 09d18cd9..bf99696c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -275,7 +275,7 @@ ## v1.6.0 * (2020.08.24) 发布`v1.6.0`版本 -* (2020.08.23) 重构代码,将与绘制相关的`Color`改为`Color32`,减少隐式转换(更新后会导致自定义的颜色丢失,可参考[问答29](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Documentation/XChartsFQA-ZH.md)进行升级) +* (2020.08.23) 重构代码,将与绘制相关的`Color`改为`Color32`,减少隐式转换(更新后会导致自定义的颜色丢失,可参考[问答29](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Documentation/XChartsFAQ-ZH.md)进行升级) * (2020.08.15) 优化`PieChart`绘制表现效果#85 * (2020.08.11) 增加`LiquidChart`数据变更动画#83 * (2020.08.11) 优化`PieChart`文本堆叠和引线效果#85 diff --git a/Documentation/CHANGELOG-EN.md b/Documentation/CHANGELOG-EN.md index bf95f773..e0912c16 100644 --- a/Documentation/CHANGELOG-EN.md +++ b/Documentation/CHANGELOG-EN.md @@ -215,7 +215,7 @@ Since the data type is upgraded to `double`, the implicit conversion of `float` ## v1.6.0 * (2020.08.24) Release `v1.6.0` version -* (2020.08.23) Refactor code, replace `Color` with `Color32` for reduce implicit conversion (Can cause custom colors to lose, reference [Q&A 29](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Documentation/XChartsFQA-ZH.md) to upgrade) +* (2020.08.23) Refactor code, replace `Color` with `Color32` for reduce implicit conversion (Can cause custom colors to lose, reference [FAQ 29](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Documentation/XChartsFAQ-ZH.md) to upgrade) * (2020.08.15) Optimized `PieChart` drawing performance effect #85 * (2020.08.11) Added `LiquidChart` data change animation#83 * (2020.08.11) Optimized `PieChart` text stack and lead line effects#85 diff --git a/Documentation/XChartsAPI-EN.md b/Documentation/XChartsAPI-EN.md index 75de6e7d..3b1e988e 100644 --- a/Documentation/XChartsAPI-EN.md +++ b/Documentation/XChartsAPI-EN.md @@ -2,7 +2,7 @@ [XCharts Homepage](https://github.com/XCharts-Team/XCharts)
[XCharts Configuration](XChartsConfiguration-EN.md)
-[XCharts Q&A](XChartsFQA-EN.md) +[XCharts FAQ](XChartsFAQ-EN.md) ## Class @@ -999,4 +999,4 @@ Inherits or Implemented: [UnityEditor.EditorWindow](#UnityEditor.EditorWindow) [XCharts Homepage](https://github.com/XCharts-Team/XCharts)
[XCharts Configuration](XChartsConfiguration-EN.md)
-[XCharts Q&A](XChartsFQA-EN.md) +[XCharts FAQ](XChartsFAQ-EN.md) diff --git a/Documentation/XChartsAPI-ZH.md b/Documentation/XChartsAPI-ZH.md index 8ab149de..e2fbc615 100644 --- a/Documentation/XChartsAPI-ZH.md +++ b/Documentation/XChartsAPI-ZH.md @@ -2,7 +2,7 @@ [XCharts主页](https://github.com/XCharts-Team/XCharts)
[XCharts配置项手册](XChartsConfiguration-ZH.md)
-[XCharts问答](XChartsFQA-ZH.md) +[XCharts问答](XChartsFAQ-ZH.md) ## Class @@ -999,4 +999,4 @@ Inherits or Implemented: [UnityEditor.EditorWindow](#UnityEditor.EditorWindow) [XCharts主页](https://github.com/XCharts-Team/XCharts)
[XCharts配置项手册](XChartsConfiguration-ZH.md)
-[XCharts问答](XChartsFQA-ZH.md) +[XCharts问答](XChartsFAQ-ZH.md) diff --git a/Documentation/XChartsConfiguration-EN.md b/Documentation/XChartsConfiguration-EN.md index 7ea8afec..e5c24c5e 100644 --- a/Documentation/XChartsConfiguration-EN.md +++ b/Documentation/XChartsConfiguration-EN.md @@ -2,7 +2,7 @@ [XCharts Homepage](https://github.com/XCharts-Team/XCharts)
[XCharts API](XChartsAPI-EN.md)
-[XCharts Q&A](XChartsFQA-EN.md) +[XCharts FAQ](XChartsFAQ-EN.md) ## Serie @@ -1416,4 +1416,4 @@ The x axis in cartesian(rectangular) coordinate. [XCharts Homepage](https://github.com/XCharts-Team/XCharts)
[XCharts API](XChartsAPI-EN.md)
-[XCharts Q&A](XChartsFQA-EN.md) +[XCharts FAQ](XChartsFAQ-EN.md) diff --git a/Documentation/XChartsConfiguration-ZH.md b/Documentation/XChartsConfiguration-ZH.md index c65f363a..ac84d545 100644 --- a/Documentation/XChartsConfiguration-ZH.md +++ b/Documentation/XChartsConfiguration-ZH.md @@ -2,7 +2,7 @@ [XCharts主页](https://github.com/XCharts-Team/XCharts)
[XChartsAPI接口](XChartsAPI-ZH.md)
-[XCharts问答](XChartsFQA-ZH.md) +[XCharts问答](XChartsFAQ-ZH.md) ## Serie 系列 @@ -1416,4 +1416,4 @@ Inherits or Implemented: [Axis](#Axis) [XCharts主页](https://github.com/XCharts-Team/XCharts)
[XChartsAPI接口](XChartsAPI-ZH.md)
-[XCharts问答](XChartsFQA-ZH.md) +[XCharts问答](XChartsFAQ-ZH.md) diff --git a/Documentation/XChartsFQA-EN.md b/Documentation/XChartsFAQ-EN.md similarity index 99% rename from Documentation/XChartsFQA-EN.md rename to Documentation/XChartsFAQ-EN.md index c037e7c1..a2ac762d 100644 --- a/Documentation/XChartsFQA-EN.md +++ b/Documentation/XChartsFAQ-EN.md @@ -1,4 +1,4 @@ -# XCharts Q&A +# XCharts FAQ [XCharts Homepage](https://github.com/XCharts-Team/XCharts)
[XCharts API](XChartsAPI-EN.md)
diff --git a/Documentation/XChartsFQA-EN.md.meta b/Documentation/XChartsFAQ-EN.md.meta similarity index 75% rename from Documentation/XChartsFQA-EN.md.meta rename to Documentation/XChartsFAQ-EN.md.meta index 712177c0..64743196 100644 --- a/Documentation/XChartsFQA-EN.md.meta +++ b/Documentation/XChartsFAQ-EN.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2929481916a9540ed9ecc270be6a3b0e +guid: e803ae0ae73794ec6891fed7551fe01d TextScriptImporter: externalObjects: {} userData: diff --git a/Documentation/XChartsFQA-ZH.md b/Documentation/XChartsFAQ-ZH.md similarity index 100% rename from Documentation/XChartsFQA-ZH.md rename to Documentation/XChartsFAQ-ZH.md diff --git a/Documentation/XChartsFQA-ZH.md.meta b/Documentation/XChartsFAQ-ZH.md.meta similarity index 75% rename from Documentation/XChartsFQA-ZH.md.meta rename to Documentation/XChartsFAQ-ZH.md.meta index 4fc853b7..57f60358 100644 --- a/Documentation/XChartsFQA-ZH.md.meta +++ b/Documentation/XChartsFAQ-ZH.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f2d61cadf902a4e20a2690f3c7d2ceea +guid: 4df833a2a1e6c4a7da37a08379dd2e18 TextScriptImporter: externalObjects: {} userData: diff --git a/Documentation/XChartsTutorial01-EN.md b/Documentation/XChartsTutorial01-EN.md index 7168929a..cd456c12 100644 --- a/Documentation/XChartsTutorial01-EN.md +++ b/Documentation/XChartsTutorial01-EN.md @@ -1,7 +1,7 @@ # 教程:5分钟上手 XCharts 3.0 [XCharts主页](https://github.com/XCharts-Team/XCharts)
-[XCharts问答](XChartsFQA-ZH.md)
+[XCharts问答](XChartsFAQ-ZH.md)
[XChartsAPI接口](XChartsAPI-ZH.md)
[XCharts配置项手册](XChartsConfiguration-ZH.md) @@ -226,6 +226,6 @@ itemStyle.color = Color.blue; ``` [XCharts主页](https://github.com/XCharts-Team/XCharts)
-[XCharts问答](XChartsFQA-ZH.md)
+[XCharts问答](XChartsFAQ-ZH.md)
[XChartsAPI接口](XChartsAPI-ZH.md)
[XCharts配置项手册](XChartsConfiguration-ZH.md) diff --git a/Documentation/XChartsTutorial01-ZH.md b/Documentation/XChartsTutorial01-ZH.md index 7168929a..cd456c12 100644 --- a/Documentation/XChartsTutorial01-ZH.md +++ b/Documentation/XChartsTutorial01-ZH.md @@ -1,7 +1,7 @@ # 教程:5分钟上手 XCharts 3.0 [XCharts主页](https://github.com/XCharts-Team/XCharts)
-[XCharts问答](XChartsFQA-ZH.md)
+[XCharts问答](XChartsFAQ-ZH.md)
[XChartsAPI接口](XChartsAPI-ZH.md)
[XCharts配置项手册](XChartsConfiguration-ZH.md) @@ -226,6 +226,6 @@ itemStyle.color = Color.blue; ``` [XCharts主页](https://github.com/XCharts-Team/XCharts)
-[XCharts问答](XChartsFQA-ZH.md)
+[XCharts问答](XChartsFAQ-ZH.md)
[XChartsAPI接口](XChartsAPI-ZH.md)
[XCharts配置项手册](XChartsConfiguration-ZH.md) diff --git a/Editor/Utilities/ThemeCheck.cs b/Editor/Utilities/ThemeCheck.cs index 5cd282e0..d9c33055 100644 --- a/Editor/Utilities/ThemeCheck.cs +++ b/Editor/Utilities/ThemeCheck.cs @@ -43,6 +43,7 @@ namespace XCharts.Editor public static void CheckDeletedAsset(string assetPath) { if (!IsThemeAsset(assetPath)) return; + if (XCSettings.Instance == null) return; var themes = XCSettings.customThemes; var changed = false; diff --git a/README.md b/README.md index d7946c1a..001fd90d 100644 --- a/README.md +++ b/README.md @@ -47,48 +47,55 @@ [XCharts3.0 教程](Documentation/XChartsTutorial01-ZH.md) [XCharts3.0 API](Documentation/XChartsAPI-ZH.md) -[XCharts3.0 问答](Documentation/XChartsFQA-ZH.md) +[XCharts3.0 问答](Documentation/XChartsFAQ-ZH.md) [XCharts3.0 配置项手册](Documentation/XChartsConfiguration-ZH.md) [XCharts3.0 更新日志](CHANGELOG.md) ## 特性 -* 参数可视化配置,效果实时预览,纯代码绘制,无需额外资源。 -* 支持折线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等十种常见免费内置图表。 -* 支持3D柱图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图等多种付费扩展图表。 -* 支持直线图、曲线图、面积图、阶梯线图等折线图。 -* 支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图等柱状图。 -* 支持环形图、玫瑰图等饼图。 -* 支持内置图表的任意组合,同一图表中可同时显示多个相同或不同类型的图表。 -* 支持实线、曲线、阶梯线、虚线、点线、点划线、双点划线等线条。 -* 支持主题定制、导入和导出,内置两种默认主题。 -* 支持自定义图表内容绘制,提供绘制点、直线、曲线、三角形、四边形、圆形、环形、扇形、边框、箭头等强大的绘图API。 -* 支持PC端和手机端上的数据筛选、视图缩放、细节展示等交互操作。 -* 支持万级大数据绘制。 -* 支持`TexMeshPro`。 +- 参数可视化配置,效果实时预览,纯代码绘制,无需额外资源。 +- 支持折线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等十种常见免费内置图表。 +- 支持3D柱图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图等多种付费扩展图表。 +- 支持直线图、曲线图、面积图、阶梯线图等折线图。 +- 支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图等柱状图。 +- 支持环形图、玫瑰图等饼图。 +- 支持内置图表的任意组合,同一图表中可同时显示多个相同或不同类型的图表。 +- 支持实线、曲线、阶梯线、虚线、点线、点划线、双点划线等线条。 +- 支持主题定制、导入和导出,内置两种默认主题。 +- 支持自定义图表内容绘制,提供绘制点、直线、曲线、三角形、四边形、圆形、环形、扇形、边框、箭头等强大的绘图API。 +- 支持PC端和手机端上的数据筛选、视图缩放、细节展示等交互操作。 +- 支持万级大数据绘制。 +- 支持`TexMeshPro`。 -## XCharts3.0 比 2.0 的改进 +## XCharts3.0 相比XCharts2.0 的改进 -* 更健壮的底层框架。 -* 更小的序列化文件。 -* 更强大的性能。 -* 更好的交互体验。 -* 更多的组件支持。 -* 更合理的组件调整。 -* 更灵活的组件插拔。 -* 更方便的二次开发。 -* 更丰富的Demo示例。 +- 更健壮的底层框架。 +- 更小的序列化文件。 +- 更强大的性能。 +- 更好的交互体验。 +- 更多的组件支持。 +- 更合理的组件调整。 +- 更灵活的组件插拔。 +- 更方便的二次开发。 +- 更丰富的Demo示例。 ## XCharts3.0 新功能 -* 增加Time时间轴。 -* 增加SingleAxis单轴。 -* 增加多种坐标系:Grid、Polar、Radar、SingleAxis。 -* 增加多种动画方式。 -* 增加多种图表交互。 -* 增加国际化支持。 -* 增加Widgets小组件。 -* 增加多种扩展图表。 +- 增加Time时间轴。 +- 增加SingleAxis单轴。 +- 增加多种坐标系:Grid、Polar、Radar、SingleAxis。 +- 增加多种动画方式。 +- 增加多种图表交互。 +- 增加国际化支持。 +- 增加Widgets小组件。 +- 增加多种扩展图表。 + +## 注意 + +- XCharts3.0 不兼容 XCharts2.0 版本,建议旧项目还是继续使用XCharts2.0,新项目使用XCharts3.0。 +- XCharts2.0 进入维护阶段,后续只修复严重bug理论上不再加新功能。 +- XCharts 理论上支持Unity 5.6及以上版本,但由于版本测试有限难免疏漏,发现版本兼容问题可提Issue。 +- XCharts 内置图表都为常见的图表,可以免费使用;扩展图表大部分为不常使用的图表,有需要的可付费获取,感谢对XCharts的支持。 ## 截图 @@ -102,6 +109,8 @@ [XCharts教程:5分钟上手教程](Documentation/XChartsTutorial01-ZH.md) + + ## 日志 [更新日志](CHANGELOG.md) diff --git a/Runtime/Internal/XCResourcesImporter.cs b/Runtime/Internal/XCResourcesImporter.cs index 77b6d67e..7ce0b980 100644 --- a/Runtime/Internal/XCResourcesImporter.cs +++ b/Runtime/Internal/XCResourcesImporter.cs @@ -21,8 +21,7 @@ namespace XCharts.Runtime public void OnGUI() { - m_EssentialResourcesImported = Resources.Load("XCSettings") != null || - XCSettings.ExistAssetFile(); + m_EssentialResourcesImported = Resources.Load("XCSettings") != null; GUILayout.BeginVertical(); { @@ -33,15 +32,19 @@ namespace XCharts.Runtime GUILayout.Space(5f); GUI.enabled = !m_EssentialResourcesImported; + GUI.enabled = true; if (GUILayout.Button("Import XCharts Essentials")) { - string packageFullPath = GetPackageFullPath(); - var sourPath = Path.Combine(packageFullPath, "Resources"); - var destPath = Path.Combine(Application.dataPath, "XCharts/Resources"); - if (RuntimeUtil.CopyFolder(sourPath, destPath)) + string packageFullPath = XChartsMgr.GetPackageFullPath(); + if (packageFullPath != null) { - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); + var sourPath = Path.Combine(packageFullPath, "Resources"); + var destPath = Path.Combine(Application.dataPath, "XCharts/Resources"); + if (RuntimeUtil.CopyFolder(sourPath, destPath)) + { + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + } } } GUILayout.Space(5f); @@ -75,55 +78,6 @@ namespace XCharts.Runtime AssetDatabase.importPackageCompleted -= ImportCallback; } - - static string GetPackageFullPath() - { - // Check for potential UPM package - string packagePath = Path.GetFullPath("Packages/com.monitor1394.xcharts"); - if (Directory.Exists(packagePath)) - { - return packagePath; - } - - packagePath = Path.GetFullPath("Assets/.."); - if (Directory.Exists(packagePath)) - { - // Search default location for development package - if (Directory.Exists(packagePath + "/Assets/Packages/com.monitor1394.xcharts/Resources")) - { - return packagePath + "/Assets/Packages/com.monitor1394.xcharts"; - } - - // Search for default location of normal XCharts AssetStore package - if (Directory.Exists(packagePath + "/Assets/XCharts/Resources")) - { - return packagePath + "/Assets/XCharts"; - } - - // Search for potential alternative locations in the user project - string[] matchingPaths = Directory.GetDirectories(packagePath, "XCharts", SearchOption.AllDirectories); - string path = ValidateLocation(matchingPaths, packagePath); - if (path != null) return packagePath + path; - } - - return null; - } - - static string ValidateLocation(string[] paths, string projectPath) - { - for (int i = 0; i < paths.Length; i++) - { - // Check if the Editor Resources folder exists. - if (Directory.Exists(paths[i] + "/Package Resources")) - { - string folderPath = paths[i].Replace(projectPath, ""); - folderPath = folderPath.TrimStart('\\', '/'); - return folderPath; - } - } - - return null; - } } public class XCResourceImporterWindow : UnityEditor.EditorWindow @@ -134,13 +88,16 @@ namespace XCharts.Runtime public static void ShowPackageImporterWindow() { - if (m_ImporterWindow == null) + var packagePath = XChartsMgr.GetPackageFullPath(); + if (packagePath != null) { - m_ImporterWindow = GetWindow(); - m_ImporterWindow.titleContent = new GUIContent("XCharts Importer"); + if (m_ImporterWindow == null) + { + m_ImporterWindow = GetWindow(); + m_ImporterWindow.titleContent = new GUIContent("XCharts Importer"); + } + m_ImporterWindow.Focus(); } - - m_ImporterWindow.Focus(); } void OnEnable() diff --git a/Runtime/Internal/XCSettings.cs b/Runtime/Internal/XCSettings.cs index ebb5178d..3ca47865 100644 --- a/Runtime/Internal/XCSettings.cs +++ b/Runtime/Internal/XCSettings.cs @@ -2,6 +2,7 @@ using UnityEngine; using System; using System.Collections.Generic; +using System.IO; #if dUI_TextMeshPro using TMPro; #endif @@ -129,8 +130,11 @@ namespace XCharts.Runtime #if UNITY_EDITOR if (s_Instance == null) { - if (!ExistAssetFile()) + var assetPath = GetSettingAssetPath(); + if (string.IsNullOrEmpty(assetPath)) XCResourceImporterWindow.ShowPackageImporterWindow(); + else + s_Instance = AssetDatabase.LoadAssetAtPath(assetPath); } else { @@ -156,6 +160,32 @@ namespace XCharts.Runtime return System.IO.File.Exists("Assets/XCharts/Resources/XCSettings.asset"); } + public static string GetSettingAssetPath() + { + var path = "Assets/XCharts/Resources/XCSettings.asset"; + if (File.Exists(path)) return path; + var dir = Application.dataPath; + string[] matchingPaths = Directory.GetDirectories(dir); + foreach (var match in matchingPaths) + { + if (match.Contains("XCharts")) + { + var jsonPath = string.Format("{0}/package.json", match); + if (File.Exists(jsonPath)) + { + var jsonText = File.ReadAllText(jsonPath); + if (jsonText.Contains("\"displayName\": \"XCharts\"")) + { + path = string.Format("{0}/Resources/XCSettings.asset", match); + if (File.Exists(path)) + return path.Substring(path.IndexOf("/Assets/") + 1); + } + } + } + } + return null; + } + public static bool AddCustomTheme(Theme theme) { if (theme == null) return false; diff --git a/Runtime/Internal/XChartsMgr.cs b/Runtime/Internal/XChartsMgr.cs index 059436d5..69484edc 100644 --- a/Runtime/Internal/XChartsMgr.cs +++ b/Runtime/Internal/XChartsMgr.cs @@ -109,24 +109,20 @@ namespace XCharts.Runtime packagePath = Path.GetFullPath("Assets/.."); if (Directory.Exists(packagePath)) { - // Search default location for development package - if (File.Exists(packagePath + "/Assets/Packages/com.monitor1394.xcharts/package.json")) + if (File.Exists(packagePath + "/Assets/Packages/XCharts/package.json")) { - return packagePath + "/Assets/Packages/com.monitor1394.xcharts"; + return packagePath + "/Assets/Packages/XCharts"; } - // Search for default location of normal XCharts AssetStore package if (File.Exists(packagePath + "/Assets/XCharts/package.json")) { return packagePath + "/Assets/XCharts"; } - // Search for potential alternative locations in the user project string[] matchingPaths = Directory.GetDirectories(packagePath, "XCharts", SearchOption.AllDirectories); string path = ValidateLocation(matchingPaths, packagePath); if (path != null) return Path.Combine(packagePath, path); } - return null; } @@ -141,7 +137,6 @@ namespace XCharts.Runtime return folderPath; } } - return null; }