Compare commits

...

136 Commits

Author SHA1 Message Date
monitor1394
b9c72c8cb9 Merge branch 'master' into 3.0 2025-01-01 23:13:07 +08:00
monitor1394
3db02b86b4 3.13.0 2025-01-01 22:52:48 +08:00
monitor1394
151ed168b5 3.13.0 2025-01-01 20:15:29 +08:00
monitor1394
be6a91b4c2 3.13.0 2024-12-31 08:44:57 +08:00
monitor1394
43de03951c 增加SymbolStylesize2参数支持长方形标记 2024-12-28 21:03:17 +08:00
monitor1394
21cd72b995 优化DrawBackground接口 2024-12-27 22:13:35 +08:00
monitor1394
d466ac2bc1 优化TextTextMeshPro下的居中对齐方式 2024-12-26 10:05:20 +08:00
monitor1394
6e9d9bfd3d 增加TooltipitemFormatter设置{f0}支持 2024-12-25 21:39:13 +08:00
monitor1394
d1438dd76f 修复YAxis在范围变更刷新时部分label可能不显示的问题 2024-12-25 16:30:25 +08:00
monitor1394
074c1a3992 增加UISlider扩展组件 2024-12-25 10:06:53 +08:00
monitor1394
5d24580725 增加SymbolStyleborderWidthemptyColor配置 2024-12-23 21:31:27 +08:00
monitor1394
301c66eccf 增加拖拽点击判断 2024-12-23 21:29:39 +08:00
monitor1394
2fc87d03cd 增加UISlider扩展组件 2024-12-17 22:19:22 +08:00
monitor1394
33b71dc711 增加UIToggle扩展组件 2024-12-10 08:49:41 +08:00
monitor1394
f5ec47c105 修复Chart节点下不能放自定义节点的问题 2024-12-07 22:21:55 +08:00
monitor1394
2e604529ee 处理Unity版本兼容问题 2024-12-04 09:18:38 +08:00
monitor1394
333dfb8e37 增加UIText扩展组件 2024-12-04 08:19:40 +08:00
monitor1394
7eddebd660 删除TextStyle的无用配置项tmpAlignment 2024-12-04 08:19:08 +08:00
monitor1394
d76b474a61 Merge branch 'master' into 3.0 2024-12-01 22:20:39 +08:00
monitor1394
19744ec124 3.12.1 2024-12-01 10:22:23 +08:00
monitor1394
1bdb756ad1 修复Tooltip在图表设置其他锚点时手机上显示位置异常的问题 2024-11-30 23:48:53 +08:00
monitor1394
bc1a11c4e3 修复Tooltip在图表设置其他锚点时手机上显示位置异常的问题 2024-11-30 23:45:28 +08:00
monitor1394
6c42fe6399 优化性能 2024-11-27 23:24:09 +08:00
monitor1394
ad77a79308 修复Unity6的一些代码警告问题 2024-11-27 22:28:47 +08:00
monitor1394
d5647a448d 修复Tooltip在特殊情况下可能会超出屏幕显示不完整的问题 2024-11-26 23:18:49 +08:00
monitor1394
756df47fe3 修复UITable在拖拽时也会点选的问题 2024-11-25 08:39:48 +08:00
monitor1394
1dd31f747e 修复Time时间轴在开启Animation时动态变更效果异常的问题 2024-11-22 22:10:12 +08:00
monitor1394
6568595abb 优化Line在数据点过密时有更好的绘制效果 2024-11-18 23:14:51 +08:00
monitor1394
61fb717d20 修复Animation无法通过代码开启的问题 (#334) 2024-11-16 17:22:40 +08:00
monitor1394
0a923400b2 修复Animation无法通过代码开启的问题 2024-11-16 17:18:06 +08:00
monitor1394
7fb0765c6c 修复DataZoom的start和end在代码动态修改时图表不刷新的问题 2024-11-13 08:40:56 +08:00
monitor1394
e6c68be728 更新文档 2024-11-05 22:17:23 +08:00
monitor1394
fdc7b41e8e 修复Title设置隐藏后运行还显示的问题 2024-11-05 08:28:57 +08:00
monitor1394
45972a4cd9 更新文档 2024-11-01 08:22:36 +08:00
monitor1394
d0d25b0221 更新文档 2024-10-31 23:28:46 +08:00
monitor1394
143a037761 更新文档 2024-10-28 22:25:14 +08:00
monitor1394
dc254fb722 更新文档 2024-10-21 08:44:16 +08:00
monitor1394
b0d6bea256 更新文档 2024-10-19 23:23:38 +08:00
monitor1394
4f38b59288 3.12.0 2024-10-01 22:59:59 +08:00
monitor1394
2acb841d2e Merge branch 'master' into 3.0 2024-09-30 18:35:24 +08:00
monitor1394
ad3a8f9ad8 3.12.0 2024-09-30 18:12:57 +08:00
monitor1394
8c1dc44e1e 3.11.2 2024-09-30 18:04:46 +08:00
monitor1394
25a06afb50 3.11.2 2024-09-30 17:42:55 +08:00
monitor1394
df4223421f 完善教程 2024-09-27 19:08:25 +08:00
monitor1394
f9b1eadd40 完善Legendformatter对多Serie的支持 (#332) 2024-09-24 18:28:21 +08:00
monitor1394
c61ad794a7 调整文档显示样式 2024-09-24 18:26:45 +08:00
monitor1394
3b6ce91c65 调整文档显示样式 2024-09-22 09:54:11 +08:00
monitor1394
c2a19ee47b 调整文档显示样式 2024-09-21 13:31:16 +08:00
monitor1394
768cf8d404 增加numericFormatterdatetime的支持 2024-09-11 08:12:14 +08:00
monitor1394
9a98d6a5df 完善AreaStyleorigin参数设置区域填充起始位置 2024-09-03 08:41:09 +08:00
monitor1394
e40e19c197 增加RingradiusGradient参数设置渐变方向 2024-08-31 22:22:33 +08:00
monitor1394
59cd12d0eb 优化Axis为时间轴时首个Label的位置 2024-08-31 22:22:16 +08:00
monitor1394
e7978cbc30 3.11.2 2024-07-31 22:52:33 +08:00
monitor1394
10a36e0295 3.11.2 2024-07-31 22:43:35 +08:00
monitor1394
5853376a44 修复Tooltip在微信小游戏平台上报错的兼容问题 (#326) 2024-07-29 22:51:02 +08:00
monitor1394
1bb9b455b4 调整AxisAxisName的默认位置 2024-07-27 23:06:02 +08:00
monitor1394
de4f650e4f 优化Axis的轴动画在初始化时关闭 2024-07-27 11:34:13 +08:00
monitor1394
feb5e7fc32 优化Axis的轴动画在初始化时关闭 2024-07-25 23:26:30 +08:00
monitor1394
378fccf8b4 优化PieLabelTooltip触发时的表现 2024-07-22 22:58:27 +08:00
monitor1394
9e1dd027e9 修复Tooltip在开启DataZoom时指示内容不准确的问题 2024-07-21 15:13:08 +08:00
monitor1394
71ecebb466 优化AxisTime时间轴时的分割效果 2024-07-20 22:21:22 +08:00
monitor1394
4903ac53f0 优化AxisTime时间轴时的分割效果 2024-07-20 21:02:24 +08:00
monitor1394
35e8f3e902 修复MarkLineLabel在初始化时可能会闪烁的问题 2024-07-17 23:16:22 +08:00
monitor1394
d5fbd33534 优化AxisTime时间轴时的Tooltip默认效果 2024-07-16 23:03:31 +08:00
monitor1394
c458846990 优化AxisTime时间轴的splitNumber为0时的表现 2024-07-14 15:23:13 +08:00
monitor1394
e3098e6e16 优化AxisTime时间轴的滚动表现 2024-07-14 15:07:26 +08:00
monitor1394
b22288eac4 优化Label显示体验 2024-07-12 21:22:53 +08:00
monitor1394
99d824e3a0 修复Label在初始化时会堆积的问题 2024-07-12 19:53:30 +08:00
monitor1394
6d41daa678 修复Label在初始化时会堆积的问题 2024-07-12 08:48:01 +08:00
monitor1394
cdac6acd8c 修复Label在初始化时会堆积的问题 2024-07-09 23:16:08 +08:00
monitor1394
94d1398bd3 修复Chart在动态创建时背景没有自适应的问题 (#323) 2024-07-06 11:33:47 +08:00
monitor1394
e2c7779493 3.11.1 2024-07-01 08:24:02 +08:00
monitor1394
9e95b8daa7 修复Serie有多个时颜色异常的问题 2024-07-01 08:15:08 +08:00
monitor1394
6d16a9c16a 修复Label在初始化时会堆积的问题 2024-06-23 22:03:09 +08:00
monitor1394
8af1796ff8 Merge branch 'master' into 3.0 2024-06-16 22:08:09 +08:00
monitor1394
3b7e8184b0 3.11.0 2024-06-16 21:59:31 +08:00
monitor1394
33b7e5c1a4 3.11.0 2024-06-16 19:21:25 +08:00
monitor1394
24270e5c69 3.11.0 2024-06-16 19:05:40 +08:00
monitor1394
e3fb5685bf 增加EditorData的添加、删除、上下移动操作按钮 2024-06-15 13:21:38 +08:00
monitor1394
89e7a09e64 增加Edge判断接口 2024-06-13 23:04:35 +08:00
monitor1394
ee5efa9f8d 增加DrawEdge绘制由上下坐标列表组成的边 2024-06-13 22:59:37 +08:00
monitor1394
2fe9a40f42 3.11.0-preview2 2024-06-11 08:28:46 +08:00
monitor1394
ddbd82bebf 修复AxisIndicatorLabel可能会遮挡住Tooltip的问题 2024-06-11 08:14:34 +08:00
monitor1394
549ee43a37 修复TooltipCrossAxisIndicatorLabel可能不显示的问题 (#315) 2024-06-11 08:11:27 +08:00
monitor1394
3b9af0f8ec 调整TooltipCorss重命名为Cross 2024-06-10 22:42:20 +08:00
monitor1394
caee79630b 增加Axism_MinCategorySpacing设置类目轴默认的最小类目间距 2024-06-09 22:59:38 +08:00
monitor1394
a12c98b1a5 修复TooltipCross在开启DataZoom时指示位置不准确的问题 2024-06-09 22:13:26 +08:00
monitor1394
8617475808 优化一个Chart里有多个Serie时的Tooltip显示问题 2024-06-08 13:24:24 +08:00
monitor1394
922901380e 修复SerieClone时动画异常问题 (#320) 2024-06-06 13:07:34 +08:00
monitor1394
96cb7ffc74 修复Seriestate在代码动态设置时不刷新的问题 2024-06-04 08:40:43 +08:00
monitor1394
74cf4fe4ce 优化坐标轴Tick最小间距 2024-06-03 08:13:17 +08:00
monitor1394
eb948f03d5 完善关系图初始化 2024-06-03 08:12:32 +08:00
monitor1394
6a6ab72ed8 调整XChartsHierarchy视图下的右键菜单到UI/XCharts 2024-05-29 21:58:31 +08:00
monitor1394
df66f5c7ee 增加3D坐标系显示边框参数 2024-05-29 13:14:21 +08:00
monitor1394
042f9d3c01 增加3D坐标系对类目轴的支持 2024-05-29 08:33:00 +08:00
monitor1394
1e6140a138 3.11.0-preview1 2024-05-20 08:33:09 +08:00
monitor1394
86125c597e 优化Editor下编辑性能 2024-05-19 11:02:03 +08:00
monitor1394
fc346d30fb 优化第三方数据导入 2024-05-19 11:01:46 +08:00
monitor1394
3e8bf7caee 优化Line3D绘制 2024-05-15 13:19:34 +08:00
monitor1394
4e3182edfc 增加JsonUtil工具类 2024-05-09 13:13:51 +08:00
monitor1394
b86cae6717 Merge pull request #311 from stefanbursuc/fix-gc-allocations-in-tooltiphandler
Fix for GC Allocations inside TooltipHandler
2024-05-01 22:22:04 +08:00
monitor1394
0c92d08f0d 修复ConvertXYAxis()多次调用后图表异常的问题 2024-04-23 22:16:28 +08:00
monitor1394
b1522a27d4 修复DataZoom控制多个轴时的GridCoord获取可能不正确的问题 (#317) 2024-04-22 22:35:39 +08:00
monitor1394
120c6d5408 增加GridCoord3D3D坐标系 2024-04-22 22:25:12 +08:00
monitor1394
e2120b3da6 优化DateTimeUtil时间戳转DateTime接口时区的问题 2024-04-16 22:30:04 +08:00
monitor1394
58e6108bb2 优化GridCoord在开启GridLayout时也显示Left Right Top Bottom参数 (#316) 2024-04-15 08:18:12 +08:00
monitor1394
3ef2e7c23c 修复TooltipCross在开启DataZoom的情况下label位置不正确的问题 (#315) 2024-04-14 19:09:08 +08:00
monitor1394
a361e191da 修复Candlesticks效果不对的问题 (#313) 2024-04-12 08:30:34 +08:00
Stefan Bursuc
f5a41b5119 Fix for GC Allocations inside TooltipHandler
In the case where the pointer is not in the chart, both calls to
ListPool<Serie>.Get() from inside the function UpdateTooltipData
are executed.

And because the pointer is not in the chart, m_ShowTooltip is set to
false in the last else clause.

This makes UpdateTooltip to skip all logic and miss the chance to release
the list back to the pool.
2024-04-08 11:24:28 +02:00
monitor1394
42079848dc 优化桑吉图折叠显示 2024-03-20 22:23:58 +08:00
monitor1394
4b8374b1ae 修复Pie在设置ItemStyleopacity时颜色不对的问题 (#309) 2024-03-20 13:36:31 +08:00
monitor1394
0990b11c1c 增加TooltiptriggerOn指定触发条件 2024-03-20 13:34:21 +08:00
monitor1394
99b1624b54 增加数据图的折叠和展开支持 2024-03-20 08:31:05 +08:00
monitor1394
78a07aa2ae 修复Pie在设置ItemStyleopacity时颜色不对的问题 (#309) 2024-03-19 22:33:19 +08:00
monitor1394
fe867d18e6 Merge branch 'master' into 3.0 2024-03-19 22:03:31 +08:00
monitor1394
113c3887ae 3.10.2 2024-03-11 08:12:28 +08:00
monitor1394
9f5040435f 修复Tooltip移出坐标系后还显示的问题 2024-03-11 08:04:07 +08:00
monitor1394
f21e9c6a32 修复Legendformatter在设置{d}通配符时显示可能不匹配的问题 (#304) 2024-03-11 08:04:00 +08:00
monitor1394
a071956675 修复Legendformatter在设置{d}通配符时显示可能不匹配的问题 2024-03-11 08:03:53 +08:00
monitor1394
eab4f9530b 修复Tooltiptitle从旧版本升级后可能不显示的问题 2024-03-11 08:03:48 +08:00
monitor1394
757ccb04fb 修复Tooltip移出坐标系后还显示的问题 2024-03-11 08:00:40 +08:00
monitor1394
b4cb62241f 修复Legendformatter在设置{d}通配符时显示可能不匹配的问题 (#304) 2024-03-11 07:01:22 +08:00
monitor1394
0fb1cab302 修复Legendformatter在设置{d}通配符时显示可能不匹配的问题 2024-03-11 07:00:31 +08:00
monitor1394
ead9034870 修复Tooltiptitle从旧版本升级后可能不显示的问题 2024-03-08 08:39:06 +08:00
monitor1394
20c87265a5 Merge branch 'master' into 3.0 2024-02-23 08:34:58 +08:00
monitor1394
1e31cf3010 Merge branch 'master' into 3.0 2023-12-01 22:22:51 +08:00
monitor1394
d33e2f66ef Merge branch 'master' into 3.0 2023-10-02 12:12:58 +08:00
monitor1394
ff4fbb2176 Merge branch 'master' into 3.0 2023-09-04 22:43:48 +08:00
monitor1394
9fc3ff862f Merge branch 'master' into 3.0 2023-06-09 08:05:20 +08:00
monitor1394
bc31f86fcf Merge branch 'master' into 3.0 2023-04-01 23:16:34 +08:00
monitor1394
c6412f5d78 Merge branch 'master' into 3.0 2022-12-01 21:45:30 +08:00
monitor1394
0e60a26333 Merge branch 'master' into 3.0 2022-11-01 07:54:45 +08:00
monitor1394
59bb60950b Merge branch 'master' into 3.0 2022-09-28 08:25:06 +08:00
monitor1394
b3320bd2cd Merge branch 'master' into 3.0 2022-08-16 08:31:50 +08:00
monitor1394
71cfbc15f3 Merge branch 'master' into 3.0 2022-07-12 07:43:08 +08:00
monitor1394
8fbda1fa73 v3.0.1 2022-06-16 08:18:07 +08:00
152 changed files with 30054 additions and 7918 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,19 @@
---
sidebar_position: 61
slug: /changelog
---
# 更新日志 # Changelog
[master](#master) [master](#master)
[v3.13.0](#v3130)
[v3.12.1](#v3121)
[v3.12.0](#v3120)
[v3.11.2](#v3112)
[v3.11.1](#v3111)
[v3.11.0](#v3110)
[v3.10.2](#v3102)
[v3.10.1](#v3101)
[v3.10.0](#v3100) [v3.10.0](#v3100)
[v3.9.0](#v390) [v3.9.0](#v390)
[v3.8.1](#v381) [v3.8.1](#v381)
@@ -66,6 +78,140 @@
## master ## master
## v3.13.0
Key Features:
* Added the `UIText` extension component
* Added the `UIToggle` extension component
* Added the `UISlider` extension component
* Refactored the `UIProgress` extension component
* Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
* Added the `size2` parameter to `SymbolStyle` to support rectangular markers
* Other optimizations and bug fixes
Detailed Changelog:
* (2025.01.01) Released `v3.13.0`
* (2024.12.27) Added the `size2` parameter to `SymbolStyle` to support rectangular markers
* (2024.12.26) Optimized `Text` alignment in `TextMeshPro` for proper centering
* (2024.12.25) Added support for `{f0}` in the `Tooltip`'s `itemFormatter` setting
* (2024.12.25) Fixed an issue where some labels on the `YAxis` might not display during range refresh
* (2024.12.23) Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
* (2024.12.17) Added the `UISlider` extension component
* (2024.12.10) Added the `UIToggle` extension component
* (2024.12.09) Fixed an issue where the `UITable`'s `scrollbar` could not be dragged
* (2024.12.07) Fixed an issue where custom nodes could not be placed under the `Chart` node
* (2024.12.05) Added the `UIText` extension component
* (2024.12.04) Removed the unused `tmpAlignment` option from `TextStyle`
## v3.12.1
Version Highlights:
* Enhanced Chinese and English support for the official website documentation.
* Optimized the rendering performance of line charts when data points are densely packed.
* Other issue fixes.
Log Details:
* (2024.12.01) Released `v3.12.1` version.
* (2024.11.30) Fixed an issue where the `Tooltip` displayed incorrectly on mobile devices when setting other anchors in charts.
* (2024.11.27) Resolved some code warning issues in `Unity6`.
* (2024.11.26) Fixed a problem where the `Tooltip` might exceed the screen and appear incomplete under specific circumstances.
* (2024.11.24) Fixed an issue where `UITable` would also select items during dragging.
* (2024.11.22) Fixed an abnormal effect issue when dynamically changing the `Time` timeline with `Animation` enabled.
* (2024.11.18) Optimized `Line` rendering for better performance when data points are densely packed.
* (2024.11.16) Fixed an issue where `Animation` could not be enabled through code (#334).
* (2024.11.13) Fixed a problem where dynamically modifying the `start` and `end` of `DataZoom` through code did not refresh the chart.
* (2024.11.05) Fixed an issue where the `Title` remained visible after being set to hidden.
* (2024.11.01) Improved `website` documentation in both English and Chinese.
## v3.12.0
Version Highlights:
* Added `radiusGradient` parameter for `Ring` to set the gradient direction
* Added support for `date` and `time` in `numericFormatter`
* Improved `origin` parameter setting for `AreaStyle` to define the starting position of area filling
* Adjusted and perfected the documentation
* Other optimizations and fixes
Log Details:
* (2024.09.30) Released version `v3.12.0`
* (2024.09.27) Improved the `5-minute tutorial`
* (2024.09.24) Improved support for multiple Series in `Legend`'s `formatter` (#332)
* (2024.09.22) Adjusted the display style of the `Documentation`
* (2024.09.09) Added support for `date` and `time` in `numericFormatter`
* (2024.09.03) Improved the setting of the `origin` parameter for `AreaStyle` to define the starting position of area filling
* (2024.09.01) Added `radiusGradient` parameter for `Ring` to set the gradient direction
* (2024.09.01) Optimized the position of the first Label when `Axis` is used as a time axis
## v3.11.2
* (2024.08.01) Release `v3.11.2`
* (2024.07.29) Fixed compatibility issue with `Tooltip` reporting error on wechat mini game platform (#326)
* (2024.07.27) Adjust the default position of `AxisName` for `Axis`
* (2024.07.22) Improved the behavior of `Pie`'s `Label` when `Tooltip` is triggered
* (2024.07.21) Fix to `Tooltip` indicating inaccurate content when opening `DataZoom`
* (2024.07.17) Fixed an issue where `Label` of `MarkLine` could flash during initialization
* (2024.07.16) Optimized the default effect of `Tooltip` when `Axis` is `Time` timeline
* (2024.07.15) Optimized segmentation when Axis is Time
* (2024.07.14) Improved movement performance when `Axis` is `Time`
* (2024.07.12) Optimized the initial display effect of `Label`
* (2024.07.06) Fix to `Chart` background not adaptive when dynamically created (#323)
## v3.11.1
* (2024.07.01) Release `v3.11.1`
* (2024.07.01) Fixed an issue where `Serie` has multiple abnormal colors
* (2024.06.23) Fixed an issue where `labels` would pile up during initialization
## v3.11.0
Release Highlights:
* Added `Line3DChart` for 3D line charts
* Added `GraphChart` for relationship graphs
* Added support for 3D coordinate systems
* Added `triggerOn` setting for `Tooltip` to define trigger conditions
* Various bug fixes and optimizations
Changelog Details:
* (2024.06.16) Released version `v3.11.0`
* (2024.06.15) Added buttons for adding, deleting, and moving data up and down under `Editor`
* (2024.06.11) Fixed issue where `Axis`'s `IndicatorLabel` might overlap with `Tooltip`
* (2024.06.11) Fixed issue where `Tooltip`'s `Axis` `IndicatorLabel` might not display when in `Cross` mode (#315)
* (2024.06.10) Renamed `Tooltip`'s `Corss` to `Cross`
* (2024.06.09) Added `minCategorySpacing` setting for `Axis` to define the default minimum category spacing
* (2024.06.09) Fixed inaccurate indicator position of `Tooltip`'s `Cross` when `Axis` is a category axis and `DataZoom` is enabled
* (2024.06.06) Fixed animation issue when `Serie` is cloned (#320)
* (2024.06.04) Fixed issue where `Serie`'s `state` does not refresh when set dynamically via code
* (2024.05.29) Adjusted the right-click menu of `XCharts` in the `Hierarchy` view to `UI/XCharts`
* (2024.05.29) Added support for 3D coordinate systems to category axes
* (2024.05.19) Optimized editing performance in `Editor`
* (2024.05.09) Added utility class `JsonUtil`
* (2024.05.01) Fixed the issue where `Tooltip` caused garbage collection (GC) on every frame (#311) (by @stefanbursuc)
* (2024.04.23) Fixed chart exception issue after multiple calls to `ConvertXYAxis()`
* (2024.04.22) Fixed potential incorrect retrieval of `GridCoord` when `DataZoom` controls multiple axes (#317)
* (2024.04.22) Added 3D coordinate system
* (2024.04.15) Optimized `DateTimeUtil` for timezone issues when converting timestamps to `DateTime`
* (2024.04.15) Optimized `GridCoord` to display `Left` `Right` `Top` `Bottom` parameters even when `GridLayout` is enabled (#316)
* (2024.04.14) Fixed incorrect label position of `Tooltip`'s `Cross` when `DataZoom` is enabled (#315)
* (2024.04.12) Fixed incorrect effect of `Candlesticks` (#313)
* (2024.03.20) Added `triggerOn` setting for `Tooltip` to define trigger conditions
* (2024.03.19) Fixed color issue when setting `opacity` in `Pie`'s `ItemStyle` (#309)
## v3.10.2
* (2024.03.11) Release `v3.10.2`
* (2024.03.11) Fix to `Legend`'s `formatter` showing possible mismatches when setting `{d}` (#304)
* (2024.03.11) Fix to `Tooltip` still showing after moving out of coordinate system
* (2024.03.08) Fixed an issue where `Tooltip`'s title might not appear after upgrading from an older version
## v3.10.1 ## v3.10.1
* (2024.02.21) Release `v3.10.1` * (2024.02.21) Release `v3.10.1`
@@ -80,7 +226,7 @@ Highlights:
* Added chart border Settings to support rounded corner charts * Added chart border Settings to support rounded corner charts
* Fixed several issues * Fixed several issues
Extended features: Extension features:
* Added `SankeyChart` Sankey chart * Added `SankeyChart` Sankey chart
* Added `border` Settings for `UITable` * Added `border` Settings for `UITable`
@@ -121,7 +267,7 @@ Highlights:
* Perfect code comments and documentation * Perfect code comments and documentation
* Fixed several issues * Fixed several issues
Extended features: Extension features:
* `UITable` adds the carousel function * `UITable` adds the carousel function
* `UITable` adds data api and callback functions * `UITable` adds data api and callback functions
@@ -191,7 +337,7 @@ Log details:
* (2023.08.22) Fixed `Bar` display hidden drawing performance exception * (2023.08.22) Fixed `Bar` display hidden drawing performance exception
* (2023.08.22) Improved Zebra histogram rendering performance (#276) * (2023.08.22) Improved Zebra histogram rendering performance (#276)
* (2023.08.16) Added Daemon daemon to resolve an error after TMP is enabled locally * (2023.08.16) Added Daemon daemon to resolve an error after TMP is enabled locally
* (2023.08.15) Fixed `Data` displaying axes incorrectly when data is between -1 and 1 (#273) (by **Ambitroc**) * (2023.08.15) Fixed `Data` displaying axes incorrectly when data is between -1 and 1 (#273) (b y@Ambitroc)
* (2023.08.14) Fixed `XCharts` updating error after` TextMeshPro `and` NewInputSystem `are enabled locally (#272) * (2023.08.14) Fixed `XCharts` updating error after` TextMeshPro `and` NewInputSystem `are enabled locally (#272)
* (2023.08.12) Fixed `Chart` error when deleted at runtime (#269) * (2023.08.12) Fixed `Chart` error when deleted at runtime (#269)
* (2023.08.11) Fixed an issue where data could not be added when DataZoom was enabled * (2023.08.11) Fixed an issue where data could not be added when DataZoom was enabled
@@ -232,7 +378,7 @@ Log details:
* (2022.06.08) Release v3.7.0 * (2022.06.08) Release v3.7.0
* (2023.06.04) Added `HelpDoc` help document skip * (2023.06.04) Added `HelpDoc` help document skip
* (2023.05.30) Fixed Serie name with `_` line causing `Legend` to not fire (#252) (by **svr2kos2**) * (2023.05.30) Fixed Serie name with `_` line causing `Legend` to not fire (#252) (by @svr2kos2)
* (2023.05.10) Added `MinMaxAuto` range type for `Axis` * (2023.05.10) Added `MinMaxAuto` range type for `Axis`
* (2023.05.10) Added support for `Clip` for `Line` * (2023.05.10) Added support for `Clip` for `Line`
* (2023.05.04) Fixed `Axis` setting` CeilRate `not taking effect in range -1 to 1 * (2023.05.04) Fixed `Axis` setting` CeilRate `not taking effect in range -1 to 1
@@ -251,9 +397,9 @@ Log details:
* (2023.04.01) Release `v3.6.0` version * (2023.04.01) Release `v3.6.0` version
* (2023.03.14) Fix for Tooltip's `titleFormater` setting `{b}` may not take effect * (2023.03.14) Fix for Tooltip's `titleFormater` setting `{b}` may not take effect
* (2023.03.14) Fix for `BarChart` not drawing bar background when data is 0 (#250) (by **Ambitroc**) * (2023.03.14) Fix for `BarChart` not drawing bar background when data is 0 (#250) (by @Ambitroc)
* (2023.03.12) Added `LabelStyle` `autoRotate` to set automatic rotation of angled vertical text * (2023.03.12) Added `LabelStyle` `autoRotate` to set automatic rotation of angled vertical text
* (2023.03.10) Added `VR` and other non-mouse input for Point location acquisition (#248) (by **Ambitroc**) * (2023.03.10) Added `VR` and other non-mouse input for Point location acquisition (#248) (by @Ambitroc)
* (2023.03.09) Adds callbacks to Chart's `onSerieClick`, `onSerieDown`, `onSerieEnter` and `onSerieExit` * (2023.03.09) Adds callbacks to Chart's `onSerieClick`, `onSerieDown`, `onSerieEnter` and `onSerieExit`
* (2023.03.09) Fixed click-check offset for `Pie` not taking effect * (2023.03.09) Fixed click-check offset for `Pie` not taking effect
* (2023.03.04) Added Positions for Legend to customize legend positions * (2023.03.04) Added Positions for Legend to customize legend positions
@@ -267,7 +413,7 @@ Log details:
* (2023.02.02) Fixed bug where datazoom xaxis label could be displayed off-chart when datazoom is turned on * (2023.02.02) Fixed bug where datazoom xaxis label could be displayed off-chart when datazoom is turned on
* (2023.02.02) Optimizes the `ignore` setting of `SerieData` to ignore data * (2023.02.02) Optimizes the `ignore` setting of `SerieData` to ignore data
* (2023.02.01) Fix `XChartsMgr.ContainsChart()` interface exception * (2023.02.01) Fix `XChartsMgr.ContainsChart()` interface exception
* (2023.01.31) Added support for `InputSystem` (#242) (by **Bian-Sh**) * (2023.01.31) Added support for `InputSystem` (#242) (by @Bian-Sh)
* (2023.01.11) Fixed chart not refreshing after removing Component from Inspector (#241) * (2023.01.11) Fixed chart not refreshing after removing Component from Inspector (#241)
* (2023.01.06) Fixed bug with `Pie` displaying abnormal Label when the last few values are 0 (#240) * (2023.01.06) Fixed bug with `Pie` displaying abnormal Label when the last few values are 0 (#240)
* (2023.01.03) deletes serie `MarkColor` and adds ItemStyle `MarkColor` * (2023.01.03) deletes serie `MarkColor` and adds ItemStyle `MarkColor`
@@ -286,7 +432,7 @@ Log details:
Highlights: Highlights:
* Updated documentation structure, added [Official XCharts Homepage](https://xcharts-team.github.io) * Updated documentation structure, added [Official XCharts Homepage](https://xcharts-team.github.io/en)
* Added support for the DataZoom box selected. * Added support for the DataZoom box selected.
* Added support for maximum width Settings for bars. * Added support for maximum width Settings for bars.
* Other optimizations. * Other optimizations.
@@ -538,7 +684,7 @@ Details:
* (2022.03.20) Release `v2.7.0` version * (2022.03.20) Release `v2.7.0` version
* (2022.02.21) Fixed chart name repeat check error #183 * (2022.02.21) Fixed chart name repeat check error #183
* (2022.02.17) Fixed bug where axis split line might be displayed outside the coordinate system #181 * (2022.02.17) Fixed bug where axis split line might be displayed outside the coordinate system #181
* (2022.02.08) Fixed {d} formatter error when value is 0 * (2022.02.08) Fixed `{d}` formatter error when value is 0
* (2022.02.08) Fixed `YAxis` `AxisLabel`'s `onZero` does not work * (2022.02.08) Fixed `YAxis` `AxisLabel`'s `onZero` does not work
* (2022.01.06) Improved `Zebra` bar chart * (2022.01.06) Improved `Zebra` bar chart

File diff suppressed because it is too large Load Diff

View File

@@ -1,155 +1,127 @@
# XCharts FAQ ---
sidebar_position: 41
slug: /faq
---
[FAQ 1: How to adjust the margin between the axis and the background?](#how-to-adjust-the-margin-between-the-axis-and-the-background) # FAQ
[FAQ 2: How to play agian the fadeIn animation?](#how-to-play-agian-the-fadein-animation)
[FAQ 3: How to customize the color of data item in line chart and pie chart?](#how-to-customize-the-color-of-data-item-in-line-chart-and-pie-chart)
[FAQ 4: How to formatter the text of axis label, such as add a units text?](#how-to-formatter-the-text-of-axis-label-such-as-add-a-units-text)
[FAQ 5: How to stack the bar of bar chart](#how-to-stack-the-bar-of-bar-chart)
[FAQ 6: How to make the bar serie in the same bar but not stack?](#how-to-make-the-bar-serie-in-the-same-bar-but-not-stack)
[FAQ 7: How to adjust the bar width and gap of barchart?](#how-to-adjust-the-bar-width-and-gap-of-barchart)
[FAQ 8: How to adjust the color of bar?](#how-to-adjust-the-color-of-bar)
[FAQ 9: Can I adjust the anchor of chart?](#can-i-adjust-the-anchor-of-chart)
[FAQ 10: Can display more than 1000 data?](#can-display-more-than-1000-data)
[FAQ 11: Can line chart drawing be dash, dot and dash-dot?](#can-line-chart-drawing-be-dash-dot-and-dash-dot)
[FAQ 12: How to limit the value range of the Y-axis?](#how-to-limit-the-value-range-of-the-y-axis)
[FAQ 13: How to customize the tick value range of value axis?](#how-to-customize-the-tick-value-range-of-value-axis)
[FAQ 14: How to display text at the top of data items?](#how-to-display-text-at-the-top-of-data-items)
[FAQ 15: How do I customize icons for data items?](#how-do-i-customize-icons-for-data-items)
[FAQ 16: How to anti-aliasing and make the chart smoother?](#how-to-anti-aliasing-and-make-the-chart-smoother)
[FAQ 17: Why does mouse over chart Tooltip not show?](#why-does-mouse-over-chart-tooltip-not-show)
[FAQ 18: How not to display the bar line of Tooltip?](#how-not-to-display-the-bar-line-of-tooltip)
[FAQ 19: How do I customize the display of Tooltip?](#how-do-i-customize-the-display-of-tooltip)
[FAQ 20: How do I get the Y-axis to display multiple decimal places?](#how-do-i-get-the-y-axis-to-display-multiple-decimal-places)
[FAQ 21: How do I dynamically update data with code?](#how-do-i-dynamically-update-data-with-code)
[FAQ 22: How to display legend? Why are legends sometimes not displayed?](#how-to-display-legend-why-are-legends-sometimes-not-displayed)
[FAQ 23: How to make chart as prefab?](#how-to-make-chart-as-prefab)
[FAQ 24: How do I draw custom graphic in chart,such as line or dot?](#how-do-i-draw-custom-content-in-chart-such-as-line-or-dot)
[FAQ 25: How to achieve similar data movement effect of ELECTRO cardiogram?](#how-to-achieve-similar-data-movement-effect-of-electro-cardiogram)
[FAQ 26: How do I use the background component? What are the conditions?](#how-do-i-use-the-background-component-what-are-the-conditions)
[FAQ 27: Mesh can not have more than 65000 vertices?](#mesh-cannot-have-more-than-65000-vertices)
[FAQ 28: Why are the parameters set in Serie reset after they run?](#why-are-the-parameters-set-in-serie-reset-after-they-run)
[FAQ 29: How to change the color of serie symbol?](#how-to-change-the-color-of-serie-symbol)
[FAQ 30: How to deal with TMP errors when importing or updating XCharts?](#what-if-tmp-errors-occur-when-importing-or-updating-xcharts)
[FAQ 31: Support empty data? How to achieve the effect of line chart disconnection?](#support-empty-data-how-to-achieve-the-effect-of-line-chart-disconnection)
[FAQ 32: 2.x What are the common problems when upgrading version 3.x?](#what-are-the-common-problems-when-upgrading-xcharts2-to-xcharts3)
## how-to-adjust-the-margin-between-the-axis-and-the-background ## FAQ 1: How to adjust the margin between the axis and the background?
`Grid` conponentwhich can adjust the left, right, up, down margins of chart. `Grid` conponentwhich can adjust the left, right, up, down margins of chart.
## how-to-play-agian-the-fadein-animation ## FAQ 2: How to play agian the fadeIn animation?
call the `chart.AnimationReset()` API. call the `chart.AnimationReset()` API.
## how-to-customize-the-color-of-data-item-in-line chart-and-pie-chart ## FAQ 3: How to customize the color of data item in line chart and pie chart?
`Theme`->`colorPalette`, or the sub component `LineStyle` and `ItemStyle` of `Serie`. `Theme`->`colorPalette`, or the sub component `LineStyle` and `ItemStyle` of `Serie`.
## how-to-formatter-the-text-of-axis-label-such-as-add-a-units-text ## FAQ 4: How to formatter the text of axis label, such as add a units text?
Adjust `formatter` and `numericFormatter` parameter of `Legend`, `AxisLabel`, `Tooltop`, `SerieLabel`. Adjust `formatter` and `numericFormatter` parameter of `Legend`, `AxisLabel`, `Tooltop`, `SerieLabel`.
## how-to-stack-the-bar-of-bar-chart ## FAQ 5: How to stack the bar of bar chart?
Set the `stack` parameter of `Serie`, the series will stack in a bar with the same `stack`. Set the `stack` parameter of `Serie`, the series will stack in a bar with the same `stack`.
## how-to-make-the-bar-serie-in-the-same-bar-but-not-stack ## FAQ 6: How to make the bar serie in the same bar but not stack?
Set the `barGap` of `Serie` to `-1``stack` to null. Set the `barGap` of `Serie` to `-1``stack` to null.
## how-to-adjust-the-bar-width-and-gap-of-barchart ## FAQ 7: How to adjust the bar width and gap of barchart?
Adjust the `barWidth` and `barGap` parameter of `Serie`, the last `serie`'s `barWidth` and `barGap` are valid when multiple `serie`. Adjust the `barWidth` and `barGap` parameter of `Serie`, the last `serie`'s `barWidth` and `barGap` are valid when multiple `serie`.
## how-to-adjust-the-color-of-bar ## FAQ 8: How to adjust the color of bar?
Adjust the `ItemStyle` of `Data` in `inspector`. Adjust the `ItemStyle` of `Data` in `inspector`.
## can-i-adjust-the-anchor-of-chart ## FAQ 9: Can I adjust the anchor of chart?
Yes, you can set any one of 16 anchors but the value use default. Yes, you can set any one of 16 anchors but the value use default.
## can-display-more-than-1000-data ## FAQ 10: Can display more than 1000 data?
Yes. But `UGUI` limits `65000` vertices to a single `Graphic`, so too much data may not be displayed completely. The sampling simplification curve can be turned on by setting the sampling distance `sampleDist`. You can also set some parameters to reduce the number of vertices in the chart to help show more data. Such as reducing the size of the chart, close or reduce the axis of the client drawing, close `Symbol` and `Label` display. A `Normal` line chart occupies fewer vertices than a `Smooth` line chart. The `1.5.0` and above versions can set `large` and `largeThreshold` parameters to enable performance mode. Yes. But `UGUI` limits `65000` vertices to a single `Graphic`, so too much data may not be displayed completely. The sampling simplification curve can be turned on by setting the sampling distance `sampleDist`. You can also set some parameters to reduce the number of vertices in the chart to help show more data. Such as reducing the size of the chart, close or reduce the axis of the client drawing, close `Symbol` and `Label` display. A `Normal` line chart occupies fewer vertices than a `Smooth` line chart. The `1.5.0` and above versions can set `large` and `largeThreshold` parameters to enable performance mode.
## can-line-chart-drawing-be-dash-dot-and-dash-dot ## FAQ 11: Can line chart drawing be dash, dot and dash-dot?
Yes. Adjust the `lineType` of `Serie`. Yes. Adjust the `lineType` of `Serie`.
## how-to-limit-the-value-range-of-the-y-axis ## FAQ 12: How to limit the value range of the Y-axis?
Select the `minMaxType` of `Axis` as `Custom`, then set `min` and `max` to the values you want. Select the `minMaxType` of `Axis` as `Custom`, then set `min` and `max` to the values you want.
## how-to-customize-the-tick-value-range-of-value-axis ## FAQ 13: How to customize the tick value range of value axis?
By default, it is automatically split by the `splitNumber` of `Axis`. Also, you can customize the `interval` to the range you want. By default, it is automatically split by the `splitNumber` of `Axis`. Also, you can customize the `interval` to the range you want.
## how-to-display-text-at-the-top-of-data-items ## FAQ 14: How to display text at the top of data items?
Adjust the `Label` of `Serie`. Adjust the `Label` of `Serie`.
## how-do-i-customize-icons-for-data-items ## FAQ 15: How do I customize icons for data items?
Set the `Icon` of `Data` in `Serie`. Set the `Icon` of `Data` in `Serie`.
## how-to-anti-aliasing-and-make-the-chart-smoother ## FAQ 16: How to anti-aliasing and make the chart smoother?
Open the `Anti-Aliasing` setting in `Unity`. Selected the UI Canvas `Render Mode` as `Screen Space-Camera`, selected `MSAA`, set `4` times or higher anti-aliasing. The sawtooth can only be reduced and unavoidable. The higher the pixel, the less obvious the sawtooth is. Open the `Anti-Aliasing` setting in `Unity`. Selected the UI Canvas `Render Mode` as `Screen Space-Camera`, selected `MSAA`, set `4` times or higher anti-aliasing. The sawtooth can only be reduced and unavoidable. The higher the pixel, the less obvious the sawtooth is.
## why-does-mouse-over-chart-tooltip-not-show ## FAQ 17: Why does mouse over chart Tooltip not show?
Verify `Toolip` is opened. Verify that the parent node of chart has turned off mouse events. Verify `Toolip` is opened. Verify that the parent node of chart has turned off mouse events.
## how-not-to-display-the-bar-line-of-tooltip ## FAQ 18: How not to display the bar line of Tooltip?
Set the `type` of `Tooltup` as `None`. Or adjust the parameters of `lineStyle`. Set the `type` of `Tooltup` as `None`. Or adjust the parameters of `lineStyle`.
## how-do-i-customize-the-display-of-tooltip ## FAQ 19: How do I customize the display of Tooltip?
See the `formatter`, `itemFormatter`, `titleFormatter` parameters of `Tooltip`. See the `formatter`, `itemFormatter`, `titleFormatter` parameters of `Tooltip`.
## how-do-i-get-the-y-axis-to-display-multiple-decimal-places ## FAQ 20: How do I get the Y-axis to display multiple decimal places?
Set the `numericFormatter` parameter of `AxisLabel`. Set the `numericFormatter` parameter of `AxisLabel`.
## how-do-i-dynamically-update-data-with-code ## FAQ 21: How do I dynamically update data with code?
See example: `Example01_UpdateData.cs` See example: `Example01_UpdateData.cs`
## how-to-display-legend-why-are-legends-sometimes-not-displayed ## FAQ 22: How to display legend? Why are legends sometimes not displayed?
First, the `name` in `Serie` must have a value that is not null. Then set `Legend` is `show`, where `data` can be empty by default, indicating that all legends are displayed. If you only want to display part of the `Serie` legend, fill in `data` with the `name` of the legend you want to display. If none of the values in `data` are `name` of the series, the legend will not be displayed. First, the `name` in `Serie` must have a value that is not null. Then set `Legend` is `show`, where `data` can be empty by default, indicating that all legends are displayed. If you only want to display part of the `Serie` legend, fill in `data` with the `name` of the legend you want to display. If none of the values in `data` are `name` of the series, the legend will not be displayed.
## how-to-make-chart-as-prefab ## FAQ 23: How to make chart as prefab?
Before make prefab, please delete all sub gameObject under chart which auto-created by `XCharts`. Before make prefab, please delete all sub gameObject under chart which auto-created by `XCharts`.
## how-do-i-draw-custom-content-in-chart-such-as-line-or-dot ## FAQ 24: How do I draw custom graphic in chart,such as line or dot?
Implement `onCustomDraw` of chart, see `Example12_CustomDrawing.cs`. Implement `onCustomDraw` of chart, see `Example12_CustomDrawing.cs`.
## how-to-achieve-similar-data-movement-effect-of-electro-cardiogram ## FAQ 25: How to achieve similar data movement effect of ELECTRO cardiogram?
See `Example_Dynamic.cs`. See `Example_Dynamic.cs`.
## how-do-i-use-the-background-component-what-are-the-conditions ## FAQ 26: How do I use the background component? What are the conditions?
Setting `show` to `true` for the `background` component. Setting `show` to `true` for the `background` component.
## mesh-cannot-have-more-than-65000-vertices ## FAQ 27: Mesh can not have more than 65000 vertices?
This is the limit of `UGUI` on the number of vertices for a single `Graphic`. `XCharts` is draw chart on a single `Graphic`, so there is also this limitation. The solution can be referred to: [FAQ 10: Can display more than 1000 data](#can-display-more-than-1000-data) This is the limit of `UGUI` on the number of vertices for a single `Graphic`. `XCharts` is draw chart on a single `Graphic`, so there is also this limitation. The solution can be referred to: [FAQ 10: Can display more than 1000 data?](#FAQ-10-can-display-more-than-1000-data)
## why-are-the-parameters-set-in-serie-reset-after-they-run ## FAQ 28: Why are the parameters set in Serie reset after they run?
Check whether `RemoveData()` and add new `Serie` in the code. If you want to keep the configuration of `Serie`, you can only `ClearData()` which just clear data and then readd the data to the old serie. Check whether `RemoveData()` and add new `Serie` in the code. If you want to keep the configuration of `Serie`, you can only `ClearData()` which just clear data and then readd the data to the old serie.
## how-to-change-the-color-of-serie-symbol ## FAQ 29: How to change the color of serie symbol?
The color of 'Symbol' is the color of 'ItemStyle' used. The color of 'Symbol' is the color of 'ItemStyle' used.
## what-if-tmp-errors-occur-when-importing-or-updating-xcharts ## FAQ 30: How to deal with TMP errors when importing or updating XCharts?
XCharts does not enable TMP by default, so there are no references to TMP on asmdef. This issue may occur when updating XCharts after TMP is enabled locally. It can be solved in the following two ways: XCharts does not enable TMP by default, so there are no references to TMP on asmdef. This issue may occur when updating XCharts after TMP is enabled locally. It can be solved in the following two ways:
@@ -158,11 +130,23 @@ XCharts does not enable TMP by default, so there are no references to TMP on asm
Version ` 3.8.0 ` after adding Daemon [XCharts - Daemon](https://github.com/XCharts-Team/XCharts-Daemon), will be XCharts - Daemon import project, When updating XCharts, the daemon automatically refreshes the asmdef based on the locally enabled TMP to ensure proper compilation. Version ` 3.8.0 ` after adding Daemon [XCharts - Daemon](https://github.com/XCharts-Team/XCharts-Daemon), will be XCharts - Daemon import project, When updating XCharts, the daemon automatically refreshes the asmdef based on the locally enabled TMP to ensure proper compilation.
## support-empty-data-how-to-achieve-the-effect-of-line-chart-disconnection ## FAQ 31: Support empty data? How to achieve the effect of line chart disconnection?
`data` of `Serie` is of type `double`, so it cannot represent empty data. Empty data can be achieved by turning on Serie's ignore and specifying ignoreValue. You can also set the ignore parameter for each SerieData. The ignoreLineBreak parameter can be set to disconnect or connect after ignoring data. `data` of `Serie` is of type `double`, so it cannot represent empty data. Empty data can be achieved by turning on Serie's ignore and specifying ignoreValue. You can also set the ignore parameter for each SerieData. The ignoreLineBreak parameter can be set to disconnect or connect after ignoring data.
## what-are-the-common-problems-when-upgrading-xcharts2-to-xcharts3 ## FAQ 32: 2.x What are the common problems when upgrading version 3.x?
1. `XCharts.Runtime.XChartsMgr` is missing the class attribute `ExtensionOfNativeClass`! 1. `XCharts.Runtime.XChartsMgr` is missing the class attribute `ExtensionOfNativeClass`!
3.x version does not need to mount XChartsMgr, directly delete the `_xcharts_` node on the scene. 3.x version does not need to mount XChartsMgr, directly delete the `_xcharts_` node on the scene.
## FAQ 33: How to display a line chart without white space on both sides and start from the 0 coordinate?
Set the `boundaryGap` parameter of the X-axis.
## FAQ 34: How to set some Series not to display Tooltips?
Setting the `itemFormatter` of `itemStyle` in `serie` to `'-'` can ignore `tooltip`.
## FAQ 35: Sometimes an overlapping line appears in the area line chart when using semi-transparent colors
This is a bug in the drawing of the area line chart. You can use light opaque colors instead of semi-transparent colors.

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -0,0 +1,9 @@
---
title: Support
sidebar_position: 51
slug: /support
---
# Support
For technical support and to purchase additional charts, you can subscribe to the `VIP` service. For details, please send an email to `monitor1394@gmail.com` for consultation.

View File

@@ -1,103 +1,170 @@
--- ---
title: Introductory tutorial: Get started with XCharts 3.0 in 5 minutes title: Getting Started
sidebar_position: 11 sidebar_position: 11
slug: /tutorial01 slug: /tutorial01
--- ---
# Tutorial: Get started with XCharts 3.0 in 5 minutes # Getting Started with XCharts in 5 Minutes
> Note: This tutorial is for XCharts 3.x version only :::warning
## What do I need to know before using XCharts Note: This tutorial is only applicable to the XCharts 3.x version. For the 2.x version, please refer to [Tutorial: Mastering XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
- Have used Unity, know the basic operation of Unity. :::
- Understand UGUI and can use UGUI.
- Understand MonoBehavior script usage in Unity, know how to hang scripts, manipulate scripts with code.
## Get and import XCharts ## Prerequisites for XCharts
XCharts can be imported into a project in any of the following ways: XCharts is a Unity chart plugin, currently only available for use on the Unity platform.
- Source XCharts directly into the project Before using XCharts, you need to:
After downloading the XCharts source code, copy the XCharts directory directly to the Assets directory of the Unity project. - Have a basic understanding of how to use Unity.
- Understand the basic usage of UGUI for making UI.
- Know how to use Unity's MonoBehavior scripts, how to attach scripts, and how to manipulate scripts with code.
- Import XCharts through `Assets/Import Package` If you are new to Unity, it is recommended to learn some basic Unity tutorials before using XCharts.
After downloading the.unitypackage file for XCharts, open Unity and go to the menu bar Assets--&gt; Import Package--&gt; Select.unitypackage import to start using XCharts. ## Obtaining and Importing XCharts
- Import XCharts through the Package Manager XCharts is primarily maintained and released through Github. You can download the source code and Package from the [Github Homepage](https://github.com/XCharts-Team).
For Unity 2018.3 and later, XCharts can be imported through the Package Manager. After opening the Package Manager, run the `Add package form git URL...`, input XCharts dead simple URL: ` https://github.com/XCharts-Team/XCharts.git use XCharts after ` wait a moment. XCharts can be imported into your project in any of the following ways:
You can also add the package directly to the manifest.json file: Open the manifest.json file in the Packages directory and add it under dependencies: ### Copying the XCharts Source Code Directly into the Project
``` json After downloading the XCharts source code, simply copy the XCharts directory into the Assets directory of your Unity project. Once compiled, it is ready to use.
"com.monitor1394.xcharts" : "https://github.com/XCharts-Team/XCharts.git",
```
To update XCharts, remove com.monitor1394.xcharts from the manifest.json file under lock (some versions of Unity may be packages-lock.json) and re-download and compile. ### Importing XCharts through Import Package
- Recommended daemon into XCharts (not required) After downloading the .unitypackage file of XCharts, open Unity, go to the menu bar Assets-->Import Package-->select the downloaded .unitypackage to import. After the import is complete and compiled, you can start using XCharts.
[XCharts Daemon](https://github.com/XCharts-Team/XCharts-Daemon) can ensure update compilation is normal, when the local open TextMeshPro or NewInputSystem would be very useful. After importing Xchart-daemon into a project, when updating XCharts, the Daemon will automatically refresh asmdef according to the status of local TMP, etc., to ensure normal compilation and facilitate the execution of automated processes such as CI-CD. ### Importing XCharts through Package Manager
## Add a simple chart For Unity versions above 2018.3, you can import XCharts through the Package Manager. Open the Package Manager, then use `Add package from git URL...`, enter the GitHub URL of XCharts: `https://github.com/XCharts-Team/XCharts.git`. After compiling, you can use XCharts.
Right-click in `Hierarchy` view or menu bar `GameObject` drop down and select `XCharts->LineChart`, can quickly create a default line chart out: For some Unity versions, you can also directly add the package to the `manifest.json` file: Open the `manifest.json` file under the `Packages` directory, and add the following under `dependencies`:
>"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git",
If you need to update `XCharts`, delete the relevant content of `com.monitor1394.xcharts` under the `lock` of the `manifest.json` file (some Unity versions may be the packages-lock.json file), and it will re-download and compile.
### Recommended Import of XCharts Daemon
The daemon [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon) ensures that the compilation is normal when updating. It is very useful when TextMeshPro or NewInputSystem is turned on locally. After importing XCharts-Daemon into the project, the daemon will automatically refresh XCharts' asmdef according to the local situation of TMP when updating XCharts, ensuring that the compilation is normal without manual intervention, which is convenient for automated processes such as CI/CD.
The import method of XCharts-Daemon can refer to the previous import method of XCharts. It can be imported into the project through source code or Package. The GitHub URL of XCharts-Daemon: https://github.com/XCharts-Team/XCharts-Daemon.git
## Basic Usage of XCharts
After importing XCharts and compiling, the XCharts menu will appear in the Unity editor's menu bar, and you can start using XCharts.
:::tip
Note: The XCharts menu in the Unity menu bar indicates that XCharts is available.
:::
### Adding a Simple Chart
In the `Hierarchy` view, right-click `UI->XCharts->LineChart` or select `LineChart` from the menu bar `XCharts` to quickly create a default line chart:
![linechart1](img/tutorial01_linechart1.png) ![linechart1](img/tutorial01_linechart1.png)
## Add multiple Seire If you need to create a chart under a certain node, you can select the node and right-click `UI->XCharts->LineChart` to create a chart under the node.
In the Inspector view, locate LineChart's panel, and with the `Add Serie` button, you can add a second Line line: ### Modifying Chart Data
For the newly created chart, its data can be modified on the Inspector panel.
For X-axis data, you can add, delete, and modify by expanding: `XAxis->Data`:
![op_axisdata](img/tutorial01_axisdata.png)
For Serie data, you can add, delete, and modify by expanding: `Serie->Data`:
![op_seriedata](img/tutorial01_seriedata.png)
Serie supports multi-dimensional data, and generally, a line chart only uses two-dimensional data: the first dimension represents the ID of the X-axis category data, and the second dimension represents the corresponding value.
### Adding Multiple Series
In the `Inspector` view, find the `LineChart` panel, and click the `Add Serie` button to add a second `Line` line:
![op_addserie](img/tutorial01_addserie.png) ![op_addserie](img/tutorial01_addserie.png)
![linechart2](img/tutorial01_linechart2.png) ![linechart2](img/tutorial01_linechart2.png)
## Add other components :::tip
The default chart does not have a `Legend`, and a `Legend` Component can be added via the `Add Component` button: Series are added through the `Add Serie` button. Different types of Series can be added. [What kinds of Series does XCharts have?](https://xcharts-team.github.io/en/docs/configuration#serie-系列)
:::
### Adding Other Main Components
By default, the chart does not have a `Legend`. If you need a `Legend` component, you can add it through the `Add Component` button:
![op_addcomponent](img/tutorial01_addcomponent.png) ![op_addcomponent](img/tutorial01_addcomponent.png)
## Add Serie components :::tip
Serie comes with only a few common components, and others are added as needed. For example, if you need to fill a line chart area with color, you can add a separate `AreaStyle` component to Serie: Main components are added through the `Add Component` button. [What main components does XCharts have?](https://xcharts-team.github.io/en/docs/configuration/#maincomponent-主组件)
:::
### Adding Serie Components
Serie only comes with a few common components, and other components need to be added when used. For example, if you need to fill the area color for the line chart, you can add an `AreaStyle` component to `Serie` separately:
![op_addseriecomponent](img/tutorial01_addseriecomponent.png) ![op_addseriecomponent](img/tutorial01_addseriecomponent.png)
![linechart3](img/tutorial01_linechart3.png) ![linechart3](img/tutorial01_linechart3.png)
## Add the SerieData component :::tip
If you need to personalize the configuration of each data item, you can add a Component to each SerieData separately. For example, we give the second data of the line chart a separate display `Label`: Serie components are added through the button on the right side of Serie. [What components can be added to Serie in XCharts?](https://xcharts-team.github.io/en/docs/configuration/#iseriecomponent-可添加到serie的组件)
:::
### Adding SerieData Components
If you need to customize the configuration of each data item individually, you can add components to each `SerieData` separately. For example, we can display `Label` for the second data of the line chart individually:
![op_addseriedatacomponent](img/tutorial01_addseriedatacomponent.png) ![op_addseriedatacomponent](img/tutorial01_addseriedatacomponent.png)
![linechart4](img/tutorial01_linechart4.png) ![linechart4](img/tutorial01_linechart4.png)
## More components and configuration parameters :::tip
XCharts has been iteratively optimized and now has dozens of main and sub-components, each with a few to dozens of configurable parameters to support a variety of flexible and complex functions. SerieData components are added through the button on the right side of SerieData after expanding. [What components can be added to SerieData in XCharts?](https://xcharts-team.github.io/en/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
Using XCharts for the first time, you can add various charts in the `Inspector` view, add or adjust the components in the chart, and the `Game` view gives real-time feedback on the effects of adjustments to familiarize yourself with the use of various components. Detailed parameter descriptions of each component can be found in the [XCharts Configuration](Configuration.md). :::
## How to adjust parameters quickly ### More Components and Configuration Parameters
XCharts is configuration and data driven. Want what effect, only need to adjust the configuration parameters under the corresponding component can be, do not need to change the nodes under the `Hierarchy` view, because those nodes are generated by the `XCharts` internal according to the configuration and data, even if changed will be restored in the refresh. XCharts has been continuously iterated and optimized, and now has dozens of main components and sub-components, each with several to dozens of configurable parameters to support a variety of functions.
How to quickly locate the component corresponding to the effect you want to change requires a certain understanding of the component. For example, if we want to show an arrow at the end of the X-axis, how do we position it? First, position the X-axis to `XAxis0`; Second, locate the axis to `AxisLine`; Finally, check to see if there are any parameters in the AxisLine component that can achieve this effect, and check [XCharts configuration](Configuration.md) for uncertain parameters. When using XCharts for the first time, it is recommended to personally test the actual effects of each chart, each component. The `Inspector` view can directly add various charts, components, and adjust various configuration parameters, and the `Game` view will provide real-time feedback on the adjustments. A detailed description of each component's parameters can be found in the [XCharts Configuration Manual](configuration.md).
`XCharts` provides a full range of parameter configuration from the global` Theme `, series` Serie `, and single data item `SerieData`. The priority in descending order is: `SerieData` -> `Serie` -> `Theme`. Take the color of `ItemStyle` for example: ### How to Quickly Adjust Parameters
1. If the `ItemStyle` of `SerieData` has a color value other than `0000`, this color value is preferred. XCharts is driven by data and parameters. To achieve the desired effect, simply adjust the configuration parameters under the corresponding component. Do not modify the nodes under the `Hierarchy` view, as those nodes are generated by XCharts internally based on configuration and data, and will be restored upon refresh.
2. If the ItemStyle of `Serie` is configured with a color value other than `0000`, this color value takes precedence.
3. Otherwise, the Color value is taken from the Color Palette of the Theme.
Usually, `0000` indicates the theme default color, and 0 or null indicates the theme default. To quickly locate the component corresponding to the effect you want to change, you need to have a certain understanding of the components. For example, we want to display an arrow at the end of the X-axis line. How to locate it? The first step, the X-axis is located at `XAxis0`; the second step, the axis line is located at `AxisLine`; finally, check if there is such a parameter under the `AxisLine` component to achieve this effect. If you are not sure about the parameters, you can refer to the [XCharts Configuration Manual](configuration.md).
## Add line charts with code `XCharts` provides comprehensive parameter configuration from the global `Theme`, series `Serie`, and individual data items `SerieData`. The priority order from high to low is: `SerieData`->`Serie`->`Theme`. Take the color of `ItemStyle` as
an example:
Attach the `LineChart` script to the gameObject: 1. If the `ItemStyle` of `SerieData` has a color value other than `0000`, this color value is used first.
2. If the `ItemStyle` of `Serie` has a color value other than `0000`, this color value is used.
3. Otherwise, the color value is taken from the `Color Palette` of the theme `Theme`.
:::tip
The color value is usually `0000` when using the default color of the theme; other parameters are `0` or null when using the default configuration of the theme; pay attention to transparency when setting colors.
:::
### Adding a Line Chart with Code
Attach the `LineChart` script to `gameObject`:
```csharp ```csharp
var chart = gameObject.GetComponent<LineChart>(); var chart = gameObject.GetComponent<LineChart>();
@@ -108,10 +175,10 @@ if (chart == null)
} }
``` ```
Resize: Adjust the size:
```csharp ```csharp
chart.SetSize(580, 300);//代码动态设置尺寸或直接操作chart.rectTransform或直接在Inspector上改 chart.SetSize(580, 300);//Dynamically set the size with code, or directly operate chart.rectTransform, or directly change it in the Inspector
``` ```
Set the title: Set the title:
@@ -121,7 +188,7 @@ var title = chart.EnsureChartComponent<Title>();
title.text = "Simple Line"; title.text = "Simple Line";
``` ```
Set whether prompt boxes and legends are displayed: Set whether to display the tooltip and legend:
```csharp ```csharp
var tooltip = chart.EnsureChartComponent<Tooltip>(); var tooltip = chart.EnsureChartComponent<Tooltip>();
@@ -131,7 +198,7 @@ var legend = chart.EnsureChartComponent<Legend>();
legend.show = false; legend.show = false;
``` ```
Set axes: Set the coordinate axis:
```csharp ```csharp
var xAxis = chart.EnsureChartComponent<XAxis>(); var xAxis = chart.EnsureChartComponent<XAxis>();
@@ -143,14 +210,22 @@ var yAxis = chart.EnsureChartComponent<YAxis>();
yAxis.type = Axis.AxisType.Value; yAxis.type = Axis.AxisType.Value;
``` ```
Clear default data and add `Line` type `Serie` for receiving data: Clear all default data (including Series), add a `Line` type `Serie` to receive data:
```csharp ```csharp
chart.RemoveData(); chart.RemoveData();
chart.AddSerie<Line>("line"); chart.AddSerie<Line>("line");
``` ```
Add 10 data: If the Serie is fixed, it is recommended to only clear the data, not to remove the Serie:
```csharp
chart.ClearData();
```
This way, you can set the configuration parameters of Serie in the UI in advance.
Add 10 data points:
```csharp ```csharp
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
@@ -160,59 +235,86 @@ for (int i = 0; i < 10; i++)
} }
``` ```
So a simple line chart comes out: Now, a simple line chart is ready:
![tutorial01_linechart_simple](img/tutorial01_linechart_simple.png) ![tutorial01_linechart_simple](img/tutorial01_linechart_simple.png)
If there are multiple series in a Chart, the data of Axis only needs to be added once, rather than repeated in multiple cycles. Remember: the number of data in Axis should be the same as the number in Serie. If there are multiple series in a Chart, the data of Axis only needs to be added once, and should not be repeated in multiple loops.
See `Examples`: `Example13_LineSimple.cs` for the complete code :::tip
You can also use code to control more parameters, there are more Examples under `Examples`, all the configurable parameters seen in the `Inspector` can be set by code. All parameters in [XCharts configuration](Configuration.md) can be controlled by code. Remember: The number of Axis data should be consistent with the number of Serie data.
In addition, unless customized, it is recommended to call the `public` interface provided under `Chart`, especially in the data-related operations section. These interfaces do some associated processing inside, such as refreshing charts. Common interfaces are: :::
1. `Chart.ClearData()` : Clear chart data (without removing Series) For the complete code, please refer to `Examples`: `Example13_LineSimple.cs`
2. `Chart.RemoveData()` : Clear chart data (will remove all Serie)
3. `chart.AddSerie()` : AddSerie
4. `chart.AddXAxisData()` : Add X-axis data
5. `chart.AddData()` : Adds Serie data
6. `chart.UpdateData()` : Updates Serie data
7. `chart.UpdateXAxisData()` : Updates the X-axis data
8. `chart.UpdateDataName()` : Updates the Serie data name
XCharts has an automatic refresh mechanism inside, but it only triggers under certain conditions. If you call the interface of the internal component, encounter the component did not refresh, and indeed can not find the reason, you can use the following two interfaces to force refresh: You can also control more parameters with code. There are more examples in `Examples`. All parameters that can be configured in the `Inspector` can be set with code. All parameters in the [XCharts Configuration Manual](configuration.md) can be controlled by code.
1. `chart.RefreshAllComponent()` : refresh chart component, to initialize all of the components, often is not recommended. ### Setting the Default Font
2. `chart.RefreshChart()` : refreshes the chart drawing, only the drawing part is refreshed, and the component text, position, etc., is not refreshed.
3. Individual components can also refresh only themselves by `SetAllDirty()`.
## Use TextMeshPro The default font used by XCharts is Unity's default font `Arial`, which may not display Chinese characters on the WebGL platform. When using XCharts in your project, it is recommended to set the font first:
XCharts supports TextMeshPro, but it is disabled by default and needs to be switched manually. It can be turned on and off in the following ways: - Find the `XCharts/Resources/XCSetting.asset` resource and modify the `Font` inside and save.
- Find the `XCharts/Resources/XCTheme-Default.asset` and `XCharts/Resources/XCTheme-Dark.asset` font configurations, and click the `Sync Font from Setting` and `Sync Font to Sub Theme` buttons to synchronize the font to the theme configuration files.
After the font is set, newly created charts will use the newly set font. For old charts, you can click the `Rebuild Chart Object` button to refresh.
:::tip
It is recommended to set the font before using XCharts; when updating XCharts, pay attention to the potential restoration of the set font.
:::
### Using TextMeshPro
XCharts supports TextMeshPro, but it is not enabled by default and needs to be switched on manually. It can be turned on and off in the following ways:
![textmeshpro1](img/tutorial01_textmeshpro.png) ![textmeshpro1](img/tutorial01_textmeshpro.png)
After opening, you need to set the global font used by TextMeshPro, or you can set it separately in the Theme: After turning it on, you need to set the global font to be used by TextMeshPro, and it can also be set individually in the Theme:
![textmeshpro-font](img/tutorial01_textmeshpro_font.png) ![textmeshpro-font](img/tutorial01_textmeshpro_font.png)
It is recommended to plan whether to use TextMeshPro at the beginning of the project and set the font. When switching TMP with many existing charts, some charts may not refresh automatically. You can manually click the `Rebuild Chart Object` button to rebuild the chart, which can be initialized normally. It is recommended to plan whether to use TextMeshPro at the beginning of the project and set the font accordingly. When switching to TMP in a project with many charts, some charts may not refresh automatically, and you can manually click the `Rebuild Chart Object` button to rebuild the chart, which will initialize normally.
When updating XCharts for TMP projects, you may encounter problems with missing TMP references and failing to compile. These problems can be solved in one of two ways: If you have enabled TMP in your project, you may encounter compilation failures due to lost TMP references when updating XCharts. This can be solved in the following two ways:
1. Find `XCharts.Runtime.asmdef` and `XCharts.Editor.asmdef` and manually add references to `TextMeshPro` 1. Find `XCharts.Runtime.asmdef` and `XCharts.Editor.asmdef`, and manually add references to `TextMeshPro`.
2. Remove the `dUI_TextMeshPro` macro for Scripting Define Symbols in PlayerSetting 2. Remove the `dUI_TextMeshPro` macro from the `Scripting Define Symbols` in `PlayerSetting`.
Version `3.8.0` after adding daemon[XCharts - Daemon](https://github.com/XCharts-Team/XCharts-Daemon), will be XCharts-Daemon import project, When updating XCharts, the daemon automatically refreshes the asmdef based on the locally enabled TMP to ensure proper compilation. After the `3.8.0` version, the [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon) daemon was added. After importing XCharts-Daemon into the project, the daemon will automatically refresh the asmdef based on the local situation of the enabled TMP when updating XCharts, ensuring normal compilation.
## Change chart parameters with code ## XCharts Code Control
All parameters seen on Inspector can be modified with code, the key is to identify whether the parameters you want to change are on the component, on the Serie, or on the specific data item SerieData. All parameters seen in the `Inspector` can be modified with code. The key is to locate the parameter you want to change, whether it is on the component, the Serie, or the specific data item SerieData.
### Change the parameters on the main component In addition, unless customized, it is recommended to call the `public` interfaces provided under `Chart`, especially for data-related and list operations. These interfaces will do some associated processing internally, such as refreshing the chart. Common interfaces include:
You need to obtain the component first, and then modify the parameters in it: 1. `chart.ClearData()`: Clear chart data (does not remove Series)
2. `chart.RemoveData()`: Clear chart data (will remove all Series)
3. `chart.AddSerie()`: Add Serie
4. `chart.AddXAxisData()`: Add X-axis data
5. `chart.AddData()`: Add Serie data
6. `chart.UpdateData()`: Update Serie data
7. `chart.UpdateXAxisData()`: Update X-axis data
8. `chart.UpdateDataName()`: Update the name of Serie data
XCharts has an automatic refresh mechanism, but it is also triggered under certain conditions. If you have called the internal component interfaces and encountered components that have not been refreshed, and you cannot find the reason, you can use the following two interfaces to force a refresh:
1. `chart.RefreshAllComponent()`: Refresh chart components, which will re-initialize all components. It is not recommended to use it frequently.
2. `chart.RefreshChart()`: Refresh chart rendering, which only refreshes the rendering part and will not refresh component text, position, etc.
3. Each component can also refresh itself by calling `SetAllDirty()`.
:::tip
Use APIs to manipulate data and various lists, not directly access the list for processing.
:::
### Changing Parameters on Main Components
You need to obtain the component first, then modify its parameters:
```csharp ```csharp
var title = chart.EnsureChartComponent<Title>(); var title = chart.EnsureChartComponent<Title>();
@@ -225,11 +327,15 @@ xAxis.boundaryGap = true;
xAxis.type = Axis.AxisType.Category; xAxis.type = Axis.AxisType.Category;
``` ```
> Note: When the earlier version does not have the EnsureChartComponent() interface, GetOrAddChartComponent() is used. :::tip
### Change Serie parameters In older versions without the `EnsureChartComponent()` interface, use `GetOrAddChartComponent()`
For newly added Serie: :::
### Changing Serie Parameters
For newly added Series:
```csharp ```csharp
var serie = chart.AddSerie<Pie>(); var serie = chart.AddSerie<Pie>();
@@ -241,7 +347,7 @@ serie.animation.dataChangeEnable = true;
serie.roundCap = true; serie.roundCap = true;
``` ```
For existing Serie: For existing Series:
```csharp ```csharp
var serie = chart.GetSerie<Pie>(); var serie = chart.GetSerie<Pie>();
@@ -253,7 +359,7 @@ serie.animation.dataChangeEnable = true;
serie.roundCap = true; serie.roundCap = true;
``` ```
Add additional components to Serie: Adding additional components to Serie:
```csharp ```csharp
serie.EnsureComponent<AreaStyle>(); serie.EnsureComponent<AreaStyle>();
@@ -262,14 +368,14 @@ var label = serie1.EnsureComponent<LabelStyle>();
label.offset = new Vector3(0,20,0); label.offset = new Vector3(0,20,0);
``` ```
### Change the parameter on the data item SerieData ### Changing Parameters on Data Item SerieData
```csharp ```csharp
var serieData = chart.AddData(0, 20); var serieData = chart.AddData(0, 20);
//var serieData = serie.GetSerieData(0); //从已有数据中获取 //var serieData = serie.GetSerieData(0); //To get from existing data
serieData.radius = 10; serieData.radius = 10;
var itemStyle = serieData.EnsureComponent<ItemStyle>(); //给数据项添加ItemStyle组件 var itemStyle = serieData.EnsureComponent<ItemStyle>(); //Add ItemStyle component to the data item
itemStyle.color = Color.blue; itemStyle.color = Color.blue;
``` ```

File diff suppressed because it is too large Load Diff

View File

@@ -6,6 +6,13 @@ slug: /changelog
# 更新日志 # 更新日志
[master](#master) [master](#master)
[v3.13.0](#v3130)
[v3.12.1](#v3121)
[v3.12.0](#v3120)
[v3.11.2](#v3112)
[v3.11.1](#v3111)
[v3.11.0](#v3110)
[v3.10.2](#v3102)
[v3.10.1](#v3101) [v3.10.1](#v3101)
[v3.10.0](#v3100) [v3.10.0](#v3100)
[v3.9.0](#v390) [v3.9.0](#v390)
@@ -72,6 +79,139 @@ slug: /changelog
## master ## master
## v3.13.0
版本要点:
* 新增`UIText`扩展组件
* 新增`UIToggle`扩展组件
* 新增`UISlider`扩展组件
* 重构`UIProgress`扩展组件
* 增加`SymbolStyle``borderWidth``emptyColor`配置
* 增加`SymbolStyle``size2`参数支持长方形标记
* 其他优化和问题修复
日志详情:
* (2025.01.01) 发布`v3.13.0`版本
* (2024.12.27) 增加`SymbolStyle``size2`参数支持长方形标记
* (2024.12.26) 优化`Text``TextMeshPro`下的居中对齐方式
* (2024.12.25) 增加`Tooltip``itemFormatter`设置`{f0}`支持
* (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题
* (2024.12.23) 增加`SymbolStyle``borderWidth``emptyColor`配置
* (2024.12.17) 增加`UISlider`扩展组件
* (2024.12.10) 增加`UIToggle`扩展组件
* (2024.12.09) 修复`UITable``scrollbar`无法拖动的问题
* (2024.12.07) 修复`Chart`节点下不能放自定义节点的问题
* (2024.12.05) 增加`UIText`扩展组件
* (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment`
## v3.12.1
版本要点:
* 完善官网文档的中英文支持
* 优化折线图数据密集时的绘制效果
* 其他问题修复
日志详情:
* (2024.12.01) 发布`v3.12.1`版本
* (2024.11.30) 修复`Tooltip`在图表设置其他锚点时手机上显示位置异常的问题
* (2024.11.27) 修复`Unity6`的一些代码警告问题
* (2024.11.26) 修复`Tooltip`在特殊情况下可能会超出屏幕显示不完整的问题
* (2024.11.24) 修复`UITable`在拖拽时也会点选的问题
* (2024.11.22) 修复`Time`时间轴在开启`Animation`时动态变更效果异常的问题
* (2024.11.18) 优化`Line`在数据点过密时有更好的绘制效果
* (2024.11.16) 修复`Animation`无法通过代码开启的问题 (#334)
* (2024.11.13) 修复`DataZoom`的start和end在代码动态修改时图表不刷新的问题
* (2024.11.05) 修复`Title`设置隐藏后运行还显示的问题
* (2024.11.01) 完善`website`中英文文档
## v3.12.0
版本要点:
* 增加`Ring``radiusGradient`参数设置渐变方向
* 增加`numericFormatter``date``time`的支持
* 完善`AreaStyle``origin`参数设置区域填充起始位置
* 调整和完善文档
* 其他优化和修复
日志详情:
* (2024.09.30) 发布`v3.12.0`版本
* (2024.09.27) 完善`5分钟教程`
* (2024.09.24) 完善`Legend``formatter`对多Serie的支持 (#332)
* (2024.09.22) 调整`Documentation`文档显示样式
* (2024.09.09) 增加`numericFormatter``date``time`的支持
* (2024.09.03) 完善`AreaStyle``origin`参数设置区域填充起始位置
* (2024.09.01) 增加`Ring``radiusGradient`参数设置渐变方向
* (2024.09.01) 优化`Axis`为时间轴时首个Label的位置
## v3.11.2
* (2024.08.01) 发布`v3.11.2`版本
* (2024.07.29) 修复`Tooltip`在微信小游戏平台上报错的兼容问题 (#326)
* (2024.07.27) 调整`Axis``AxisName`的默认位置
* (2024.07.22) 优化`Pie``Label``Tooltip`触发时的表现
* (2024.07.21) 修复`Tooltip`在开启`DataZoom`时指示内容不准确的问题
* (2024.07.17) 修复`MarkLine``Label`在初始化时可能会闪烁的问题
* (2024.07.16) 优化`Axis``Time`时间轴时的`Tooltip`默认效果
* (2024.07.15) 优化`Axis``Time`时间轴时的分割效果
* (2024.07.14) 优化`Axis``Time`时间轴时的移动表现
* (2024.07.12) 优化`Label`的初始化显示效果
* (2024.07.06) 修复`Chart`在动态创建时背景没有自适应的问题 (#323)
## v3.11.1
* (2024.07.01) 发布`v3.11.1`版本
* (2024.07.01) 修复`Serie`有多个时颜色异常的问题
* (2024.06.23) 修复`Label`在初始化时会堆积的问题
## v3.11.0
版本要点:
* 增加`Line3DChart`3D折线图
* 增加`GraphChart`关系图
* 增加`3D`坐标系支持
* 增加`Tooltip``triggerOn`设置触发条件
* 其他问题修复和优化
日志详情:
* (2024.06.16) 发布`v3.11.0`版本
* (2024.06.15) 增加`Editor``Data`的添加、删除、上下移动操作按钮
* (2024.06.11) 修复`Axis``IndicatorLabel`可能会遮挡住`Tooltip`的问题
* (2024.06.11) 修复`Tooltip``Cross``Axis``IndicatorLabel`可能不显示的问题 (#315)
* (2024.06.10) 调整`Tooltip``Corss`重命名为`Cross`
* (2024.06.09) 增加`Axis``minCategorySpacing`设置类目轴默认的最小类目间距
* (2024.06.09) 修复`Tooltip``Cross``Axis`是类目轴并且开启`DataZoom`的情况下指示位置不准确的问题
* (2024.06.06) 修复`Serie``Clone`时动画异常问题 (#320)
* (2024.06.04) 修复`Serie``state`在代码动态设置时不刷新的问题
* (2024.05.29) 调整`XCharts``Hierarchy`视图下的右键菜单到`UI/XCharts`
* (2024.05.29) 增加`3D`坐标系对类目轴的支持
* (2024.05.19) 优化`Editor`下的编辑性能
* (2024.05.09) 增加`JsonUtil`工具类
* (2024.05.01) 修复`Tooltip`每帧产生GC的问题 (#311) (by @stefanbursuc)
* (2024.04.23) 修复`ConvertXYAxis()`多次调用后图表异常的问题
* (2024.04.22) 修复`DataZoom`控制多个轴时的`GridCoord`获取可能不正确的问题 (#317)
* (2024.04.22) 增加`3D`坐标系
* (2024.04.15) 优化`DateTimeUtil`时间戳转`DateTime`接口时区的问题
* (2024.04.15) 优化`GridCoord`在开启`GridLayout`时也显示`Left` `Right` `Top` `Bottom`参数 (#316)
* (2024.04.14) 修复`Tooltip``Cross`在开启`DataZoom`的情况下`label`位置不正确的问题 (#315)
* (2024.04.12) 修复`Candlesticks`效果不对的问题 (#313)
* (2024.03.20) 增加`Tooltip``triggerOn`设置触发条件
* (2024.03.19) 修复`Pie`在设置`ItemStyle``opacity`时颜色不对的问题 (#309)
## v3.10.2
* (2024.03.11) 发布`v3.10.2`版本
* (2024.03.11) 修复`Legend``formatter`在设置`{d}`通配符时显示可能不匹配的问题 (#304)
* (2024.03.11) 修复`Tooltip`移出坐标系后还显示的问题
* (2024.03.08) 修复`Tooltip``title`从旧版本升级后可能不显示的问题
## v3.10.1 ## v3.10.1
* (2024.02.21) 发布`v3.10.1`版本 * (2024.02.21) 发布`v3.10.1`版本
@@ -100,12 +240,19 @@ slug: /changelog
* (2024.01.23) 增加`{y}`通配符用于获取Y轴的类目名 * (2024.01.23) 增加`{y}`通配符用于获取Y轴的类目名
* (2024.01.23) 增加`Line`支持X轴和Y轴都为`Category`类目轴 * (2024.01.23) 增加`Line`支持X轴和Y轴都为`Category`类目轴
* (2024.01.18) 修复`Animation``type`代码动态修改无效的问题 * (2024.01.18) 修复`Animation``type`代码动态修改无效的问题
* (2024.01.16) 增加`UIImage`图片组件
* (2024.01.16) 优化`Background`组件,可设置圆角和边框
* (2024.01.13) 增加`Chart`的更多快捷创建图表菜单 * (2024.01.13) 增加`Chart`的更多快捷创建图表菜单
* (2024.01.09) 增加`Background``borderStyle`,给图表默认设置圆角 * (2024.01.09) 增加`Background``borderStyle`,给图表默认设置圆角
* (2024.01.07) 修复`Tooltop`的第一个`ContentLabelStyle`设置`color`无效的问题 * (2024.01.07) 修复`Tooltop`的第一个`ContentLabelStyle`设置`color`无效的问题
* (2024.01.03) 增加`UITable``carouselStyle``hoverPause`
* (2024.01.02) 增加`UITable``scrollStyle``borderStyle`
* (2024.01.02) 增加`UITable``columnHeadStyle``opaque`
* (2024.01.01) 调整`UITable``border`边框相关设置,用`BorderStyle`代替
* (2024.01.01) 增加`BorderStyle`边框样式 * (2024.01.01) 增加`BorderStyle`边框样式
* (2023.12.26) 增加`Heatmap``maxCache`参数支持 * (2023.12.26) 增加`Heatmap``maxCache`参数支持
* (2023.12.25) 优化`Line`开启`clip`时绘制的顶点数 * (2023.12.25) 优化`Line`开启`clip`时绘制的顶点数
* (2023.12.22) 增加`UITable`的行边框
* (2023.12.22) 修复`Scatter`散点图部分边界数据不显示的问题 * (2023.12.22) 修复`Scatter`散点图部分边界数据不显示的问题
* (2023.12.21) 修复`TriggerTooltip()`接口在指定0或最大index时可能无法触发的问题 * (2023.12.21) 修复`TriggerTooltip()`接口在指定0或最大index时可能无法触发的问题
* (2023.12.19) 修复`Legend``LabelStyle`设置`formatter`后不生效的问题 * (2023.12.19) 修复`Legend``LabelStyle`设置`formatter`后不生效的问题
@@ -144,15 +291,27 @@ slug: /changelog
* (2023.11.23) 增加`Axis``Animation`支持动画效果 * (2023.11.23) 增加`Axis``Animation`支持动画效果
* (2023.11.16) 取消`Legend``formatter`,用`LabelStyle`的代替 * (2023.11.16) 取消`Legend``formatter`,用`LabelStyle`的代替
* (2023.11.14) 完善`LabelStyle``formatter`的注释和文档(#291) * (2023.11.14) 完善`LabelStyle``formatter`的注释和文档(#291)
* (2023.11.14) 增加`UITable``GetData()``GetContent()`接口
* (2023.11.12) 增加`UITable``onTableClick`点击表格回调
* (2023.11.11) 重构`UITable``SeparatorStyle`,可分开设置行列的分割线
* (2023.11.11) 修复`Documentation`部分注释生成文档不完整的问题 (#290) * (2023.11.11) 修复`Documentation`部分注释生成文档不完整的问题 (#290)
* (2023.11.11) 修复`Legend``formatter`在数据变更时没有自动刷新的问题 * (2023.11.11) 修复`Legend``formatter`在数据变更时没有自动刷新的问题
* (2023.11.05) 增加`UITable``ColumnStyle`重构Column相关参数
* (2023.11.05) 增加`UITable``RowStyle`重构Row相关参数
* (2023.11.05) 修复`SerieEventData``value`一直是0的问题 (#287) * (2023.11.05) 修复`SerieEventData``value`一直是0的问题 (#287)
* (2023.11.03) 修复`Bar`设置渐变色时鼠标移出效果异常的问题 (#285) * (2023.11.03) 修复`Bar`设置渐变色时鼠标移出效果异常的问题 (#285)
* (2023.11.02) 优化`SerieData`设置`ignore``formatter`的忽略问题 * (2023.11.02) 优化`SerieData`设置`ignore``formatter`的忽略问题
* (2023.11.01) 增加`UITable``CarouselStyle`轮播功能
* (2023.11.01) 增加`UITable``AddColumn()``UpdateColumn()`接口
* (2023.11.01) 增加`MarkLine``onTop`设置是否显示在最上层 * (2023.11.01) 增加`MarkLine``onTop`设置是否显示在最上层
* (2023.10.23) 修复`UITable`点击`Rebuild Object`异常的问题
* (2023.10.23) 修复`UITable`尺寸变化时不刷新的问题
* (2023.10.21) 修复`Pie`有0数据时`Label`的位置异常的问题 * (2023.10.21) 修复`Pie`有0数据时`Label`的位置异常的问题
* (2023.10.21) 增加`Axis`的对数轴支持子刻度 * (2023.10.21) 增加`Axis`的对数轴支持子刻度
* (2023.10.19) 修复`Pie`设置玫瑰图时引导线异常的问题 * (2023.10.19) 修复`Pie`设置玫瑰图时引导线异常的问题
* (2023.10.17) 修复`UITable`首次初始化异常的问题
* (2023.10.17) 增加`UITable`的数据操作接口
* (2023.10.17) 增加`UITable``RefreshTable()`刷新接口
* (2023.10.15) 修复`Line`设置`Animation``AlongPath`时动画异常的问题 (#281) * (2023.10.15) 修复`Line`设置`Animation``AlongPath`时动画异常的问题 (#281)
* (2023.10.12) 修复`MarkLine`指定`yValue`时对数值轴无效的问题 * (2023.10.12) 修复`MarkLine`指定`yValue`时对数值轴无效的问题
* (2023.10.11) 修复`Serie``showDataDimension`设置无效的问题 * (2023.10.11) 修复`Serie``showDataDimension`设置无效的问题
@@ -197,7 +356,7 @@ slug: /changelog
* (2023.08.22) 修复`Bar`显示隐藏时绘制表现异常的问题 * (2023.08.22) 修复`Bar`显示隐藏时绘制表现异常的问题
* (2023.08.22) 优化`Zebra`斑马柱图的绘制表现 (#276) * (2023.08.22) 优化`Zebra`斑马柱图的绘制表现 (#276)
* (2023.08.16) 增加`Daemon`守护程序解决本地开启TMP后更新版本报错问题 * (2023.08.16) 增加`Daemon`守护程序解决本地开启TMP后更新版本报错问题
* (2023.08.15) 修复`Data`数据在-1到1之间时坐标轴显示错误的问题 (#273) (by **Ambitroc**) * (2023.08.15) 修复`Data`数据在-1到1之间时坐标轴显示错误的问题 (#273) (by @Ambitroc)
* (2023.08.14) 修复`XCharts`本地开启`TextMeshPro``NewInputSystem`后更新版本会报错的问题 (#272) * (2023.08.14) 修复`XCharts`本地开启`TextMeshPro``NewInputSystem`后更新版本会报错的问题 (#272)
* (2023.08.12) 修复`Chart`在运行时被删除时会异常报错的问题 (#269) * (2023.08.12) 修复`Chart`在运行时被删除时会异常报错的问题 (#269)
* (2023.08.11) 修复`DataZoom`开启时可能会导致无法添加数据的问题 * (2023.08.11) 修复`DataZoom`开启时可能会导致无法添加数据的问题
@@ -238,7 +397,7 @@ slug: /changelog
* (2023.06.08) 发布`v3.7.0`版本 * (2023.06.08) 发布`v3.7.0`版本
* (2023.06.04) 增加`HelpDoc`帮助文档跳转 * (2023.06.04) 增加`HelpDoc`帮助文档跳转
* (2023.05.30) 修复`Serie`的名字带`_`线导致`Legend`无法触发的问题 (#259) (by **svr2kos2**) * (2023.05.30) 修复`Serie`的名字带`_`线导致`Legend`无法触发的问题 (#259) (by @svr2kos2)
* (2023.05.10) 增加`Axis``MinMaxAuto`范围类型 * (2023.05.10) 增加`Axis``MinMaxAuto`范围类型
* (2023.05.10) 增加`Line``Clip`的支持 * (2023.05.10) 增加`Line``Clip`的支持
* (2023.05.04) 优化`Axis`在-1到1范围时设置`CeilRate`不生效的问题 * (2023.05.04) 优化`Axis`在-1到1范围时设置`CeilRate`不生效的问题
@@ -257,9 +416,9 @@ slug: /changelog
版本要点: 版本要点:
* 增加`InputSystem`支持 (by **Bian-Sh**) * 增加`InputSystem`支持 (by @Bian-Sh)
* 增加官网[在线示例](https://xcharts-team.github.io/examples/)多版本支持 (by **SHL-COOL**) * 增加官网[在线示例](https://xcharts-team.github.io/examples/)多版本支持 (by @SHL-COOL)
* 完善对`VR`的支持 (by **Ambitroc**) * 完善对`VR`的支持 (by @Ambitroc)
* 增加`UITable``UIStatistic`等[扩展UI组件](https://xcharts-team.github.io/docs/ui) * 增加`UITable``UIStatistic`等[扩展UI组件](https://xcharts-team.github.io/docs/ui)
* 增加`ItemStyle``MarkColor` * 增加`ItemStyle``MarkColor`
* 增加通配符`{h}`的支持 * 增加通配符`{h}`的支持
@@ -275,9 +434,9 @@ slug: /changelog
* (2023.04.01) 发布`v3.6.0`版本 * (2023.04.01) 发布`v3.6.0`版本
* (2023.03.14) 修复`Tooltip``titleFormater`设置`{b}`可能不生效的问题 * (2023.03.14) 修复`Tooltip``titleFormater`设置`{b}`可能不生效的问题
* (2023.03.14) 修复`BarChart`在数据为0时不绘制柱条背景的问题 (#250) (by **Ambitroc**) * (2023.03.14) 修复`BarChart`在数据为0时不绘制柱条背景的问题 (#250) (by @Ambitroc)
* (2023.03.12) 增加`LabelStyle``autoRotate`可设置有角度的竖版文本的自动旋转 * (2023.03.12) 增加`LabelStyle``autoRotate`可设置有角度的竖版文本的自动旋转
* (2023.03.10) 增加`VR`等其他非鼠标输入方式的Point位置获取 (#248) (by **Ambitroc**) * (2023.03.10) 增加`VR`等其他非鼠标输入方式的Point位置获取 (#248) (by @Ambitroc)
* (2023.03.09) 增加`Chart``onSerieClick``onSerieDown``onSerieEnter``onSerieExit`回调 * (2023.03.09) 增加`Chart``onSerieClick``onSerieDown``onSerieEnter``onSerieExit`回调
* (2023.03.09) 修复`Pie`的点击选中偏移不生效的问题 * (2023.03.09) 修复`Pie`的点击选中偏移不生效的问题
* (2023.03.04) 增加`Legend``Positions`可自定义图例的位置 * (2023.03.04) 增加`Legend``Positions`可自定义图例的位置
@@ -291,7 +450,7 @@ slug: /changelog
* (2023.02.02) 修复`DataZoom`开启时`X轴``Label`可能会显示在图表外的问题 * (2023.02.02) 修复`DataZoom`开启时`X轴``Label`可能会显示在图表外的问题
* (2023.02.02) 优化`SerieData``ignore`设置时的忽略数据判断 * (2023.02.02) 优化`SerieData``ignore`设置时的忽略数据判断
* (2023.02.01) 修复`XChartsMgr.ContainsChart()`接口异常 * (2023.02.01) 修复`XChartsMgr.ContainsChart()`接口异常
* (2023.01.31) 增加`InputSystem`的支持 (#242) (by **Bian-Sh**) * (2023.01.31) 增加`InputSystem`的支持 (#242) (by @Bian-Sh)
* (2023.01.11) 修复`Inspector`上移除`Component`后图表没有及时刷新的问题 (#241) * (2023.01.11) 修复`Inspector`上移除`Component`后图表没有及时刷新的问题 (#241)
* (2023.01.06) 修复`Pie`在最后的几个数据都为0时`Label`显示不正常的问题 (#240) * (2023.01.06) 修复`Pie`在最后的几个数据都为0时`Label`显示不正常的问题 (#240)
* (2023.01.03) 删除`Serie``MarkColor`,增加`ItemStyle``MarkColor` * (2023.01.03) 删除`Serie``MarkColor`,增加`ItemStyle``MarkColor`

File diff suppressed because it is too large Load Diff

View File

@@ -5,183 +5,147 @@ slug: /faq
# 常见问题 # 常见问题
[FAQ 1如何调整坐标轴与背景的边距](#如何调整坐标轴与背景的边距) ## FAQ 1如何调整坐标轴与背景的边距
[FAQ 2如何让初始动画重新播放](#如何让初始动画重新播放)
[FAQ 3如何自定义折线图饼图的颜色](#如何自定义折线图饼图的颜色)
[FAQ 4如何给坐标轴上的文本加上单位](#如何给坐标轴上的文本加上单位)
[FAQ 5如何让柱形图的柱子堆叠显示](#如何让柱形图的柱子堆叠显示)
[FAQ 6如何让柱形图的柱子同柱但不重叠](#如何让柱形图的柱子同柱但不重叠)
[FAQ 7如何调整柱形图的柱子宽度和间距](#如何调整柱形图的柱子宽度和间距)
[FAQ 8如何调整柱形图单个柱子的颜色](#如何调整柱形图单个柱子的颜色)
[FAQ 9如何调整图表的对齐方式](#如何调整图表的对齐方式)
[FAQ 10可以显示超过1000以上的大数据吗](#可以显示超过1000以上的大数据吗)
[FAQ 11折线图可以画虚线、点线、点划线吗](#折线图可以画虚线点线点划线吗)
[FAQ 12如何限定Y轴的值范围](#如何限定y轴的值范围)
[FAQ 13如何自定义数值轴刻度大小](#如何自定义数值轴刻度大小)
[FAQ 14如何在数据项顶上显示文本](#如何在数据项顶上显示文本)
[FAQ 15如何给数据项自定义图标](#如何给数据项自定义图标)
[FAQ 16锯齿太严重如何让图表更顺滑](#锯齿太严重如何让图表更顺滑)
[FAQ 17为什么鼠标移上图表Tooltip不显示](#为什么鼠标移上图表tooltip不显示)
[FAQ 18如何取消Tooltip的竖线](#如何取消tooltip的竖线)
[FAQ 19如何自定义Tooltip的显示内容](#如何自定义tooltip的显示内容)
[FAQ 20如何让y轴显示多位小数](#如何让y轴显示多位小数)
[FAQ 21如何用代码动态更新数据](#如何用代码动态更新数据)
[FAQ 22如何显示图例为什么有时候图例无法显示](#如何显示图例为什么有时候图例无法显示)
[FAQ 23如何做成预设](#如何做成预设)
[FAQ 24如何在图表上画点画线等自定义内容](#如何在图表上画点画线等自定义内容)
[FAQ 25如何实现心电图类似的数据移动效果](#如何实现心电图类似的数据移动效果)
[FAQ 26如何使用背景组件有什么条件限制](#如何使用背景组件有什么条件限制)
[FAQ 27Mesh can not have more than 65000 vertices](#mesh_cannot_have_more_than_65000_vertices)
[FAQ 28为什么serie里设置的参数运行后又被重置了?](#为什么serie里设置的参数运行后又被重置了)
[FAQ 29如何修改serie的symbol的颜色?](#如何修改serie的symbol的颜色)
[FAQ 30导入或更新XCharts时TMP报错如何处理](#导入或更新xcharts时tmp报错怎么办)
[FAQ 31支持空数据吗如何实现折线图断开的效果?](#支持空数据吗如何实现折线图断开的效果)
[FAQ 322.x版本升级3.x版本时常见的问题有哪些](#xcharts2升级xcharts3时常见的问题有哪些)
[FAQ 33折线图如何两边不留空白而从0坐标开始显示](#折线图如何两边不留空白而从0坐标开始显示)
[FAQ 34如何设置部分Serie不显示Tooltip](#如何设置部分serie不显示tooltip)
## 如何调整坐标轴与背景的边距
调整`Grid`组件,可调整上下左右边距。 调整`Grid`组件,可调整上下左右边距。
## 如何让初始动画重新播放 ## FAQ 2如何让初始动画重新播放
调用`chart.AnimationReset()`接口。 调用`chart.AnimationReset()`接口。
## 如何自定义折线图饼图的颜色 ## FAQ 3如何自定义折线图饼图的颜色
通过`Theme``colorPalette`调整,或者部分`Serie`下的`LineStyle``ItemStyle` 通过`Theme``colorPalette`调整,或者部分`Serie`下的`LineStyle``ItemStyle`
## 如何给坐标轴上的文本加上单位 ## FAQ 4如何给坐标轴上的文本加上单位
通过`formatter``numericFormatter`参数,在`Legend``Axis``AxisLabel``Tooltop``Serie``Label`都提供该参数的配置。 通过`formatter``numericFormatter`参数,在`Legend``Axis``AxisLabel``Tooltop``Serie``Label`都提供该参数的配置。
## 如何让柱形图的柱子堆叠显示 ## FAQ 5如何让柱形图的柱子堆叠显示
设置`Serie`下的`stack``stack`相同的`serie`会堆叠显示在一个柱子上。 设置`Serie`下的`stack``stack`相同的`serie`会堆叠显示在一个柱子上。
## 如何让柱形图的柱子同柱但不重叠 ## FAQ 6如何让柱形图的柱子同柱但不重叠
设置`Serie`下的`barGap``-1``stack`为空。 设置`Serie`下的`barGap``-1``stack`为空。
## 如何调整柱形图的柱子宽度和间距 ## FAQ 7如何调整柱形图的柱子宽度和间距
调整`Serie`下的`barWidth``barGap`,多个`serie`时最后一个`serie``barWidth``barGap`有效。 调整`Serie`下的`barWidth``barGap`,多个`serie`时最后一个`serie``barWidth``barGap`有效。
## 如何调整柱形图单个柱子的颜色 ## FAQ 8如何调整柱形图单个柱子的颜色
可通过调整单个`Data`下的`ItemStyle`调整,也可以通过两个`serie`同柱不堆叠来实现,通过设置数据项为`0`来达到类似效果。 可通过调整单个`Data`下的`ItemStyle`调整,也可以通过两个`serie`同柱不堆叠来实现,通过设置数据项为`0`来达到类似效果。
## 如何调整图表的对齐方式 ## FAQ 9如何调整图表的对齐方式
调整RectTransform的锚点和UGUI的其他组件的用法一致。 调整RectTransform的锚点和UGUI的其他组件的用法一致。
## 可以显示超过1000以上的大数据吗 ## FAQ 10可以显示超过1000以上的大数据吗
可以。但`UGUI`对单个`Graphic`限制`65000`个顶点,所以太多的数据不一定能显示完全。可通过设置采样距离`sampleDist`开启采样简化过密曲线。也可以通过设置一些参数来减少图表的顶点数有助于显示更多数据。如缩小图表的尺寸,关闭或减少坐标轴的客户端绘制,关闭`Serie``symbol``label`显示等。折线图的普通线图`Normal`比平滑线图`Smooth`占用顶点数更少。`1.5.0`以上版本可以设置`large``largeThreshold`参数来开启性能模式。 可以。但`UGUI`对单个`Graphic`限制`65000`个顶点,所以太多的数据不一定能显示完全。可通过设置采样距离`sampleDist`开启采样简化过密曲线。也可以通过设置一些参数来减少图表的顶点数有助于显示更多数据。如缩小图表的尺寸,关闭或减少坐标轴的客户端绘制,关闭`Serie``symbol``label`显示等。折线图的普通线图`Normal`比平滑线图`Smooth`占用顶点数更少。`1.5.0`以上版本可以设置`large``largeThreshold`参数来开启性能模式。
## 折线图可以画虚线点线点划线吗 ## FAQ 11折线图可以画虚线点线点划线吗
可以。通过`Serie`下的`lineType`选择线条样式。当要显示的数据过多(成千以上)数据间过密时建议使用`Normal`或者`Step`样式。 可以。通过`Serie`下的`lineType`选择线条样式。当要显示的数据过多(成千以上)数据间过密时建议使用`Normal`或者`Step`样式。
## 如何限定y轴的值范围 ## FAQ 12如何限定Y轴的值范围
设置`Axis`下的`minMaxType``Custom`,自定义`min``max` 设置`Axis`下的`minMaxType``Custom`,自定义`min``max`
## 如何自定义数值轴刻度大小 ## FAQ 13如何自定义数值轴刻度大小
默认时通过`Axis`下的`splitNumer`进行自动划分。也可以设置`interval`自定义刻度大小。 默认时通过`Axis`下的`splitNumer`进行自动划分。也可以设置`interval`自定义刻度大小。
## 如何在数据项顶上显示文本 ## FAQ 14如何在数据项顶上显示文本
通过设置`Serie`下的`Label`。3.0版本需要先添加`LabelStyle`组件。 通过设置`Serie`下的`Label`。3.0版本需要先添加`LabelStyle`组件。
## 如何给数据项自定义图标 ## FAQ 15如何给数据项自定义图标
通过设置`Serie``data`下的数据项可单独设置`icon`相关参数。 通过设置`Serie``data`下的数据项可单独设置`icon`相关参数。
## 锯齿太严重如何让图表更顺滑 ## FAQ 16锯齿太严重如何让图表更顺滑
开启抗锯齿设置(在`Unity`里设置。调整UI渲染模式为`Camera`模式,开启`MSAA`,设置`4`倍或更高抗锯齿。 开启抗锯齿设置(在`Unity`里设置。调整UI渲染模式为`Camera`模式,开启`MSAA`,设置`4`倍或更高抗锯齿。
## 为什么鼠标移上图表tooltip不显示 ## FAQ 17为什么鼠标移上图表Tooltip不显示
确认`Tooltip`是否开启;确认父节点是否关闭了鼠标事件。 确认`Tooltip`是否开启;确认父节点是否关闭了鼠标事件。
## 如何取消tooltip的竖线 ## FAQ 18如何取消Tooltip的竖线
设置`Tooltip``type``None`。或者调整`lineStyle`的参数。 设置`Tooltip``type``None`。或者调整`lineStyle`的参数。
## 如何自定义tooltip的显示内容 ## FAQ 19如何自定义Tooltip的显示内容
自定义总的内容可以通过`Tooltip``formatter`。如果只是想调整所有的`serie`的显示格式可以用`itemFormatter``titleFormatter`结合。如果想每个`serie`的显示格式不一样,可以定制`serie``itemStyle`里的`tooltipFormatter`。具体的用法请查阅[XCharts配置项手册](https://xcharts-team.github.io/docs/configuration#Tooltip-itemFormatter)。 自定义总的内容可以通过`Tooltip``formatter`。如果只是想调整所有的`serie`的显示格式可以用`itemFormatter``titleFormatter`结合。如果想每个`serie`的显示格式不一样,可以定制`serie``itemStyle`里的`tooltipFormatter`。具体的用法请查阅[XCharts配置项手册](https://xcharts-team.github.io/docs/configuration#Tooltip-itemFormatter)。
## 如何让y轴显示多位小数 ## FAQ 20如何让y轴显示多位小数
设置`Axis`下的`AxisLabel`中的`formatter``{value:f1}``{value:f2}``1.5.0`及以上版本通过`numericFormatter`设置。 设置`Axis`下的`AxisLabel`中的`formatter``{value:f1}``{value:f2}``1.5.0`及以上版本通过`numericFormatter`设置。
## 如何用代码动态更新数据 ## FAQ 21如何用代码动态更新数据
请查阅`Example`下的代码,`Example13_LineSimple.cs`就是一个简单添加数据构建折线图的例子,其他`Demo`也都是通过代码控制不同的组件实现不同的功能相关API请查看文档[XChartsAPI接口](api.md) 。 请查阅`Example`下的代码,`Example13_LineSimple.cs`就是一个简单添加数据构建折线图的例子,其他`Demo`也都是通过代码控制不同的组件实现不同的功能相关API请查看文档[XChartsAPI接口](api.md) 。
## 如何显示图例为什么有时候图例无法显示 ## FAQ 22如何显示图例为什么有时候图例无法显示
首先,你的`serie`里的`name`需有值不为空。然后开启`Legend`显示,里面的`data`可以默认为空,表示显示所有的图例。如果你只想显示部分`serie`的图例,在`data`中填入要显示的图例的`name`即可。如果`data`中的值都不是系列的`name`,那图例就不会显示。 首先,你的`serie`里的`name`需有值不为空。然后开启`Legend`显示,里面的`data`可以默认为空,表示显示所有的图例。如果你只想显示部分`serie`的图例,在`data`中填入要显示的图例的`name`即可。如果`data`中的值都不是系列的`name`,那图例就不会显示。
## 如何做成预设 ## FAQ 23如何做成预设
做成prefab前执行一下`Rebuild Chart Object`重新刷新节点,避免有冗余的节点存在。 做成prefab前执行一下`Rebuild Chart Object`重新刷新节点,避免有冗余的节点存在。
## 如何在图表上画点画线等自定义内容 ## FAQ 24如何在图表上画点画线等自定义内容
`XCharts`有自定义绘制回调`onCustomDraw`,具体可参考`Example12_CustomDrawing.cs` `XCharts`有自定义绘制回调`onCustomDraw`,具体可参考`Example12_CustomDrawing.cs`
## 如何实现心电图类似的数据移动效果 ## FAQ 25如何实现心电图类似的数据移动效果
参考`Example`目录下的`Example_Dynamic.cs`。主要通过设置`maxCache`参数实现。`axis``serie`都设置相同的`maxCache``maxCache`可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。 参考`Example`目录下的`Example_Dynamic.cs`。主要通过设置`maxCache`参数实现。`axis``serie`都设置相同的`maxCache``maxCache`可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
## 如何使用背景组件有什么条件限制 ## FAQ 26如何使用背景组件有什么条件限制
设置`background`组件的`show``true` 设置`background`组件的`show``true`
## 区域折线图在用半透明颜色时有时候会一条叠加的线 ## FAQ 27Mesh can not have more than 65000 vertices
这是区域折线图绘制的bug。可以用浅的不透的颜色替代半透明颜色。
## mesh_cannot_have_more_than_65000_vertices
这是`UGUI`对单个`Graphic`的顶点数限制。`XCharts`是将图形绘制在单个`Graphic`上,所以也会有这个限制。解决的办法可以参考:[FAQ 10可以显示超过1000以上的大数据吗](#可以显示超过1000以上的大数据吗) 这是`UGUI`对单个`Graphic`的顶点数限制。`XCharts`是将图形绘制在单个`Graphic`上,所以也会有这个限制。解决的办法可以参考:[FAQ 10可以显示超过1000以上的大数据吗](#可以显示超过1000以上的大数据吗)
## 为什么serie里设置的参数运行后又被重置了 ## FAQ 28为什么serie里设置的参数运行后又被重置了
检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。 检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。
## 如何修改serie的symbol的颜色 ## FAQ 29如何修改serie的symbol的颜色
`Symbol` 的颜色是使用的 `ItemStyle``color` `Symbol` 的颜色是使用的 `ItemStyle``color`
## 导入或更新xcharts时tmp报错怎么办 ## FAQ 30导入或更新XCharts时TMP报错如何处理
XCharts默认时不开启TMP所以asmdef上没有TMP的引用。当本地开启TMP后再更新XCharts可能会出现这个问题。可通过以下两种方式解决 XCharts默认时不开启TMP所以asmdef上没有TMP的引用。当本地开启TMP后再更新XCharts可能会出现这个问题。可通过以下两种方式的任意一种解决:
1. 找到`XCharts.Runtime.asmdef``XCharts.Editor.asmdef`,手动加上 `TextMeshPro`的引用 1. 找到`XCharts.Runtime.asmdef``XCharts.Editor.asmdef`,手动加上 `TextMeshPro`的引用
2. 移除`PlayerSetting``Scripting Define Symbols``dUI_TextMeshPro` 2. 移除`PlayerSetting``Scripting Define Symbols``dUI_TextMeshPro`
`3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序将XCharts-Daemon导入项目后在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef确保编译正常。 `3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序将XCharts-Daemon导入项目后在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef确保编译正常。
## 支持空数据吗如何实现折线图断开的效果 ## FAQ 31支持空数据吗如何实现折线图断开的效果
`Serie``data``double`类型,所以无法表示空数据。可通过开启`Serie``ignore`和指定`ignoreValue`来达到空数据的效果。也可以每个`SerieData`设置`ignore`参数。忽略数据后断开还是连接可设置`ignoreLineBreak`参数。 `Serie``data``double`类型,所以无法表示空数据。可通过开启`Serie``ignore`和指定`ignoreValue`来达到空数据的效果。也可以每个`SerieData`设置`ignore`参数。忽略数据后断开还是连接可设置`ignoreLineBreak`参数。
## xcharts2升级xcharts3时常见的问题有哪些 ## FAQ 322.x版本升级3.x版本时常见的问题有哪些
1. 'XCharts.Runtime.XChartsMgr' is missing the class attribute 'ExtensionOfNativeClass'! 1. 出现:`'XCharts.Runtime.XChartsMgr' is missing the class attribute 'ExtensionOfNativeClass'!`的问题时是因为3.x版本时不需要挂载XChartsMgr直接删掉场景上的`_xcharts_`节点即可。
3.x版本时不需要挂载XChartsMgr直接删掉场景上的`_xcharts_`节点即可。
## 折线图如何两边不留空白而从0坐标开始显示 ## FAQ 33折线图如何两边不留空白而从0坐标开始显示
设置X轴的`boundaryGap`参数。 设置X轴的`boundaryGap`参数。
## 如何设置部分serie不显示tooltip ## FAQ 34如何设置部分Serie不显示Tooltip
`serie``itemStyle``itemFormatter`设置为`-`可以忽略`tooltip` `serie``itemStyle``itemFormatter`设置为`-`可以忽略`serie``tooltip`
## FAQ 35区域折线图在用半透明颜色时有时候会一条叠加的线
这是区域折线图绘制的bug。可以用浅的不透的颜色替代半透明颜色。

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -79,11 +79,14 @@ slug: /support
| 102 | [漏斗图](https://xcharts-team.github.io/docs/funnel) |FunnelChart | 98¥ | | 102 | [漏斗图](https://xcharts-team.github.io/docs/funnel) |FunnelChart | 98¥ |
| 103 | [3D金字塔](https://xcharts-team.github.io/docs/pyramid) |PyramidChart | 98¥ | | 103 | [3D金字塔](https://xcharts-team.github.io/docs/pyramid) |PyramidChart | 98¥ |
| 104 | [树形矩图](https://xcharts-team.github.io/docs/treemap) |TreemapChart | 98¥ | | 104 | [树形矩图](https://xcharts-team.github.io/docs/treemap) |TreemapChart | 98¥ |
| 105 | [桑基图](https://xcharts-team.github.io/docs/sankey) |SankeyChart | 98¥ |
| 201 | [3D柱图](https://xcharts-team.github.io/docs/bar3d) |Bar3DChart | 198¥ | | 201 | [3D柱图](https://xcharts-team.github.io/docs/bar3d) |Bar3DChart | 198¥ |
| 202 | [3D饼图](https://xcharts-team.github.io/docs/pie3d) |Pie3DChart | 198¥ | | 202 | [3D饼图](https://xcharts-team.github.io/docs/pie3d) |Pie3DChart | 198¥ |
| 203 | [甘特图](https://xcharts-team.github.io/docs/gantt) |GanttChart | 198¥ | | 203 | [甘特图](https://xcharts-team.github.io/docs/gantt) |GanttChart | 198¥ |
| 204 | [仪表盘](https://xcharts-team.github.io/docs/gauge) |GaugeChart | 198¥ | | 204 | [仪表盘](https://xcharts-team.github.io/docs/gauge) |GaugeChart | 198¥ |
| 205 | [水位图](https://xcharts-team.github.io/docs/liquid) |LiquidChart | 198¥ | | 205 | [水位图](https://xcharts-team.github.io/docs/liquid) |LiquidChart | 198¥ |
| 206 | [3D折线图](https://xcharts-team.github.io/docs/line3d) |Line3DChart | 198¥ |
| 207 | [关系图](https://xcharts-team.github.io/docs/graph) |GraphChart | 198¥ |
扩展图表的在线效果图也可以查看[WebGL在线Demo](https://xcharts-team.github.io/examples/) 扩展图表的在线效果图也可以查看[WebGL在线Demo](https://xcharts-team.github.io/examples/)

View File

@@ -6,84 +6,146 @@ slug: /tutorial01
# 教程5分钟上手 XCharts 3.0 # 教程5分钟上手 XCharts 3.0
> 本教程适用XCharts 3.x版本2.x版本请看 [教程5分钟上手XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/教程5分钟上手XCharts.md) :::warning
## 使用 XCharts 前需要掌握什么 Note本教程仅适用XCharts 3.x版本2.x版本请看 [教程5分钟上手XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/教程5分钟上手XCharts.md)
- 会简单使用Unity :::
- 了解UGUI会使用UGUI
- 了解Unity的MonoBehavior脚本用法知道怎么挂脚本用代码操作脚本
## 获取和导入 XCharts ## XCharts的前提条件
XCharts可通过以下任意一种方式导入到项目: XCharts是一个Unity图表插件目前只能在Unity平台使用。
- 直接将XCharts源码到项目 使用XCharts前,你需要:
下载好XCharts源码后直接将XCharts目录拷贝到Unity项目工程的Assets目录下 - 掌握Unity的基本用法
- 掌握UGUI制作UI的基本用法。
- 了解Unity的MonoBehavior脚本用法知道怎么挂脚本和用代码操作脚本。
- 通过`Assets/Import Package`导入XCharts 如果你刚接触Unity建议先学习Unity相关的基础教程再使用XCharts
下载好XCharts的.unitypackage文件后打开Unity菜单栏 Assets-->Import Package-->选中.unitypackage导入即可开始使用XCharts。 ## XCharts的获取和导入
- 通过`Package Manager`导入XCharts XCharts主要通过Github来维护更新和发布可以到[【Github主页】](https://github.com/XCharts-Team)进行下载获取源码和Pacakge对于无Github访问条件的用户可以访问[【国内镜像】](https://gitee.com/monitor1394/unity-ugui-XCharts)进行下载。国内镜像的版本更新可能会相对滞后。
对于Unity 2018.3以上版本,可通过 Package Manager来导入XCharts打开Package Manager后通过 `Add package form git URL...`输入XCharts3.0的GitHub URL: `https://github.com/XCharts-Team/XCharts.git#3.0` 稍等片刻后即可使用XCharts。 XCharts可通过以下任意一种方式导入到你的项目
也可以直接将package加入到`manifest.json`文件:打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入: ### 直接将XCharts源码拷贝到项目
``` json 下载好XCharts源码后直接将XCharts目录拷贝到Unity项目工程的Assets目录下。编译通过后即可使用。
"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git#3.0",
```
如需更新`XCharts`,删除`manifest.json`文件部分Unity版本可能是packages-lock.json文件的`lock`下的`com.monitor1394.xcharts`相关内容即会重新下载编译。 ### 通过Import Package导入XCharts
- 建议先导入XCharts的守护程序非必须 下载好XCharts的.unitypackage文件后打开Unity菜单栏 Assets-->Import Package-->选中下载好的.unitypackage进行导入。导入完成并通过编译后即可开始使用XCharts。
守护程序[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)可以确保更新时编译正常当本地开启TextMeshPro或NewInputSystem时将会非常有用。将XCharts-Daemon导入项目后在更新XCharts时守护程序会自动根据本地TMP等的开启情况刷新asmdef确保编译正常不用手动去解决方便CI-CD等自动化流程执行。 ### 通过Package Manager导入XCharts
## 添加一个简单图表 对于2018.3以上的Unity版本可通过Package Manager来导入XCharts打开Package Manager后通过 `Add package form git URL...`输入XCharts的GitHub URL: `https://github.com/XCharts-Team/XCharts.git` 编译通过后即可使用XCharts。
在`Hierarchy`视图下右键或菜单栏`GameObject`下拉选择`XCharts->LineChart`,即可快速创建一个默认的折线图出来 对于部分Unity版本也可以直接将package加入到`manifest.json`文件:打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入
>"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git",
如需更新`XCharts`,删除`manifest.json`文件部分Unity版本可能是packages-lock.json文件`lock`下的`com.monitor1394.xcharts`相关内容即会重新下载编译。
### 建议导入XCharts的守护程序
守护程序[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)可以确保更新时编译正常当本地开启TextMeshPro或NewInputSystem时将会非常有用。将XCharts-Daemon导入项目后在更新XCharts时守护程序会自动根据本地TMP等的开启情况刷新XCharts的asmdef确保编译正常不用手动去解决方便CI/CD等自动化流程执行。
XCharts-Daemon的导入方式可参考刚才的XCharts导入方式。可以通过源码或Package的方式导入项目XCharts-Daemon的Github URLhttps://github.com/XCharts-Team/XCharts-Daemon.git
## XCharts的基本使用
导入XCharts并编译通过后Unity编辑器的菜单栏会显示XCharts这时可以开始使用XCharts了。
:::tip
Unity的菜单栏出现XCharts菜单时才表示XCharts可用。
:::
### 添加一个简单图表
`Hierarchy`视图下右键`UI->XCharts->LineChart`或菜单栏`XCharts`下拉选择`LineChart`,即可快速创建一个默认的折线图:
![linechart1](img/tutorial01_linechart1.png) ![linechart1](img/tutorial01_linechart1.png)
## 添加多个Seire 如需在某个节点下创建图表,可以选中节点右键`UI->XCharts->LineChart`即可在节点下创建图表。
### 修改图表数据
刚创建的图表它的数据可以在Inspector视图面板上进行修改。
对于X轴数据可通过`XAxis->Data`展开后进行增删和修改:
![op_axisdata](img/tutorial01_axisdata.png)
对于Serie数据可通过`Serie->Data`展开后进行增删和修改:
![op_seriedata](img/tutorial01_seriedata.png)
Serie支持多维数据一般折线图只用到二维数据第一维表示X轴类目数据的编号第二维表示对应的数值。
### 添加多个Seire
`Inspector`视图,找到`LineChart`的面板,通过`Add Serie`按钮,可以添加第二条`Line`折线: `Inspector`视图,找到`LineChart`的面板,通过`Add Serie`按钮,可以添加第二条`Line`折线:
![op_addserie](img/tutorial01_addserie.png) ![op_addserie](img/tutorial01_addserie.png)
![linechart2](img/tutorial01_linechart2.png) ![linechart2](img/tutorial01_linechart2.png)
## 添加其他组件 :::tip
Serie通过`Add Serie`按钮添加。可添加不同类型的Serie。[XCharts有哪些Serie](https://xcharts-team.github.io/docs/configuration#serie-系列)
:::
### 添加其他主组件
默认图表没有`Legend`,需要`Legend`组件可通过`Add Component`按钮添加: 默认图表没有`Legend`,需要`Legend`组件可通过`Add Component`按钮添加:
![op_addcomponent](img/tutorial01_addcomponent.png) ![op_addcomponent](img/tutorial01_addcomponent.png)
## 添加Serie组件 :::tip
Serie只自带了几个常见的组件其他组件按需额外添加。比如需要给折线图区域填充颜色可单独给`Serie`添加`AreaStyle`组件: 主组件通过`Add Component`按钮添加。[XCharts有哪些主组件](https://xcharts-team.github.io/docs/configuration/#maincomponent-主组件)
:::
### 添加Serie组件
Serie只自带了几个常见的组件其他组件用到时需额外添加。比如需要给折线图进行区域填充颜色可单独给`Serie`添加`AreaStyle`组件:
![op_addseriecomponent](img/tutorial01_addseriecomponent.png) ![op_addseriecomponent](img/tutorial01_addseriecomponent.png)
![linechart3](img/tutorial01_linechart3.png) ![linechart3](img/tutorial01_linechart3.png)
## 添加SerieData组件 :::tip
如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加`Component`。比如我们给折线图的第二个数据单独显示`Label` Serie组件通过Serie右边的按钮添加。[XCharts有哪些Serie组件](https://xcharts-team.github.io/docs/configuration/#iseriecomponent-可添加到serie的组件)
:::
### 添加SerieData组件
如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加组件。比如我们给折线图的第二个数据单独显示`Label`
![op_addseriedatacomponent](img/tutorial01_addseriedatacomponent.png) ![op_addseriedatacomponent](img/tutorial01_addseriedatacomponent.png)
![linechart4](img/tutorial01_linechart4.png) ![linechart4](img/tutorial01_linechart4.png)
## 更多组件和配置参数 :::tip
XCharts经过不断的迭代优化目前已有多达几十种的主组件和子组件每个组件有几个至几十个不等的可配置参数以支持各种灵活而复杂的功能。 SerieData组件通过展开SerieData后Component右边的按钮添加。[XCharts有哪些SerieData组件](https://xcharts-team.github.io/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
首次使用XCharts可在 `Inspector` 视图添加各种图表,给图表添加或调整里面组件,`Game` 视图会实时反馈调整后的效果,以熟悉各种组件的使用。各个组件的详细参数说明可查阅[XCharts配置项手册](configuration.md)。 :::
## 如何快速调整参数 ### 更多组件和配置参数
`XCharts`是配置和数据来驱动的。想要什么效果,只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`视图下的节点,因为那些节点是由`XCharts`内部根据配置和数据生成的,即使改了也会在刷新时还原回来 XCharts经过不断的迭代优化,目前已有多达几十种的主组件和子组件,每个组件有几个到几十个的可配置参数,用来支持多样化的功能
首次使用XCharts建议亲自去测试下各个图表各个组件的实际效果。`Inspector` 视图可以直接添加各种图表,各种组件以及调整各个配置参数,`Game` 视图会实时反馈调整后的效果。各个组件的详细参数说明可查阅[XCharts配置项手册](configuration.md)。
### 如何快速调整参数
XCharts是数据和参数驱动的。想要什么效果只需要去调整对应组件下的配置参数就可以不能去改`Hierarchy`视图下的节点因为那些节点是由XCharts内部根据配置和数据生成的即使改了也会在刷新时被还原掉。
如何快速定位你想要改的效果所对应的组件这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头如何定位第一步X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果,对于不太确定的参数可以查阅[XCharts配置项手册](configuration.md)。 如何快速定位你想要改的效果所对应的组件这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头如何定位第一步X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果,对于不太确定的参数可以查阅[XCharts配置项手册](configuration.md)。
@@ -93,9 +155,13 @@ XCharts经过不断的迭代优化目前已有多达几十种的主组件和
2. 如果`Serie``ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。 2. 如果`Serie``ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
3. 否则颜色值取自主题`Theme``Color Palette` 3. 否则颜色值取自主题`Theme``Color Palette`
通常颜色值为0000时表示用主题默认颜色配置为0或null时表示用主题默认配置。 :::tip
## 用代码添加折线图 通常颜色值为0000时表示用主题默认颜色其他参数为0或null时表示用主题默认配置设置颜色时注意透明度。
:::
### 用代码添加折线图
`gameObject`挂上`LineChart`脚本: `gameObject`挂上`LineChart`脚本:
@@ -143,13 +209,21 @@ var yAxis = chart.EnsureChartComponent<YAxis>();
yAxis.type = Axis.AxisType.Value; yAxis.type = Axis.AxisType.Value;
``` ```
清空默认数据,添加`Line`类型的`Serie`用于接收数据: 清空所有默认数据包含Serie,添加`Line`类型的`Serie`用于接收数据:
```csharp ```csharp
chart.RemoveData(); chart.RemoveData();
chart.AddSerie<Line>("line"); chart.AddSerie<Line>("line");
``` ```
如果Serie是固定的建议只是清空数据不用把Serie也清掉
```csharp
chart.ClearData();
```
这样可以提前在UI上设置好Serie的配置参数。
添加10个数据 添加10个数据
```csharp ```csharp
@@ -164,30 +238,34 @@ for (int i = 0; i < 10; i++)
![tutorial01_linechart_simple](img/tutorial01_linechart_simple.png) ![tutorial01_linechart_simple](img/tutorial01_linechart_simple.png)
如果一个Chart里面有多个系列时则Axis的data只需要加一次不要多个循环加重复了。记住Axis的数据个数要和Serie的数据个数一致。 如果一个Chart里面有多个系列时则Axis的data只需要加一次不要多个循环加重复了。
:::danger
请确保Axis的数据个数和Serie的数据个数一致。
:::
完整代码请查阅`Examples``Example13_LineSimple.cs` 完整代码请查阅`Examples``Example13_LineSimple.cs`
你还可以用代码控制更多的参数,`Examples`下还有更多的其他例子,凡是`Inspector`上看到的可配置的参数,都可以通过代码来设置。[XCharts配置项手册](configuration.md)里面的所有参数都是可以通过代码控制的。 你还可以用代码控制更多的参数,`Examples`下还有更多的其他例子,凡是`Inspector`上看到的可配置的参数,都可以通过代码来设置。[XCharts配置项手册](configuration.md)里面的所有参数都是可以通过代码控制的。
另外,除非定制,建议调用`Chart`下提供的`public`接口,特别是数据相关操作部分。这些接口内部会做一些关联处理,比如刷新图表等。常见的接口有: ### 设置默认字体
1. `chart.ClearData()`清空图表数据不移除Series XCharts默认使用的是Unity默认字体`Arial`在WebGL平台上可能无法显示中文。在将XCharts用在你的项目时建议先设置好字体
2. `chart.RemoveData()`清除图表数据会移除所有Serie
3. `chart.AddSerie()`添加Serie
4. `chart.AddXAxisData()`添加X轴数据
5. `chart.AddData()`添加Serie数据
6. `chart.UpdateData()`更新Serie数据
7. `chart.UpdateXAxisData()`更新X轴数据
8. `chart.UpdateDataName()`更新Serie数据的名字
XCharts内部有自动刷新机制但也是在一定条件才会触发。如果自己调用了内部组件的接口碰到组件没有刷新确实找不到原因的话可以用以下两个接口强制刷新 - 找到`XCharts/Resources/XCSetting.asset`资源,修改里面的`Font`并保存。
- 找到`XCharts/Resources/XCTheme-Default.asset``XCharts/Resources/XCTheme-Default.asset`两个字体配置,点击`Sync Font from Setting``Sync Font to Sub Theme`按钮将字体同步到主题配置文件上。
1. `chart.RefreshAllComponent()`:刷新图表组件,会重新初始化所有组件,不建议频繁待用 字体设置好后,新创建的图表就会用新设置的字体了。对于旧图表,可以点击`Rebuild Chart Object`进行刷新
2. `chart.RefreshChart()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
3. 各个组件也可以通过`SetAllDirty()`只刷新自己。
## 使用TextMeshPro :::warning
使用XCharts前建议先设置好字体更新XCharts时注意设置的字体可能被还原的问题。
:::
### 使用TextMeshPro
XCharts支持TextMeshPro但默认是不开启的需要自己手动切换。可通过以下方式开启和关闭 XCharts支持TextMeshPro但默认是不开启的需要自己手动切换。可通过以下方式开启和关闭
@@ -206,10 +284,33 @@ XCharts支持TextMeshPro但默认是不开启的需要自己手动切换
`3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序将XCharts-Daemon导入项目后在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef确保编译正常。 `3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序将XCharts-Daemon导入项目后在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef确保编译正常。
## 用代码改图表参数 ## XCharts的代码控制
`Inspector`上看到的所有参数都可以用代码来修改关键是要定位好你要改的参数是在组件上、还是Serie上、还是在具体的数据项SerieData上。 `Inspector`上看到的所有参数都可以用代码来修改关键是要定位好你要改的参数是在组件上、还是Serie上、还是在具体的数据项SerieData上。
另外,除非定制,建议调用`Chart`下提供的`public`接口,特别是数据相关和列表的操作。这些接口内部会做一些关联处理,比如刷新图表等。常见的接口有:
1. `chart.ClearData()`清空图表数据不移除Series
2. `chart.RemoveData()`清除图表数据会移除所有Serie
3. `chart.AddSerie()`添加Serie
4. `chart.AddXAxisData()`添加X轴数据
5. `chart.AddData()`添加Serie数据
6. `chart.UpdateData()`更新Serie数据
7. `chart.UpdateXAxisData()`更新X轴数据
8. `chart.UpdateDataName()`更新Serie数据的名字
XCharts内部有自动刷新机制但也是在一定条件才会触发。如果自己调用了内部组件的接口碰到组件没有刷新确实找不到原因的话可以用以下两个接口强制刷新
1. `chart.RefreshAllComponent()`:刷新图表组件,会重新初始化所有组件,不建议频繁待用。
2. `chart.RefreshChart()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
3. 各个组件也可以通过`SetAllDirty()`只刷新自己。
:::danger
用API去操作数据和各种list而不是直接访问list进行处理
:::
### 改主组件上的参数 ### 改主组件上的参数
需要先获取组件,再修改里面的参数: 需要先获取组件,再修改里面的参数:
@@ -225,7 +326,11 @@ xAxis.boundaryGap = true;
xAxis.type = Axis.AxisType.Category; xAxis.type = Axis.AxisType.Category;
``` ```
> 注:低版本没有`EnsureChartComponent()`接口时,用`GetOrAddChartComponent()` :::note
低版本没有`EnsureChartComponent()`接口时,用`GetOrAddChartComponent()`
:::
### 改Serie的参数 ### 改Serie的参数

View File

@@ -46,6 +46,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_AutoColor"); PropertyField(prop, "m_AutoColor");
PropertyField(prop, "m_ShowStartLine"); PropertyField(prop, "m_ShowStartLine");
PropertyField(prop, "m_ShowEndLine"); PropertyField(prop, "m_ShowEndLine");
PropertyField(prop, "m_ShowZLine");
} }
} }

View File

@@ -27,7 +27,10 @@ namespace XCharts.Editor
} }
PropertyField(prop, "m_Color"); PropertyField(prop, "m_Color");
PropertyField(prop, "m_Size"); PropertyField(prop, "m_Size");
PropertyField(prop, "m_Size2");
PropertyField(prop, "m_Gap"); PropertyField(prop, "m_Gap");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_EmptyColor");
PropertyField(prop, "m_Offset"); PropertyField(prop, "m_Offset");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }

View File

@@ -27,14 +27,13 @@ namespace XCharts.Editor
PropertyField(prop, "m_Color"); PropertyField(prop, "m_Color");
PropertyField(prop, "m_FontSize"); PropertyField(prop, "m_FontSize");
PropertyField(prop, "m_LineSpacing"); PropertyField(prop, "m_LineSpacing");
PropertyField(prop, "m_Alignment");
PropertyField(prop, "m_AutoAlign");
#if dUI_TextMeshPro #if dUI_TextMeshPro
PropertyField(prop, "m_TMPFontStyle"); PropertyField(prop, "m_TMPFontStyle");
PropertyField(prop, "m_TMPSpriteAsset"); PropertyField(prop, "m_TMPSpriteAsset");
PropertyField(prop, "m_TMPAlignment");
#else #else
PropertyField(prop, "m_FontStyle"); PropertyField(prop, "m_FontStyle");
PropertyField(prop, "m_Alignment");
PropertyField(prop, "m_AutoAlign");
PropertyField(prop, "m_AutoWrap"); PropertyField(prop, "m_AutoWrap");
#endif #endif
--EditorGUI.indentLevel; --EditorGUI.indentLevel;

View File

@@ -0,0 +1,23 @@
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Editor
{
[CustomPropertyDrawer(typeof(ViewControl), true)]
public class ViewControlDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "ViewControl"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeComponentFoldout(prop, "", true))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Alpha");
PropertyField(prop, "m_Beta");
--EditorGUI.indentLevel;
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 1d778205a63524227a09c7e5b0e8736f guid: faeb8611591ee4c038e88fdb5a67b5ae
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -64,6 +64,7 @@ namespace XCharts.Editor
if (type == Axis.AxisType.Category) if (type == Axis.AxisType.Category)
{ {
PropertyField("m_MaxCache"); PropertyField("m_MaxCache");
PropertyField("m_MinCategorySpacing");
PropertyField("m_BoundaryGap"); PropertyField("m_BoundaryGap");
} }
else else
@@ -106,6 +107,15 @@ namespace XCharts.Editor
[ComponentEditor(typeof(YAxis))] [ComponentEditor(typeof(YAxis))]
public class YAxisEditor : AxisEditor { } public class YAxisEditor : AxisEditor { }
[ComponentEditor(typeof(XAxis3D))]
public class XAxis3DEditor : AxisEditor { }
[ComponentEditor(typeof(YAxis3D))]
public class YAxis3DEditor : AxisEditor { }
[ComponentEditor(typeof(ZAxis3D))]
public class ZAxis3DEditor : AxisEditor { }
[ComponentEditor(typeof(SingleAxis))] [ComponentEditor(typeof(SingleAxis))]
public class SingleAxisEditor : AxisEditor public class SingleAxisEditor : AxisEditor
{ {

View File

@@ -0,0 +1,23 @@
using UnityEditor;
using XCharts.Runtime;
namespace XCharts.Editor
{
[ComponentEditor(typeof(GridCoord3D))]
public class GridCoord3DEditor : MainComponentEditor<GridCoord3D>
{
public override void OnInspectorGUI()
{
++EditorGUI.indentLevel;
PropertyField("m_Left");
PropertyField("m_Bottom");
PropertyField("m_BoxWidth");
PropertyField("m_BoxHeight");
PropertyField("m_BoxDepth");
PropertyField("m_XYExchanged");
PropertyField("m_ShowBorder");
PropertyField("m_ViewControl");
--EditorGUI.indentLevel;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c9a4a8a30b1124c4e996e234d5717a07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -11,13 +11,10 @@ namespace XCharts.Editor
++EditorGUI.indentLevel; ++EditorGUI.indentLevel;
var layoutIndex = baseProperty.FindPropertyRelative("m_LayoutIndex").intValue; var layoutIndex = baseProperty.FindPropertyRelative("m_LayoutIndex").intValue;
PropertyField("m_LayoutIndex"); PropertyField("m_LayoutIndex");
if (layoutIndex < 0) PropertyField("m_Left");
{ PropertyField("m_Right");
PropertyField("m_Left"); PropertyField("m_Top");
PropertyField("m_Right"); PropertyField("m_Bottom");
PropertyField("m_Top");
PropertyField("m_Bottom");
}
PropertyField("m_BackgroundColor"); PropertyField("m_BackgroundColor");
PropertyField("m_ShowBorder"); PropertyField("m_ShowBorder");
PropertyField("m_BorderWidth"); PropertyField("m_BorderWidth");

View File

@@ -11,6 +11,7 @@ namespace XCharts.Editor
++EditorGUI.indentLevel; ++EditorGUI.indentLevel;
PropertyField("m_Type"); PropertyField("m_Type");
PropertyField("m_Trigger"); PropertyField("m_Trigger");
PropertyField("m_TriggerOn");
PropertyField("m_Position"); PropertyField("m_Position");
PropertyField("m_FixedX"); PropertyField("m_FixedX");
PropertyField("m_FixedY"); PropertyField("m_FixedY");

View File

@@ -16,6 +16,7 @@ namespace XCharts.Editor
PropertyField("m_RoundCap"); PropertyField("m_RoundCap");
PropertyField("m_Clockwise"); PropertyField("m_Clockwise");
PropertyField("m_AvoidLabelOverlap"); PropertyField("m_AvoidLabelOverlap");
PropertyField("m_RadiusGradient");
PropertyField("m_ItemStyle"); PropertyField("m_ItemStyle");
PropertyField("m_Animation"); PropertyField("m_Animation");

View File

@@ -9,8 +9,8 @@ namespace XCharts.Editor
{ {
public class SerieBaseEditor public class SerieBaseEditor
{ {
internal BaseChart chart { get; private set; } public BaseChart chart { get; private set; }
internal Serie serie { get; private set; } public Serie serie { get; private set; }
//Editor m_Inspector; //Editor m_Inspector;
internal SerializedProperty baseProperty; internal SerializedProperty baseProperty;

View File

@@ -53,14 +53,18 @@ namespace XCharts.Editor
} }
} }
private HeaderMenuInfo headMenuInfo = new HeaderMenuInfo("Import ECharts Data", null);
private void HeadMenuInfoCallback()
{
PraseExternalDataEditor.UpdateData(chart, serie, null, false);
PraseExternalDataEditor.ShowWindow();
}
private void PropertyFieldData() private void PropertyFieldData()
{ {
m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null, headMenuInfo.action = HeadMenuInfoCallback;
new HeaderMenuInfo("Import ECharts Data", () => m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null, headMenuInfo);
{
PraseExternalDataEditor.UpdateData(chart, serie, null, false);
PraseExternalDataEditor.ShowWindow();
}));
if (!m_DataFoldout) return; if (!m_DataFoldout) return;
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
var m_Datas = FindProperty("m_Data"); var m_Datas = FindProperty("m_Data");
@@ -103,14 +107,18 @@ namespace XCharts.Editor
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
private HeaderMenuInfo linkHeadMenuInfo = new HeaderMenuInfo("Import ECharts Link", null);
private void LinkHeadMenuInfoCallback()
{
PraseExternalDataEditor.UpdateData(chart, serie, null, false);
PraseExternalDataEditor.ShowWindow();
}
protected void PropertyFieldLinks() protected void PropertyFieldLinks()
{ {
m_LinksFoldout = ChartEditorHelper.DrawHeader("Links", m_LinksFoldout, false, null, null, linkHeadMenuInfo.action = LinkHeadMenuInfoCallback;
new HeaderMenuInfo("Import ECharts Link", () => m_LinksFoldout = ChartEditorHelper.DrawHeader("Links", m_LinksFoldout, false, null, null, linkHeadMenuInfo);
{
//PraseExternalDataEditor.UpdateData(chart, serie, null, true);
//PraseExternalDataEditor.ShowWindow();
}));
if (!m_LinksFoldout) return; if (!m_LinksFoldout) return;
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
var m_Links = FindProperty("m_Links"); var m_Links = FindProperty("m_Links");
@@ -154,6 +162,84 @@ namespace XCharts.Editor
} }
} }
private void DrawSerieDataHeader(Rect drawRect, HeaderCallbackContext context)
{
var serieData = context.serieData;
var fieldCount = context.fieldCount;
var showName = context.showName;
var index = context.index;
var dimension = context.dimension;
//drawRect.width -= 2f;
var maxX = drawRect.xMax;
var currentWidth = drawRect.width;
var lastX = drawRect.x;
var lastWid = drawRect.width;
var lastFieldWid = EditorGUIUtility.fieldWidth;
var lastLabelWid = EditorGUIUtility.labelWidth;
var sereName = serieData.FindPropertyRelative("m_Name");
var data = serieData.FindPropertyRelative("m_Data");
#if UNITY_2019_3_OR_NEWER
var gap = 2;
var namegap = 3;
var buttomLength = 30;
#else
var gap = 0;
var namegap = 0;
var buttomLength = 30;
#endif
if (showName)
{
buttomLength += 12;
}
if (fieldCount <= 1)
{
while (2 > data.arraySize)
{
var value = data.arraySize == 0 ? index : 0;
data.arraySize++;
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
SerializedProperty element = data.GetArrayElementAtIndex(1);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
drawRect.x = startX;
drawRect.xMax = maxX - buttomLength;
EditorGUI.PropertyField(drawRect, element, GUIContent.none);
}
else
{
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
var dataWidTotal = currentWidth - (startX + 20.5f + 1) - buttomLength;
var dataWid = dataWidTotal / fieldCount;
var xWid = dataWid - 0;
for (int i = 0; i < dimension; i++)
{
var dataCount = i < 1 ? 2 : i + 1;
while (dataCount > data.arraySize)
{
var value = data.arraySize == 0 ? index : 0;
data.arraySize++;
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
drawRect.x = startX + i * xWid;
drawRect.width = dataWid + 25;
SerializedProperty element = data.GetArrayElementAtIndex(dimension <= 1 ? 1 : i);
EditorGUI.PropertyField(drawRect, element, GUIContent.none);
}
if (showName)
{
drawRect.x = startX + (fieldCount - 1) * xWid;
drawRect.width = dataWid + 40 + dimension * namegap - 2.5f;
EditorGUI.PropertyField(drawRect, sereName, GUIContent.none);
}
drawRect.x = lastX;
drawRect.width = lastWid;
ChartEditorHelper.UpDownAddDeleteButton(drawRect, context.listProp, index);
EditorGUIUtility.fieldWidth = lastFieldWid;
EditorGUIUtility.labelWidth = lastLabelWid;
}
}
private void DrawSerieData(int dimension, SerializedProperty m_Datas, int index, bool showName) private void DrawSerieData(int dimension, SerializedProperty m_Datas, int index, bool showName)
{ {
bool flag; bool flag;
@@ -165,70 +251,16 @@ namespace XCharts.Editor
var fieldCount = dimension + (showName ? 1 : 0); var fieldCount = dimension + (showName ? 1 : 0);
var serieData = m_Datas.GetArrayElementAtIndex(index); var serieData = m_Datas.GetArrayElementAtIndex(index);
var dataIndex = serieData.FindPropertyRelative("m_Index").intValue; var dataIndex = serieData.FindPropertyRelative("m_Index").intValue;
m_DataElementFoldout[index] = ChartEditorHelper.DrawHeader("SerieData " + dataIndex, flag, false, null, var callbackContext = new HeaderCallbackContext()
delegate (Rect drawRect) {
{ serieData = serieData,
//drawRect.width -= 2f; fieldCount = fieldCount,
var maxX = drawRect.xMax; showName = showName,
var currentWidth = drawRect.width; index = index,
var lastX = drawRect.x; dimension = dimension,
var lastWid = drawRect.width; listProp = m_Datas
var lastFieldWid = EditorGUIUtility.fieldWidth; };
var lastLabelWid = EditorGUIUtility.labelWidth; m_DataElementFoldout[index] = ChartEditorHelper.DrawSerieDataHeader("SerieData " + dataIndex, flag, false, null, callbackContext, DrawSerieDataHeader);
//var serieData = m_Datas.GetArrayElementAtIndex(index);
var sereName = serieData.FindPropertyRelative("m_Name");
var data = serieData.FindPropertyRelative("m_Data");
#if UNITY_2019_3_OR_NEWER
var gap = 2;
var namegap = 3;
#else
var gap = 0;
var namegap = 0;
#endif
if (fieldCount <= 1)
{
while (2 > data.arraySize)
{
var value = data.arraySize == 0 ? index : 0;
data.arraySize++;
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
SerializedProperty element = data.GetArrayElementAtIndex(1);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
drawRect.x = startX;
drawRect.xMax = maxX;
EditorGUI.PropertyField(drawRect, element, GUIContent.none);
}
else
{
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
var dataWidTotal = (currentWidth - (startX + 20.5f + 1));
var dataWid = dataWidTotal / fieldCount;
var xWid = dataWid - 0;
for (int i = 0; i < dimension; i++)
{
var dataCount = i < 1 ? 2 : i + 1;
while (dataCount > data.arraySize)
{
var value = data.arraySize == 0 ? index : 0;
data.arraySize++;
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
drawRect.x = startX + i * xWid;
drawRect.width = dataWid + 25;
SerializedProperty element = data.GetArrayElementAtIndex(dimension <= 1 ? 1 : i);
EditorGUI.PropertyField(drawRect, element, GUIContent.none);
}
if (showName)
{
drawRect.x = startX + (fieldCount - 1) * xWid;
drawRect.width = dataWid + 40 + dimension * namegap - 2.5f;
EditorGUI.PropertyField(drawRect, sereName, GUIContent.none);
}
EditorGUIUtility.fieldWidth = lastFieldWid;
EditorGUIUtility.labelWidth = lastLabelWid;
}
});
if (m_DataElementFoldout[index]) if (m_DataElementFoldout[index])
{ {
if (!(serie is ISimplifiedSerie)) if (!(serie is ISimplifiedSerie))
@@ -306,7 +338,10 @@ namespace XCharts.Editor
var sourceIndex = dataLink.FindPropertyRelative("m_Source"); var sourceIndex = dataLink.FindPropertyRelative("m_Source");
var targetIndex = dataLink.FindPropertyRelative("m_Target"); var targetIndex = dataLink.FindPropertyRelative("m_Target");
var value = dataLink.FindPropertyRelative("m_Value"); var value = dataLink.FindPropertyRelative("m_Value");
ChartEditorHelper.MakeThreeField(ref drawRect, drawRect.width, sourceIndex, targetIndex, value, ""); var hig = ChartEditorHelper.MakeThreeField(ref drawRect, drawRect.width, sourceIndex, targetIndex, value, "");
var btnRect = drawRect;
btnRect.y -= hig;
ChartEditorHelper.UpDownAddDeleteButton(btnRect, m_Datas, index);
}); });
if (m_LinksElementFoldout[index]) if (m_LinksElementFoldout[index])
{ {

View File

@@ -6,6 +6,16 @@ using XCharts.Runtime;
namespace XCharts.Editor namespace XCharts.Editor
{ {
public class HeaderCallbackContext
{
public int fieldCount = 0;
public SerializedProperty serieData;
public bool showName;
public int index;
public int dimension;
public SerializedProperty listProp;
}
public class HeaderMenuInfo public class HeaderMenuInfo
{ {
public string name; public string name;
@@ -43,6 +53,8 @@ namespace XCharts.Editor
public const float GAP_WIDTH = 0; public const float GAP_WIDTH = 0;
public const float DIFF_WIDTH = 1; public const float DIFF_WIDTH = 1;
#endif #endif
public const float ICON_WIDHT = 10;
public const float ICON_GAP = 0;
static Dictionary<string, GUIContent> s_GUIContentCache; static Dictionary<string, GUIContent> s_GUIContentCache;
static ChartEditorHelper() static ChartEditorHelper()
@@ -96,31 +108,33 @@ namespace XCharts.Editor
{ {
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;
var diff = 13 + EditorGUI.indentLevel * 14; var diff = 12 + EditorGUI.indentLevel * 14;
var offset = diff - INDENT_WIDTH; var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 2; var tempWidth = (rectWidth - startX + diff) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1); var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1); var centerYRect = new Rect(centerXRect.x + tempWidth - offset + 3.4f, drawRect.y, tempWidth - 1, drawRect.height - 1);
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none); EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none); EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
public static void MakeThreeField(ref Rect drawRect, float rectWidth, SerializedProperty prop1, public static float MakeThreeField(ref Rect drawRect, float rectWidth, SerializedProperty prop1,
SerializedProperty prop2, SerializedProperty prop3, string name) SerializedProperty prop2, SerializedProperty prop3, string name, bool btnSpacing = true)
{ {
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;
var diff = 13 + EditorGUI.indentLevel * 14; var diff = 13f + EditorGUI.indentLevel * 14;
var offset = diff - INDENT_WIDTH; var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 3; var tempWidth = (rectWidth - startX + diff - (btnSpacing ? (ICON_WIDHT + ICON_GAP) * 4 : 0)) / 3 + 8.5f;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1); var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1); var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
var centerZRect = new Rect(centerYRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1); var centerZRect = new Rect(centerYRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none); EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none); EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
EditorGUI.PropertyField(centerZRect, prop3, GUIContent.none); EditorGUI.PropertyField(centerZRect, prop3, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; var hig = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.y += hig;
return hig;
} }
public static void MakeVector2(ref Rect drawRect, float rectWidth, SerializedProperty prop, string name) public static void MakeVector2(ref Rect drawRect, float rectWidth, SerializedProperty prop, string name)
@@ -312,7 +326,13 @@ namespace XCharts.Editor
var foldoutRect = drawRect; var foldoutRect = drawRect;
foldoutRect.xMax -= 10; foldoutRect.xMax -= 10;
bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true); bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true);
ChartEditorHelper.DrawMenu(drawRect, menus); if (!flag)
{
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var sizeRect = new Rect(startX, drawRect.y + 1f, (EditorGUI.indentLevel + 1) * 15, drawRect.height - 1);
EditorGUI.IntField(sizeRect, GUIContent.none, listProp.arraySize);
DrawMenu(drawRect, menus);
}
height += headerHeight; height += headerHeight;
drawRect.y += headerHeight; drawRect.y += headerHeight;
drawRect.width = rawWidth; drawRect.width = rawWidth;
@@ -335,15 +355,12 @@ namespace XCharts.Editor
{ {
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
var listSize = listProp.arraySize; var listSize = listProp.arraySize;
var iconWidth = 10;
var iconGap = 0f;
if (showSize) if (showSize)
{ {
var headerHeight = DrawSplitterAndBackground(drawRect); var headerHeight = DrawSplitterAndBackground(drawRect);
if (showOrder) if (showOrder)
{ {
var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth + 2, drawRect.height); var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - ICON_WIDHT + 2, drawRect.height);
var oldColor = GUI.contentColor; var oldColor = GUI.contentColor;
GUI.contentColor = Color.black; GUI.contentColor = Color.black;
GUI.contentColor = oldColor; GUI.contentColor = oldColor;
@@ -396,40 +413,14 @@ namespace XCharts.Editor
DrawSplitterAndBackground(drawRect); DrawSplitterAndBackground(drawRect);
if (showOrder) if (showOrder)
{ {
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 - 2 * iconGap, drawRect.height) : new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * ICON_GAP, drawRect.height) :
new Rect(drawRect.x, drawRect.y, drawRect.width - 4 * iconWidth, drawRect.height); new Rect(drawRect.x, drawRect.y, drawRect.width - 4 * ICON_WIDHT, drawRect.height);
EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i)); EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i));
var iconRect = new Rect(drawRect.width - 4 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); UpDownAddDeleteButton(drawRect, listProp, i);
var oldColor = GUI.contentColor; drawRect.y += EditorGUI.GetPropertyHeight(element);
GUI.contentColor = Color.black; height += EditorGUI.GetPropertyHeight(element);
if (GUI.Button(iconRect, EditorCustomStyles.iconUp, EditorCustomStyles.invisibleButton))
{
if (i > 0) listProp.MoveArrayElement(i, i - 1);
}
iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
if (GUI.Button(iconRect, EditorCustomStyles.iconDown, EditorCustomStyles.invisibleButton))
{
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
}
iconRect = new Rect(drawRect.width - 2 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
if (GUI.Button(iconRect, EditorCustomStyles.iconAdd, EditorCustomStyles.invisibleButton))
{
if (i < listProp.arraySize && i >= 0) listProp.InsertArrayElementAtIndex(i);
}
iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
if (GUI.Button(iconRect, EditorCustomStyles.iconRemove, EditorCustomStyles.invisibleButton))
{
if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
}
else
{
drawRect.y += EditorGUI.GetPropertyHeight(element);
height += EditorGUI.GetPropertyHeight(element);
}
GUI.contentColor = oldColor;
} }
else else
{ {
@@ -442,6 +433,34 @@ namespace XCharts.Editor
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
public static void UpDownAddDeleteButton(Rect drawRect, SerializedProperty listProp, int i)
{
var temp = INDENT_WIDTH + GAP_WIDTH + ICON_GAP;
var iconRect = new Rect(drawRect.width - 4 * ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height);
var oldColor = GUI.contentColor;
GUI.contentColor = Color.black;
if (GUI.Button(iconRect, EditorCustomStyles.iconUp, EditorCustomStyles.invisibleButton))
{
if (i > 0) listProp.MoveArrayElement(i, i - 1);
}
iconRect = new Rect(drawRect.width - 3 * ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height);
if (GUI.Button(iconRect, EditorCustomStyles.iconDown, EditorCustomStyles.invisibleButton))
{
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
}
iconRect = new Rect(drawRect.width - 2 * ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height);
if (GUI.Button(iconRect, EditorCustomStyles.iconAdd, EditorCustomStyles.invisibleButton))
{
if (i < listProp.arraySize && i >= 0) listProp.InsertArrayElementAtIndex(i);
}
iconRect = new Rect(drawRect.width - ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height);
if (GUI.Button(iconRect, EditorCustomStyles.iconRemove, EditorCustomStyles.invisibleButton))
{
if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
}
GUI.contentColor = oldColor;
}
public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key, public static bool PropertyField(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty prop) SerializedProperty prop)
{ {
@@ -586,6 +605,31 @@ namespace XCharts.Editor
return state; return state;
} }
public static bool DrawSerieDataHeader(string title, bool state, bool drawBackground, SerializedProperty activeField,
HeaderCallbackContext context, Action<Rect, HeaderCallbackContext> drawCallback, params HeaderMenuInfo[] menus)
{
var rect = GUILayoutUtility.GetRect(1f, HEADER_HEIGHT);
var labelRect = DrawHeaderInternal(rect, title, ref state, drawBackground, activeField);
DrawMenu(rect, menus);
if (drawCallback != null)
{
drawCallback(rect, context);
}
var e = Event.current;
if (e.type == EventType.MouseDown)
{
if (labelRect.Contains(e.mousePosition))
{
if (e.button == 0)
{
state = !state;
e.Use();
}
}
}
return state;
}
internal static bool DrawHeader(string title, bool state, bool drawBackground, SerializedProperty activeField, internal static bool DrawHeader(string title, bool state, bool drawBackground, SerializedProperty activeField,
Action<Rect> drawCallback, List<HeaderMenuInfo> menus) Action<Rect> drawCallback, List<HeaderMenuInfo> menus)
{ {

View File

@@ -8,6 +8,8 @@ namespace XCharts.Editor
{ {
public class PraseExternalDataEditor : UnityEditor.EditorWindow public class PraseExternalDataEditor : UnityEditor.EditorWindow
{ {
[SerializeField] private int m_DataDimension = 1;
[SerializeField] private double m_DefaultYValue = 0;
private static BaseChart s_Chart; private static BaseChart s_Chart;
private static Serie s_Serie; private static Serie s_Serie;
private static Axis s_Axis; private static Axis s_Axis;
@@ -46,8 +48,13 @@ namespace XCharts.Editor
return; return;
} }
EditorGUILayout.LabelField("Input external data (echarts data):"); EditorGUILayout.LabelField("Input external data (echarts data):");
m_DataDimension = EditorGUILayout.IntField("Data Dimension", m_DataDimension);
if (m_DataDimension < 1)
m_DataDimension = 1;
else if (m_DataDimension == 2)
m_DefaultYValue = EditorGUILayout.DoubleField("Default Y Value", m_DefaultYValue);
inputJsonText = EditorGUILayout.TextArea(inputJsonText, GUILayout.Height(400)); inputJsonText = EditorGUILayout.TextArea(inputJsonText, GUILayout.Height(400));
if (GUILayout.Button("Add")) if (GUILayout.Button("Try Add"))
{ {
if (s_Serie != null) if (s_Serie != null)
{ {
@@ -76,7 +83,7 @@ namespace XCharts.Editor
} }
} }
private static bool ParseArrayData(Axis axis, string arrayData) private bool ParseArrayData(Axis axis, string arrayData)
{ {
arrayData = arrayData.Trim(); arrayData = arrayData.Trim();
if (!arrayData.StartsWith("data: Array")) return false; if (!arrayData.StartsWith("data: Array")) return false;
@@ -95,7 +102,7 @@ namespace XCharts.Editor
return true; return true;
} }
private static bool ParseArrayData(Serie serie, string arrayData) private bool ParseArrayData(Serie serie, string arrayData)
{ {
arrayData = arrayData.Trim(); arrayData = arrayData.Trim();
if (!arrayData.StartsWith("data: Array")) return false; if (!arrayData.StartsWith("data: Array")) return false;
@@ -120,7 +127,7 @@ namespace XCharts.Editor
return true; return true;
} }
private static bool ParseJsonData(Axis axis, string jsonData) private bool ParseJsonData(Axis axis, string jsonData)
{ {
if (!CheckJsonData(ref jsonData)) return false; if (!CheckJsonData(ref jsonData)) return false;
axis.data.Clear(); axis.data.Clear();
@@ -140,7 +147,7 @@ namespace XCharts.Editor
/// 从json中导入数据 /// 从json中导入数据
/// </summary> /// </summary>
/// <param name="jsonData"></param> /// <param name="jsonData"></param>
private static bool ParseJsonData(Serie serie, string jsonData) private bool ParseJsonData(Serie serie, string jsonData)
{ {
if (!CheckJsonData(ref jsonData)) return false; if (!CheckJsonData(ref jsonData)) return false;
if (s_LinksData) serie.ClearLinks(); if (s_LinksData) serie.ClearLinks();
@@ -156,7 +163,10 @@ namespace XCharts.Editor
if (data.Length == 2 && !double.TryParse(data[0], out value)) if (data.Length == 2 && !double.TryParse(data[0], out value))
{ {
double.TryParse(data[1], out value); double.TryParse(data[1], out value);
serieData.data = new List<double>() { i, value }; if (m_DataDimension == 2)
serieData.data = new List<double>() { i, m_DefaultYValue, value };
else
serieData.data = new List<double>() { i, value };
serieData.name = data[0].Replace("\"", "").Trim(); serieData.name = data[0].Replace("\"", "").Trim();
} }
else else
@@ -187,7 +197,10 @@ namespace XCharts.Editor
if (a.StartsWith("value:")) if (a.StartsWith("value:"))
{ {
double value = double.Parse(a.Substring(6, a.Length - 6)); double value = double.Parse(a.Substring(6, a.Length - 6));
serieData.data = new List<double>() { i, value }; if (m_DataDimension == 2)
serieData.data = new List<double>() { i, m_DefaultYValue, value };
else
serieData.data = new List<double>() { i, value };
} }
else if (a.StartsWith("name:")) else if (a.StartsWith("name:"))
{ {
@@ -213,7 +226,10 @@ namespace XCharts.Editor
if (flag) if (flag)
{ {
var serieData = new SerieData(); var serieData = new SerieData();
serieData.data = new List<double>() { i, value }; if (m_DataDimension == 2)
serieData.data = new List<double>() { i, m_DefaultYValue, value };
else
serieData.data = new List<double>() { i, value };
serie.AddSerieData(serieData); serie.AddSerieData(serieData);
} }
} }

View File

@@ -14,14 +14,14 @@ namespace XCharts.Editor
public partial class XChartsEditor public partial class XChartsEditor
{ {
[MenuItem("XCharts/BarChart/Baisc Column", priority = 45)] [MenuItem("XCharts/BarChart/Baisc Column", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Baisc Column", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Baisc Column", priority = 45)]
public static void AddBarChart() public static void AddBarChart()
{ {
AddChart<BarChart>("BarChart"); AddChart<BarChart>("BarChart");
} }
[MenuItem("XCharts/BarChart/Zebra Column", priority = 45)] [MenuItem("XCharts/BarChart/Zebra Column", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Zebra Column", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Zebra Column", priority = 45)]
public static void AddBarChart_ZebraColumn() public static void AddBarChart_ZebraColumn()
{ {
var chart = AddChart<BarChart>("BarChart", "Zebra Column"); var chart = AddChart<BarChart>("BarChart", "Zebra Column");
@@ -29,7 +29,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Capsule Column", priority = 45)] [MenuItem("XCharts/BarChart/Capsule Column", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Capsule Column", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Capsule Column", priority = 45)]
public static void AddBarChart_CapsuleColumn() public static void AddBarChart_CapsuleColumn()
{ {
var chart = AddChart<BarChart>("BarChart", "Capsule Column"); var chart = AddChart<BarChart>("BarChart", "Capsule Column");
@@ -37,7 +37,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Grouped Column", priority = 45)] [MenuItem("XCharts/BarChart/Grouped Column", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Grouped Column", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Grouped Column", priority = 45)]
public static void AddBarChart_GroupedColumn() public static void AddBarChart_GroupedColumn()
{ {
var chart = AddChart<BarChart>("BarChart", "Grouped Column"); var chart = AddChart<BarChart>("BarChart", "Grouped Column");
@@ -45,7 +45,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Stacked Column", priority = 45)] [MenuItem("XCharts/BarChart/Stacked Column", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Stacked Column", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Stacked Column", priority = 45)]
public static void AddBarChart_StackedColumn() public static void AddBarChart_StackedColumn()
{ {
var chart = AddChart<BarChart>("BarChart", "Stacked Column"); var chart = AddChart<BarChart>("BarChart", "Stacked Column");
@@ -53,7 +53,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Percent Column", priority = 45)] [MenuItem("XCharts/BarChart/Percent Column", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Percent Column", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Percent Column", priority = 45)]
public static void AddBarChart_PercentColumn() public static void AddBarChart_PercentColumn()
{ {
var chart = AddChart<BarChart>("BarChart", "Percent Column"); var chart = AddChart<BarChart>("BarChart", "Percent Column");
@@ -61,7 +61,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Baisc Bar", priority = 45)] [MenuItem("XCharts/BarChart/Baisc Bar", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Baisc Bar", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Baisc Bar", priority = 45)]
public static void AddBarChart_BasicBar() public static void AddBarChart_BasicBar()
{ {
var chart = AddChart<BarChart>("BarChart"); var chart = AddChart<BarChart>("BarChart");
@@ -69,7 +69,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Zebra Bar", priority = 45)] [MenuItem("XCharts/BarChart/Zebra Bar", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Zebra Bar", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Zebra Bar", priority = 45)]
public static void AddBarChart_ZebraBar() public static void AddBarChart_ZebraBar()
{ {
var chart = AddChart<BarChart>("BarChart", "Zebra Bar"); var chart = AddChart<BarChart>("BarChart", "Zebra Bar");
@@ -77,7 +77,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Capsule Bar", priority = 45)] [MenuItem("XCharts/BarChart/Capsule Bar", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Capsule Bar", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Capsule Bar", priority = 45)]
public static void AddBarChart_CapsuleBar() public static void AddBarChart_CapsuleBar()
{ {
var chart = AddChart<BarChart>("BarChart", "Capsule Bar"); var chart = AddChart<BarChart>("BarChart", "Capsule Bar");
@@ -85,7 +85,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Grouped Bar", priority = 45)] [MenuItem("XCharts/BarChart/Grouped Bar", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Grouped Bar", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Grouped Bar", priority = 45)]
public static void AddBarChart_GroupedBar() public static void AddBarChart_GroupedBar()
{ {
var chart = AddChart<BarChart>("BarChart", "Grouped Bar"); var chart = AddChart<BarChart>("BarChart", "Grouped Bar");
@@ -93,7 +93,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Stacked Bar", priority = 45)] [MenuItem("XCharts/BarChart/Stacked Bar", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Stacked Bar", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Stacked Bar", priority = 45)]
public static void AddBarChart_StackedBar() public static void AddBarChart_StackedBar()
{ {
var chart = AddChart<BarChart>("BarChart", "Stacked Bar"); var chart = AddChart<BarChart>("BarChart", "Stacked Bar");
@@ -101,7 +101,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/BarChart/Percent Bar", priority = 45)] [MenuItem("XCharts/BarChart/Percent Bar", priority = 45)]
[MenuItem("GameObject/XCharts/BarChart/Percent Bar", priority = 45)] [MenuItem("GameObject/UI/XCharts/BarChart/Percent Bar", priority = 45)]
public static void AddBarChart_PercentBar() public static void AddBarChart_PercentBar()
{ {
var chart = AddChart<BarChart>("BarChart", "Percent Bar"); var chart = AddChart<BarChart>("BarChart", "Percent Bar");

View File

@@ -14,14 +14,14 @@ namespace XCharts.Editor
public partial class XChartsEditor public partial class XChartsEditor
{ {
[MenuItem("XCharts/LineChart/Basic Line", priority = 44)] [MenuItem("XCharts/LineChart/Basic Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Basic Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Basic Line", priority = 44)]
public static void AddLineChart() public static void AddLineChart()
{ {
AddChart<LineChart>("LineChart"); AddChart<LineChart>("LineChart");
} }
[MenuItem("XCharts/LineChart/Area Line", priority = 44)] [MenuItem("XCharts/LineChart/Area Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Area Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Area Line", priority = 44)]
public static void AddLineChart_Area() public static void AddLineChart_Area()
{ {
var chart = AddChart<LineChart>("LineChart_Area", "Area Line"); var chart = AddChart<LineChart>("LineChart_Area", "Area Line");
@@ -29,7 +29,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Smooth Line", priority = 44)] [MenuItem("XCharts/LineChart/Smooth Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Smooth Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Smooth Line", priority = 44)]
public static void AddLineChart_Smooth() public static void AddLineChart_Smooth()
{ {
var chart = AddChart<LineChart>("LineChart_Smooth", "Smooth Line"); var chart = AddChart<LineChart>("LineChart_Smooth", "Smooth Line");
@@ -37,7 +37,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Smooth Area", priority = 44)] [MenuItem("XCharts/LineChart/Smooth Area", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Smooth Area Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Smooth Area Line", priority = 44)]
public static void AddLineChart_SmoothArea() public static void AddLineChart_SmoothArea()
{ {
var chart = AddChart<LineChart>("LineChart_SmoothArea", "Smooth Area Line"); var chart = AddChart<LineChart>("LineChart_SmoothArea", "Smooth Area Line");
@@ -45,7 +45,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Stack Line", priority = 44)] [MenuItem("XCharts/LineChart/Stack Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Stack Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Stack Line", priority = 44)]
public static void AddLineChart_Stack() public static void AddLineChart_Stack()
{ {
var chart = AddChart<LineChart>("LineChart_Stack", "Stack Line"); var chart = AddChart<LineChart>("LineChart_Stack", "Stack Line");
@@ -53,7 +53,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Stack Area Line", priority = 44)] [MenuItem("XCharts/LineChart/Stack Area Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Stack Area Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Stack Area Line", priority = 44)]
public static void AddLineChart_StackArea() public static void AddLineChart_StackArea()
{ {
var chart = AddChart<LineChart>("LineChart_StackArea", "Stack Area Line"); var chart = AddChart<LineChart>("LineChart_StackArea", "Stack Area Line");
@@ -61,7 +61,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Step Line", priority = 44)] [MenuItem("XCharts/LineChart/Step Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Step Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Step Line", priority = 44)]
public static void AddLineChart_Step() public static void AddLineChart_Step()
{ {
var chart = AddChart<LineChart>("LineChart_Step", "Step Line"); var chart = AddChart<LineChart>("LineChart_Step", "Step Line");
@@ -69,7 +69,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Dashed Line", priority = 44)] [MenuItem("XCharts/LineChart/Dashed Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Dashed Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Dashed Line", priority = 44)]
public static void AddLineChart_Dash() public static void AddLineChart_Dash()
{ {
var chart = AddChart<LineChart>("LineChart_Dashed", "Dashed Line"); var chart = AddChart<LineChart>("LineChart_Dashed", "Dashed Line");
@@ -77,7 +77,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Time Line", priority = 44)] [MenuItem("XCharts/LineChart/Time Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Time Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Time Line", priority = 44)]
public static void AddLineChart_Time() public static void AddLineChart_Time()
{ {
var chart = AddChart<LineChart>("LineChart_Time", "Time Line"); var chart = AddChart<LineChart>("LineChart_Time", "Time Line");
@@ -85,7 +85,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/LineChart/Log Line", priority = 44)] [MenuItem("XCharts/LineChart/Log Line", priority = 44)]
[MenuItem("GameObject/XCharts/LineChart/Log Line", priority = 44)] [MenuItem("GameObject/UI/XCharts/LineChart/Log Line", priority = 44)]
public static void AddLineChart_Log() public static void AddLineChart_Log()
{ {
var chart = AddChart<LineChart>("LineChart_Log", "Log Line"); var chart = AddChart<LineChart>("LineChart_Log", "Log Line");

View File

@@ -14,14 +14,14 @@ namespace XCharts.Editor
public partial class XChartsEditor public partial class XChartsEditor
{ {
[MenuItem("XCharts/PieChart/Pie", priority = 46)] [MenuItem("XCharts/PieChart/Pie", priority = 46)]
[MenuItem("GameObject/XCharts/PieChart/Pie", priority = 46)] [MenuItem("GameObject/UI/XCharts/PieChart/Pie", priority = 46)]
public static void AddPieChart() public static void AddPieChart()
{ {
AddChart<PieChart>("PieChart"); AddChart<PieChart>("PieChart");
} }
[MenuItem("XCharts/PieChart/Pie With Label", priority = 46)] [MenuItem("XCharts/PieChart/Pie With Label", priority = 46)]
[MenuItem("GameObject/XCharts/PieChart/Pie With Label", priority = 46)] [MenuItem("GameObject/UI/XCharts/PieChart/Pie With Label", priority = 46)]
public static void AddPieChart_WithLabel() public static void AddPieChart_WithLabel()
{ {
var chart = AddChart<PieChart>("PieChart"); var chart = AddChart<PieChart>("PieChart");
@@ -29,7 +29,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/PieChart/Donut", priority = 46)] [MenuItem("XCharts/PieChart/Donut", priority = 46)]
[MenuItem("GameObject/XCharts/PieChart/Donut", priority = 46)] [MenuItem("GameObject/UI/XCharts/PieChart/Donut", priority = 46)]
public static void AddPieChart_Donut() public static void AddPieChart_Donut()
{ {
var chart = AddChart<PieChart>("PieChart"); var chart = AddChart<PieChart>("PieChart");
@@ -37,7 +37,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/PieChart/Donut With Label", priority = 46)] [MenuItem("XCharts/PieChart/Donut With Label", priority = 46)]
[MenuItem("GameObject/XCharts/PieChart/Donut With Label", priority = 46)] [MenuItem("GameObject/UI/XCharts/PieChart/Donut With Label", priority = 46)]
public static void AddPieChart_DonutWithLabel() public static void AddPieChart_DonutWithLabel()
{ {
var chart = AddChart<PieChart>("PieChart"); var chart = AddChart<PieChart>("PieChart");
@@ -45,7 +45,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/PieChart/Radius Rose", priority = 46)] [MenuItem("XCharts/PieChart/Radius Rose", priority = 46)]
[MenuItem("GameObject/XCharts/PieChart/Radius Rose", priority = 46)] [MenuItem("GameObject/UI/XCharts/PieChart/Radius Rose", priority = 46)]
public static void AddPieChart_RadiusRose() public static void AddPieChart_RadiusRose()
{ {
var chart = AddChart<PieChart>("PieChart"); var chart = AddChart<PieChart>("PieChart");
@@ -53,7 +53,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/PieChart/Area Rose", priority = 46)] [MenuItem("XCharts/PieChart/Area Rose", priority = 46)]
[MenuItem("GameObject/XCharts/PieChart/Area Rose", priority = 46)] [MenuItem("GameObject/UI/XCharts/PieChart/Area Rose", priority = 46)]
public static void AddPieChart_AreaRose() public static void AddPieChart_AreaRose()
{ {
var chart = AddChart<PieChart>("PieChart"); var chart = AddChart<PieChart>("PieChart");

View File

@@ -14,14 +14,14 @@ namespace XCharts.Editor
public partial class XChartsEditor public partial class XChartsEditor
{ {
[MenuItem("XCharts/PolarChart/Line", priority = 54)] [MenuItem("XCharts/PolarChart/Line", priority = 54)]
[MenuItem("GameObject/XCharts/PolarChart/Line", priority = 54)] [MenuItem("GameObject/UI/XCharts/PolarChart/Line", priority = 54)]
public static void PolarChart() public static void PolarChart()
{ {
AddChart<PolarChart>("PolarChart"); AddChart<PolarChart>("PolarChart");
} }
[MenuItem("XCharts/PolarChart/Radial Bar", priority = 54)] [MenuItem("XCharts/PolarChart/Radial Bar", priority = 54)]
[MenuItem("GameObject/XCharts/PolarChart/Radial Bar", priority = 54)] [MenuItem("GameObject/UI/XCharts/PolarChart/Radial Bar", priority = 54)]
public static void PolarChart_RadialBar() public static void PolarChart_RadialBar()
{ {
var chart = AddChart<PolarChart>("PolarChart"); var chart = AddChart<PolarChart>("PolarChart");
@@ -29,7 +29,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/PolarChart/Tangential Bar", priority = 54)] [MenuItem("XCharts/PolarChart/Tangential Bar", priority = 54)]
[MenuItem("GameObject/XCharts/PolarChart/Tangential Bar", priority = 54)] [MenuItem("GameObject/UI/XCharts/PolarChart/Tangential Bar", priority = 54)]
public static void PolarChart_TangentialBar() public static void PolarChart_TangentialBar()
{ {
var chart = AddChart<PolarChart>("PolarChart"); var chart = AddChart<PolarChart>("PolarChart");
@@ -37,7 +37,7 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/PolarChart/Heatmap", priority = 54)] [MenuItem("XCharts/PolarChart/Heatmap", priority = 54)]
[MenuItem("GameObject/XCharts/PolarChart/Heatmap", priority = 54)] [MenuItem("GameObject/UI/XCharts/PolarChart/Heatmap", priority = 54)]
public static void PolarChart_Heatmap() public static void PolarChart_Heatmap()
{ {
var chart = AddChart<PolarChart>("PolarChart"); var chart = AddChart<PolarChart>("PolarChart");

View File

@@ -19,7 +19,11 @@ namespace XCharts.Editor
GameObject selectObj = Selection.activeGameObject; GameObject selectObj = Selection.activeGameObject;
if (selectObj == null) if (selectObj == null)
{ {
#if UNITY_2023_1_OR_NEWER
var canvas = UnityEngine.Object.FindFirstObjectByType<Canvas>();
#else
var canvas = GameObject.FindObjectOfType<Canvas>(); var canvas = GameObject.FindObjectOfType<Canvas>();
#endif
if (canvas != null) return canvas.transform; if (canvas != null) return canvas.transform;
else else
{ {
@@ -96,21 +100,21 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/EmptyChart", priority = 43)] [MenuItem("XCharts/EmptyChart", priority = 43)]
[MenuItem("GameObject/XCharts/EmptyChart", priority = 43)] [MenuItem("GameObject/UI/XCharts/EmptyChart", priority = 43)]
public static void AddBaseChart() public static void AddBaseChart()
{ {
AddChart<BaseChart>("EmptyChart"); AddChart<BaseChart>("EmptyChart");
} }
[MenuItem("XCharts/RadarChart/Polygon Radar", priority = 47)] [MenuItem("XCharts/RadarChart/Polygon Radar", priority = 47)]
[MenuItem("GameObject/XCharts/RadarChart/Polygon Radar", priority = 47)] [MenuItem("GameObject/UI/XCharts/RadarChart/Polygon Radar", priority = 47)]
public static void AddRadarChart() public static void AddRadarChart()
{ {
AddChart<RadarChart>("RadarChart"); AddChart<RadarChart>("RadarChart");
} }
[MenuItem("XCharts/RadarChart/Cirle Radar", priority = 47)] [MenuItem("XCharts/RadarChart/Cirle Radar", priority = 47)]
[MenuItem("GameObject/XCharts/RadarChart/Cirle Radar", priority = 47)] [MenuItem("GameObject/UI/XCharts/RadarChart/Cirle Radar", priority = 47)]
public static void AddRadarChart_CirleRadar() public static void AddRadarChart_CirleRadar()
{ {
var chart = AddChart<RadarChart>("RadarChart"); var chart = AddChart<RadarChart>("RadarChart");
@@ -118,14 +122,14 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/ScatterChart/Scatter", priority = 48)] [MenuItem("XCharts/ScatterChart/Scatter", priority = 48)]
[MenuItem("GameObject/XCharts/ScatterChart/Scatter", priority = 48)] [MenuItem("GameObject/UI/XCharts/ScatterChart/Scatter", priority = 48)]
public static void AddScatterChart() public static void AddScatterChart()
{ {
AddChart<ScatterChart>("ScatterChart"); AddChart<ScatterChart>("ScatterChart");
} }
[MenuItem("XCharts/ScatterChart/Bubble", priority = 48)] [MenuItem("XCharts/ScatterChart/Bubble", priority = 48)]
[MenuItem("GameObject/XCharts/ScatterChart/Bubble", priority = 48)] [MenuItem("GameObject/UI/XCharts/ScatterChart/Bubble", priority = 48)]
public static void AddScatterChart_Bubble() public static void AddScatterChart_Bubble()
{ {
var chart = AddChart<ScatterChart>("ScatterChart"); var chart = AddChart<ScatterChart>("ScatterChart");
@@ -133,14 +137,14 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/HeatmapChart/Heatmap", priority = 49)] [MenuItem("XCharts/HeatmapChart/Heatmap", priority = 49)]
[MenuItem("GameObject/XCharts/HeatmapChart/Heatmap", priority = 49)] [MenuItem("GameObject/UI/XCharts/HeatmapChart/Heatmap", priority = 49)]
public static void AddHeatmapChart() public static void AddHeatmapChart()
{ {
AddChart<HeatmapChart>("HeatmapChart"); AddChart<HeatmapChart>("HeatmapChart");
} }
[MenuItem("XCharts/HeatmapChart/Count Heatmap", priority = 49)] [MenuItem("XCharts/HeatmapChart/Count Heatmap", priority = 49)]
[MenuItem("GameObject/XCharts/HeatmapChart/Count Heatmap", priority = 49)] [MenuItem("GameObject/UI/XCharts/HeatmapChart/Count Heatmap", priority = 49)]
public static void AddHeatmapChart_Count() public static void AddHeatmapChart_Count()
{ {
var chart = AddChart<HeatmapChart>("HeatmapChart"); var chart = AddChart<HeatmapChart>("HeatmapChart");
@@ -148,14 +152,14 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/RingChart/Ring", priority = 51)] [MenuItem("XCharts/RingChart/Ring", priority = 51)]
[MenuItem("GameObject/XCharts/RingChart/Ring", priority = 51)] [MenuItem("GameObject/UI/XCharts/RingChart/Ring", priority = 51)]
public static void AddRingChart() public static void AddRingChart()
{ {
AddChart<RingChart>("RingChart"); AddChart<RingChart>("RingChart");
} }
[MenuItem("XCharts/RingChart/Multiple Ring", priority = 51)] [MenuItem("XCharts/RingChart/Multiple Ring", priority = 51)]
[MenuItem("GameObject/XCharts/RingChart/Multiple Ring", priority = 51)] [MenuItem("GameObject/UI/XCharts/RingChart/Multiple Ring", priority = 51)]
public static void AddRingChart_MultiRing() public static void AddRingChart_MultiRing()
{ {
var chart = AddChart<RingChart>("RingChart"); var chart = AddChart<RingChart>("RingChart");
@@ -163,35 +167,35 @@ namespace XCharts.Editor
} }
[MenuItem("XCharts/CandlestickChart/Candlestick", priority = 54)] [MenuItem("XCharts/CandlestickChart/Candlestick", priority = 54)]
[MenuItem("GameObject/XCharts/CandlestickChart/Candlestick", priority = 54)] [MenuItem("GameObject/UI/XCharts/CandlestickChart/Candlestick", priority = 54)]
public static void CandlestickChart() public static void CandlestickChart()
{ {
AddChart<CandlestickChart>("CandlestickChart"); AddChart<CandlestickChart>("CandlestickChart");
} }
[MenuItem("XCharts/ParallelChart/Parallel", priority = 55)] [MenuItem("XCharts/ParallelChart/Parallel", priority = 55)]
[MenuItem("GameObject/XCharts/ParallelChart/Parallel", priority = 55)] [MenuItem("GameObject/UI/XCharts/ParallelChart/Parallel", priority = 55)]
public static void ParallelChart() public static void ParallelChart()
{ {
AddChart<ParallelChart>("ParallelChart"); AddChart<ParallelChart>("ParallelChart");
} }
[MenuItem("XCharts/SimplifiedChart/Line", priority = 56)] [MenuItem("XCharts/SimplifiedChart/Line", priority = 56)]
[MenuItem("GameObject/XCharts/SimplifiedChart/Line", priority = 56)] [MenuItem("GameObject/UI/XCharts/SimplifiedChart/Line", priority = 56)]
public static void SimplifiedLineChart() public static void SimplifiedLineChart()
{ {
AddChart<SimplifiedLineChart>("SimplifiedLineChart"); AddChart<SimplifiedLineChart>("SimplifiedLineChart");
} }
[MenuItem("XCharts/SimplifiedChart/Bar", priority = 57)] [MenuItem("XCharts/SimplifiedChart/Bar", priority = 57)]
[MenuItem("GameObject/XCharts/SimplifiedChart/Bar", priority = 57)] [MenuItem("GameObject/UI/XCharts/SimplifiedChart/Bar", priority = 57)]
public static void SimplifiedBarChart() public static void SimplifiedBarChart()
{ {
AddChart<SimplifiedBarChart>("SimplifiedBarChart"); AddChart<SimplifiedBarChart>("SimplifiedBarChart");
} }
[MenuItem("XCharts/SimplifiedChart/Candlestick", priority = 58)] [MenuItem("XCharts/SimplifiedChart/Candlestick", priority = 58)]
[MenuItem("GameObject/XCharts/SimplifiedChart/Candlestick", priority = 58)] [MenuItem("GameObject/UI/XCharts/SimplifiedChart/Candlestick", priority = 58)]
public static void SimplifiedCandlestickChart() public static void SimplifiedCandlestickChart()
{ {
AddChart<SimplifiedCandlestickChart>("SimplifiedCandlestickChart"); AddChart<SimplifiedCandlestickChart>("SimplifiedCandlestickChart");

View File

@@ -17,24 +17,52 @@ namespace XCharts.Example
public bool loopUpdate = false; public bool loopUpdate = false;
public float loopUpadteTime = 1f; public float loopUpadteTime = 1f;
public int maxCache = 0; public int maxCache = 0;
public bool insertDataToHead = false;
BaseChart chart; BaseChart chart;
float lastAddTime; float lastAddTime;
float lastUpdateTime; float lastUpdateTime;
int dataCount; int dataCount;
int lastMaxCache = 0;
bool lastInsertDataToHead = false;
void Awake() void Awake()
{ {
chart = gameObject.GetComponent<BaseChart>(); chart = gameObject.GetComponent<BaseChart>();
chart.onInit = () =>
{
dataCount = chart.GetSerie(0).dataCount;
SetMaxCache(maxCache);
SetInsertDataToHead(insertDataToHead);
lastMaxCache = maxCache;
lastInsertDataToHead = insertDataToHead;
};
} }
void Start() void SetMaxCache(int maxCache)
{ {
if (maxCache > 0) chart.SetMaxCache(maxCache);
}
void SetInsertDataToHead(bool insertDataToHead)
{
foreach (var serie in chart.series)
serie.insertDataToHead = insertDataToHead;
var coms = chart.GetChartComponents<XAxis>();
if (coms != null)
{ {
chart.SetMaxCache(maxCache); foreach (var com in coms)
{
var axis = com as XAxis;
if (axis.type == Axis.AxisType.Category)
{
axis.insertDataToHead = insertDataToHead;
Debug.LogError("axis:" + axis + "," + insertDataToHead);
}
}
} }
dataCount = chart.GetSerie(0).dataCount;
} }
void Update() void Update()
@@ -51,6 +79,16 @@ namespace XCharts.Example
{ {
chart.ClearData(); chart.ClearData();
} }
if (lastMaxCache != maxCache)
{
lastMaxCache = maxCache;
SetMaxCache(maxCache);
}
if (lastInsertDataToHead != insertDataToHead)
{
lastInsertDataToHead = insertDataToHead;
SetInsertDataToHead(insertDataToHead);
}
lastAddTime += Time.deltaTime; lastAddTime += Time.deltaTime;
if (loopAdd && lastAddTime >= loopAddTime) if (loopAdd && lastAddTime >= loopAddTime)
{ {
@@ -84,14 +122,8 @@ namespace XCharts.Example
} }
else else
{ {
AddXAxisData();
var xAxis = chart.GetChartComponent<XAxis>(); var xAxis = chart.GetChartComponent<XAxis>();
if (xAxis != null)
{
if (xAxis.type == Axis.AxisType.Category)
{
chart.AddXAxisData("x" + (xAxis.GetAddedDataCount() + 1));
}
}
foreach (var serie in chart.series) foreach (var serie in chart.series)
{ {
AddSerieRandomData(serie, xAxis); AddSerieRandomData(serie, xAxis);
@@ -99,6 +131,19 @@ namespace XCharts.Example
} }
} }
void AddXAxisData()
{
var xAxes = chart.GetChartComponents<XAxis>();
foreach (var com in xAxes)
{
var xAxis = com as XAxis;
if (xAxis.type == Axis.AxisType.Category)
{
chart.AddXAxisData("x" + (xAxis.GetAddedDataCount() + 1), xAxis.index);
}
}
}
void UpdateData() void UpdateData()
{ {
foreach (var serie in chart.series) foreach (var serie in chart.series)

View File

@@ -34,7 +34,7 @@ namespace XCharts.Example
void AddData() void AddData()
{ {
chart.RemoveData(); chart.RemoveData();
chart.GetChartComponent<Tooltip>().type = Tooltip.Type.Corss; chart.GetChartComponent<Tooltip>().type = Tooltip.Type.Cross;
var angleAxis = chart.GetChartComponent<AngleAxis>(); var angleAxis = chart.GetChartComponent<AngleAxis>();
angleAxis.type = Axis.AxisType.Value; angleAxis.type = Axis.AxisType.Value;
angleAxis.minMaxType = Axis.AxisMinMaxType.Custom; angleAxis.minMaxType = Axis.AxisMinMaxType.Custom;

View File

@@ -1,82 +1,71 @@
<h2 align="center">XCharts</h2>
<p align="center"> <p align="center">
<a href=""> A powerful, easy-to-use, configurable charting and data visualization library for Unity.<br/>Unity数据可视化图表插件。<br/>
<img src="" alt="" width="" height=""> <a href="https://github.com/XCharts-Team/XCharts">中文文档</a>
</a>
</p>
<h2 align="center">XCharts</h3>
<p align="center">
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
<br>
Unity数据可视化图表插件。
<br>
<a href="https://github.com/XCharts-Team/XCharts">中文文档</a>
</p> </p>
<p align="center"> <p align="center">
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE"> <a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/XCharts-Team/XCharts"> <img src="https://img.shields.io/github/license/XCharts-Team/XCharts"></img>
</a> </a>
<a href="https://github.com/XCharts-Team/XCharts/releases"> <a href="https://github.com/XCharts-Team/XCharts/releases">
<img src="https://img.shields.io/github/v/release/XCharts-Team/XCharts?include_prereleases"> <img src="https://img.shields.io/github/v/release/XCharts-Team/XCharts?include_prereleases"></img>
</a> </a>
<a href=""> <a href="">
<img src="https://img.shields.io/github/repo-size/monitor1394/unity-ugui-xcharts"> <img src="https://img.shields.io/github/repo-size/monitor1394/unity-ugui-xcharts"></img>
</a> </a>
<a href=""> <a href="">
<img src="https://img.shields.io/github/languages/code-size/monitor1394/unity-ugui-xcharts"> <img src="https://img.shields.io/github/languages/code-size/monitor1394/unity-ugui-xcharts"></img>
</a> </a>
<a href=""> <a href="">
<img src="https://img.shields.io/badge/Unity-5.6+-green"> <img src="https://img.shields.io/badge/Unity-5.6+-green"></img>
</a> </a>
<a href=""> <a href="">
<img src="https://img.shields.io/badge/TextMeshPro-YES-green"> <img src="https://img.shields.io/badge/TextMeshPro-YES-green"></img>
</a> </a>
</p> </p>
<p align="center"> <p align="center">
<a href=""> <a href="">
<img src="https://img.shields.io/github/stars/XCharts-Team/XCharts?style=social"> <img src="https://img.shields.io/github/stars/XCharts-Team/XCharts?style=social"></img>
</a> </a>
<a href=""> <a href="">
<img src="https://img.shields.io/github/forks/XCharts-Team/XCharts?style=social"> <img src="https://img.shields.io/github/forks/XCharts-Team/XCharts?style=social"></img>
</a> </a>
<a href=""> <a href="">
<img src="https://img.shields.io/github/issues-closed/XCharts-Team/XCharts?color=green&label=%20%20%20%20issues&logoColor=green&style=social"> <img src="https://img.shields.io/github/issues-closed/XCharts-Team/XCharts?color=green&label=%20%20%20%20issues&logoColor=green&style=social"></img>
</a> </a>
</p> </p>
![XCharts](Documentation~/zh/img/xcharts.png) ![XCharts](Documentation~/zh/img/xcharts.png)
A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extended charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, and treemap. ## Overview
[XCharts3.0 Homepage](https://xcharts-team.github.io) A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extension charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, treemap, sankey, line3d and graph chart.
[XCharts3.0 Tutorial](Documentation~/en/tutorial01.md) ## Key Features
[XCharts3.0 API](Documentation~/en/api.md)
[XCharts3.0 FAQ](Documentation~/en/faq.md)
[XCharts3.0 Configurate](Documentation~/en/configuration.md)
[XCharts3.0 Changelog](Documentation~/en/changelog.md)
[XCharts3.0 Support](Documentation~/en/support.md)
## Features - __Pure Code Rendering__: Charts are rendered with pure code, eliminating the need for extra texture or shader resources.
- __Visual Configuration__: Configure parameters visually with real-time preview and support for dynamic configuration and data adjustments at runtime.
- __High Customizability__: Themes and configuration parameters can be adjusted as needed, with support for custom drawing and callbacks.
- __Built-in and Extension Charts__: Supports a variety of chart types, including 3D charts and special chart types like gauges and treemaps.
- __Multiple Chart Combinations__: Combine multiple charts of the same or different types within a single instance.
- __Various Coordinate Systems__: Supports different coordinate systems such as Cartesian, polar, and single axes.
- __Rich Components__: Includes titles, legends, tooltips, and more.
- __Custom Drawing__: Utilize a powerful API for custom drawing of points, lines, and other graphics.
- __Large Data Rendering__: Capable of rendering tens of thousands of data points with support for sampling rendering.
- __Custom Themes__: Customize themes and use the included light and dark default themes.
- __Animations and Interactions__: Supports various animations and interactions for a dynamic user experience.
- __Third-Party Extensions__: Integrates with TextMeshPro and the New Input System.
- __Version and Compatibility__: Compatible with all Unity versions above 5.6 and runs on all platforms.
* __Pure code rendering__: The chart is completely rendered with pure code, without the need for additional texture or shader resources. ## Documentation
* __Visual configuration__: Visual configuration of parameters with real-time preview of the effect, and support for dynamic modification of configuration and data during runtime.
* __High customizability__: Supports arbitrary adjustments from theme and configuration parameters; supports custom drawing, callback functions, and custom implementations of charts. - [XCharts3.0 Homepage](https://xcharts-team.github.io/en)
* __Multiple built-in charts__: Supports various built-in charts such as line charts, bar charts, pie charts, radar charts, scatter plots, heat maps, polar charts, K-line charts, parallel coordinates, etc. - [XCharts3.0 Tutorial](Documentation~/en/tutorial01.md)
* __Multiple extended charts__: Supports extended charts such as 3D column charts, 3D pie charts, funnel charts, pyramids, dashboards, water level charts, iconic bar charts, Gantt charts, and tree maps. - [XCharts3.0 API](Documentation~/en/api.md)
* __Multiple extended features__: Supports extended UI components such as tables and statistical values. - [XCharts3.0 FAQ](Documentation~/en/faq.md)
* __Multiple chart combinations__: Supports arbitrary combinations of built-in charts, with multiple same or different types of charts displayed simultaneously in the same chart. - [XCharts3.0 Configurate](Documentation~/en/configuration.md)
* __Various coordinate systems__: Supports coordinate systems such as Cartesian coordinates, polar coordinates, and single axes. - [XCharts3.0 Changelog](Documentation~/en/changelog.md)
* __Rich components__: Supports common components such as titles, legends, tooltips, markings, marking areas, data area zooming, and visual mapping. - [XCharts3.0 Support](Documentation~/en/support.md)
* __Rich line charts__: Supports various line charts such as straight line charts, curved line charts, dashed line charts, area charts, step line charts, etc.
* __Rich bar charts__: Supports various bar charts such as stacked bar charts, stacked percentage bar charts, zebra bar charts, and capsule bar charts.
* __Rich pie charts__: Supports various pie charts such as ring charts, rose charts, ring rose charts, etc.
* __Rich lines__: Supports various lines such as solid lines, curves, step lines, dashed lines, dot lines, dotted lines, and double dot-dashed lines.
* __Custom drawing__: Supports custom chart content drawing with powerful drawing APIs for drawing points, lines, and other graphics.
* __Large data rendering__: Supports rendering of tens of thousands of data points; supports sampling rendering; special simplified charts support better performance.
* __Custom themes__: Supports theme customization and import/export; includes both light and dark default themes.
* __Animations and interactions__: Supports various animations such as fade-in animation, fade-out animation, change animation, addition animation, and * interactive animation; supports interactive operations such as data filtering, view zooming, and detailed display on multiple platforms.
* __Third-party extensions__: Supports integration with TexMeshPro and New Input System.
* __Version and compatibility__: Supports all Unity versions above 5.6 and runs on all platforms.
## Screenshots ## Screenshots
@@ -84,55 +73,43 @@ A powerful and easy-to-use data visualization library for Unity. It supports mo
![extendchart](Documentation~/en/img/readme_extendchart.png) ![extendchart](Documentation~/en/img/readme_extendchart.png)
## Attention ## Important Notes
* `XCharts3.0` is not fully compatible with `XCharts2.0` version, upgrading `3.0` may require some code adjustments, and some chart configurations need to be readjusting. It is recommended that old projects can continue to use `XCharts2.0`, and new projects are recommended to use `XCharts3.0`. - `XCharts3.0` is not fully compatible with `XCharts2.0`. Upgrading to 3.0 may require code adjustments and reconfiguration of some charts.
* `XCharts2.0` enters the maintenance phase, and only serious `bugs` will be fixed later, in principle, no more new features will be added. - `XCharts2.0` is in the maintenance phase with only critical bug fixes applied.
* `XCharts` theoretically supports `Unity 5.6` and above, but due to limited version testing, it is inevitable to slip up, and version compatibility issues can be raised. - While XCharts supports Unity 5.6 and above, compatibility issues may arise due to limited testing.
* This repository only contains `XCharts` source code, does not contain `Demo` sample section. Need to look at ` Demo ` please go to the sample source code [XCharts - Demo](https://github.com/XCharts-Team/XCharts-Demo) repo. You can also view the running effect of `WebGL` in your browser [Online Demo](https://xcharts-team.github.io/examples/). - This repository contains only the `XCharts` source code. For demos, visit the [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) repo or the [Online Demo](https://xcharts-team.github.io/en/examples/).
## Use ## Getting Started
* Import `XCharts` unitypackage or source code into the project. 1. Import the `XCharts` unitypackage or source code into your Unity project.
* Right-click `Hierarchy` view and choose `XCharts->LineChart` to create a default LineChart. 2. Create a chart by right-clicking in the `Hierarchy` view and selecting `UI->XCharts->LineChart`.
* You can adjust the parameters of each component in `Inspector` and see the real-time effects in `Game` view. 3. Adjust component parameters in the `Inspector` to see real-time effects in the `Game` view.
* For more details, see [[XCharts Tutorial: 5-minute tutorial]](Documentation~/en/tutorial01.md) 4. For more details, refer to the [5-minute tutorial](Documentation~/en/tutorial01.md).
* For the first time, it is recommended to read the tutorial carefully.
## Branch ## Branch Information
* `master` : indicates the development branch. The latest changes and new features are first committed to the `master` branch, and after some time from the `master` branch `merge` to the `3.0` branch, and the `release` version. - __master__ indicates the development branch. The latest changes and new features are first committed to the `master` branch, and after some time from the `master` branch `merge` to the `3.0` branch, and the `release` version.
* `3.0` : Stable branch of XCharts 3.0. It is generally updated once a month, with the latest changes from the `master` branch `merge`, and the `release` version is released. - __3.0__ Stable branch of XCharts 3.0. It is generally updated once a month, with the latest changes from the `master` branch `merge`, and the `release` version is released.
* `2.0` : A stable branch of XCharts 2.0. With Demo, currently no longer maintenance, only to modify serious bugs. - __2.0__ A stable branch of XCharts 2.0. With Demo, currently no longer maintenance, only to modify serious bugs.
* `2.0-upm` : Stable UMP branch of XCharts 2.0. Only the Package part is included without Demo. It is dedicated to the UMP and is not maintained. - __2.0-upm__ Stable UMP branch of XCharts 2.0. Only the Package part is included without Demo. It is dedicated to the UMP and is not maintained.
* `1.0` : Stable branch of XCharts 1.0. With Demo, no maintenance. - __1.0__ Stable branch of XCharts 1.0. With Demo, no maintenance.
* `1.0-upm` : stable UMP branch of XCharts 1.0. No Demo, no maintenance. - __1.0-upm__ stable UMP branch of XCharts 1.0. No Demo, no maintenance.
## FAQ ## FAQ
* Is `XCharts` free to use? - __Is XCharts free to use?__ Yes, XCharts is free under the MIT license and includes value-added VIP services.
A: `XCharts` uses the `MIT` licence and is free to use. You can also subscribe to `VIP` to enjoy more value-added services. - __Does XCharts support dynamic data addition and modification?__ Yes, but data must be parsed or retrieved by the user.
- __Does this plugin work on platforms other than Unity?__ No, it is designed for Unity only.
* Does `XCharts` support code to dynamically add and modify data? Does it support getting data from `Excel` or a database?
A: Support code to dynamically add and modify data, but data needs to be parsed or retrieved by itself, and then added to `XCharts` by calling the public interface of `XCharts`.
* Does this plugin work on other platforms (e.g. Winform or WPF) besides Unity?
A: It is currently only supported on Unity. Theoretically any version of Unity that supports `UGUI` can run `XCharts`.
* What about the jags? What magnitude of data is supported?
A: XCharts is based on UGUI implementation, so the problems encountered in UGUI will also exist in XCharts. For example, the sawtooth problem, such as the number of vertices in `Mesh` exceeds `65535`. Solutions to these two problems can be found in [Q&A 16](Documentation~/en/faq.md) and [Q&A 27](Documentation~/en/faq.md).
Due to the `Mesh` of the `65535` vertex limit, the current `XCharts` single `Line` supports about `20,000` of data, of course, open sampling can support more data to draw, but at the same time it will consume more CPU.
## Changelog ## Changelog
* [Changelog](Documentation~/en/changelog.md) - [Changelog](Documentation~/en/changelog.md)
## Licenses ## Licenses
* [MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md) - XCharts is released under the [MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md).
* Free commercial, secondary development
* The extended charts and advanced features sections require a separate purchase license
## Other ## Contact
email: `monitor1394@gmail.com` - For more information or support, contact us at `monitor1394@gmail.com`.

101
README.md
View File

@@ -1,15 +1,8 @@
<p align="center">
<a href="">
<img src="" alt="" width="" height=""></img>
</a>
</p>
<h2 align="center">XCharts</h2> <h2 align="center">XCharts</h2>
<p align="center"> <p align="center">
A powerful, easy-to-use, configurable charting and data visualization library for Unity. A powerful, easy-to-use, configurable charting and data visualization library for Unity.<br/>Unity数据可视化图表插件。<br/>
<br/> <a href="README-en.md">English README</a>
Unity数据可视化图表插件。
<br/>
<a href="README-en.md">English README</a>
</p> </p>
<p align="center"> <p align="center">
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE"> <a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">
@@ -45,7 +38,7 @@
![XCharts](Documentation~/zh/img/xcharts.png) ![XCharts](Documentation~/zh/img/xcharts.png)
一款基于`UGUI`的功能强大简单易用的数据可视化图表插件。支持`折线图``柱状图``饼图``雷达图``散点图``热力图``环形图``K线图``极坐标``平行坐标`等十种内置图表,以及`3D饼图``3D柱图``3D金字塔``漏斗图``仪表盘``水位图``象形柱图``甘特图``矩形树图``桑基图`等多种扩展图表。 一款基于`UGUI`的功能强大简单易用的`Unity`数据可视化图表插件。支持`折线图``柱状图``饼图``雷达图``散点图``热力图``环形图``K线图``极坐标``平行坐标`等十种内置图表,以及`3D饼图``3D柱图``3D金字塔``漏斗图``仪表盘``水位图``象形柱图``甘特图``矩形树图``桑基图``3D折线图``关系图`等十几种扩展图表。
[XCharts 官方主页](https://xcharts-team.github.io) [XCharts 官方主页](https://xcharts-team.github.io)
[XCharts 在线示例](https://xcharts-team.github.io/examples) [XCharts 在线示例](https://xcharts-team.github.io/examples)
@@ -63,7 +56,7 @@
- __可视化配置__参数可视化配置效果实时预览支持运行时代码动态修改配置和数据。 - __可视化配置__参数可视化配置效果实时预览支持运行时代码动态修改配置和数据。
- __高自由定制__支持从主题和配置参数上任意调整支持代码自定义绘制自定义回调以及自定义实现图表。 - __高自由定制__支持从主题和配置参数上任意调整支持代码自定义绘制自定义回调以及自定义实现图表。
- __多内置图表__支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种内置图表。 - __多内置图表__支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种内置图表。
- __多扩展图表__支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图等多种扩展图表。 - __多扩展图表__支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种扩展图表。
- __多扩展组件__支持表格、统计数值等多种扩展UI组件。 - __多扩展组件__支持表格、统计数值等多种扩展UI组件。
- __多图表组合__支持内置图表的任意组合同一图中可同时显示多个相同或不同类型的图表。 - __多图表组合__支持内置图表的任意组合同一图中可同时显示多个相同或不同类型的图表。
- __多种坐标系__支持直角坐标系、极坐标系、单轴等多种坐标系。 - __多种坐标系__支持直角坐标系、极坐标系、单轴等多种坐标系。
@@ -87,42 +80,33 @@
## 仓库 ## 仓库
| 相关仓库 | 仓库介绍 | - __[XCharts](https://github.com/XCharts-Team/XCharts)__ XCharts核心功能完全免费。
| -- | --| - __[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)__ XCharts守护程序用于确保XCharts更新时的编译正常。非必须但建议使用。
| [XCharts](https://github.com/XCharts-Team/XCharts) | XCharts核心功能完全免费。 | - __[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)__ XCharts官方示例不包含扩展图表部分。订阅购买扩展图表后可导入示例。
| [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon) | XCharts的守护程序用于确保XCharts更新时的编译正常。非必须但建议使用。 | - __[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)__ XCharts专业版包含所有扩展图表和扩展组件。订阅SVIP后可访问使用。
| [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) | XCharts官方示例,包含扩展图表部分。订阅VIP的用户购买扩展图表后,可加入对应图表的示例。 | - __[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo)__ XCharts专业版官方示例,包含所有扩展图表和扩展组件的示例。订阅SVIP后可访问使用。
| [XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro) | XCharts完全版包含所有扩展图表和扩展组件。订阅SVIP后可访问使用。 | - __[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)__ XCharts的扩展UI组件。订阅VIP后可访问使用。
| [XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) | XCharts完全版官方示例包含所有扩展图表和扩展组件的示例。订阅SVIP后可访问使用。 | - __[XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart)__ XCharts扩展图表3D柱图。订阅购买后可访问使用。
| [XCharts-UI](https://github.com/XCharts-Team/XCharts-UI) | XCharts扩展UI组件。订阅VIP后可访问使用。 | - __[XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart)__ XCharts扩展图表:漏斗图。订阅购买后可访问使用。
| [XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart) | XCharts扩展图表3D柱图。订阅购买后可访问使用。 | - __[XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart)__ XCharts扩展图表甘特图。订阅购买后可访问使用。
| [XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart) | XCharts扩展图表漏斗图。订阅购买后可访问使用。 | - __[XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart)__ XCharts扩展图表仪表盘。订阅购买后可访问使用。
| [XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart) | XCharts扩展图表甘特图。订阅购买后可访问使用。 | - __[XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart)__ XCharts扩展图表水位图。订阅购买后可访问使用。
| [XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart) | XCharts扩展图表仪表盘。订阅购买后可访问使用。 | - __[XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart)__ XCharts扩展图表象形住图。订阅购买后可访问使用。
| [XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart) | XCharts扩展图表水位图。订阅购买后可访问使用。 | - __[XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart)__ XCharts扩展图表3D饼图。订阅购买后可访问使用。
| [XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart) | XCharts扩展图表象形住图。订阅购买后可访问使用。 | - __[XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart)__ XCharts扩展图表3D金字塔。订阅购买后可访问使用。
| [XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart) | XCharts扩展图表3D饼图。订阅购买后可访问使用。 | - __[XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart)__ XCharts扩展图表矩形树图。订阅购买后可访问使用。
| [XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart) | XCharts扩展图表3D金字塔。订阅购买后可访问使用。 | - __[XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart)__ XCharts扩展图表桑基图。订阅购买后可访问使用。
| [XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart) | XCharts扩展图表矩形树图。订阅购买后可访问使用。 | - __[XCharts-Line3DChart](https://github.com/XCharts-Team/XCharts-Line3DChart)__ XCharts扩展图表3D折线图。订阅购买后可访问使用。
| [XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart) | XCharts扩展图表桑基图。订阅购买后可访问使用。 | - __[XCharts-GraphChart](https://github.com/XCharts-Team/XCharts-GraphChart)__ XCharts扩展图表关系图。订阅购买后可访问使用。
## 分支 ## 分支
| 分支 | 分支介绍 | - __[master](https://github.com/XCharts-Team/XCharts/tree/master)__ XCharts3.0的开发分支。最新的修改和功能都先提交到`master`分支,稳定后再发布`release`版本。
|--|--| - __[3.0](https://github.com/XCharts-Team/XCharts/tree/3.0)__ XCharts3.0的稳定分支。一般一个月一发布,`master`分支稳定后,`merge``3.0`分支,并发布`release`版本。
| [master](https://github.com/XCharts-Team/XCharts/tree/master) | XCharts3.0的开发分支。最新的修改和功能都先提交到`master`分支,稳定后后再从`master`分支`merge``3.0`分支,并发布`release`版本。| - __[2.0](https://github.com/XCharts-Team/XCharts/tree/2.0)__ XCharts2.0的稳定分支。带Demo目前基本不再维护仅修改严重bug。
| [3.0](https://github.com/XCharts-Team/XCharts/tree/3.0) | XCharts3.0的稳定分支。一般一个月一发布,`master`分支稳定后,`merge``3.0`分支,并发布`release`版本。| - __[2.0-upm](https://github.com/XCharts-Team/XCharts/tree/2.0-upm)__ XCharts2.0的稳定UMP分支。不带Demo只包含Package部分不再维护。
| [2.0](https://github.com/XCharts-Team/XCharts/tree/2.0) | XCharts2.0的稳定分支。带Demo目前基本不再维护仅修改严重bug。| - __[1.0](https://github.com/XCharts-Team/XCharts/tree/1.0)__ XCharts1.0的稳定分支。带Demo不再维护。
| [2.0-upm](https://github.com/XCharts-Team/XCharts/tree/2.0-upm) | XCharts2.0的稳定UMP分支。不带Demo只包含Package部分不再维护。| - __[1.0-upm](https://github.com/XCharts-Team/XCharts/tree/1.0-upm)__ XCharts1.0的稳定UMP分支。不带Demo不再维护。
| [1.0](https://github.com/XCharts-Team/XCharts/tree/1.0) | XCharts1.0的稳定分支。带Demo不再维护。|
| [1.0-upm](https://github.com/XCharts-Team/XCharts/tree/1.0-upm) | XCharts1.0的稳定UMP分支。不带Demo不再维护。|
## 注意
- `XCharts3.0` 不完全兼容 `XCharts2.0` 版本,升级`3.0`时,部分代码和配置可能需要重新调整。建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`
- `XCharts2.0` 进入维护阶段,后续只修复严重`bug`,原则上不再加新功能。
- `XCharts` 理论上支持`Unity 5.6`及以上版本,但由于版本测试有限难免疏漏,发现问题可提`Issue`
- 本仓库只包含`XCharts`源码,不包含`Demo`示例部分。需要查看`Demo`示例源码请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。也可以在浏览器查看`WebGL`下的运行效果 [在线Demo](https://xcharts-team.github.io/examples/) 。
## 使用 ## 使用
@@ -133,24 +117,31 @@
- 更多细节,请看[【XCharts教程5分钟上手教程】](Documentation~/zh/tutorial01.md)。 - 更多细节,请看[【XCharts教程5分钟上手教程】](Documentation~/zh/tutorial01.md)。
- 首次使用,建议先认真看一遍教程。 - 首次使用,建议先认真看一遍教程。
## 注意
- __XCharts3.0不完全兼容XCharts2.0版本。__ 升级`3.0`时,部分代码和配置可能需要重新调整。建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`
- __XCharts2.0只维护不加新功能。__ `2.0`只修复严重`bug`,原则上不再加新功能。
- __XCharts支持Unity 5.6及以上版本。__ 但由于版本测试有限难免疏漏,发现问题可提`Issue`
- __本仓库只包含XCharts源码不包含Demo示例部分。__ 需要查看`Demo`示例源码请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。也可以在浏览器查看运行效果 [在线Demo](https://xcharts-team.github.io/examples/) 。
## FAQ ## FAQ
- `XCharts`可以免费使用吗? - __XCharts可以免费使用吗__
答:`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。 `XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。
- `XCharts`支持代码动态添加和修改数据吗?支持从`Excel`或数据库中获取数据吗? - __XCharts支持代码动态添加和修改数据吗支持从`Excel`或数据库中获取数据吗?__
答:`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。 `XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。
- `XCharts`除了用在`Unity`平台,还能用在`Winform``WPF`等平台吗? - __XCharts除了用在Unity平台还能用在WinformWPF等平台吗__
答:`XCharts`只支持在`Unity`平台使用。理论上任何支持`UGUI``Unity`版本都能运行`XCharts` `XCharts`只支持在`Unity`平台使用。理论上任何支持`UGUI``Unity`版本都能运行`XCharts`
- 锯齿怎么解决?支持多大量级的数据? - __锯齿怎么解决?支持多大量级的数据?__
答:`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考[问答16](Documentation~/zh/faq.md)和[问答27](Documentation~/zh/faq.md)。 `XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考[问答16](Documentation~/zh/faq.md)和[问答27](Documentation~/zh/faq.md)。
由于`Mesh``65535`顶点数的限制,目前`XCharts`的单条`Line`支持约`2万`的数据量当然开启采样可以支持更多数据的绘制但同时也会更消耗CPU。 由于`Mesh``65535`顶点数的限制,目前`XCharts`的单条`Line`支持约`2万`的数据量当然开启采样可以支持更多数据的绘制但同时也会更消耗CPU。
## 日志 ## 日志
- [更新日志](Documentation~/zh/changelog.md) - 各版本的详细更新日志请查看 [更新日志](Documentation~/zh/changelog.md)
## Licenses ## Licenses

View File

@@ -22,7 +22,7 @@ namespace XCharts.Runtime
radiusAxis.axisLabel.show = false; radiusAxis.axisLabel.show = false;
var tooltip = EnsureChartComponent<Tooltip>(); var tooltip = EnsureChartComponent<Tooltip>();
tooltip.type = Tooltip.Type.Corss; tooltip.type = Tooltip.Type.Cross;
tooltip.trigger = Tooltip.Trigger.Axis; tooltip.trigger = Tooltip.Trigger.Axis;
RemoveData(); RemoveData();

View File

@@ -37,7 +37,7 @@ namespace XCharts.Runtime
animationType = attribute.type; animationType = attribute.type;
enableSerieDataAnimation = attribute.enableSerieDataAddedAnimation; enableSerieDataAnimation = attribute.enableSerieDataAddedAnimation;
} }
UpdateAnimationType(serie.animation, animationType,enableSerieDataAnimation); UpdateAnimationType(serie.animation, animationType, enableSerieDataAnimation);
} }
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation) public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)
@@ -48,12 +48,12 @@ namespace XCharts.Runtime
animation.context.enableSerieDataAddedAnimation = enableSerieDataAnimation; animation.context.enableSerieDataAddedAnimation = enableSerieDataAnimation;
} }
public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip) public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip, ref float rate)
{ {
if (animation.context.type == AnimationType.AlongPath) if (animation.context.type == AnimationType.AlongPath)
{ {
var dist = Vector3.Distance(lp, cp); var dist = Vector3.Distance(lp, cp);
var rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist; rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist;
ip = Vector3.Lerp(lp, cp, rate); ip = Vector3.Lerp(lp, cp, rate);
return true; return true;
} }
@@ -62,7 +62,15 @@ namespace XCharts.Runtime
var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000); var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
var endPos = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000); var endPos = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000);
return UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip); if (UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip))
{
rate = Vector3.Distance(lp, ip) / Vector3.Distance(lp, cp);
return true;
}
else
{
return false;
}
} }
} }
} }

View File

@@ -67,7 +67,7 @@ namespace XCharts.Runtime
string objName = component.GetType().Name + axis.index; string objName = component.GetType().Name + axis.index;
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.transform.localPosition = Vector3.zero; axisObj.transform.localPosition = Vector3.zero;
axisObj.SetActive(axis.show); axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags; axisObj.hideFlags = chart.chartHideFlags;

View File

@@ -75,7 +75,8 @@ namespace XCharts.Runtime
Left, Left,
Right, Right,
Bottom, Bottom,
Top Top,
Center
} }
[SerializeField] protected bool m_Show = true; [SerializeField] protected bool m_Show = true;
@@ -98,6 +99,7 @@ namespace XCharts.Runtime
[SerializeField] protected bool m_Inverse = false; [SerializeField] protected bool m_Inverse = false;
[SerializeField] private bool m_Clockwise = true; [SerializeField] private bool m_Clockwise = true;
[SerializeField] private bool m_InsertDataToHead; [SerializeField] private bool m_InsertDataToHead;
[SerializeField][Since("v3.11.0")] private float m_MinCategorySpacing = 0;
[SerializeField] protected List<Sprite> m_Icons = new List<Sprite>(); [SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
[SerializeField] protected List<string> m_Data = new List<string>(); [SerializeField] protected List<string> m_Data = new List<string>();
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine; [SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
@@ -405,6 +407,15 @@ namespace XCharts.Runtime
get { return m_InsertDataToHead; } get { return m_InsertDataToHead; }
set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); } set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); }
} }
/// <summary>
/// The minimum spacing between categories.
/// ||类目之间的最小间距。
/// </summary>
public float minCategorySpacing
{
get { return m_MinCategorySpacing; }
set { if (PropertyUtil.SetStruct(ref m_MinCategorySpacing, value)) SetAllDirty(); }
}
public override bool vertsDirty public override bool vertsDirty
{ {
@@ -458,6 +469,17 @@ namespace XCharts.Runtime
base.SetComponentDirty(); base.SetComponentDirty();
} }
/// <summary>
/// 重置状态。
/// </summary>
public override void ResetStatus()
{
context.minValue = 0;
context.maxValue = 0;
context.destMinValue = 0;
context.destMaxValue = 0;
}
public Axis Clone() public Axis Clone()
{ {
var axis = new Axis(); var axis = new Axis();
@@ -729,10 +751,14 @@ namespace XCharts.Runtime
/// <param name="value"></param> /// <param name="value"></param>
/// <param name="axisLength"></param> /// <param name="axisLength"></param>
/// <returns></returns> /// <returns></returns>
public float GetDistance(double value, float axisLength) public float GetDistance(double value, float axisLength = 0)
{ {
if (context.minMaxRange == 0) if (context.minMaxRange == 0)
return 0; return 0;
if (axisLength == 0)
{
axisLength = context.length;
}
if (IsCategory() && boundaryGap) if (IsCategory() && boundaryGap)
{ {
@@ -919,5 +945,43 @@ namespace XCharts.Runtime
(float)(Math.Abs(context.minValue) * (axisLength / (Math.Abs(context.minValue) + Math.Abs(context.maxValue)))) (float)(Math.Abs(context.minValue) * (axisLength / (Math.Abs(context.minValue) + Math.Abs(context.maxValue))))
); );
} }
public Vector3 GetCategoryPosition(int categoryIndex, int dataCount = 0)
{
if (dataCount <= 0)
{
dataCount = data.Count;
}
if (IsCategory() && dataCount > 0)
{
Vector3 pos;
if (boundaryGap)
{
var each = context.length / dataCount;
pos = context.start + context.dire * (each * (categoryIndex + 0.5f));
}
else
{
var each = context.length / (dataCount - 1);
pos = context.start + context.dire * (each * categoryIndex);
}
if (axisLabel.distance != 0)
{
if (this is YAxis)
{
pos.x = GetLabelObjectPosition(0).x;
}
else
{
pos.y = GetLabelObjectPosition(0).y;
}
}
return pos;
}
else
{
return Vector3.zero;
}
}
} }
} }

View File

@@ -0,0 +1,160 @@
using UnityEngine;
using UnityEngine.UI;
using XUGL;
namespace XCharts.Runtime
{
public static class Axis3DHelper
{
public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, ZAxis3D zAxis, double xValue, double yValue, double zValue)
{
var x = xAxis.GetDistance(xValue);
var y = yAxis.GetDistance(yValue);
var z = zAxis.GetDistance(zValue);
var dest = grid.context.pointA;
dest += xAxis.context.dire * x;
dest += yAxis.context.dire * y;
dest += zAxis.context.dire * z;
return dest;
}
public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, double xValue, double yValue)
{
var x = xAxis.GetDistance(xValue);
var y = yAxis.GetDistance(yValue);
var dest = grid.context.pointA;
dest += xAxis.context.dire * x;
dest += yAxis.context.dire * y;
return dest;
}
internal static void DrawAxisTick(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
Vector3 start, Vector3 end, Vector3 relativedDire)
{
var tickLength = axis.axisTick.GetLength(theme.tickLength);
var axisLength = Vector3.Distance(start, end);
var axisDire = (end - start).normalized;
if (axis.position == Axis.AxisPosition.Right)
{
relativedDire = -relativedDire;
}
if (AxisHelper.NeedShowSplit(axis))
{
var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
if (axis.IsTime())
{
size += 1;
if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue))
size += 1;
}
var tickWidth = axis.axisTick.GetWidth(theme.tickWidth);
var tickColor = axis.axisTick.GetColor(theme.tickColor);
var current = start;
for (int i = 0; i < size; i++)
{
var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
var hideTick = (i == 0 && (!axis.axisTick.showStartTick || axis.axisTick.alignWithLabel)) ||
(i == size - 1 && !axis.axisTick.showEndTick);
if (axis.axisTick.show && !hideTick)
{
UGL.DrawLine(vh, current, current + relativedDire * tickLength, tickWidth, tickColor);
}
current += axisDire * scaleWidth;
}
}
if (axis.show && axis.axisLine.show && axis.axisLine.showArrow)
{
}
}
public static void DrawAxisSplit(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
Vector3 start, Vector3 end, Axis relativedAxis)
{
if (relativedAxis == null) return;
var axisLength = Vector3.Distance(start, end);
var axisDire = (end - start).normalized;
var splitLength = relativedAxis.context.length;
var relativeDire = relativedAxis.context.dire;
var axisLineWidth = axis.axisLine.GetWidth(theme.lineWidth);
splitLength -= axisLineWidth;
var lineColor = axis.splitLine.GetColor(theme.splitLineColor);
var lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
var lineType = axis.splitLine.GetType(theme.splitLineType);
var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
if (axis.IsTime())
{
size += 1;
if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue))
size += 1;
}
var current = start;
for (int i = 0; i < size; i++)
{
var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom);
if (axis.boundaryGap && axis.axisTick.alignWithLabel)
current -= axisDire * scaleWidth / 2;
if (axis.splitArea.show && i <= size - 1)
{
var p1 = current;
var p2 = current + relativeDire * splitLength;
var p3 = p2 + axisDire * scaleWidth;
var p4 = p1 + axisDire * scaleWidth;
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, axis.splitArea.GetColor(i, theme));
}
if (axis.splitLine.show)
{
if (axis.splitLine.NeedShow(i, size))
{
if (relativedAxis == null || !relativedAxis.axisLine.show
|| (Vector3.Distance(current, relativedAxis.context.start) > 0.5f && Vector3.Distance(current, relativedAxis.context.end) > 0.5f))
{
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
current,
current + relativeDire * splitLength,
lineColor);
}
}
}
current += axisDire * scaleWidth;
}
}
public static Vector3 GetLabelPosition(int i, Axis axis, Axis relativedAxis, AxisTheme theme, float scaleWid)
{
var axisStart = axis.context.start;
var axisEnd = axis.context.end;
var axisDire = axis.context.dire;
var relativedDire = relativedAxis != null ? relativedAxis.context.dire : Vector3.zero;
var axisLength = Vector3.Distance(axisStart, axisEnd);
var inside = axis.axisLabel.inside;
var fontSize = axis.axisLabel.textStyle.GetFontSize(theme);
var current = axis.offset;
if (axis.position == Axis.AxisPosition.Right)
{
relativedDire = -relativedDire;
}
if (axis.IsTime() || axis.IsValue())
{
scaleWid = axis.context.minMaxRange != 0 ?
axis.GetDistance(axis.GetLabelValue(i), axisLength) :
0;
}
return axisStart + axisDire * scaleWid + axis.axisLabel.offset - relativedDire * (axis.axisLabel.distance + fontSize / 2);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 52469636872044a81a291bb00b71a140
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -15,6 +15,9 @@ namespace XCharts.Runtime
/// 坐标轴的起点Y /// 坐标轴的起点Y
/// </summary> /// </summary>
public float y; public float y;
public Vector3 start;
public Vector3 end;
public Vector3 dire;
/// <summary> /// <summary>
/// 坐标轴原点X /// 坐标轴原点X
/// </summary> /// </summary>
@@ -25,6 +28,7 @@ namespace XCharts.Runtime
public float zeroY; public float zeroY;
public float width; public float width;
public float height; public float height;
public float length;
public Vector3 position; public Vector3 position;
public float left; public float left;
public float right; public float right;

View File

@@ -58,7 +58,7 @@ namespace XCharts
(!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2))) (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
{ {
axis.context.pointerValue = j; axis.context.pointerValue = j;
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j); axis.context.pointerLabelPosition = axis.GetCategoryPosition(j, dataCount);
if (j != lastPointerValue) if (j != lastPointerValue)
{ {
if (chart.onAxisPointerValueChanged != null) if (chart.onAxisPointerValueChanged != null)
@@ -78,7 +78,7 @@ namespace XCharts
(!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2))) (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
{ {
axis.context.pointerValue = j; axis.context.pointerValue = j;
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j); axis.context.pointerLabelPosition = axis.GetCategoryPosition(j, dataCount);
if (j != lastPointerValue) if (j != lastPointerValue)
{ {
if (chart.onAxisPointerValueChanged != null) if (chart.onAxisPointerValueChanged != null)
@@ -139,7 +139,7 @@ namespace XCharts
} }
} }
internal void UpdateAxisMinMaxValue(int axisIndex, Axis axis, bool updateChart = true) internal void UpdateAxisMinMaxValue(int axisIndex, Axis axis, bool cancelAnimation = false)
{ {
if (!axis.show) if (!axis.show)
return; return;
@@ -147,7 +147,7 @@ namespace XCharts
if (axis.IsCategory()) if (axis.IsCategory())
{ {
axis.context.minValue = 0; axis.context.minValue = 0;
axis.context.maxValue = SeriesHelper.GetMaxSerieDataCount(chart.series) - 1; axis.context.maxValue = axis.data.Count > 0 ? axis.data.Count - 1 : SeriesHelper.GetMaxSerieDataCount(chart.series) - 1;
axis.context.minMaxRange = axis.context.maxValue; axis.context.minMaxRange = axis.context.maxValue;
return; return;
} }
@@ -173,7 +173,7 @@ namespace XCharts
{ {
m_LastSplitNumber = axis.splitNumber; m_LastSplitNumber = axis.splitNumber;
m_LastInterval = axis.interval; m_LastInterval = axis.interval;
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue, axis.context.needAnimation); axis.UpdateMinMaxValue(tempMinValue, tempMaxValue, !cancelAnimation && axis.context.needAnimation);
axis.context.offset = 0; axis.context.offset = 0;
axis.context.lastCheckInverse = axis.inverse; axis.context.lastCheckInverse = axis.inverse;
UpdateAxisTickValueList(axis); UpdateAxisTickValueList(axis);
@@ -191,14 +191,11 @@ namespace XCharts
} }
} }
if (updateChart) UpdateAxisLabelText(axis);
{ chart.RefreshChart();
UpdateAxisLabelText(axis);
chart.RefreshChart();
}
} }
if (axis.context.needAnimation && (axis.context.minValue != axis.context.destMinValue || axis.context.maxValue != axis.context.destMaxValue)) if (!cancelAnimation && axis.context.needAnimation && (axis.context.minValue != axis.context.destMinValue || axis.context.maxValue != axis.context.destMaxValue))
{ {
var duration = axis.animation.duration == 0 var duration = axis.animation.duration == 0
? SeriesHelper.GetMinAnimationDuration(chart.series) / 1000f ? SeriesHelper.GetMinAnimationDuration(chart.series) / 1000f
@@ -369,11 +366,13 @@ namespace XCharts
} }
} }
protected void InitAxis(Axis relativedAxis, Orient orient, protected void InitAxis3D(Axis relativedAxis, Orient orient)
float axisStartX, float axisStartY, float axisLength, float relativedLength)
{ {
Axis axis = component; Axis axis = component;
var axisLength = (axis.context.end - axis.context.start).magnitude;
if (axisLength == 0) return;
chart.InitAxisRuntimeData(axis); chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis); var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName, var axisObj = ChartHelper.AddObject(objName,
@@ -381,7 +380,116 @@ namespace XCharts
chart.chartMinAnchor, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartMaxAnchor,
chart.chartPivot, chart.chartPivot,
chart.chartSizeDelta); chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(axisObj);
axis.gameObject = axisObj;
axis.context.labelObjectList.Clear();
if (!axis.show)
return;
var axisLabelTextStyle = axis.axisLabel.textStyle;
var dataZoom = chart.GetDataZoomOfAxis(axis);
var splitNumber = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
var totalWidth = 0f;
var eachWidth = AxisHelper.GetEachWidth(axis, axisLength, dataZoom);
var gapWidth = axis.boundaryGap ? eachWidth / 2 : 0;
var textWidth = axis.axisLabel.width > 0 ?
axis.axisLabel.width :
AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom);
var textHeight = axis.axisLabel.height > 0 ?
axis.axisLabel.height :
20f;
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
var inside = axis.axisLabel.inside;
var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter :
((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ?
TextAnchor.MiddleLeft :
TextAnchor.MiddleRight);
if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1;
axis.context.aligment = defaultAlignment;
for (int i = 0; i < splitNumber; i++)
{
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
var labelName = AxisHelper.GetLabelName(axis, axisLength, i,
axis.context.destMinValue,
axis.context.destMaxValue,
dataZoom, isPercentStack);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
ChartCached.GetAxisLabelName(i),
axisObj.transform,
new Vector2(textWidth, textHeight),
axis, chart.theme.axis, labelName,
Color.clear,
defaultAlignment,
chart.theme.GetColor(i));
if (i == 0)
axis.axisLabel.SetRelatedText(label.text, labelWidth);
var pos = GetLabelPosition(totalWidth + gapWidth, i);
label.SetPosition(pos);
axis.context.labelObjectList.Add(label);
totalWidth += labelWidth;
}
if (axis.axisName.show)
{
ChartLabel label = null;
var offset = axis.axisName.labelStyle.offset;
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
switch (axis.axisName.labelStyle.position)
{
case LabelStyle.Position.Start:
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.context.start + offset);
break;
case LabelStyle.Position.Middle:
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition((axis.context.start + axis.context.end) / 2 + offset);
break;
default:
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.context.end + offset);
break;
}
}
}
protected void InitAxis(Axis relativedAxis, Orient orient,
float axisStartX, float axisStartY, float axisLength, float relativedLength)
{
Axis axis = component;
chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName,
chart.transform,
chart.chartMinAnchor,
chart.chartMaxAnchor,
chart.chartPivot,
chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show); axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags; axisObj.hideFlags = chart.chartHideFlags;
@@ -465,7 +573,7 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleRight); chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleRight);
label.SetActive(axis.axisName.labelStyle.show); label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.position == Axis.AxisPosition.Top ? label.SetPosition(axis.position == Axis.AxisPosition.Top ?
new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset) : new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
new Vector2(zeroPos.x - offset.x, posY + offset.y)); new Vector2(zeroPos.x - offset.x, posY + offset.y));
@@ -475,7 +583,7 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show); label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.position == Axis.AxisPosition.Top ? label.SetPosition(axis.position == Axis.AxisPosition.Top ?
new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset) : new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset) :
new Vector2(axisStartX + axisLength / 2 + offset.x, posY + offset.y)); new Vector2(axisStartX + axisLength / 2 + offset.x, posY + offset.y));
@@ -485,7 +593,7 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleLeft); chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleLeft);
label.SetActive(axis.axisName.labelStyle.show); label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.position == Axis.AxisPosition.Top ? label.SetPosition(axis.position == Axis.AxisPosition.Top ?
new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset) : new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
new Vector2(axisStartX + axisLength + offset.x, posY + offset.y)); new Vector2(axisStartX + axisLength + offset.x, posY + offset.y));
@@ -502,7 +610,7 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show); label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.position == Axis.AxisPosition.Right ? label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY - offset.y) : new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY - offset.y) :
new Vector2(posX + offset.x, axisStartY - offset.y)); new Vector2(posX + offset.x, axisStartY - offset.y));
@@ -512,7 +620,7 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show); label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.position == Axis.AxisPosition.Right ? label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) : new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) :
new Vector2(posX + offset.x, axisStartY + axisLength / 2 + offset.y)); new Vector2(posX + offset.x, axisStartY + axisLength / 2 + offset.y));
@@ -522,7 +630,7 @@ namespace XCharts
//LabelStyle.Position //LabelStyle.Position
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show); label.SetActive(axis.axisName.labelStyle.show, true);
label.SetPosition(axis.position == Axis.AxisPosition.Right ? label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY + axisLength + offset.y) : new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY + axisLength + offset.y) :
new Vector2(posX + offset.x, axisStartY + axisLength + offset.y)); new Vector2(posX + offset.x, axisStartY + axisLength + offset.y));
@@ -611,12 +719,6 @@ namespace XCharts
if (AxisHelper.NeedShowSplit(axis)) if (AxisHelper.NeedShowSplit(axis))
{ {
var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom); var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
if (axis.IsTime())
{
size += 1;
if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue))
size += 1;
}
var tickWidth = axis.axisTick.GetWidth(theme.tickWidth); var tickWidth = axis.axisTick.GetWidth(theme.tickWidth);
var tickColor = axis.axisTick.GetColor(theme.tickColor); var tickColor = axis.axisTick.GetColor(theme.tickColor);
var current = orient == Orient.Horizonal ? startX : startY; var current = orient == Orient.Horizonal ? startX : startY;

View File

@@ -65,7 +65,10 @@ namespace XCharts.Runtime
if (axis.splitNumber <= 0) if (axis.splitNumber <= 0)
{ {
var eachWid = coordinateWid / dataCount; var eachWid = coordinateWid / dataCount;
var min = axis is YAxis ? 20 : 80;
var min = axis.minCategorySpacing > 0
? axis.minCategorySpacing
: (Mathf.Abs(axis.context.dire.y) < 0.01 ? 80 : 20);
if (eachWid > min) return dataCount; if (eachWid > min) return dataCount;
var tick = Mathf.CeilToInt(min / eachWid); var tick = Mathf.CeilToInt(min / eachWid);
return tick <= 1 ? dataCount : (int)(dataCount / tick); return tick <= 1 ? dataCount : (int)(dataCount / tick);

View File

@@ -15,6 +15,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_AutoColor; [SerializeField] private bool m_AutoColor;
[SerializeField][Since("v3.3.0")] private bool m_ShowStartLine = true; [SerializeField][Since("v3.3.0")] private bool m_ShowStartLine = true;
[SerializeField][Since("v3.3.0")] private bool m_ShowEndLine = true; [SerializeField][Since("v3.3.0")] private bool m_ShowEndLine = true;
[SerializeField][Since("v3.11.0")] private bool m_ShowZLine = true;
/// <summary> /// <summary>
/// The distance between the split line and axis line. /// The distance between the split line and axis line.
@@ -53,6 +54,15 @@ namespace XCharts.Runtime
get { return m_ShowEndLine; } get { return m_ShowEndLine; }
set { if (PropertyUtil.SetStruct(ref m_ShowEndLine, value)) SetVerticesDirty(); } set { if (PropertyUtil.SetStruct(ref m_ShowEndLine, value)) SetVerticesDirty(); }
} }
/// <summary>
/// Whether to show the Z axis part of the split line. Generally used for 3D coordinate systems.
/// ||是否显示Z轴部分分割线。一般用于3D坐标系。
/// </summary>
public bool showZLine
{
get { return m_ShowZLine; }
set { if (PropertyUtil.SetStruct(ref m_ShowZLine, value)) SetVerticesDirty(); }
}
public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } } public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
public override void ClearVerticesDirty() public override void ClearVerticesDirty()

View File

@@ -45,6 +45,7 @@ namespace XCharts.Runtime
axis.context.x = parallel.context.x; axis.context.x = parallel.context.x;
axis.context.y = parallel.context.y + (axis.index) * each; axis.context.y = parallel.context.y + (axis.index) * each;
axis.context.width = parallel.context.width; axis.context.width = parallel.context.width;
axis.context.length = parallel.context.width;
} }
else else
{ {
@@ -52,6 +53,7 @@ namespace XCharts.Runtime
axis.context.x = parallel.context.x + (axis.index) * each; axis.context.x = parallel.context.x + (axis.index) * each;
axis.context.y = parallel.context.y; axis.context.y = parallel.context.y;
axis.context.width = parallel.context.height; axis.context.width = parallel.context.height;
axis.context.length = parallel.context.height;
} }
axis.context.orient = m_Orient; axis.context.orient = m_Orient;
axis.context.height = 0; axis.context.height = 0;

View File

@@ -99,7 +99,7 @@ namespace XCharts.Runtime
var radius = polar.context.outsideRadius - polar.context.insideRadius; var radius = polar.context.outsideRadius - polar.context.insideRadius;
var objName = component.GetType().Name + axis.index; var objName = component.GetType().Name + axis.index;
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.transform.localPosition = Vector3.zero; axisObj.transform.localPosition = Vector3.zero;
axisObj.SetActive(axis.show && axis.axisLabel.show); axisObj.SetActive(axis.show && axis.axisLabel.show);
axisObj.hideFlags = chart.chartHideFlags; axisObj.hideFlags = chart.chartHideFlags;
@@ -124,7 +124,7 @@ namespace XCharts.Runtime
label.text.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter)); label.text.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter));
label.SetText(labelName); label.SetText(labelName);
label.SetPosition(GetLabelPosition(polar, axis, angleAxis.context.startAngle, totalWidth)); label.SetPosition(GetLabelPosition(polar, axis, angleAxis.context.startAngle, totalWidth));
label.SetActive(true); label.SetActive(true, true);
label.SetTextActive(true); label.SetTextActive(true);
axis.context.labelObjectList.Add(label); axis.context.labelObjectList.Add(label);

View File

@@ -123,6 +123,12 @@ namespace XCharts.Runtime
else else
context.y = chartY + context.bottom; context.y = chartY + context.bottom;
context.start = new Vector3(context.x, context.y);
if (m_Orient == Orient.Horizonal)
context.end = new Vector3(context.x + context.width, context.y);
else
context.end = new Vector3(context.x, context.y + context.height);
context.length = (context.end - context.start).magnitude;
context.position = new Vector3(context.x, context.y); context.position = new Vector3(context.x, context.y);
} }

View File

@@ -28,6 +28,7 @@ namespace XCharts.Runtime
splitLine.show = false; splitLine.show = false;
splitLine.lineStyle.type = LineStyle.Type.None; splitLine.lineStyle.type = LineStyle.Type.None;
axisLabel.textLimit.enable = true; axisLabel.textLimit.enable = true;
axisName.labelStyle.offset = new Vector3(5, 0, 0);
} }
} }
} }

View File

@@ -1,5 +1,6 @@
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace XCharts.Runtime namespace XCharts.Runtime
{ {
@@ -16,7 +17,28 @@ namespace XCharts.Runtime
public override void Update() public override void Update()
{ {
UpdateAxisMinMaxValue(component.index, component); UpdateAxisMinMaxValue(component.index, component);
UpdatePointerValue(component); if (!chart.isTriggerOnClick)
{
UpdatePointerValue(component);
}
}
public override void OnPointerClick(PointerEventData eventData)
{
base.OnPointerClick(eventData);
if (chart.isTriggerOnClick)
{
UpdatePointerValue(component);
}
}
public override void OnPointerExit(PointerEventData eventData)
{
base.OnPointerExit(eventData);
if (chart.isTriggerOnClick)
{
component.context.pointerValue = double.PositiveInfinity;
}
} }
public override void DrawBase(VertexHelper vh) public override void DrawBase(VertexHelper vh)
@@ -35,6 +57,11 @@ namespace XCharts.Runtime
var relativedAxis = chart.GetChartComponent<YAxis>(axis.gridIndex); var relativedAxis = chart.GetChartComponent<YAxis>(axis.gridIndex);
axis.context.x = grid.context.x; axis.context.x = grid.context.x;
axis.context.y = AxisHelper.GetXAxisXOrY(grid, axis, relativedAxis); axis.context.y = AxisHelper.GetXAxisXOrY(grid, axis, relativedAxis);
axis.context.start = new Vector3(grid.context.x, axis.context.y);
axis.context.end = new Vector3(grid.context.x + grid.context.width, axis.context.y);
var vec = axis.context.end - axis.context.start;
axis.context.dire = vec.normalized;
axis.context.length = vec.magnitude;
axis.context.zeroY = grid.context.y; axis.context.zeroY = grid.context.y;
axis.context.zeroX = grid.context.x + axis.context.offset; axis.context.zeroX = grid.context.x + axis.context.offset;
} }

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6350e9983955e49c5b48704d3866cbfe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// The x axis in cartesian(rectangular) coordinate.
/// ||直角坐标系 grid 中的 x 轴。
/// </summary>
[Since("v3.11.0")]
[System.Serializable]
[RequireChartComponent(typeof(GridCoord3D))]
[ComponentHandler(typeof(XAxis3DHander), true)]
public class XAxis3D : Axis
{
public override void SetDefaultValue()
{
m_Show = true;
m_Type = AxisType.Category;
m_Min = 0;
m_Max = 0;
m_SplitNumber = 0;
m_BoundaryGap = true;
m_Position = AxisPosition.Bottom;
m_Offset = 0;
m_Data = new List<string>() { "x1", "x2", "x3", "x4", "x5" };
m_Icons = new List<Sprite>(5);
splitLine.show = false;
splitLine.lineStyle.type = LineStyle.Type.None;
axisLabel.textLimit.enable = true;
axisName.name = "X";
axisName.labelStyle.position = LabelStyle.Position.Middle;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9129bca9c2a864e1ea337d7eb74d1024
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,190 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace XCharts.Runtime
{
[UnityEngine.Scripting.Preserve]
internal sealed class XAxis3DHander : AxisHandler<XAxis3D>
{
protected override Orient orient { get { return Orient.Horizonal; } }
public override void InitComponent()
{
InitXAxis(component);
}
public override void Update()
{
UpdateAxisMinMaxValue(component.index, component);
if (!chart.isTriggerOnClick)
{
UpdatePointerValue(component);
}
}
public override void OnPointerClick(PointerEventData eventData)
{
base.OnPointerClick(eventData);
if (chart.isTriggerOnClick)
{
UpdatePointerValue(component);
}
}
public override void OnPointerExit(PointerEventData eventData)
{
base.OnPointerExit(eventData);
if (chart.isTriggerOnClick)
{
component.context.pointerValue = double.PositiveInfinity;
}
}
public override void DrawBase(VertexHelper vh)
{
UpdatePosition(component);
DrawXAxisSplit(vh, component);
DrawXAxisLine(vh, component);
DrawXAxisTick(vh, component);
}
private void UpdatePosition(XAxis3D axis)
{
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
if (grid != null)
{
if (axis.position == Axis.AxisPosition.Right || axis.position == Axis.AxisPosition.Top)
{
axis.context.start = grid.xyExchanged ? grid.context.pointD : grid.context.pointB;
axis.context.end = grid.context.pointC;
}
else
{
axis.context.start = grid.context.pointA;
axis.context.end = grid.xyExchanged ? grid.context.pointB : grid.context.pointD;
}
var vect = axis.context.end - axis.context.start;
axis.context.x = axis.context.start.x;
axis.context.y = axis.context.start.y;
axis.context.dire = vect.normalized;
axis.context.length = vect.magnitude;
}
}
private void InitXAxis(XAxis3D xAxis)
{
var theme = chart.theme;
var xAxisIndex = xAxis.index;
xAxis.painter = chart.painter;
xAxis.refreshComponent = delegate ()
{
var yAxis = chart.GetChartComponent<YAxis3D>(xAxis.index);
InitAxis3D(yAxis, orient);
};
xAxis.refreshComponent();
}
internal override void UpdateAxisLabelText(Axis axis)
{
base.UpdateAxisLabelText(axis);
if (axis.IsTime() || axis.IsValue())
{
for (int i = 0; i < axis.context.labelObjectList.Count; i++)
{
var label = axis.context.labelObjectList[i];
if (label != null)
{
var pos = GetLabelPosition(0, i);
label.SetPosition(pos);
CheckValueLabelActive(component, i, label, pos);
}
}
}
}
protected override Vector3 GetLabelPosition(float scaleWid, int i)
{
var yAxis = chart.GetChartComponent<YAxis3D>(component.index);
return Axis3DHelper.GetLabelPosition(i, component, yAxis, chart.theme.axis, scaleWid);
}
private void DrawXAxisSplit(VertexHelper vh, XAxis3D xAxis)
{
if (AxisHelper.NeedShowSplit(xAxis))
{
var grid = chart.GetChartComponent<GridCoord3D>(xAxis.gridIndex);
var relativedAxis = chart.GetChartComponent<YAxis3D>(xAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
var isLeft = grid.IsLeft();
if (grid.xyExchanged)
{
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
grid.context.pointA,
grid.context.pointB,
relativedAxis);
if (xAxis.splitLine.showZLine)
{
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(xAxis.gridIndex);
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
isLeft ? grid.context.pointD : grid.context.pointA,
isLeft ? grid.context.pointC : grid.context.pointB,
relativedAxis2);
}
}
else
{
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
grid.context.pointA,
grid.context.pointD,
relativedAxis);
if (xAxis.splitLine.showZLine)
{
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(xAxis.gridIndex);
Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
grid.context.pointB,
grid.context.pointC,
relativedAxis2);
}
}
}
}
private void DrawXAxisTick(VertexHelper vh, XAxis3D xAxis)
{
if (AxisHelper.NeedShowSplit(xAxis))
{
var grid = chart.GetChartComponent<GridCoord3D>(xAxis.gridIndex);
if (grid == null)
return;
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
var relativedAxis = chart.GetChartComponent<YAxis3D>(xAxis.gridIndex);
Axis3DHelper.DrawAxisTick(vh, xAxis, chart.theme.axis, dataZoom,
xAxis.context.start,
xAxis.context.end,
-relativedAxis.context.dire);
}
}
private void DrawXAxisLine(VertexHelper vh, XAxis3D axis)
{
if (axis.show && axis.axisLine.show)
{
var theme = chart.theme.axis;
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
var lineType = axis.axisLine.GetType(theme.lineType);
var lineColor = axis.axisLine.GetColor(theme.lineColor);
var start = axis.context.start;
var end = axis.context.end;
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor);
}
}
internal override float GetAxisLineXOrY()
{
return component.context.y;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fc1147481a423494d963df29b423f3a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine;
namespace XCharts.Runtime namespace XCharts.Runtime
{ {
@@ -25,6 +26,7 @@ namespace XCharts.Runtime
splitLine.lineStyle.type = LineStyle.Type.None; splitLine.lineStyle.type = LineStyle.Type.None;
axisLabel.textLimit.enable = false; axisLabel.textLimit.enable = false;
axisTick.showStartTick = true; axisTick.showStartTick = true;
axisName.labelStyle.offset = new Vector3(0, 22, 0);
} }
} }
} }

View File

@@ -35,6 +35,11 @@ namespace XCharts.Runtime
var relativedAxis = chart.GetChartComponent<XAxis>(axis.gridIndex); var relativedAxis = chart.GetChartComponent<XAxis>(axis.gridIndex);
axis.context.x = AxisHelper.GetYAxisXOrY(grid, axis, relativedAxis); axis.context.x = AxisHelper.GetYAxisXOrY(grid, axis, relativedAxis);
axis.context.y = grid.context.y; axis.context.y = grid.context.y;
axis.context.start = new Vector3(axis.context.x, grid.context.y);
axis.context.end = new Vector3(axis.context.x, grid.context.y + grid.context.height);
var vect = axis.context.end - axis.context.start;
axis.context.dire = vect.normalized;
axis.context.length = vect.magnitude;
axis.context.zeroX = axis.context.x; axis.context.zeroX = axis.context.x;
axis.context.zeroY = axis.context.y + axis.context.offset; axis.context.zeroY = axis.context.y + axis.context.offset;
} }

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aa26616789b6b4903aae479a4c552b89
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
namespace XCharts.Runtime
{
/// <summary>
/// The x axis in cartesian(rectangular) coordinate.
/// ||直角坐标系 grid 中的 y 轴。
/// </summary>
[Since("v3.11.0")]
[System.Serializable]
[RequireChartComponent(typeof(GridCoord3D), typeof(XAxis3D))]
[ComponentHandler(typeof(YAxis3DHander), true)]
public class YAxis3D : Axis
{
public override void SetDefaultValue()
{
m_Show = true;
m_Type = AxisType.Value;
m_Min = 0;
m_Max = 0;
m_SplitNumber = 0;
m_BoundaryGap = false;
m_Position = AxisPosition.Left;
m_Data = new List<string>(5);
splitLine.show = true;
splitLine.lineStyle.type = LineStyle.Type.None;
axisLabel.textLimit.enable = false;
axisTick.showStartTick = true;
axisName.name = "Y";
axisName.labelStyle.position = LabelStyle.Position.Middle;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a3cb4a6657aaf473bbae7162eb189cc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,176 @@
using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
{
[UnityEngine.Scripting.Preserve]
internal sealed class YAxis3DHander : AxisHandler<YAxis3D>
{
protected override Orient orient { get { return Orient.Vertical; } }
public override void InitComponent()
{
InitYAxis(component);
}
public override void Update()
{
UpdateAxisMinMaxValue(component.index, component);
UpdatePointerValue(component);
}
public override void DrawBase(VertexHelper vh)
{
UpdatePosition(component);
DrawYAxisSplit(vh, component.index, component);
DrawYAxisLine(vh, component.index, component);
DrawYAxisTick(vh, component.index, component);
}
private void UpdatePosition(YAxis3D axis)
{
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
if (grid != null)
{
if (axis.position == Axis.AxisPosition.Right)
{
axis.context.start = grid.xyExchanged ? grid.context.pointB : grid.context.pointD;
axis.context.end = grid.context.pointC;
}
else
{
axis.context.start = grid.context.pointA;
axis.context.end = grid.xyExchanged ? grid.context.pointD : grid.context.pointB;
}
axis.context.x = axis.context.start.x;
axis.context.y = axis.context.start.y;
var vect = axis.context.end - axis.context.start;
axis.context.dire = vect.normalized;
axis.context.length = vect.magnitude;
}
}
private void InitYAxis(YAxis3D yAxis)
{
var theme = chart.theme;
var yAxisIndex = yAxis.index;
yAxis.painter = chart.painter;
yAxis.refreshComponent = delegate ()
{
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
if (grid != null)
{
var xAxis = chart.GetChartComponent<YAxis3D>(yAxis.index);
InitAxis3D(xAxis, orient);
}
};
yAxis.refreshComponent();
}
internal override void UpdateAxisLabelText(Axis axis)
{
base.UpdateAxisLabelText(axis);
if (axis.IsTime() || axis.IsValue())
{
for (int i = 0; i < axis.context.labelObjectList.Count; i++)
{
var label = axis.context.labelObjectList[i];
if (label != null)
{
var pos = GetLabelPosition(0, i);
label.SetPosition(pos);
CheckValueLabelActive(axis, i, label, pos);
}
}
}
}
protected override Vector3 GetLabelPosition(float scaleWid, int i)
{
var xAxis = chart.GetChartComponent<XAxis3D>(component.index);
return Axis3DHelper.GetLabelPosition(i, component, xAxis, chart.theme.axis, scaleWid);
}
private void DrawYAxisSplit(VertexHelper vh, int yAxisIndex, YAxis3D yAxis)
{
if (AxisHelper.NeedShowSplit(yAxis))
{
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
var relativedAxis = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
var isLeft = grid.IsLeft();
if (grid.xyExchanged)
{
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
grid.context.pointA,
grid.context.pointD,
relativedAxis);
if (yAxis.splitLine.showZLine)
{
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(yAxis.gridIndex);
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
grid.context.pointB, grid.context.pointC, relativedAxis2);
}
}
else
{
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
grid.context.pointA,
grid.context.pointB,
relativedAxis);
if (yAxis.splitLine.showZLine)
{
var relativedAxis2 = chart.GetChartComponent<ZAxis3D>(yAxis.gridIndex);
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
isLeft ? grid.context.pointD : grid.context.pointA,
isLeft ? grid.context.pointC : grid.context.pointB,
relativedAxis2);
}
}
}
}
private void DrawYAxisTick(VertexHelper vh, int yAxisIndex, YAxis3D yAxis)
{
if (AxisHelper.NeedShowSplit(yAxis))
{
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
if (grid == null)
return;
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
var relativedAxis = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
Axis3DHelper.DrawAxisTick(vh, yAxis, chart.theme.axis, dataZoom,
yAxis.context.start,
yAxis.context.end,
-relativedAxis.context.dire);
}
}
private void DrawYAxisLine(VertexHelper vh, int axisIndex, YAxis3D axis)
{
if (axis.show && axis.axisLine.show)
{
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
if (grid == null)
return;
var theme = chart.theme.axis;
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
var lineType = axis.axisLine.GetType(theme.lineType);
var lineColor = axis.axisLine.GetColor(theme.lineColor);
var start = axis.context.start;
var end = axis.context.end;
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor);
}
}
internal override float GetAxisLineXOrY()
{
return component.context.x;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56b4be734c61645e1bf91c22a6e3da6c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 378448672ed084b0798c7ad343314693
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
namespace XCharts.Runtime
{
/// <summary>
/// The x axis in cartesian(rectangular) coordinate.
/// ||直角坐标系 grid 中的 y 轴。
/// </summary>
[Since("v3.11.0")]
[System.Serializable]
[RequireChartComponent(typeof(GridCoord3D), typeof(XAxis3D))]
[ComponentHandler(typeof(ZAxis3DHander), true)]
public class ZAxis3D : Axis
{
public override void SetDefaultValue()
{
m_Show = true;
m_Type = AxisType.Value;
m_Min = 0;
m_Max = 0;
m_SplitNumber = 0;
m_BoundaryGap = false;
m_Position = AxisPosition.Left;
m_Data = new List<string>(5);
splitLine.show = true;
splitLine.lineStyle.type = LineStyle.Type.None;
axisLabel.textLimit.enable = false;
axisTick.showStartTick = true;
axisName.name = "Z";
axisName.labelStyle.position = LabelStyle.Position.Middle;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 65aa8ae88610c431ebdab86935af2379
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,198 @@
using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
{
[UnityEngine.Scripting.Preserve]
internal sealed class ZAxis3DHander : AxisHandler<ZAxis3D>
{
protected override Orient orient { get { return Orient.Vertical; } }
public override void InitComponent()
{
InitYAxis(component);
}
public override void Update()
{
UpdateAxisMinMaxValue(component.index, component);
UpdatePointerValue(component);
}
public override void DrawBase(VertexHelper vh)
{
UpdatePosition(component);
DrawZAxisSplit(vh, component.index, component);
DrawZAxisLine(vh, component.index, component);
DrawZAxisTick(vh, component.index, component);
}
private void UpdatePosition(ZAxis3D axis)
{
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
if (grid != null)
{
if (grid.context.pointB.x < grid.context.pointA.x)
{
axis.context.start = grid.context.pointD;
axis.context.end = grid.context.pointH;
}
else if (axis.position == Axis.AxisPosition.Center)
{
axis.context.start = grid.context.pointB;
axis.context.end = grid.context.pointF;
}
else if (axis.position == Axis.AxisPosition.Right)
{
axis.context.start = grid.context.pointC;
axis.context.end = grid.context.pointG;
}
else
{
axis.context.start = grid.context.pointA;
axis.context.end = grid.context.pointE;
}
axis.context.x = axis.context.start.x;
axis.context.y = axis.context.start.y;
var vect = axis.context.end - axis.context.start;
axis.context.dire = vect.normalized;
axis.context.length = vect.magnitude;
}
}
private void InitYAxis(ZAxis3D yAxis)
{
var theme = chart.theme;
var yAxisIndex = yAxis.index;
yAxis.painter = chart.painter;
yAxis.refreshComponent = delegate ()
{
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
if (grid != null)
{
var relativedAxis = chart.GetChartComponent<ZAxis3D>(yAxis.index);
InitAxis3D(relativedAxis, orient);
}
};
yAxis.refreshComponent();
}
internal override void UpdateAxisLabelText(Axis axis)
{
base.UpdateAxisLabelText(axis);
if (axis.IsTime() || axis.IsValue())
{
for (int i = 0; i < axis.context.labelObjectList.Count; i++)
{
var label = axis.context.labelObjectList[i];
if (label != null)
{
var pos = GetLabelPosition(0, i);
label.SetPosition(pos);
CheckValueLabelActive(axis, i, label, pos);
}
}
}
}
protected override Vector3 GetLabelPosition(float scaleWid, int i)
{
var grid = chart.GetChartComponent<GridCoord3D>(component.gridIndex);
if (grid == null)
return Vector3.zero;
var yAxis = chart.GetChartComponent<XAxis3D>(component.index);
return Axis3DHelper.GetLabelPosition(i, component, yAxis,
chart.theme.axis,
scaleWid);
}
private void DrawZAxisSplit(VertexHelper vh, int yAxisIndex, ZAxis3D yAxis)
{
if (AxisHelper.NeedShowSplit(yAxis))
{
var grid = chart.GetChartComponent<GridCoord3D>(yAxis.gridIndex);
if (grid == null)
return;
var isLeft = grid.IsLeft();
if (grid.xyExchanged)
{
var relativedAxis = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
isLeft ? grid.context.pointD : grid.context.pointA,
isLeft ? grid.context.pointH : grid.context.pointE,
relativedAxis);
if (yAxis.splitLine.showZLine)
{
var relativedAxis2 = chart.GetChartComponent<YAxis3D>(yAxis.gridIndex);
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
grid.context.pointB,
grid.context.pointF,
relativedAxis2);
}
}
else
{
var relativedAxis = chart.GetChartComponent<YAxis3D>(yAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
isLeft ? grid.context.pointD : grid.context.pointA,
isLeft ? grid.context.pointH : grid.context.pointE,
relativedAxis);
if (yAxis.splitLine.showZLine)
{
var relativedAxis2 = chart.GetChartComponent<XAxis3D>(yAxis.gridIndex);
Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
grid.context.pointB,
grid.context.pointF,
relativedAxis2);
}
}
}
}
private void DrawZAxisTick(VertexHelper vh, int yAxisIndex, ZAxis3D zAxis)
{
if (AxisHelper.NeedShowSplit(zAxis))
{
var grid = chart.GetChartComponent<GridCoord3D>(zAxis.gridIndex);
if (grid == null)
return;
var dataZoom = chart.GetDataZoomOfAxis(zAxis);
var relativedDire = grid.context.pointA - grid.context.pointB;
Axis3DHelper.DrawAxisTick(vh, zAxis, chart.theme.axis, dataZoom,
zAxis.context.start,
zAxis.context.end,
relativedDire.normalized);
}
}
private void DrawZAxisLine(VertexHelper vh, int axisIndex, ZAxis3D axis)
{
if (axis.show && axis.axisLine.show)
{
var grid = chart.GetChartComponent<GridCoord3D>(axis.gridIndex);
if (grid == null)
return;
var theme = chart.theme.axis;
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
var lineType = axis.axisLine.GetType(theme.lineType);
var lineColor = axis.axisLine.GetColor(theme.lineColor);
var start = axis.context.start;
var end = axis.context.end;
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor);
}
}
internal override float GetAxisLineXOrY()
{
return component.context.x;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67fb4be32885d4915979719c676aac5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -100,6 +100,12 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); } set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); }
} }
/// <summary>
/// the rect of background.
/// ||背景的矩形区域。
/// </summary>
public Rect rect { get; set; }
public override void SetDefaultValue() public override void SetDefaultValue()
{ {
m_Show = true; m_Show = true;

View File

@@ -15,7 +15,7 @@ namespace XCharts.Runtime
component.refreshComponent = delegate () component.refreshComponent = delegate ()
{ {
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor, var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
component.gameObject = backgroundObj; component.gameObject = backgroundObj;
backgroundObj.hideFlags = chart.chartHideFlags; backgroundObj.hideFlags = chart.chartHideFlags;
@@ -50,7 +50,7 @@ namespace XCharts.Runtime
var borderColor = component.borderStyle.GetRuntimeBorderColor(); var borderColor = component.borderStyle.GetRuntimeBorderColor();
var cornerRadius = component.borderStyle.GetRuntimeCornerRadius(); var cornerRadius = component.borderStyle.GetRuntimeCornerRadius();
UGL.DrawRoundRectangleWithBorder(vh, chart.chartRect, backgroundColor, backgroundColor, cornerRadius, UGL.DrawRoundRectangleWithBorder(vh, chart.chartRect, backgroundColor, backgroundColor, cornerRadius,
borderWidth, borderColor); borderWidth, borderColor, 0, 1f);
} }
} }
} }

View File

@@ -82,5 +82,11 @@ namespace XCharts.Runtime
{ {
return m_Show && roundedCorner ? m_CornerRadius : null; return m_Show && roundedCorner ? m_CornerRadius : null;
} }
public bool IsCricle()
{
return roundedCorner && m_CornerRadius[0] == 1 && m_CornerRadius[1] == 1 &&
m_CornerRadius[2] == 1 && m_CornerRadius[3] == 1;
}
} }
} }

View File

@@ -209,10 +209,29 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_ItemMarker, value)) SetVerticesDirty(); } set { if (PropertyUtil.SetClass(ref m_ItemMarker, value)) SetVerticesDirty(); }
} }
/// <summary> /// <summary>
/// Standard numeric format strings. /// Standard number and date format string. Used to format a Double value or a DateTime date as a string.
/// ||标准数字格式字符串。用于将数值格式化显示为字符串。 /// numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
/// 使用Axx的形式A是格式说明符的单字符支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明从0-99。 /// The number format uses the Axx format: A is a single-character format specifier that supports C currency,
/// 参考https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings /// D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal.
/// xx is precision specification, from 0-99. E.g. F1, E2<br />
/// Date format: Starts with `date`, which is used to format DateTime. Common date formats are:
/// yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: date:yyyy-MM-dd HH:mm:ss<br />
/// Time format: Starts with `time`, which is used to format TimeSpan. Common time formats are:
/// d day, HH hour, mm minute, ss second, fffffff fractional part.
/// Only the version of Unity2018 or later can support formatting, and the characters inside should be escaped.
/// For example: time:HH\:mm\:ss<br />
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
/// Note: The date and time formats are only supported by 'v3.12.0' or later.<br/>
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
/// 数字格式使用Axx的形式A是格式说明符的单字符支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明从0-99。如F1, E2<br/>
/// 日期格式:以`date`开头用来格式化DateTime常见格式有yyyy年MM月dd日HH时mm分ss秒fff毫秒。如date:yyyy-MM-dd HH:mm:ss<br/>
/// 时间格式:以`time`开头用来格式化TimeSpan常见格式有d日HH时mm分ss秒fffffff小数部分。
/// 需要Unity2018以上版本才支持格式化并且里面的字符要转义。如time:d\.HH\:mm\:ss<br/>
/// 数值格式化参考https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
/// 日期格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings <br/>
/// 时间格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-timespan-format-strings <br/>
/// 注意date和time格式需要`v3.12.0`以上版本才支持。
/// </summary> /// </summary>
public string numericFormatter public string numericFormatter
{ {

View File

@@ -349,6 +349,69 @@ namespace XCharts.Runtime
} }
} }
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
{
UpdateRuntimeData(graphWidth, graphWidth);
float x, y, width, height;
width = rectWidth == 0 ? graphWidth - runtimeLeft - runtimeRight : rectWidth;
height = rectHeight == 0 ? graphHeight - runtimeBottom - runtimeTop : rectHeight;
switch (align)
{
case Align.BottomCenter:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + runtimeBottom;
break;
case Align.BottomLeft:
x = graphX + runtimeLeft;
y = graphY + runtimeBottom;
break;
case Align.BottomRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + runtimeBottom;
break;
case Align.Center:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.CenterLeft:
x = graphX + runtimeLeft;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.CenterRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.TopCenter:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + graphHeight - runtimeTop - height;
break;
case Align.TopLeft:
x = graphX + runtimeLeft;
y = graphY + graphHeight - runtimeTop - height;
break;
case Align.TopRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + graphHeight - runtimeTop - height;
break;
default:
return new Rect(0, 0, 0, 0);
}
return new Rect(x, y, width, height);
}
/// <summary> /// <summary>
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot /// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
/// </summary> /// </summary>

View File

@@ -84,12 +84,16 @@ namespace XCharts.Runtime
[SerializeField] protected Sprite m_Image; [SerializeField] protected Sprite m_Image;
[SerializeField] protected Image.Type m_ImageType; [SerializeField] protected Image.Type m_ImageType;
[SerializeField] protected Color32 m_Color; [SerializeField] protected Color32 m_Color;
[SerializeField][Since("v3.13.0")] protected float m_BorderWidth = 0f;
[SerializeField][Since("v3.13.0")] protected Color32 m_EmptyColor;
[SerializeField][Since("v3.13.0")] protected float m_Size2 = 0f;
public virtual void Reset() public virtual void Reset()
{ {
m_Show = false; m_Show = false;
m_Type = SymbolType.EmptyCircle; m_Type = SymbolType.EmptyCircle;
m_Size = 0f; m_Size = 0f;
m_Size2 = 0f;
m_Gap = 0; m_Gap = 0;
m_Width = 0f; m_Width = 0f;
m_Height = 0f; m_Height = 0f;
@@ -126,6 +130,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); } set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
} }
/// <summary> /// <summary>
/// the size of symbol.
/// ||标记的大小。当为Rect时size2表示高度。
/// </summary>
public float size2
{
get { return m_Size2; }
set { if (PropertyUtil.SetStruct(ref m_Size2, value)) SetVerticesDirty(); }
}
/// <summary>
/// the gap of symbol and line segment. /// the gap of symbol and line segment.
/// ||图形标记和线条的间隙距离。 /// ||图形标记和线条的间隙距离。
/// </summary> /// </summary>
@@ -183,6 +196,24 @@ namespace XCharts.Runtime
get { return m_Color; } get { return m_Color; }
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); } set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
} }
/// <summary>
/// the border width of symbol.
/// ||图形的边框宽度。
/// </summary>
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); }
}
/// <summary>
/// the color of empty symbol.
/// ||空心图形的颜色。
/// </summary>
public Color32 emptyColor
{
get { return m_EmptyColor; }
set { if (PropertyUtil.SetStruct(ref m_EmptyColor, value)) SetAllDirty(); }
}
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } } public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 }; private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
/// <summary> /// <summary>

View File

@@ -27,7 +27,6 @@ namespace XCharts.Runtime
#if dUI_TextMeshPro #if dUI_TextMeshPro
[SerializeField] private TMP_FontAsset m_TMPFont; [SerializeField] private TMP_FontAsset m_TMPFont;
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal; [SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
[SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left;
[SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset; [SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset;
#endif #endif
public bool show public bool show
@@ -147,15 +146,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); } set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
} }
/// <summary> /// <summary>
/// the text alignment of TextMeshPro.
/// ||TextMeshPro字体对齐方式。
/// </summary>
public TextAlignmentOptions tmpAlignment
{
get { return m_TMPAlignment; }
set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); }
}
/// <summary>
/// the sprite asset of TextMeshPro. /// the sprite asset of TextMeshPro.
/// ||TextMeshPro的Sprite Asset。 /// ||TextMeshPro的Sprite Asset。
/// </summary> /// </summary>
@@ -214,11 +204,7 @@ namespace XCharts.Runtime
public void UpdateAlignmentByLocation(Location location) public void UpdateAlignmentByLocation(Location location)
{ {
#if dUI_TextMeshPro
m_TMPAlignment = location.runtimeTMPTextAlignment;
#else
m_Alignment = location.runtimeTextAlignment; m_Alignment = location.runtimeTextAlignment;
#endif
} }
public Color GetColor(Color defaultColor) public Color GetColor(Color defaultColor)

View File

@@ -22,7 +22,7 @@ namespace XCharts.Runtime
chart.chartMinAnchor, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartMaxAnchor,
chart.chartPivot, chart.chartPivot,
chart.chartSizeDelta); chart.chartSizeDelta, -1, chart.childrenNodeNames);
commentObj.SetActive(comment.show); commentObj.SetActive(comment.show);
commentObj.hideFlags = chart.chartHideFlags; commentObj.hideFlags = chart.chartHideFlags;
@@ -34,7 +34,7 @@ namespace XCharts.Runtime
var labelPos = chart.chartPosition + item.location.GetPosition(chart.chartWidth, chart.chartHeight); var labelPos = chart.chartPosition + item.location.GetPosition(chart.chartWidth, chart.chartHeight);
var label = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common, var label = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common,
GetContent(item), Color.clear, TextAnchor.MiddleCenter); GetContent(item), Color.clear, TextAnchor.MiddleCenter);
label.SetActive(comment.show && item.show); label.SetActive(comment.show && item.show, true);
label.SetPosition(labelPos); label.SetPosition(labelPos);
label.text.SetLocalPosition(labelStyle.offset); label.text.SetLocalPosition(labelStyle.offset);
} }

View File

@@ -17,6 +17,8 @@ namespace XCharts.Runtime
private bool m_CheckDataZoomLabel; private bool m_CheckDataZoomLabel;
private float m_DataZoomLastStartIndex; private float m_DataZoomLastStartIndex;
private float m_DataZoomLastEndIndex; private float m_DataZoomLastEndIndex;
private float m_LastStart;
private float m_LastEnd;
public override void InitComponent() public override void InitComponent()
{ {
@@ -25,7 +27,7 @@ namespace XCharts.Runtime
dataZoom.refreshComponent = delegate () dataZoom.refreshComponent = delegate ()
{ {
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform, var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
dataZoom.gameObject = dataZoomObject; dataZoom.gameObject = dataZoomObject;
dataZoomObject.hideFlags = chart.chartHideFlags; dataZoomObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(dataZoomObject); ChartHelper.HideAllObject(dataZoomObject);
@@ -62,6 +64,10 @@ namespace XCharts.Runtime
{ {
CheckDataZoomScale(component); CheckDataZoomScale(component);
CheckDataZoomLabel(component); CheckDataZoomLabel(component);
if (m_LastStart != component.start || m_LastEnd != component.end)
{
UpdateDataZoomRange(component, component.start, component.end);
}
} }
public override void DrawUpper(VertexHelper vh) public override void DrawUpper(VertexHelper vh)
@@ -404,6 +410,8 @@ namespace XCharts.Runtime
dataZoom.start = start; dataZoom.start = start;
if (!dataZoom.endLock) if (!dataZoom.endLock)
dataZoom.end = end; dataZoom.end = end;
m_LastStart = dataZoom.start;
m_LastEnd = dataZoom.end;
if (dataZoom.realtime) if (dataZoom.realtime)
{ {
chart.OnDataZoomRangeChanged(dataZoom); chart.OnDataZoomRangeChanged(dataZoom);

View File

@@ -75,7 +75,7 @@ namespace XCharts.Runtime
public void Init(BaseChart chart) public void Init(BaseChart chart)
{ {
m_Chart = chart; m_Chart = chart;
m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme); m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme, chart.childrenNodeNames);
} }
public void Update() public void Update()
@@ -155,14 +155,14 @@ namespace XCharts.Runtime
} }
private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle, private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle,
ThemeStyle theme) ThemeStyle theme, List<string> childrenNodeNames)
{ {
var anchorMax = new Vector2(0, 1); var anchorMax = new Vector2(0, 1);
var anchorMin = new Vector2(0, 1); var anchorMin = new Vector2(0, 1);
var pivot = new Vector2(0, 1); var pivot = new Vector2(0, 1);
var sizeDelta = new Vector2(100, 100); var sizeDelta = new Vector2(100, 100);
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childrenNodeNames);
labelGameObject.transform.SetAsLastSibling(); labelGameObject.transform.SetAsLastSibling();
labelGameObject.hideFlags = m_Chart.chartHideFlags; labelGameObject.hideFlags = m_Chart.chartHideFlags;
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo); ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);

View File

@@ -184,16 +184,29 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); } set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
} }
/// <summary> /// <summary>
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string. numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br /> /// Standard number and date format string. Used to format a Double value or a DateTime date as a string.
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency, D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal. xx is precision specification, from 0-99. E.g. F1, E2<br /> /// numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
/// Date format Common date formats are: yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: yyyy-MM-dd HH:mm:ss<br /> /// The number format uses the Axx format: A is a single-character format specifier that supports C currency,
/// D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal.
/// xx is precision specification, from 0-99. E.g. F1, E2<br />
/// Date format: Starts with `date`, which is used to format DateTime. Common date formats are:
/// yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: date:yyyy-MM-dd HH:mm:ss<br />
/// Time format: Starts with `time`, which is used to format TimeSpan. Common time formats are:
/// d day, HH hour, mm minute, ss second, fffffff fractional part.
/// Only the version of Unity2018 or later can support formatting, and the characters inside should be escaped.
/// For example: time:HH\:mm\:ss<br />
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/> /// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/> /// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
/// Note: The date and time formats are only supported by 'v3.12.0' or later.<br/>
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/> /// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
/// 数字格式使用Axx的形式A是格式说明符的单字符支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明从0-99。如F1, E2<br/> /// 数字格式使用Axx的形式A是格式说明符的单字符支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明从0-99。如F1, E2<br/>
/// 日期格式常见格式yyyy年MM月dd日HH时mm分ss秒fff毫秒。如yyyy-MM-dd HH:mm:ss<br/> /// 日期格式:以`date`开头用来格式化DateTime常见格式yyyy年MM月dd日HH时mm分ss秒fff毫秒。如date:yyyy-MM-dd HH:mm:ss<br/>
/// 时间格式:以`time`开头用来格式化TimeSpan常见格式有d日HH时mm分ss秒fffffff小数部分。
/// 需要Unity2018以上版本才支持格式化并且里面的字符要转义。如time:d\.HH\:mm\:ss<br/>
/// 数值格式化参考https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/> /// 数值格式化参考https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
/// 日期格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings /// 日期格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings <br/>
/// 时间格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-timespan-format-strings <br/>
/// 注意date和time格式需要`v3.12.0`以上版本才支持。
/// </summary> /// </summary>
public string numericFormatter public string numericFormatter
{ {
@@ -405,7 +418,7 @@ namespace XCharts.Runtime
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
{ {
var newNumericFormatter = numericFormatter; var newNumericFormatter = numericFormatter;
if (value == 0) if (value == 0 && !DateTimeUtil.IsDateOrTimeRegex(newNumericFormatter))
{ {
newNumericFormatter = "f0"; newNumericFormatter = "f0";
} }
@@ -444,6 +457,8 @@ namespace XCharts.Runtime
} }
} }
private static bool isDateFormatter = false;
private static string newFormatter = null;
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue) public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
{ {
var timestamp = (int)value; var timestamp = (int)value;
@@ -457,7 +472,17 @@ namespace XCharts.Runtime
{ {
try try
{ {
dateString = dateTime.ToString(numericFormatter); if(DateTimeUtil.IsDateOrTimeRegex(numericFormatter, ref isDateFormatter, ref newFormatter))
{
if(isDateFormatter)
dateString = ChartCached.NumberToDateStr(timestamp, newFormatter);
else
dateString = ChartCached.NumberToTimeStr(timestamp, newFormatter);
}
else
{
dateString = dateTime.ToString(numericFormatter);
}
} }
catch catch
{ {

View File

@@ -45,7 +45,7 @@ namespace XCharts.Runtime
{ {
var content = serieLabel.formatter; var content = serieLabel.formatter;
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue, FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
dataTotal, serieName, dataName, dataName, color, serieData, chart); dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index);
if (serieLabel.formatterFunction == null) if (serieLabel.formatterFunction == null)
return content; return content;
else else

View File

@@ -55,7 +55,7 @@ namespace XCharts.Runtime
{ {
legend.OnChanged(); legend.OnChanged();
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor, var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
legend.gameObject = legendObject; legend.gameObject = legendObject;
legendObject.hideFlags = chart.chartHideFlags; legendObject.hideFlags = chart.chartHideFlags;
//ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_"); //ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_");
@@ -87,11 +87,14 @@ namespace XCharts.Runtime
ChartHelper.HideAllObject(legendObject); ChartHelper.HideAllObject(legendObject);
if (!legend.show) return; if (!legend.show) return;
var textLimitInitFlag = false; var textLimitInitFlag = false;
var isAnySerieColorByData = SeriesHelper.IsAnyColorByDataSerie(chart.series);
for (int i = 0; i < datas.Count; i++) for (int i = 0; i < datas.Count; i++)
{ {
if (!SeriesHelper.IsLegalLegendName(datas[i])) continue; if (!SeriesHelper.IsLegalLegendName(datas[i])) continue;
string legendName = datas[i]; string legendName = datas[i];
var legendContent = GetFormatterContent(legend, i, datas[i]); var serieIndex = isAnySerieColorByData ? 0 : i;
var dataIndex = isAnySerieColorByData ? i : 0;
var legendContent = GetFormatterContent(legend, dataIndex, datas[i], serieIndex);
if (legend.textLimit.enable) if (legend.textLimit.enable)
legendContent = legend.textLimit.GetLimitContent(legendContent); legendContent = legend.textLimit.GetLimitContent(legendContent);
var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]); var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]);
@@ -158,7 +161,7 @@ namespace XCharts.Runtime
legend.refreshComponent(); legend.refreshComponent();
} }
private string GetFormatterContent(Legend legend, int dataIndex, string category) private string GetFormatterContent(Legend legend, int dataIndex, string category, int serieIndex)
{ {
#pragma warning disable 0618 #pragma warning disable 0618
if (string.IsNullOrEmpty(legend.formatter) && string.IsNullOrEmpty(legend.labelStyle.formatter)) if (string.IsNullOrEmpty(legend.formatter) && string.IsNullOrEmpty(legend.labelStyle.formatter))
@@ -168,7 +171,7 @@ namespace XCharts.Runtime
var formatter = string.IsNullOrEmpty(legend.labelStyle.formatter) ? legend.formatter : legend.labelStyle.formatter; var formatter = string.IsNullOrEmpty(legend.labelStyle.formatter) ? legend.formatter : legend.labelStyle.formatter;
var content = formatter.Replace("{name}", category); var content = formatter.Replace("{name}", category);
content = content.Replace("{value}", category); content = content.Replace("{value}", category);
var serie = chart.GetSerie(0); var serie = chart.GetSerie(serieIndex);
FormatterHelper.ReplaceContent(ref content, dataIndex, legend.labelStyle.numericFormatter, serie, chart, category); FormatterHelper.ReplaceContent(ref content, dataIndex, legend.labelStyle.numericFormatter, serie, chart, category);
return content; return content;
} }

View File

@@ -48,7 +48,7 @@ namespace XCharts.Runtime
var objAnchorMin = new Vector2(0, 1); var objAnchorMin = new Vector2(0, 1);
var objAnchorMax = new Vector2(0, 1); var objAnchorMax = new Vector2(0, 1);
var objPivot = new Vector2(0, 1); var objPivot = new Vector2(0, 1);
var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta); var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta, -1, chart.childrenNodeNames);
var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta); var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta);
var img = ChartHelper.EnsureComponent<Image>(btnObj); var img = ChartHelper.EnsureComponent<Image>(btnObj);
img.color = Color.clear; img.color = Color.clear;
@@ -58,7 +58,7 @@ namespace XCharts.Runtime
var label = ChartHelper.AddChartLabel("content", btnObj.transform, legend.labelStyle, theme.legend, var label = ChartHelper.AddChartLabel("content", btnObj.transform, legend.labelStyle, theme.legend,
content, contentColor, TextAnchor.MiddleLeft); content, contentColor, TextAnchor.MiddleLeft);
label.SetActive(true); label.SetActive(true, true);
var item = new LegendItem(); var item = new LegendItem();
item.index = i; item.index = i;

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
public override void InitComponent() public override void InitComponent()
{ {
m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor, m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags; m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(m_MarkLineLabelRoot); ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkArea(component); InitMarkArea(component);
@@ -45,7 +45,7 @@ namespace XCharts.Runtime
var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis, var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis,
component.text, Color.clear, TextAnchor.MiddleCenter); component.text, Color.clear, TextAnchor.MiddleCenter);
UpdateRuntimeData(component); UpdateRuntimeData(component);
label.SetActive(markArea.label.show); label.SetActive(markArea.label.show, true);
label.SetPosition(component.runtimeLabelPosition); label.SetPosition(component.runtimeLabelPosition);
label.SetText(component.text); label.SetText(component.text);
markArea.runtimeLabel = label; markArea.runtimeLabel = label;

View File

@@ -13,7 +13,7 @@ namespace XCharts.Runtime
public override void InitComponent() public override void InitComponent()
{ {
m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor, m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags; m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(m_MarkLineLabelRoot); ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkLine(component); InitMarkLine(component);
@@ -86,7 +86,7 @@ namespace XCharts.Runtime
content, Color.clear, TextAnchor.MiddleCenter); content, Color.clear, TextAnchor.MiddleCenter);
var pos = MarkLineHelper.GetLabelPosition(data); var pos = MarkLineHelper.GetLabelPosition(data);
label.SetIconActive(false); label.SetIconActive(false);
label.SetActive(data.label.show && data.runtimeInGrid); label.SetActive(false, true);
label.SetPosition(pos); label.SetPosition(pos);
data.runtimeLabel = label; data.runtimeLabel = label;
}; };

View File

@@ -41,7 +41,7 @@ namespace XCharts.Runtime
{ {
radar.UpdateRadarCenter(chart); radar.UpdateRadarCenter(chart);
var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor, var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
radar.gameObject = radarObject; radar.gameObject = radarObject;
radar.gameObject.hideFlags = chart.chartHideFlags; radar.gameObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT); ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT);
@@ -53,7 +53,7 @@ namespace XCharts.Runtime
var label = ChartHelper.AddChartLabel(objName, radarObject.transform, radar.axisName.labelStyle, var label = ChartHelper.AddChartLabel(objName, radarObject.transform, radar.axisName.labelStyle,
chart.theme.common, radar.GetFormatterIndicatorContent(i), Color.clear, TextAnchor.MiddleCenter); chart.theme.common, radar.GetFormatterIndicatorContent(i), Color.clear, TextAnchor.MiddleCenter);
label.SetActive(radar.axisName.show && radar.indicator && radar.axisName.labelStyle.show); label.SetActive(radar.axisName.show && radar.indicator && radar.axisName.labelStyle.show, true);
AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset); AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset);
} }
chart.RefreshBasePainter(); chart.RefreshBasePainter();

View File

@@ -22,7 +22,7 @@ namespace XCharts.Runtime
var pivot = title.location.runtimePivot; var pivot = title.location.runtimePivot;
var objName = ChartCached.GetComponentObjectName(title); var objName = ChartCached.GetComponentObjectName(title);
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax, var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
pivot, chart.chartSizeDelta); pivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
title.gameObject = titleObject; title.gameObject = titleObject;
title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1); title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
anchorMin = title.location.runtimeAnchorMin; anchorMin = title.location.runtimeAnchorMin;
@@ -39,11 +39,11 @@ namespace XCharts.Runtime
m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title, m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
GetTitleText(title), Color.clear, title.location.runtimeTextAlignment); GetTitleText(title), Color.clear, title.location.runtimeTextAlignment);
m_LabelObject.SetActive(title.show && title.labelStyle.show); m_LabelObject.SetActive(title.show && title.labelStyle.show, true);
m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle, m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment); GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment);
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show); m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show, true);
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset; m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
}; };
title.refreshComponent(); title.refreshComponent();

View File

@@ -37,7 +37,7 @@ namespace XCharts.Runtime
/// crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes. /// crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes.
/// ||十字准星指示器。坐标轴显示Label和交叉线。 /// ||十字准星指示器。坐标轴显示Label和交叉线。
/// </summary> /// </summary>
Corss, Cross,
/// <summary> /// <summary>
/// Auto select indicator according to serie type. /// Auto select indicator according to serie type.
/// ||根据serie的类型自动选择显示指示器。 /// ||根据serie的类型自动选择显示指示器。
@@ -73,6 +73,23 @@ namespace XCharts.Runtime
Auto Auto
} }
/// <summary> /// <summary>
/// the condition of trigger tooltip.
/// ||触发条件。
/// </summary>
public enum TriggerOn
{
/// <summary>
/// Trigger when mouse move.
/// ||鼠标移动时触发。
/// </summary>
MouseMove,
/// <summary>
/// Trigger when mouse click.
/// ||鼠标点击时触发。
/// </summary>
Click,
}
/// <summary>
/// Position type. /// Position type.
/// ||坐标类型。 /// ||坐标类型。
/// </summary> /// </summary>
@@ -102,6 +119,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_Show = true; [SerializeField] private bool m_Show = true;
[SerializeField] private Type m_Type = Type.Auto; [SerializeField] private Type m_Type = Type.Auto;
[SerializeField] private Trigger m_Trigger = Trigger.Auto; [SerializeField] private Trigger m_Trigger = Trigger.Auto;
[SerializeField][Since("v3.11.0")] private TriggerOn m_TriggerOn = TriggerOn.MouseMove;
[SerializeField][Since("v3.3.0")] private Position m_Position = Position.Auto; [SerializeField][Since("v3.3.0")] private Position m_Position = Position.Auto;
[SerializeField] private string m_ItemFormatter; [SerializeField] private string m_ItemFormatter;
[SerializeField] private string m_TitleFormatter; [SerializeField] private string m_TitleFormatter;
@@ -144,6 +162,12 @@ namespace XCharts.Runtime
public TooltipContext context = new TooltipContext(); public TooltipContext context = new TooltipContext();
public TooltipView view; public TooltipView view;
/// <summary>
/// the callback of tooltip click index.
/// ||Tooltip为Click触发时点击的X轴索引的回调。
/// </summary>
public System.Action<int> onClickIndex { get; set; }
/// <summary> /// <summary>
/// Whether to show the tooltip component. /// Whether to show the tooltip component.
/// ||是否显示提示框组件。 /// ||是否显示提示框组件。
@@ -172,6 +196,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Trigger, value)) SetAllDirty(); } set { if (PropertyUtil.SetStruct(ref m_Trigger, value)) SetAllDirty(); }
} }
/// <summary> /// <summary>
/// Condition of trigger tooltip.
/// ||触发条件。
/// </summary>
public TriggerOn triggerOn
{
get { return m_TriggerOn; }
set { if (PropertyUtil.SetStruct(ref m_TriggerOn, value)) SetAllDirty(); }
}
/// <summary>
/// Type of position. /// Type of position.
/// ||显示位置类型。 /// ||显示位置类型。
/// </summary> /// </summary>
@@ -211,7 +244,7 @@ namespace XCharts.Runtime
/// {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/> /// {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/>
/// {f}为数据总和。<br/> /// {f}为数据总和。<br/>
/// {g}为数据总个数。<br/> /// {g}为数据总个数。<br/>
/// {f}为value所对应的y轴的类目值。<br/> /// {y}为value所对应的y轴的类目值。<br/>
/// {.1}表示指定index为1的serie对应颜色的圆点。<br/> /// {.1}表示指定index为1的serie对应颜色的圆点。<br/>
/// {a1}、{b1}、{c1}中的1表示指定index为1的serie。<br/> /// {a1}、{b1}、{c1}中的1表示指定index为1的serie。<br/>
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。<br/> /// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。<br/>
@@ -260,16 +293,29 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } } public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } }
/// <summary> /// <summary>
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string. numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br /> /// Standard number and date format string. Used to format a Double value or a DateTime date as a string.
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency, D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal. xx is precision specification, from 0-99. E.g. F1, E2<br /> /// numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
/// Date format Common date formats are: yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: yyyy-MM-dd HH:mm:ss<br /> /// The number format uses the Axx format: A is a single-character format specifier that supports C currency,
/// D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal.
/// xx is precision specification, from 0-99. E.g. F1, E2<br />
/// Date format: Starts with `date`, which is used to format DateTime. Common date formats are:
/// yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: date:yyyy-MM-dd HH:mm:ss<br />
/// Time format: Starts with `time`, which is used to format TimeSpan. Common time formats are:
/// d day, HH hour, mm minute, ss second, fffffff fractional part.
/// Only the version of Unity2018 or later can support formatting, and the characters inside should be escaped.
/// For example: time:HH\:mm\:ss<br />
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/> /// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/> /// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
/// Note: The date and time formats are only supported by 'v3.12.0' or later.<br/>
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/> /// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
/// 数字格式使用Axx的形式A是格式说明符的单字符支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明从0-99。如F1, E2<br/> /// 数字格式使用Axx的形式A是格式说明符的单字符支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明从0-99。如F1, E2<br/>
/// 日期格式常见格式yyyy年MM月dd日HH时mm分ss秒fff毫秒。如yyyy-MM-dd HH:mm:ss<br/> /// 日期格式:以`date`开头用来格式化DateTime常见格式yyyy年MM月dd日HH时mm分ss秒fff毫秒。如date:yyyy-MM-dd HH:mm:ss<br/>
/// 时间格式:以`time`开头用来格式化TimeSpan常见格式有d日HH时mm分ss秒fffffff小数部分。
/// 需要Unity2018以上版本才支持格式化并且里面的字符要转义。如time:d\.HH\:mm\:ss<br/>
/// 数值格式化参考https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/> /// 数值格式化参考https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
/// 日期格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings /// 日期格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings <br/>
/// 时间格式化参考https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-timespan-format-strings <br/>
/// 注意date和time格式需要`v3.12.0`以上版本才支持。
/// </summary> /// </summary>
public string numericFormatter public string numericFormatter
{ {
@@ -503,37 +549,6 @@ namespace XCharts.Runtime
SetContentActive(flag); SetContentActive(flag);
} }
/// <summary>
/// 更新文本框位置
/// </summary>
/// <param name="pos"></param>
public void UpdateContentPos(Vector2 pos, float width, float height)
{
if (view != null)
{
switch (m_Position)
{
case Position.Auto:
#if UNITY_ANDROID || UNITY_IOS
if (m_FixedY == 0) pos.y = ChartHelper.GetActualValue(0.7f, height);
else pos.y = ChartHelper.GetActualValue(m_FixedY, height);
#endif
break;
case Position.Custom:
pos.x = ChartHelper.GetActualValue(m_FixedX, width);
pos.y = ChartHelper.GetActualValue(m_FixedY, height);
break;
case Position.FixedX:
pos.x = ChartHelper.GetActualValue(m_FixedX, width);
break;
case Position.FixedY:
pos.y = ChartHelper.GetActualValue(m_FixedY, height);
break;
}
view.UpdatePosition(pos);
}
}
/// <summary> /// <summary>
/// 设置文本框是否显示 /// 设置文本框是否显示
/// </summary> /// </summary>

View File

@@ -19,6 +19,7 @@ namespace XCharts.Runtime
public float width; public float width;
public float height; public float height;
public float angle; public float angle;
public int xAxisClickIndex = -1;
public Tooltip.Type type; public Tooltip.Type type;
public Tooltip.Trigger trigger; public Tooltip.Trigger trigger;
public TooltipData data = new TooltipData(); public TooltipData data = new TooltipData();

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI; using UnityEngine.UI;
using XUGL; using XUGL;
@@ -36,6 +37,15 @@ namespace XCharts.Runtime
DrawTooltipIndicator(vh, component); DrawTooltipIndicator(vh, component);
} }
public override void OnPointerExit(PointerEventData eventData)
{
base.OnPointerExit(eventData);
if (chart.isTriggerOnClick)
{
component.context.xAxisClickIndex = -1;
}
}
private void InitTooltip(Tooltip tooltip) private void InitTooltip(Tooltip tooltip)
{ {
tooltip.painter = chart.m_PainterUpper; tooltip.painter = chart.m_PainterUpper;
@@ -43,7 +53,7 @@ namespace XCharts.Runtime
{ {
var objName = ChartCached.GetComponentObjectName(tooltip); var objName = ChartCached.GetComponentObjectName(tooltip);
tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
var tooltipObject = tooltip.gameObject; var tooltipObject = tooltip.gameObject;
tooltipObject.transform.localPosition = Vector3.zero; tooltipObject.transform.localPosition = Vector3.zero;
tooltipObject.hideFlags = chart.chartHideFlags; tooltipObject.hideFlags = chart.chartHideFlags;
@@ -55,6 +65,7 @@ namespace XCharts.Runtime
m_LabelRoot = ChartHelper.AddObject("label", tooltip.gameObject.transform, chart.chartMinAnchor, m_LabelRoot = ChartHelper.AddObject("label", tooltip.gameObject.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
m_LabelRoot.transform.SetSiblingIndex(0);
ChartHelper.HideAllObject(m_LabelRoot); ChartHelper.HideAllObject(m_LabelRoot);
m_IndicatorLabels.Clear(); m_IndicatorLabels.Clear();
foreach (var com in chart.components) foreach (var com in chart.components)
@@ -70,6 +81,7 @@ namespace XCharts.Runtime
m_IndicatorLabels[labelName] = item; m_IndicatorLabels[labelName] = item;
} }
} }
chart.isTriggerOnClick = tooltip.triggerOn == Tooltip.TriggerOn.Click;
}; };
tooltip.refreshComponent(); tooltip.refreshComponent();
} }
@@ -93,40 +105,57 @@ namespace XCharts.Runtime
private void UpdateTooltipData(Tooltip tooltip) private void UpdateTooltipData(Tooltip tooltip)
{ {
showTooltip = false; m_ShowTooltip = false;
if (tooltip.trigger == Tooltip.Trigger.None) return; if (tooltip.trigger == Tooltip.Trigger.None) return;
if (!chart.isPointerInChart || !tooltip.show) chart.isTriggerOnClick = tooltip.triggerOn == Tooltip.TriggerOn.Click;
if ((tooltip.show && chart.isPointerInChart) &&
((tooltip.triggerOn == Tooltip.TriggerOn.Click && chart.isPointerClick) ||
(tooltip.triggerOn == Tooltip.TriggerOn.MouseMove))
)
{ {
if (tooltip.IsActive()) for (int i = chart.series.Count - 1; i >= 0; i--)
{ {
tooltip.ClearValue(); var serie = chart.series[i];
tooltip.SetActive(false); if (!(serie is INeedSerieContainer))
{
m_ShowTooltip = true;
m_ContainerSeries = null;
return;
}
} }
return; m_ContainerSeries = ListPool<Serie>.Get();
} UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries);
for (int i = chart.series.Count - 1; i >= 0; i--) if (m_ContainerSeries.Count > 0)
{
var serie = chart.series[i];
if (!(serie is INeedSerieContainer))
{ {
showTooltip = true; m_ShowTooltip = true;
containerSeries = null;
return; return;
} }
} }
containerSeries = ListPool<Serie>.Get();
UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref containerSeries); if (!m_ShowTooltip && tooltip.IsActive())
if (containerSeries.Count > 0)
{ {
showTooltip = true; tooltip.ClearValue();
tooltip.SetActive(false);
component.context.xAxisClickIndex = -1;
chart.pointerClickEventData = null;
} }
} }
private bool showTooltip; private bool m_ShowTooltip;
private List<Serie> containerSeries; private List<Serie> m_ContainerSeries;
private void UpdateTooltip(Tooltip tooltip) private void UpdateTooltip(Tooltip tooltip)
{ {
if (!showTooltip) return; if (!m_ShowTooltip)
{
if (m_ContainerSeries != null)
{
ListPool<Serie>.Release(m_ContainerSeries);
m_ContainerSeries = null;
}
return;
}
var anyTrigger = false; var anyTrigger = false;
for (int i = chart.series.Count - 1; i >= 0; i--) for (int i = chart.series.Count - 1; i >= 0; i--)
{ {
@@ -141,24 +170,33 @@ namespace XCharts.Runtime
} }
} }
} }
if (containerSeries != null) if (!anyTrigger && m_ContainerSeries == null)
{ {
if (!SetSerieTooltip(tooltip, containerSeries)) m_ContainerSeries = ListPool<Serie>.Get();
showTooltip = false; UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries);
}
if (m_ContainerSeries != null)
{
if (!SetSerieTooltip(tooltip, m_ContainerSeries))
m_ShowTooltip = false;
else else
anyTrigger = true; anyTrigger = true;
ListPool<Serie>.Release(containerSeries); ListPool<Serie>.Release(m_ContainerSeries);
m_ContainerSeries = null;
} }
if (!showTooltip || !anyTrigger) if (!m_ShowTooltip || !anyTrigger)
{ {
if (tooltip.context.type == Tooltip.Type.Corss && m_PointerContainer != null && m_PointerContainer.IsPointerEnter()) if (tooltip.context.type == Tooltip.Type.Cross && m_PointerContainer != null && m_PointerContainer.IsPointerEnter())
{ {
m_ShowTooltip = true;
tooltip.SetActive(true); tooltip.SetActive(true);
tooltip.SetContentActive(false); tooltip.SetContentActive(false);
} }
else else
{ {
m_ShowTooltip = false;
tooltip.SetActive(false); tooltip.SetActive(false);
chart.pointerClickEventData = null;
} }
} }
else else
@@ -173,7 +211,7 @@ namespace XCharts.Runtime
if (tooltip.context.type == Tooltip.Type.None) return; if (tooltip.context.type == Tooltip.Type.None) return;
if (m_PointerContainer != null) if (m_PointerContainer != null)
{ {
if (tooltip.context.type == Tooltip.Type.Corss) if (tooltip.context.type == Tooltip.Type.Cross)
{ {
if (m_PointerContainer is GridCoord) if (m_PointerContainer is GridCoord)
{ {
@@ -217,14 +255,15 @@ namespace XCharts.Runtime
{ {
if (label == null) return; if (label == null) return;
if (double.IsNaN(axis.context.pointerValue)) return; if (double.IsNaN(axis.context.pointerValue)) return;
label.SetActive(true); label.SetActive(true, true);
label.SetTextActive(true); label.SetTextActive(true);
label.SetPosition(axis.context.pointerLabelPosition + axis.indicatorLabel.offset); label.SetPosition(axis.context.pointerLabelPosition + axis.indicatorLabel.offset);
if (axis.IsCategory()) if (axis.IsCategory())
{ {
var index = (int)axis.context.pointerValue; var index = (int)axis.context.pointerValue;
var category = axis.GetData(index); var dataZoom = chart.GetDataZoomOfAxis(axis);
var category = axis.GetData(index, dataZoom);
label.SetText(axis.indicatorLabel.GetFormatterContent(index, category)); label.SetText(axis.indicatorLabel.GetFormatterContent(index, category));
} }
else if (axis.IsTime()) else if (axis.IsTime())
@@ -275,20 +314,26 @@ namespace XCharts.Runtime
serie.context.tooltipTrigger : tooltip.trigger; serie.context.tooltipTrigger : tooltip.trigger;
} }
var isTriggerAxis = tooltip.IsTriggerAxis(); var isTriggerAxis = tooltip.IsTriggerAxis();
var inchart = true;
if (container is GridCoord) if (container is GridCoord)
{ {
var xAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex); var xAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
var yAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex); var yAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
UpdateAxisPointerDataIndex(serie, xAxis, yAxis, container as GridCoord, isTriggerAxis); inchart = UpdateAxisPointerDataIndex(serie, xAxis, yAxis, container as GridCoord, isTriggerAxis);
} }
else if (container is PolarCoord) else if (container is PolarCoord)
{ {
var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index); var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index);
tooltip.context.angle = (float)m_AngleAxis.context.pointerValue; tooltip.context.angle = (float)m_AngleAxis.context.pointerValue;
} }
list.Add(serie); if (inchart)
if (!isTriggerAxis) {
chart.RefreshTopPainter(); list.Add(serie);
if (!isTriggerAxis)
{
chart.RefreshTopPainter();
}
}
} }
} }
m_PointerContainer = container; m_PointerContainer = container;
@@ -297,10 +342,11 @@ namespace XCharts.Runtime
} }
} }
private void UpdateAxisPointerDataIndex(Serie serie, XAxis xAxis, YAxis yAxis, GridCoord grid, bool isTriggerAxis) private bool UpdateAxisPointerDataIndex(Serie serie, XAxis xAxis, YAxis yAxis, GridCoord grid, bool isTriggerAxis)
{ {
serie.context.pointerAxisDataIndexs.Clear(); serie.context.pointerAxisDataIndexs.Clear();
if (xAxis == null || yAxis == null) return; if (xAxis == null || yAxis == null) return false;
var flag = true;
if (serie is Heatmap) if (serie is Heatmap)
{ {
GetSerieDataByXYAxis(serie, xAxis, yAxis); GetSerieDataByXYAxis(serie, xAxis, yAxis);
@@ -313,7 +359,7 @@ namespace XCharts.Runtime
serie.context.pointerEnter = true; serie.context.pointerEnter = true;
serie.context.pointerAxisDataIndexs.Add(index); serie.context.pointerAxisDataIndexs.Add(index);
serie.context.pointerItemDataIndex = index; serie.context.pointerItemDataIndex = index;
yAxis.context.axisTooltipValue = yAxis.context.pointerValue; yAxis.context.axisTooltipValue = index;
} }
} }
else if (yAxis.IsTime()) else if (yAxis.IsTime())
@@ -329,20 +375,45 @@ namespace XCharts.Runtime
if (isTriggerAxis) if (isTriggerAxis)
{ {
var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue; var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue;
if (chart.isTriggerOnClick)
{
if (serie.insertDataToHead)
index = index + (serie.context.totalDataIndex - serie.context.clickTotalDataIndex);
else if (serie.context.totalDataIndex >= serie.dataCount)
index = index - (serie.context.totalDataIndex - serie.context.clickTotalDataIndex);
if (index < 0 || index >= serie.dataCount)
{
index = -1;
flag = false;
}
}
if (component.context.xAxisClickIndex != index)
{
component.context.xAxisClickIndex = index;
if (component.onClickIndex != null)
{
component.onClickIndex(index);
}
}
serie.context.pointerEnter = true; serie.context.pointerEnter = true;
serie.context.pointerAxisDataIndexs.Add(index); serie.context.pointerAxisDataIndexs.Add(index);
serie.context.pointerItemDataIndex = index; serie.context.pointerItemDataIndex = index;
xAxis.context.axisTooltipValue = xAxis.context.pointerValue; xAxis.context.axisTooltipValue = index;
} }
} }
else else
{ {
serie.context.pointerEnter = true;
if (isTriggerAxis) if (isTriggerAxis)
{
serie.context.pointerEnter = true;
GetSerieDataIndexByAxis(serie, xAxis, grid); GetSerieDataIndexByAxis(serie, xAxis, grid);
}
else else
{
GetSerieDataIndexByItem(serie, xAxis, grid); GetSerieDataIndexByItem(serie, xAxis, grid);
}
} }
return flag;
} }
private void GetSerieDataByXYAxis(Serie serie, Axis xAxis, Axis yAxis) private void GetSerieDataByXYAxis(Serie serie, Axis xAxis, Axis yAxis)
@@ -447,7 +518,7 @@ namespace XCharts.Runtime
{ {
axis.context.axisTooltipValue = serie.GetSerieData(serie.context.pointerItemDataIndex).GetData(dimension); axis.context.axisTooltipValue = serie.GetSerieData(serie.context.pointerItemDataIndex).GetData(dimension);
} }
else if (component.type == Tooltip.Type.Corss) else if (component.type == Tooltip.Type.Cross)
{ {
axis.context.axisTooltipValue = axis.context.pointerValue; axis.context.axisTooltipValue = axis.context.pointerValue;
} }
@@ -465,7 +536,7 @@ namespace XCharts.Runtime
if (tooltip.context.trigger == Tooltip.Trigger.None) return false; if (tooltip.context.trigger == Tooltip.Trigger.None) return false;
tooltip.context.data.param.Clear(); tooltip.context.data.param.Clear();
tooltip.context.data.title = serie.serieName; tooltip.context.data.title = serie.serieName;
tooltip.context.pointer = chart.pointerPos; tooltip.context.pointer = GetTooltipPointerPos();
serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null, serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null,
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.ignoreDataDefaultContent, tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.ignoreDataDefaultContent,
@@ -473,12 +544,20 @@ namespace XCharts.Runtime
ref tooltip.context.data.title); ref tooltip.context.data.title);
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart); TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
tooltip.SetActive(true); tooltip.SetActive(m_ShowTooltip);
tooltip.view.Refresh(); tooltip.view.Refresh();
TooltipHelper.LimitInRect(tooltip, chart.chartRect); TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
return true; return true;
} }
private Vector2 GetTooltipPointerPos()
{
if (chart.isTriggerOnClick && chart.isPointerClick)
return chart.clickPos;
else
return chart.pointerPos;
}
private bool SetSerieTooltip(Tooltip tooltip, List<Serie> series) private bool SetSerieTooltip(Tooltip tooltip, List<Serie> series)
{ {
if (tooltip.context.trigger == Tooltip.Trigger.None) if (tooltip.context.trigger == Tooltip.Trigger.None)
@@ -490,13 +569,15 @@ namespace XCharts.Runtime
string category = null; string category = null;
var showCategory = false; var showCategory = false;
var isTriggerByAxis = false; var isTriggerByAxis = false;
var isTriggerByItem = false; var isTriggerByItem = tooltip.context.trigger == Tooltip.Trigger.Item;
var dataIndex = -1; var dataIndex = -1;
var timestamp = -1;
double axisRange = 0;
tooltip.context.data.param.Clear(); tooltip.context.data.param.Clear();
tooltip.context.pointer = chart.pointerPos; tooltip.context.pointer = GetTooltipPointerPos();
if (m_PointerContainer is GridCoord) if (m_PointerContainer is GridCoord)
{ {
GetAxisCategory(m_PointerContainer.index, ref dataIndex, ref category); GetAxisCategory(m_PointerContainer.index, ref dataIndex, ref category, ref timestamp, ref axisRange);
if (tooltip.context.trigger == Tooltip.Trigger.Axis) if (tooltip.context.trigger == Tooltip.Trigger.Axis)
{ {
isTriggerByAxis = true; isTriggerByAxis = true;
@@ -506,7 +587,9 @@ namespace XCharts.Runtime
tooltip.context.data.title = series[0].serieName; tooltip.context.data.title = series[0].serieName;
} }
else else
{
tooltip.context.data.title = category; tooltip.context.data.title = category;
}
} }
else if (tooltip.context.trigger == Tooltip.Trigger.Item) else if (tooltip.context.trigger == Tooltip.Trigger.Item)
{ {
@@ -515,46 +598,69 @@ namespace XCharts.Runtime
} }
} }
var triggerSerieCount = 0;
for (int i = 0; i < series.Count; i++) for (int i = 0; i < series.Count; i++)
{ {
var serie = series[i]; var serie = series[i];
if (!serie.show) continue; if (!serie.show) continue;
if (isTriggerByItem && serie.context.pointerItemDataIndex < 0) continue; if (isTriggerByItem && serie.context.pointerItemDataIndex < 0) continue;
triggerSerieCount++;
serie.context.isTriggerByAxis = isTriggerByAxis; serie.context.isTriggerByAxis = isTriggerByAxis;
if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0) if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0)
serie.context.pointerItemDataIndex = dataIndex; serie.context.pointerItemDataIndex = dataIndex;
if (timestamp >= 0)
{
showCategory = false;
var serieData = serie.GetSerieData(serie.context.pointerItemDataIndex);
if (serieData != null)
{
tooltip.context.data.title = DateTimeUtil.GetDefaultDateTimeString((int)serieData.GetData(0), axisRange);
}
}
serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category, serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category,
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter,
tooltip.ignoreDataDefaultContent, tooltip.ignoreDataDefaultContent,
ref tooltip.context.data.param, ref tooltip.context.data.param,
ref tooltip.context.data.title); ref tooltip.context.data.title);
} }
if (triggerSerieCount <= 0)
{
return false;
}
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart); TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
if (tooltip.context.data.param.Count > 0 || !string.IsNullOrEmpty(tooltip.context.data.title)) if (tooltip.context.data.param.Count > 0 || !string.IsNullOrEmpty(tooltip.context.data.title))
{ {
tooltip.SetActive(true); tooltip.SetActive(m_ShowTooltip);
if (tooltip.view != null) if (tooltip.view != null)
tooltip.view.Refresh(); tooltip.view.Refresh();
TooltipHelper.LimitInRect(tooltip, chart.chartRect); TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
return true; return true;
} }
return false; return false;
} }
private bool GetAxisCategory(int gridIndex, ref int dataIndex, ref string category) private bool GetAxisCategory(int gridIndex, ref int dataIndex, ref string category, ref int timestamp, ref double axisRange)
{ {
foreach (var component in chart.components) foreach (var component in chart.components)
{ {
if (component is Axis) if (component is Axis)
{ {
var axis = component as Axis; var axis = component as Axis;
if (axis.gridIndex == gridIndex && axis.IsCategory()) if (axis.gridIndex == gridIndex)
{ {
dataIndex = double.IsNaN(axis.context.pointerValue) if (axis.IsCategory())
? axis.context.dataZoomStartIndex {
: axis.context.dataZoomStartIndex + (int)axis.context.pointerValue; dataIndex = double.IsNaN(axis.context.pointerValue)
category = axis.GetData(dataIndex); ? axis.context.dataZoomStartIndex
return true; : (int)axis.context.axisTooltipValue;
category = axis.GetData(dataIndex);
return true;
}
else if (axis.IsTime())
{
timestamp = (int)axis.context.pointerValue;
axisRange = axis.context.minMaxRange;
}
} }
} }
} }
@@ -613,7 +719,7 @@ namespace XCharts.Runtime
float splitWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, dataCount, dataZoom); float splitWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, dataCount, dataZoom);
switch (tooltip.context.type) switch (tooltip.context.type)
{ {
case Tooltip.Type.Corss: case Tooltip.Type.Cross:
case Tooltip.Type.Line: case Tooltip.Type.Line:
float pX = grid.context.x; float pX = grid.context.x;
pX += xAxis.IsCategory() ? pX += xAxis.IsCategory() ?
@@ -625,7 +731,7 @@ namespace XCharts.Runtime
Vector2 ep = new Vector2(pX, grid.context.y + grid.context.height); Vector2 ep = new Vector2(pX, grid.context.y + grid.context.height);
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme.tooltip.lineColor); var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme.tooltip.lineColor);
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor); ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
if (tooltip.context.type == Tooltip.Type.Corss) if (tooltip.context.type == Tooltip.Type.Cross)
{ {
sp = new Vector2(grid.context.x, chart.pointerPos.y); sp = new Vector2(grid.context.x, chart.pointerPos.y);
ep = new Vector2(grid.context.x + grid.context.width, chart.pointerPos.y); ep = new Vector2(grid.context.x + grid.context.width, chart.pointerPos.y);
@@ -679,7 +785,7 @@ namespace XCharts.Runtime
float splitWidth = AxisHelper.GetDataWidth(yAxis, grid.context.height, dataCount, dataZoom); float splitWidth = AxisHelper.GetDataWidth(yAxis, grid.context.height, dataCount, dataZoom);
switch (tooltip.context.type) switch (tooltip.context.type)
{ {
case Tooltip.Type.Corss: case Tooltip.Type.Cross:
case Tooltip.Type.Line: case Tooltip.Type.Line:
float pY = (float)(grid.context.y + yAxis.context.pointerValue * splitWidth + float pY = (float)(grid.context.y + yAxis.context.pointerValue * splitWidth +
(yAxis.boundaryGap ? splitWidth / 2 : 0)); (yAxis.boundaryGap ? splitWidth / 2 : 0));
@@ -689,7 +795,7 @@ namespace XCharts.Runtime
Vector2 ep = new Vector2(grid.context.x + grid.context.width, pY); Vector2 ep = new Vector2(grid.context.x + grid.context.width, pY);
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme.tooltip.lineColor); var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme.tooltip.lineColor);
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor); ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
if (tooltip.context.type == Tooltip.Type.Corss) if (tooltip.context.type == Tooltip.Type.Cross)
{ {
sp = new Vector2(chart.pointerPos.x, grid.context.y); sp = new Vector2(chart.pointerPos.x, grid.context.y);
ep = new Vector2(chart.pointerPos.x, grid.context.y + grid.context.height); ep = new Vector2(chart.pointerPos.x, grid.context.y + grid.context.height);
@@ -734,7 +840,7 @@ namespace XCharts.Runtime
switch (tooltip.context.type) switch (tooltip.context.type)
{ {
case Tooltip.Type.Corss: case Tooltip.Type.Cross:
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor); ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
var dist = Vector2.Distance(chart.pointerPos, cenPos); var dist = Vector2.Distance(chart.pointerPos, cenPos);
if (dist > radius) dist = radius; if (dist > radius) dist = radius;

View File

@@ -44,7 +44,8 @@ namespace XCharts.Runtime
param.serieData.name, param.serieData.name,
param.color, param.color,
param.serieData, param.serieData,
chart); chart,
param.serieIndex);
foreach (var item in content.Split('|')) foreach (var item in content.Split('|'))
{ {
param.columns.Add(item); param.columns.Add(item);
@@ -58,7 +59,7 @@ namespace XCharts.Runtime
return "-".Equals(itemFormatter) ||"{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase); return "-".Equals(itemFormatter) ||"{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
} }
public static void LimitInRect(Tooltip tooltip, Rect chartRect) public static void LimitInRect(BaseChart chart, Tooltip tooltip, Rect chartRect)
{ {
if (tooltip.view == null) if (tooltip.view == null)
return; return;
@@ -78,7 +79,55 @@ namespace XCharts.Runtime
} }
if (pos.y > chartRect.y + chartRect.height) if (pos.y > chartRect.y + chartRect.height)
pos.y = chartRect.y + chartRect.height; pos.y = chartRect.y + chartRect.height;
tooltip.UpdateContentPos(pos, chartRect.width / 2, chartRect.height / 2); var screenGap = 10;
var screenPos = chart.LocalPointToScreenPoint(pos);
if (screenPos.x < screenGap)
pos.x += Mathf.Abs(screenPos.x) + screenGap;
if (screenPos.x + tooltip.context.width > Screen.width - screenGap)
pos.x -= Mathf.Abs(screenPos.x + tooltip.context.width - Screen.width) + screenGap;
if (screenPos.y < tooltip.context.height + screenGap)
pos.y += Mathf.Abs(screenPos.y - tooltip.context.height) + screenGap;
if (screenPos.y > Screen.height - screenGap)
pos.y -= Mathf.Abs(screenPos.y - Screen.height) + screenGap;
UpdateContentPos(tooltip, pos, chartRect);
}
/// <summary>
/// 更新文本框位置
/// </summary>
/// <param name="pos"></param>
private static void UpdateContentPos(Tooltip tooltip, Vector2 pos, Rect chartRect)
{
if (tooltip.view != null)
{
var width = chartRect.width;
var height = chartRect.height;
switch (tooltip.position)
{
case Tooltip.Position.Auto:
#if UNITY_ANDROID || UNITY_IOS
if (tooltip.fixedY == 0) pos.y = chartRect.x + ChartHelper.GetActualValue(0.7f, height);
else pos.y = chartRect.y + ChartHelper.GetActualValue(tooltip.fixedY, height);
#endif
break;
case Tooltip.Position.Custom:
pos = new Vector2(chartRect.x, chartRect.y);
pos.x += ChartHelper.GetActualValue(tooltip.fixedX, width);
pos.y += ChartHelper.GetActualValue(tooltip.fixedY, height);
break;
case Tooltip.Position.FixedX:
pos = new Vector2(chartRect.x, pos.y);
pos.x += ChartHelper.GetActualValue(tooltip.fixedX, width);
break;
case Tooltip.Position.FixedY:
pos = new Vector2(pos.x, chartRect.y);
pos.y += ChartHelper.GetActualValue(tooltip.fixedY, height);
break;
}
tooltip.view.UpdatePosition(pos);
}
} }
public static string GetItemNumericFormatter(Tooltip tooltip, Serie serie, SerieData serieData) public static string GetItemNumericFormatter(Tooltip tooltip, Serie serie, SerieData serieData)

View File

@@ -241,6 +241,7 @@ namespace XCharts.Runtime
view.title = ChartHelper.AddChartLabel("title", view.gameObject.transform, tooltip.titleLabelStyle, theme.tooltip, view.title = ChartHelper.AddChartLabel("title", view.gameObject.transform, tooltip.titleLabelStyle, theme.tooltip,
"", Color.clear, TextAnchor.MiddleLeft); "", Color.clear, TextAnchor.MiddleLeft);
view.title.gameObject.SetActive(true);
var item = CreateViewItem(0, view.gameObject.transform, tooltip, theme.tooltip); var item = CreateViewItem(0, view.gameObject.transform, tooltip, theme.tooltip);
view.m_Items.Add(item); view.m_Items.Add(item);

View File

@@ -386,8 +386,8 @@ namespace XCharts.Runtime
} }
} }
public float runtimeRangeMinHeight { get { return (float) ((rangeMin - min) / (max - min) * itemHeight); } } public float runtimeRangeMinHeight { get { return (float)((rangeMin - min) / (max - min) * itemHeight); } }
public float runtimeRangeMaxHeight { get { return (float) ((rangeMax - min) / (max - min) * itemHeight); } } public float runtimeRangeMaxHeight { get { return (float)((rangeMax - min) / (max - min) * itemHeight); } }
public void AddColors(List<Color32> colors) public void AddColors(List<Color32> colors)
{ {
@@ -413,6 +413,25 @@ namespace XCharts.Runtime
} }
} }
public Color32 GetColor(double xValue, double yValue, double zValue, byte alpha = 255)
{
Color32 color;
if (m_Dimension == 0)
{
color = GetColor(xValue);
}
else if (m_Dimension == 1)
{
color = GetColor(yValue);
}
else
{
color = GetColor(zValue);
}
color.a = alpha;
return color;
}
public Color32 GetColor(double value) public Color32 GetColor(double value)
{ {
int index = GetIndex(value); int index = GetIndex(value);
@@ -437,7 +456,7 @@ namespace XCharts.Runtime
if (index == splitNumber - 1) if (index == splitNumber - 1)
return m_InRange[index].color; return m_InRange[index].color;
else else
return Color32.Lerp(m_InRange[index].color, m_InRange[index + 1].color, (float) rate); return Color32.Lerp(m_InRange[index].color, m_InRange[index + 1].color, (float)rate);
} }
} }

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 14f9081aa22ba4bcb9cdbfbb95c7221e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,270 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using XUGL;
namespace XCharts.Runtime
{
/// <summary>
/// View control component in 3D coordinate system.
/// ||3D视角控制组件。
/// </summary>
[Since("v3.11.0")]
[Serializable]
public class ViewControl : ChildComponent
{
[SerializeField][Range(-90, 180)] private float m_Alpha = 90f;
[SerializeField][Range(-90, 90)] private float m_Beta = 55f;
/// <summary>
/// The angle of the view in the x-z plane.
/// ||视角在x-z平面的角度。
/// </summary>
public float alpha
{
get { return m_Alpha; }
set { if (PropertyUtil.SetStruct(ref m_Alpha, value)) SetVerticesDirty(); }
}
/// <summary>
/// The angle of the view in the y-z plane.
/// ||视角在y-z平面的角度。
/// </summary>
public float beta
{
get { return m_Beta; }
set { if (PropertyUtil.SetStruct(ref m_Beta, value)) SetVerticesDirty(); }
}
}
/// <summary>
/// Grid component.
/// ||Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart can be drawn in grid.
/// ||3D网格组件。
/// 3D直角坐标系内绘图网格。可以在网格上绘制3D折线图3D柱状图3D散点图。
/// </summary>
[Serializable]
[ComponentHandler(typeof(GridCoord3DHandler), true)]
public class GridCoord3D : CoordSystem, IUpdateRuntimeData, ISerieContainer
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Left = 0.15f;
[SerializeField] private float m_Right = 0.2f;
[SerializeField] private float m_Top = 0.3f;
[SerializeField] private float m_Bottom = 0.15f;
[SerializeField] private bool m_ShowBorder = false;
[SerializeField] private float m_BoxWidth = 0.55f;
[SerializeField] private float m_BoxHeight = 0.4f;
[SerializeField] private float m_BoxDepth = 0.2f;
[SerializeField] private bool m_XYExchanged = false;
[SerializeField] private ViewControl m_ViewControl = new ViewControl();
public GridCoord3DContext context = new GridCoord3DContext();
/// <summary>
/// Whether to show the grid in rectangular coordinate.
/// ||是否显示直角坐标系网格。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between grid component and the left side of the container.
/// ||grid 组件离容器左侧的距离。
/// </summary>
public float left
{
get { return m_Left; }
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the right side of the container.
/// ||grid 组件离容器右侧的距离。
/// </summary>
public float right
{
get { return m_Right; }
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the top side of the container.
/// ||grid 组件离容器上侧的距离。
/// </summary>
public float top
{
get { return m_Top; }
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the bottom side of the container.
/// ||grid 组件离容器下侧的距离。
/// </summary>
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
}
/// <summary>
/// Whether to show the grid border.
/// ||是否显示网格边框。
/// </summary>
public bool showBorder
{
get { return m_ShowBorder; }
set { if (PropertyUtil.SetStruct(ref m_ShowBorder, value)) SetVerticesDirty(); }
}
/// <summary>
/// The width of the box in the coordinate system.
/// ||坐标系的宽度。
/// </summary>
public float boxWidth
{
get { return m_BoxWidth; }
set { if (PropertyUtil.SetStruct(ref m_BoxWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of the box in the coordinate system.
/// ||坐标系的高度。
/// </summary>
public float boxHeight
{
get { return m_BoxHeight; }
set { if (PropertyUtil.SetStruct(ref m_BoxHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// The depth of the box in the coordinate system.
/// ||坐标系的深度。
/// </summary>
public float boxDepth
{
get { return m_BoxDepth; }
set { if (PropertyUtil.SetStruct(ref m_BoxDepth, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to exchange the x and y axes.
/// ||是否交换x和y轴。
/// </summary>
public bool xyExchanged
{
get { return m_XYExchanged; }
set { if (PropertyUtil.SetStruct(ref m_XYExchanged, value)) SetVerticesDirty(); }
}
/// <summary>
/// View control component in 3D coordinate system.
/// ||3D视角控制组件。
/// </summary>
public ViewControl viewControl
{
get { return m_ViewControl; }
//set { if (PropertyUtil.SetClass(ref m_ViewControl, value)) SetVerticesDirty(); }
}
public void UpdateRuntimeData(BaseChart chart)
{
var chartX = chart.chartX;
var chartY = chart.chartY;
var chartWidth = chart.chartWidth;
var chartHeight = chart.chartHeight;
var actualLeft = left <= 1 ? left * chartWidth : left;
var actualBottom = bottom <= 1 ? bottom * chartHeight : bottom;
var actualBoxWidth = m_BoxWidth <= 1 ? m_BoxWidth * chartWidth : m_BoxWidth;
var actualBoxHeight = m_BoxHeight <= 1 ? m_BoxHeight * chartHeight : m_BoxHeight;
var actualBoxDepth = m_BoxDepth <= 1 ? m_BoxDepth * chartWidth : m_BoxDepth;
context.x = chartX + actualLeft;
context.y = chartY + actualBottom;
context.pointA.x = context.x;
context.pointA.y = context.y;
var angle = m_ViewControl.alpha * Mathf.Deg2Rad;
context.pointD.x = context.x + actualBoxWidth * Mathf.Sin(angle);
context.pointD.y = context.y - actualBoxWidth * Mathf.Cos(angle);
angle = (90 - m_ViewControl.beta) * Mathf.Deg2Rad;
context.pointB.x = context.x + actualBoxDepth * Mathf.Cos(angle);
context.pointB.y = context.y + actualBoxDepth * Mathf.Sin(angle);
context.pointC = context.pointB + (context.pointD - context.pointA);
context.pointE.x = context.pointA.x;
context.pointE.y = context.pointA.y + actualBoxHeight;
var diff = context.pointE - context.pointA;
context.pointF = context.pointB + diff;
context.pointG = context.pointC + diff;
context.pointH = context.pointD + diff;
var minX = Mathf.Min(context.pointA.x, context.pointB.x, context.pointC.x, context.pointD.x, context.pointE.x, context.pointF.x, context.pointG.x, context.pointH.x);
var minY = Mathf.Min(context.pointA.y, context.pointB.y, context.pointC.y, context.pointD.y, context.pointE.y, context.pointF.y, context.pointG.y, context.pointH.y);
var maxX = Mathf.Max(context.pointA.x, context.pointB.x, context.pointC.x, context.pointD.x, context.pointE.x, context.pointF.x, context.pointG.x, context.pointH.x);
var maxY = Mathf.Max(context.pointA.y, context.pointB.y, context.pointC.y, context.pointD.y, context.pointE.y, context.pointF.y, context.pointG.y, context.pointH.y);
context.maxRect.x = minX;
context.maxRect.y = minY;
context.maxRect.width = maxX - minX;
context.maxRect.height = maxY - minY;
}
/// <summary>
/// The opening of the coordinate system faces to the left.
/// 坐标系开口朝向左边。
/// </summary>
/// <returns></returns>
public bool IsLeft()
{
return context.pointB.x < context.pointA.x;
}
/// <summary>
/// Whether the pointer is in the grid.
/// ||指针是否在网格内。
/// </summary>
/// <returns></returns>
public bool IsPointerEnter()
{
return context.isPointerEnter;
}
/// <summary>
/// Whether the given position is in the grid.
/// ||给定的位置是否在网格内。
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public bool Contains(Vector3 pos)
{
if (!context.maxRect.Contains(pos)) return false;
if (UGLHelper.IsPointInPolygon(pos, context.pointA, context.pointB, context.pointC, context.pointD)) return true;
if (UGLHelper.IsPointInPolygon(pos, context.pointB, context.pointF, context.pointG, context.pointC)) return true;
if (IsLeft())
if (UGLHelper.IsPointInPolygon(pos, context.pointC, context.pointG, context.pointH, context.pointD)) return true;
else
if (UGLHelper.IsPointInPolygon(pos, context.pointA, context.pointE, context.pointF, context.pointB)) return true;
return false;
}
/// <summary>
/// Clamp the position of pos to the grid.
/// ||将位置限制在网格内。
/// </summary>
/// <param name="pos"></param>
public void Clamp(ref Vector3 pos)
{
//TODO:
}
/// <summary>
/// Determines whether a given line segment will not intersect the Grid boundary at all.
/// ||判断给定的线段是否与Grid边界是否完全不会相交。
/// </summary>
/// <param name="sp"></param>
/// <param name="ep"></param>
/// <returns></returns>
public bool NotAnyIntersect(Vector3 sp, Vector3 ep)
{
//TODO:
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95f8c8c3492e54987af59175d94f8761
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using System.Collections.Generic;
using UnityEngine;
namespace XCharts.Runtime
{
public class GridCoord3DContext : MainComponentContext
{
public float x;
public float y;
public Rect maxRect = new Rect(0, 0, 0, 0);
public bool isPointerEnter;
public List<ChartLabel> endLabelList = new List<ChartLabel>();
//public Vector3 position = Vector3.zero;
public Vector3 pointA = Vector3.zero;
public Vector3 pointB = Vector3.zero;
public Vector3 pointC = Vector3.zero;
public Vector3 pointD = Vector3.zero;
public Vector3 pointE = Vector3.zero;
public Vector3 pointF = Vector3.zero;
public Vector3 pointG = Vector3.zero;
public Vector3 pointH = Vector3.zero;
}
}

Some files were not shown because too many files have changed in this diff Show More