Compare commits

...

72 Commits
v3.11.1 ... 2.0

Author SHA1 Message Date
monitor1394
1d2f83169d 修复Pie只有一个数据时设置border后显示异常的问题 (#237) 2022-12-28 18:17:00 +08:00
monitor1394
a7c4e24555 [bug][datazoom] fix datazoom range error (#221) 2022-08-30 08:10:18 +08:00
monitor1394
6fad4fcccc update to Unity2019.4.39f1 2022-08-16 06:54:04 +08:00
monitor1394
95e40c6f1a v2.8.2 2022-08-15 22:12:44 +08:00
monitor1394
8e30a370b5 support tooltip formatter for HeatmapChart 2022-08-15 22:11:36 +08:00
monitor1394
d94e304058 v2.8.2 2022-07-13 21:45:54 +08:00
monitor1394
34dc49004e fix serielabel refresh exception (#215) 2022-07-13 21:45:09 +08:00
monitor1394
61c6d68c4c set tooltip on heighest layer 2022-06-30 13:38:46 +08:00
monitor1394
50a666fecc v2.8.1 2022-05-06 08:20:32 +08:00
monitor1394
626a187758 v2.8.1 2022-05-06 08:16:48 +08:00
monitor1394
dee06f8d6f add delegate callback function for legend 2022-05-03 22:30:51 +08:00
monitor1394
e6eea34a45 fix ring tooltip bug #192 2022-04-21 22:07:30 +08:00
monitor1394
76b8146e53 fix datazoom exception 2022-04-21 22:07:07 +08:00
monitor1394
240eda0be2 v2.8.0 2022-04-10 22:34:04 +08:00
monitor1394
6fa093bc80 add debug info 2022-04-10 22:27:27 +08:00
monitor1394
5884fd99dd Fixed VisualMap not working in some cases 2022-04-09 13:13:02 +08:00
monitor1394
f177799202 Merge pull request #190 from DK-Kermit/patch-1
Update XChartsMgr.cs
2022-04-08 14:23:34 +08:00
Kermit
2d3f5dd51d Update XChartsMgr.cs
修复因XChartsMgr不存在,而创建新对象时导致的死循环问题。
由于Awake会在组件被创建时同步执行一次,而在执行Awake时m_XCharts并没有被赋值,所以导致死循环。
让对象处于关闭状态,添加组件时就不会同步执行Awake方法,而是延迟到下一次开启对象时执行。
在下一次开启对象时,m_XCharts已经被赋值,所以不会导致死循环问题。
死循环发生在Awake时调用XThemeMgr.ReloadThemeList,而ReloadThemeList方法中有调用了实例。
2022-04-08 14:12:15 +08:00
monitor1394
b9ca646e0c Merge pull request #188 from Sterling-zzp/2.0
修复Radar初始化时画线取色错误
2022-04-08 10:48:38 +08:00
Sterling
c157c07b0d 修复Radar初始化时画线取色错误 2022-04-08 09:37:44 +08:00
monitor1394
82d0788905 Fixed axis precision issue #184 2022-03-24 08:32:27 +08:00
monitor1394
a7ac0277a7 2.7.0 2022-03-20 19:18:28 +08:00
monitor1394
3f36c27384 update doc link 2022-03-18 13:12:01 +08:00
monitor1394
e4da5e30dc update doc link 2022-03-18 13:08:36 +08:00
monitor1394
bfa68fd037 refactor code to support 3d pie 2022-03-16 07:43:46 +08:00
monitor1394
c002ac071b Fixed chart name repeat check error #183 2022-02-21 21:30:33 +08:00
monitor1394
5c2ea52118 Fixed MissingReferenceException #183 2022-02-17 08:39:55 +08:00
monitor1394
0e25a23ed2 Fixed axis split line bug #181 2022-02-17 08:29:57 +08:00
monitor1394
41a9606bee Fixed {d} formatter error when value is 0 2022-02-09 22:02:16 +08:00
monitor1394
6f6248be77 fixed y axis label onZero does not work 2022-02-08 20:50:47 +08:00
monitor1394
2b5275b15d improve zebra bar chart 2022-01-06 21:47:21 +08:00
monitor1394
ca26fd7c21 Improved zebra bar chart 2022-01-06 21:25:18 +08:00
monitor1394
a2e790561e v2.6.0 2021-12-30 08:19:48 +08:00
monitor1394
f0e94d35b6 fixed emphasis label 2021-12-21 07:01:54 +08:00
monitor1394
76f640f64d Fixed markline label refresh when serie hide #178 2021-12-17 21:27:14 +08:00
monitor1394
9d8dc80494 Improved radarchart 2021-12-10 13:22:00 +08:00
monitor1394
bc1d2ac095 Fixed y axis does not refresh when serie hidden 2021-12-08 20:53:12 +08:00
monitor1394
913c8e1fb2 optimize emptyRect symbol 2021-12-04 14:12:34 +08:00
monitor1394
634bb45dc4 optimize emptyRect symbol 2021-12-04 14:10:28 +08:00
monitor1394
e4827ac262 Added new symbol type: EmptyRect, EmptyTriangle, EmptyDiamond 2021-12-04 08:46:32 +08:00
monitor1394
9ad8a86ffc set symbol empty area color by itemStyle's backgroundColor 2021-12-04 08:26:56 +08:00
monitor1394
23a8ce52d1 Fixed formatter {c} not work #175 2021-12-03 13:08:20 +08:00
monitor1394
38584f618b Fixed axis boundaryGap display error #174 2021-12-03 08:38:00 +08:00
monitor1394
84c47e0d84 inspector show seriedata.selected 2021-12-01 21:35:08 +08:00
monitor1394
7ff1405de5 Fixed serie ignore display error #173 2021-11-30 21:40:18 +08:00
monitor1394
acae09bf28 v2.5.0 2021-11-27 22:12:08 +08:00
monitor1394
b304bd2033 add tooltip delegate function: positionFunction 2021-11-27 22:06:15 +08:00
monitor1394
72c29235d8 Add Time axis warning 2021-11-03 06:48:45 +08:00
monitor1394
5f18f060e3 Optimized SerieData to support tree data 2021-11-02 21:23:01 +08:00
monitor1394
a281028a22 Removed settings for TextMeshPro when package first imported 2021-10-29 07:26:33 +08:00
monitor1394
fe702f3447 Added support for {e} in Tooltip #170 2021-10-29 07:05:30 +08:00
monitor1394
6888ba96e3 增加Treemap扩展支持 2021-10-24 19:23:17 +08:00
monitor1394
b261ef0573 improve radar chart 2021-09-12 15:01:40 +08:00
monitor1394
64d0b047b3 fix pie chart fade out animation #168 2021-09-07 21:44:05 +08:00
monitor1394
5c395ade25 Fixed bug where GaugeChart does not refresh label when changing splitNumber #167 2021-09-06 21:33:44 +08:00
monitor1394
5149376806 v2.4.0 2021-08-31 22:29:49 +08:00
monitor1394
d8f739cbdf v2.4.0 2021-08-31 21:13:59 +08:00
monitor1394
71fb45af9f 优化RingChart的渐变效果 2021-08-31 21:05:02 +08:00
monitor1394
ca63d041b9 修复DataZoom拖动时SerieLabel不刷新的问题 (#165) 2021-08-31 13:41:46 +08:00
monitor1394
8fccfdb5fc Fixed the problem of displaying exceptions after adding data again when DataZoom is enable (#163) 2021-08-26 20:46:50 +08:00
monitor1394
f08ae794ae 修复Theme主题切换无法保持到场景上的问题 (#166) 2021-08-26 20:42:11 +08:00
monitor1394
8efa8145b1 匀速动画优化 2021-08-25 13:41:41 +08:00
monitor1394
e247ad9e71 增加AnimationalongWithLinePath参数设置折线轨迹匀速动画 2021-08-24 07:21:00 +08:00
monitor1394
645506a6fd Added serie's ignoreLineBreak parameter (#164) 2021-08-22 09:26:14 +08:00
monitor1394
c5ef7e765b Fixed axis label may not be updated when datazoom is turn on (#164) 2021-08-22 07:55:16 +08:00
monitor1394
3949018555 Improved Axis's AxisLabel text rotate setting to avoid inconsistency offset in DataZoom (#163) 2021-08-15 22:36:14 +08:00
monitor1394
34b0a97198 Added Legend's textAutoColor to set the text color match with Serie color (#163) 2021-08-15 22:36:06 +08:00
monitor1394
de3e482687 优化BarChart设置Corner时正负柱条圆角对称 2021-08-12 22:16:36 +08:00
monitor1394
8dbbbd7405 优化Serie的数据全为0时Y轴不显示的问题 2021-08-03 08:23:02 +08:00
monitor1394
3316fce8a5 修复Serie开启ignore时被忽略的数据还会参与计算的问题 (#161) 2021-07-29 08:27:23 +08:00
monitor1394
f85f96a560 完善BarChartZebra斑马柱图渐变支持 2021-07-29 08:05:54 +08:00
monitor1394
8f6f5790b6 修复TextMeshPro Enable时找不到XCharts路径的问题 (#160) 2021-07-26 21:28:13 +08:00
60 changed files with 1510 additions and 435 deletions

View File

@@ -1,7 +1,14 @@
# 更新日志
[master](#master)
[branch-2.0](#branch-2.0)
[v2.8.2](#v2.8.2)
[v2.8.1](#v2.8.1)
[v2.8.0](#v2.8.0)
[v2.7.0](#v2.7.0)
[v2.6.0](#v2.6.0)
[v2.5.0](#v2.5.0)
[v2.4.0](#v2.4.0)
[v2.3.0](#v2.3.0)
[v2.2.3](#v2.2.3)
[v2.2.2](#v2.2.2)
@@ -37,7 +44,85 @@
[v0.5.0](#v0.5.0)
[v0.1.0](#v0.1.0)
## master
## branch-2.0
## v2.8.2
* (2022.08.15) Release `v2.8.2` version
* (2022.08.15) Added support for the `HeatmapChart` formatter for custom Tooltip
* (2022.07.13) Fixed `SerieLabel` refresh exception #215
* (2022.06.30) Optimize `Radar` so that the `Tooltip` layer is above `Indicator`
## v2.8.1
* (2022.05.03) Added `onLegendClick`, `onLegendEnter` and `onLegendExit` delegate callbacks for `Legend`
* (2022.04.21) Fixed bug #192 with `RingChart` `Tooltip` exception
* (2022.04.21) Fixed error when setting `minShowNum` in `DataZoom`
## v2.8.0
* (2022.04.10) Added the debug information panel
* (2022.04.09) Fixed `VisualMap` not working in some cases
* (2022.04.08) Optimized `XCharts` initialization #190
* (2022.04.08) Fixed color error #187 in `Radar`
* (2022.03.24) Fixed `Axis` precision issue #184
## v2.7.0
* (2022.03.20) Release `v2.7.0` version
* (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.08) Fixed {d} formatter error when value is 0
* (2022.02.08) Fixed `YAxis` `AxisLabel`'s `onZero` does not work
* (2022.01.06) Improved `Zebra` bar chart
## v2.6.0
* (2021.12.30) Release `v2.6.0` version
* (2021.12.21) Fixed `Emphasis` dont work
* (2021.12.17) Fixed `MarkLine` does not auto refresh label active when serie hide #178
* (2021.12.10) Improved `Radar`'s `AxisLine` and `SplitLine` to be controlled separately
* (2021.12.08) Fixed y axis does not refresh when serie hidden
* (2021.12.04) Added `Symbol` new types: `EmptyRect`, `EmptyTriangle`, `EmptyDiamond`
* (2021.12.04) Added setting symbol empty area color by itemStyle's backgroundColor
* (2021.12.03) Fixed formatter `{c}` not work #175
* (2021.12.03) Fixed axis `boundaryGap` display error in some cases #174
* (2021.11.30) Fixed serie `ignore` display error in some cases #173
## v2.5.0
* (2021.11.27) Release `v2.5.0` version
* (2021.11.27) Added `Tooltip` delegate function `positionFunction`
* (2021.10.29) Removed settings for `TextMeshPro` when package first imported
* (2021.10.29) Added support for `{e}` in `Tooltip` #170
* (2021.09.08) Improved `RadarChart`
* (2021.09.07) Fixed bug where `label` does not disappear at the end of `PieChart` fade animation #168
* (2021.09.06) Fixed bug where `GaugeChart` changing `splitNumber` with code does not refresh `label` #167
## v2.4.0
### Main points
* LineChart support the line of ignore data is disconnected or connected
* LineChart support animation at a constant speed
* Other optimizations and bug fixes
### Details
* (2021.08.31) Release `v2.4.0` version
* (2021.08.31) Optimized the gradient effect of `RingChart`
* (2021.08.31) Fixed bug where `SerieLabel` does not refresh when `DataZoom` is dragged (#165)
* (2021.08.25) Fixed an issue where the theme switch could not be save to the scene (#166)
* (2021.08.24) Added `Animation`'s `alongWithLinePath`
* (2021.08.22) Added `Serie`'s `ignoreLineBreak` (#164)
* (2021.08.22) Fixed `Axis` label may not be updated when `DataZoom` is turn on (#164)
* (2021.08.15) Improved `Axis`'s `AxisLabel` text rotate setting to avoid inconsistency offset in `DataZoom` (#163)
* (2021.08.14) Added `Legend`'s `textAutoColor` to set the text color match with `Serie` color (#163)
* (2021.08.12) Optimize `BarChart` setting `Corner` when the positive and negative columns are fillet symmetric
* (2021.08.03) Fixed y axis not displaying when all data is 0
* (2021.07.29) Fixed ignored data will also participate in calculations when `ignore` is enabled (#161)
* (2021.07.29) Improved `BarChart`'s `Zebra` gradient support
* (2021.07.26) Fixed issue where `XCharts` path could not be found when `TextMeshPro Enable` (#160)
## v2.3.0
@@ -206,7 +291,7 @@ Since the data type is upgraded to `double`, the implicit conversion of `float`
## v1.6.0
* (2020.08.24) Release `v1.6.0` version
* (2020.08.23) Refactor code, replace `Color` with `Color32` for reduce implicit conversion (Can cause custom colors to lose, reference [Q&A 29](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md) to upgrade)
* (2020.08.23) Refactor code, replace `Color` with `Color32` for reduce implicit conversion (Can cause custom colors to lose, reference [Q&A 29](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md) to upgrade)
* (2020.08.15) Optimized `PieChart` drawing performance effect #85
* (2020.08.11) Added `LiquidChart` data change animation#83
* (2020.08.11) Optimized `PieChart` text stack and lead line effects#85

View File

@@ -1,7 +1,14 @@
# 更新日志
[master](#master)
[branch-2.0](#branch-2.0)
[v2.8.2](#v2.8.2)
[v2.8.1](#v2.8.1)
[v2.8.0](#v2.8.0)
[v2.7.0](#v2.7.0)
[v2.6.0](#v2.6.0)
[v2.5.0](#v2.5.0)
[v2.4.0](#v2.4.0)
[v2.3.0](#v2.3.0)
[v2.2.3](#v2.2.3)
[v2.2.2](#v2.2.2)
@@ -37,7 +44,90 @@
[v0.5.0](#v0.5.0)
[v0.1.0](#v0.1.0)
## master
## branch-2.0
* (2022.12.28) 修复`Pie`只有一个数据时设置`border`后显示异常的问题 (#237)
* (2022.08.30) 修复`DataZoom`在某些情况下计算范围不准确的问题 (#221)
## v2.8.2
* (2022.08.15) 发布`v2.8.2`版本
* (2022.08.15) 增加`HeatmapChart`对自定义`Tooltip``formatter`的支持
* (2022.07.13) 修复`SerieLabel`刷新异常的问题 #215
* (2022.06.30) 优化`Radar``Tooltip`的层在`Indicator`之上
## v2.8.1
* (2022.05.06) 发布`v2.8.1`版本
* (2022.05.03) 增加`Legend``onLegendClick`,`onLegendEnter``onLegendExit`委托回调
* (2022.04.21) 修复`RingChart``Tooltip`异常的问题 #192
* (2022.04.21) 修复`DataZoom`设置`minShowNum`时可能会报错的问题
## v2.8.0
* (2022.04.10) 发布`v2.8.0`版本
* (2022.04.10) 增加`Debug`调试信息面板
* (2022.04.09) 修复`VisualMap`某些情况下不生效的问题
* (2022.04.08) 优化`XCharts`初始化 #190
* (2022.04.08) 修复`Radar`的颜色异常问题 #187
* (2022.03.24) 修复`Axis`的精度问题 #184
## v2.7.0
* (2022.03.20) 发布`v2.7.0`版本
* (2022.02.21) 修复`Chart``chartName`重复检测问题 #183
* (2022.02.17) 修复`Axis``SplitLine`可能会显示在坐标系外的问题 #181
* (2022.02.08) 修复数据全0时`{d}`显示不正确的问题
* (2022.02.08) 修复`YAxis``AxisLabel``onZero`参数不生效的问题
* (2022.01.06) 优化`Zebra`斑马柱图
## v2.6.0
* (2021.12.30) 发布`v2.6.0`版本
* (2021.12.21) 修复`Emphasis`不生效的问题
* (2021.12.17) 修复`MarkLine`在运行时`Label`不自动刷新显示隐藏的问题 #178
* (2021.12.10) 完善`Radar``AxisLine``SplitLine`可单独控制
* (2021.12.08) 修复`Serie`隐藏后`Y`轴最大值不刷新的问题
* (2021.12.04) 增加`Symbol`新类型:`EmptyRect`,`EmptyTriangle`,`EmptyDiamond`
* (2021.12.04) 增加`Symbol``Empty`区域颜色可通过`ItemStyle``backgroundColor`设置的支持
* (2021.12.03) 修复`Formatter``{c}`通配符不生效的问题 #175
* (2021.12.03) 修复`Axis``boundaryGap`某些情况下显示的问题 #174
* (2021.11.30) 修复`Serie``ignore`某些情况下绘制异常的问题 #173
## v2.5.0
* (2021.11.27) 发布`v2.5.0`版本
* (2021.11.27) 增加`Tooltip``positionFunction`的坐标设置委托函数
* (2021.10.29) 移除`XCharts`首次导入时`TextMeshPro`的相关设置
* (2021.10.29) 增加`Tooltip`对通配符`{e}`的支持 #170
* (2021.09.08) 完善`RadarChart`
* (2021.09.07) 修复`PieChart`渐出动画结束时`label`没有消失的问题 #168
* (2021.09.06) 修复`GaugeChart`用代码改变`splitNumber`不会刷新`label`的问题 #167
## v2.4.0
### 版本要点
* 折线图支持忽略数据的连线是断开还是连接
* 折线图支持轨迹匀速动画
* 其他优化和问题修复
### 日志详情
* (2021.08.31) 发布`v2.4.0`版本
* (2021.08.31) 优化`RingChart`的渐变效果
* (2021.08.31) 修复`DataZoom`拖动时`SerieLabel`不刷新的问题 (#165)
* (2021.08.25) 修复`Theme`主题切换无法保持到场景上的问题 (#166)
* (2021.08.24) 增加`Animation``alongWithLinePath`参数设置折线轨迹匀速动画
* (2021.08.22) 增加`Serie``ignoreLineBreak`参数设置忽略数据连线是否断开 (#164)
* (2021.08.22) 修复`Axis``DataZoom`开启时`Label`可能不更新的问题 (#164)
* (2021.08.15) 优化`Axis``AxisLabel`文本旋转设置避免在DataZoom开启时偏移不一致 (#163)
* (2021.08.14) 增加`Legend``textAutoColor`设置文本颜色和`Serie`一致 (#163)
* (2021.08.12) 优化`BarChart`设置`Corner`时正负柱条圆角对称
* (2021.08.03) 优化`Serie`的数据全为0时Y轴不显示的问题
* (2021.07.29) 修复`Serie`开启`ignore`时被忽略的数据还会参与计算的问题 (#161)
* (2021.07.29) 完善`BarChart``Zebra`斑马柱图渐变支持
* (2021.07.26) 修复`TextMeshPro Enable`时找不到`XCharts`路径的问题 (#160)
## v2.3.0
@@ -208,7 +298,7 @@
## v1.6.0
* (2020.08.24) 发布`v1.6.0`版本
* (2020.08.23) 重构代码,将与绘制相关的`Color`改为`Color32`,减少隐式转换(更新后会导致自定义的颜色丢失,可参考[问答29](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md)进行升级)
* (2020.08.23) 重构代码,将与绘制相关的`Color`改为`Color32`,减少隐式转换(更新后会导致自定义的颜色丢失,可参考[问答29](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts问答.md)进行升级)
* (2020.08.15) 优化`PieChart`绘制表现效果#85
* (2020.08.11) 增加`LiquidChart`数据变更动画#83
* (2020.08.11) 优化`PieChart`文本堆叠和引线效果#85

View File

@@ -176,6 +176,9 @@
* `ceilRate`最大最小值向上取整的倍率。默认为0时自动计算。
* `splitNumber`:分割段数。默认为 `5`
* `isAxisTooltip`是否Tooltip显示轴线上的所有数据。只对Mutiple类型的Radar有效。
* `outRangeColor`:数值超出范围时显示的颜色。
* `connectCenter`:数值是否连线到中心点。
* `lineGradient`:数值线段是否渐变。
* `splitLine`:分割线条 [AxisSplitLine](#AxisSplitLine)。
* `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。
* `indicator`:是否显示指示器。
@@ -187,6 +190,7 @@
* `name`:指示器名称。
* `max`:指示器的最大值,默认为 0 无限制。
* `min`:指示器的最小值,默认为 0 无限制。
* `range`:指示器的正常值范围,当数值超出这个范围时显示`Radar``outRangeColor`颜色。
* `textStyle`:文本样式 [TextStyle](#TextStyle)。
## `TextLimit`
@@ -229,6 +233,7 @@
* `{b}`为当前所指示或`index``0``serie`的数据项`serieData``name`,或者类目值(如折线图的`X`轴)。
* `{c}`为当前所指示或`index``0``serie``y`维(`dimesion``1`)的数值。
* `{d}`为当前所指示或`index``0``serie``y`维(`dimesion``1`)百分比值,注意不带`%`号。
* `{e}`为当前所指示或`index``0``serie`的数据项`serieData``name`
* `{.1}`表示指定`index``1``serie`对应颜色的圆点。
* `{a1}``{b1}``{c1}`中的`1`表示指定`index``1``serie`
* `{c1:2}`表示索引为`1``serie`的当前指示数据项的第`3`个数据一个数据项有多个数据index为`2`表示第`3`个数据)。
@@ -810,6 +815,7 @@ K线图系列。
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒。如果要设置单个数据项的渐出时长,可以用代码定制:`customFadeOutDuration`
* `dataChangeEnable`:是否开启数据变更动画。
* `dataChangeDuration`:数据变更动画时长,单位毫秒。
* `alongWithLinePath`:是否沿着线的轨迹进行匀速动画。
## `AreaStyle`

View File

@@ -152,10 +152,10 @@
## 为什么升级到1_6_0版本后很多自定义颜色丢失了_应该如何升级
1.6.0版本为了减少隐式转换,将所有的绘制相关的`Color`都改为了`Color32`,所以会导致一些自定义的颜色的丢失。影响到的主要组件有:`ItemStyle``LineStyle``AreaStyle``Vessel``VisualMap``AxisSplitArea``AxisSplitLine``GaugeAxis``SerieLabel`等。可以用脚本[UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)进行升级。
1.6.0版本为了减少隐式转换,将所有的绘制相关的`Color`都改为了`Color32`,所以会导致一些自定义的颜色的丢失。影响到的主要组件有:`ItemStyle``LineStyle``AreaStyle``Vessel``VisualMap``AxisSplitArea``AxisSplitLine``GaugeAxis``SerieLabel`等。可以用脚本[UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)进行升级。
升级步骤如下:
1. 备份好你的项目。
2. 先不升级`XCharts`,只下载或拷贝脚本[UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)放到旧项目的`Editor`由于旧版本可能不存在某些新版本才有的图表或者属性配置可能会编译错误需要处理按34步骤处理一下。
2. 先不升级`XCharts`,只下载或拷贝脚本[UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)放到旧项目的`Editor`由于旧版本可能不存在某些新版本才有的图表或者属性配置可能会编译错误需要处理按34步骤处理一下。
3. 若是由`itemStyle.toColor2`引起的编译报错,可将导出地方的`itemStyle.toColor2`改为`Color.clear`;导入的地方注释掉即可。
4. 若是由`LiquidChart`引起的编译报错,将所有涉及`LiquidChart`的地方都注释掉即可。
5. 编译通过后,通过`菜单栏->XCharts->ExportColorConfig`导出旧版本的颜色配置文件(配置文件默认保存到`Assets`下的`color.config`)。

View File

@@ -176,7 +176,10 @@ Radar coordinate conponnet for radar charts.
* `center`: the center of radar chart. The `center[0]` is the x-coordinate, and the `center[1]` is the y-coordinate. When value between 0 and 1 represents a percentage relative to the chart.[default:[0.5f,0.4f]].
* `ceilRate`: The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.[default:0].
* `splitNumber`: Segments of indicator axis.[default:5].
* `splitNumber`: Tooltip displays all the data on the axis.[default:false].
* `isAxisTooltip`: Tooltip displays all the data on the axis.[default:false].
* `outRangeColor`: The color displayed when data out of range.[default:red]
* `connectCenter`: Whether serie data connect to radar center with line.[default:false]
* `lineGradient`: Whether need gradient for data line..[default:true]
* `splitLine`: The split line style of radar [AxisSplitLine](#AxisSplitLine).
* `splitArea`: The split area style of radar [AxisSplitArea](#AxisSplitArea).
* `indicator`: Whether to show indicator.
@@ -190,6 +193,7 @@ Indicator of radar chart, which is used to assign multiple variables(dimensions)
* `name`: The name of indicator.
* `max`: The maximum value of indicator, with default value of 0, but we recommend to set it manually.
* `min`: The minimum value of indicator, with default value of 0.
* `min`: Normal range. When the value is outside this range, the display color is automatically changed.
* `textStyle`: The text style of indicator [TextStyle](#TextStyle).
## `TextLimit`
@@ -233,6 +237,7 @@ Tooltip component.
* `{b}` is the `name` of the `serieData` that is currently indicated or whose `index` is `0`, or a `category` value (such as the X-axis of a line chart).
* `{c}` is the value of a Y-dimension (`dimesion` is 1) from the `serie` that is currently indicated or whose `index` is `0`.
* `{d}` is the percentage value of Y-dimensions (`dimesion` is 1) from the `serie` that is currently indicated or whose `index` is `0`, with no `%` sign.
* `{e}` is the `name` of the `serieData` that is currently indicated or whose `index` is `0`.
* `{.1}` represents a dot from serie corresponding color that specifies `index` as `1`.
* `1` in `{a1}`, `{b1}`, `{c1}` represents a `serie` that specifies an `index` of `1`.
* `{c1:2}` represents the third data from `serie`'s current indication data item indexed to `1` (a data item has multiple data, `index` 2 represents the third data).

View File

@@ -148,10 +148,10 @@ A: Check whether `RemoveData()` and add new `Serie` in the code. If you want to
## Why_are_many_custom_colors_lost_after_upgrading_to_1_6_0_How_should_I_upgrade
A: In version `1.6.0`, in order to reduce implicit conversion, all drawing related `Color` was changed to `Color32`, so some custom colors were lost. The main components affected are: `ItemStyle`, `LineStyle`, `AreaStyle`, `Vessel`, `VisualMap`, `AxisSplitArea`, `AxisSplitLine`, `GaugeAxis`,`SerieLabel`, etc. Can use the script [UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) to upgrade.
A: In version `1.6.0`, in order to reduce implicit conversion, all drawing related `Color` was changed to `Color32`, so some custom colors were lost. The main components affected are: `ItemStyle`, `LineStyle`, `AreaStyle`, `Vessel`, `VisualMap`, `AxisSplitArea`, `AxisSplitLine`, `GaugeAxis`,`SerieLabel`, etc. Can use the script [UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) to upgrade.
The upgrade steps are as follows:
1. Back up the project.
2. Download or copy the script [UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) in the old project `Editor`, Change the `color` field inside to `color.clear` (because some fields may not exist in the old version).
2. Download or copy the script [UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) in the old project `Editor`, Change the `color` field inside to `color.clear` (because some fields may not exist in the old version).
3. After compilation, the old version of color configuration file is exported through `menu bar -> XCharts-> ExportColorConfig` (the configuration file is saved by default to `color.config` under `Assets`).
4. Upgrade `XCharts` to the latest version.
5. The custom color can be restored by importing `color.config` through `menu bar -> XCharts-> ImportColorConfig` (if `color.config` is not under `Assets` of the upgraded project, copy it to this directory).

View File

@@ -137,6 +137,12 @@ namespace XCharts
EditorGUILayout.PropertyField(serializedObject.FindProperty(filed));
}
}
if (XChartsMgr.Instance.IsRepeatChartName(m_Chart, m_ChartName.stringValue))
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.HelpBox("chart name is repeated:" + m_ChartName.stringValue, MessageType.Error);
EditorGUILayout.EndHorizontal();
}
}
BlockEnd();

View File

@@ -28,6 +28,7 @@ namespace XCharts
PropertyField(prop, "m_DataChangeEnable");
PropertyField(prop, "m_DataChangeDuration");
PropertyField(prop, "m_ActualDuration");
PropertyField(prop, "m_AlongWithLinePath");
--EditorGUI.indentLevel;
}
}

View File

@@ -29,6 +29,12 @@ namespace XCharts
EditorGUI.indentLevel++;
PropertyField(prop, isPolar ? "m_PolarIndex" : "m_GridIndex");
PropertyField(prop, "m_Type");
if (type == Axis.AxisType.Time)
{
var chartTypeName = prop.serializedObject.targetObject.GetType().Name;
if (!chartTypeName.Equals("GanttChart"))
EditorGUILayout.HelpBox("The Time axis is currently only supported in GanttChart.", MessageType.Warning);
}
PropertyField(prop, "m_Position");
PropertyField(prop, "m_Offset");
if (type == Axis.AxisType.Log)

View File

@@ -25,6 +25,7 @@ namespace XCharts
PropertyField(prop, "m_ItemHeight");
PropertyField(prop, "m_ItemGap");
PropertyField(prop, "m_ItemAutoColor");
PropertyField(prop, "m_TextAutoColor");
PropertyField(prop, "m_SelectedMode");
PropertyField(prop, "m_Orient");
PropertyField(prop, "m_Location");

View File

@@ -28,6 +28,9 @@ namespace XCharts
PropertyField(prop, "m_SplitNumber");
PropertyField(prop, "m_CeilRate");
PropertyField(prop, "m_IsAxisTooltip");
PropertyField(prop, "m_OutRangeColor");
PropertyField(prop, "m_ConnectCenter");
PropertyField(prop, "m_LineGradient");
PropertyField(prop, "m_AxisLine");
PropertyField(prop, "m_SplitLine");
PropertyField(prop, "m_SplitArea");
@@ -50,6 +53,7 @@ namespace XCharts
PropertyField(prop, "m_Name");
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyTwoFiled(prop, "m_Range");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}

View File

@@ -68,6 +68,7 @@ namespace XCharts
PropertyField(prop, "m_Clip");
PropertyField(prop, "m_Ignore");
PropertyField(prop, "m_IgnoreValue");
PropertyField(prop, "m_IgnoreLineBreak");
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_Large");
PropertyField(prop, "m_LargeThreshold");
@@ -401,6 +402,8 @@ namespace XCharts
{
EditorGUI.indentLevel += 2;
var m_Ignore = serieData.FindPropertyRelative("m_Ignore");
var m_Selected = serieData.FindPropertyRelative("m_Selected");
var m_Id = serieData.FindPropertyRelative("m_Id");
var m_EnableIcon = serieData.FindPropertyRelative("m_EnableIconStyle");
var m_Icon = serieData.FindPropertyRelative("m_IconStyle");
var m_EnableLabel = serieData.FindPropertyRelative("m_EnableLabel");
@@ -413,6 +416,10 @@ namespace XCharts
var m_Symbol = serieData.FindPropertyRelative("m_Symbol");
EditorGUI.PropertyField(drawRect, m_Ignore);
AddHeight(EditorGUI.GetPropertyHeight(m_Ignore));
EditorGUI.PropertyField(drawRect, m_Selected);
AddHeight(EditorGUI.GetPropertyHeight(m_Selected));
EditorGUI.PropertyField(drawRect, m_Id);
AddHeight(EditorGUI.GetPropertyHeight(m_Id));
EditorGUI.PropertyField(drawRect, m_Icon);
ChartEditorHelper.MakeBool(drawRect, m_EnableIcon, 1, "(enable)");
AddHeight(EditorGUI.GetPropertyHeight(m_Icon));

View File

@@ -11,7 +11,7 @@
<br>
</p>
<p align="center">
<a href="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/LICENSE">
<a href="https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/LICENSE">
<img src="https://img.shields.io/github/license/monitor1394/unity-ugui-XCharts">
</a>
<a href="https://github.com/monitor1394/unity-ugui-XCharts/releases">
@@ -45,11 +45,11 @@
A powerful, easy-to-use, configurable charting and data visualization library for Unity. Supporting line, bar, pie, radar, scatter, heatmap, gauge, ring, polar, liquid and other common chart.
[XCharts Homepage](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
[XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-api-EN.md)
[XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
[XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG-EN.md)
[Tutorial - Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
[XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
[XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-api-EN.md)
[XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
[XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/CHANGELOG-EN.md)
[Tutorial - Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
## XCharts 2.0
@@ -78,21 +78,21 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
## Screenshot
![linechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-line.png)
![barchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-bar.png)
![piechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-pie.png)
![radarchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-radar.png)
![scatterchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-scatter.png)
![heatmapchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-heatmap.png)
![gaugechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-gauge.png)
![ringchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-ring.png)
![polarchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-polar.png)
![liquidchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-liquid.png)
![combinations](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-combinations.png)
![linechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-line.png)
![barchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-bar.png)
![piechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-pie.png)
![radarchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-radar.png)
![scatterchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-scatter.png)
![heatmapchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-heatmap.png)
![gaugechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-gauge.png)
![ringchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-ring.png)
![polarchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-polar.png)
![liquidchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-liquid.png)
![combinations](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-combinations.png)
## Cheat Sheet
![cheatsheet](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-cheatsheet.gif)
![cheatsheet](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/screenshot/xcharts-cheatsheet.gif)
`XCharts` consist of components and data. Different components and data can be combined into different types of charts. The component is divided into main component and sub component. The main component contains the sub components.
@@ -179,9 +179,9 @@ The following is the relationship structure of LineChart:
2. In unity menu bar, `Component->XCharts->LineChart`.
3. In `Inspector`,`Add Component->LineChart`.
4. Then a simple line chart is done.
5. In `Inspector` you can adjust the parameters of components, and in `Game` will feedback the adjustment effect in realtime 。the detail of parameters go to see: [XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md).
5. In `Inspector` you can adjust the parameters of components, and in `Game` will feedback the adjustment effect in realtime 。the detail of parameters go to see: [XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-configuration-EN.md).
* See more examples of code dynamic control: [Tutorial - Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md).
* See more examples of code dynamic control: [Tutorial - Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md).
* Enable TextMeshPro:
1. `XCharts -> TextMeshPro Enable` or `Project Setting -> XCharts -> Enable TextMeshPro`
@@ -191,19 +191,19 @@ The following is the relationship structure of LineChart:
## Documents
* [XCharts Homepage](https://github.com/monitor1394/unity-ugui-XCharts)
* [XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
* [XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-api-EN.md)
* [XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
* [XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG-EN.md)
* [XCharts Tutorial: Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
* [XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
* [XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-api-EN.md)
* [XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
* [XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/CHANGELOG-EN.md)
* [XCharts Tutorial: Get start with XCharts in 5 minute](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
## Changelog
[XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG.md)
[XCharts Changelog](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/CHANGELOG.md)
## Licenses
[MIT License](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/LICENSE.md)
[MIT License](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/LICENSE.md)
## Contact

View File

@@ -132,7 +132,21 @@ namespace XCharts
/// 点击饼图区域回调。参数PointerEventDataSerieIndexSerieDataIndex
/// </summary>
public Action<PointerEventData, int, int> onPointerClickPie { set { m_OnPointerClickPie = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerClickPie; } }
/// <summary>
/// the callback function of click legend.
/// 点击图例按钮回调。参数legendIndex, legendName, show
/// </summary>
public Action<int, string, bool> onLegendClick { set { m_OnLegendClick = value; } }
/// <summary>
/// the callback function of enter legend.
/// 鼠标进入图例回调。参数legendIndex, legendName
/// </summary>
public Action<int, string> onLegendEnter { set { m_OnLegendEnter = value; } }
/// <summary>
/// the callback function of exit legend.
/// 鼠标退出图例回调。参数legendIndex, legendName
/// </summary>
public Action<int, string> onLegendExit { set { m_OnLegendExit = value; } }
/// <summary>
/// Redraw chart in next frame.
/// 在下一帧刷新图表。
@@ -543,7 +557,7 @@ namespace XCharts
foreach (var legend in m_Legends)
{
var iconColor = LegendHelper.GetIconColor(this, legendIndex, legendName, active);
var contentColor = LegendHelper.GetContentColor(legend, m_Theme, active);
var contentColor = LegendHelper.GetContentColor(legendIndex, legend, m_Theme, active);
legend.UpdateButtonColor(legendName, iconColor);
legend.UpdateContentColor(legendName, contentColor);
}
@@ -643,6 +657,9 @@ namespace XCharts
{
m_Theme.CopyTheme(theme);
SetAllComponentDirty();
#if UNITY_EDITOR
UnityEditor.EditorUtility.SetDirty(this);
#endif
}
/// <summary>

View File

@@ -88,10 +88,10 @@ namespace XCharts
[SerializeField] protected int m_PolarIndex;
[SerializeField] protected AxisPosition m_Position;
[SerializeField] protected float m_Offset;
[SerializeField] protected float m_Min;
[SerializeField] protected float m_Max;
[SerializeField] protected double m_Min;
[SerializeField] protected double m_Max;
[SerializeField] protected int m_SplitNumber = 5;
[SerializeField] protected float m_Interval = 0;
[SerializeField] protected double m_Interval = 0;
[SerializeField] protected bool m_BoundaryGap = true;
[SerializeField] protected int m_MaxCache = 0;
[SerializeField] protected float m_LogBase = 10;
@@ -180,7 +180,7 @@ namespace XCharts
/// The minimun value of axis.Valid when `minMaxType` is `Custom`
/// 设定的坐标轴刻度最小值当minMaxType为Custom时有效。
/// </summary>
public float min
public double min
{
get { return m_Min; }
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetAllDirty(); }
@@ -189,7 +189,7 @@ namespace XCharts
/// The maximum value of axis.Valid when `minMaxType` is `Custom`
/// 设定的坐标轴刻度最大值当minMaxType为Custom时有效。
/// </summary>
public float max
public double max
{
get { return m_Max; }
set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetAllDirty(); }
@@ -207,7 +207,7 @@ namespace XCharts
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
/// 强制设置坐标轴分割间隔。无法在类目轴中使用。
/// </summary>
public float interval
public double interval
{
get { return m_Interval; }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetAllDirty(); }
@@ -489,6 +489,12 @@ namespace XCharts
return axis;
}
public override void SetComponentDirty()
{
m_NeedUpdateFilterData = true;
base.SetComponentDirty();
}
public void Copy(Axis axis)
{
show = axis.show;
@@ -706,13 +712,13 @@ namespace XCharts
int start = 0, end = 0;
if (dataZoom.runtimeInvert)
{
end = Mathf.CeilToInt(data.Count * dataZoom.end / 100);
end = Mathf.RoundToInt(data.Count * dataZoom.end / 100);
start = end - range;
if (start < 0) start = 0;
}
else
{
start = Mathf.FloorToInt(data.Count * dataZoom.start / 100);
start = Mathf.RoundToInt(data.Count * dataZoom.start / 100);
end = start + range;
if (end > data.Count) end = data.Count;
}
@@ -722,13 +728,15 @@ namespace XCharts
filterEnd = end;
filterMinShow = dataZoom.minShowNum;
m_NeedUpdateFilterData = false;
if (data.Count > 0)
if (data.Count > 0 && filterMinShow < data.Count)
{
if (range < dataZoom.minShowNum)
if (range < filterMinShow)
{
if (dataZoom.minShowNum > data.Count) range = data.Count;
else range = dataZoom.minShowNum;
if (filterMinShow > data.Count) range = data.Count;
else range = filterMinShow;
}
if (range > data.Count - start)
start = data.Count - range;
filterData = data.GetRange(start, range);
}
else

View File

@@ -0,0 +1,154 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.UI;
namespace XCharts
{
[Serializable]
public class DebugInfo
{
private bool m_ShowDebugInfo = false;
private TextStyle m_DebugInfoTextStyle = new TextStyle()
{
fontSize = 18,
backgroundColor = new Color32(32, 32, 32, 170),
color = Color.white
};
private static StringBuilder s_Sb = new StringBuilder();
private static readonly float INTERVAL = 0.2f;
private static readonly float MAXCACHE = 20;
private int m_FrameCount = 0;
private float m_LastTime = 0f;
private float m_LastCheckShowTime = 0f;
private int m_LastRefreshCount = 0;
private BaseChart m_Chart;
private ChartLabel m_Label;
private List<float> m_FpsList = new List<float>();
public float fps { get; private set; }
public float avgFps { get; private set; }
public int refreshCount { get; internal set; }
internal int clickChartCount { get; set; }
public void Init(BaseChart chart)
{
m_Chart = chart;
m_Label = AddDebugInfoObject("debug", chart.transform, m_DebugInfoTextStyle, chart.theme);
}
public void Update()
{
if (clickChartCount >= 3)
{
m_ShowDebugInfo = !m_ShowDebugInfo;
ChartHelper.SetActive(m_Label.gameObject.transform, m_ShowDebugInfo);
clickChartCount = 0;
m_LastCheckShowTime = Time.realtimeSinceStartup;
return;
}
if (Time.realtimeSinceStartup - m_LastCheckShowTime > 0.5f)
{
m_LastCheckShowTime = Time.realtimeSinceStartup;
clickChartCount = 0;
}
if (!m_ShowDebugInfo || m_Label == null)
return;
m_FrameCount++;
if (Time.realtimeSinceStartup - m_LastTime >= INTERVAL)
{
fps = m_FrameCount / (Time.realtimeSinceStartup - m_LastTime);
m_FrameCount = 0;
m_LastTime = Time.realtimeSinceStartup;
if (m_LastRefreshCount == refreshCount)
{
m_LastRefreshCount = 0;
refreshCount = 0;
}
m_LastRefreshCount = refreshCount;
if (m_FpsList.Count > MAXCACHE)
{
m_FpsList.RemoveAt(0);
}
m_FpsList.Add(fps);
avgFps = GetAvg(m_FpsList);
if (m_Label != null)
{
s_Sb.Length = 0;
s_Sb.AppendFormat("v{0}\n", XChartsMgr.version);
s_Sb.AppendFormat("fps : {0:f0} / {1:f0}\n", fps, avgFps);
s_Sb.AppendFormat("draw : {0}\n", refreshCount);
var dataCount = m_Chart.series.GetAllSerieDataCount();
SetValueWithKInfo(s_Sb, "data", dataCount);
var vertCount = 0;
foreach (var serie in m_Chart.series.list)
vertCount += serie.runtimeVertCount;
SetValueWithKInfo(s_Sb, "b-vert", m_Chart.m_BasePainterVertCount);
SetValueWithKInfo(s_Sb, "s-vert", vertCount);
SetValueWithKInfo(s_Sb, "t-vert", m_Chart.m_TopPainterVertCount, false);
m_Label.SetText(s_Sb.ToString());
}
}
}
private static void SetValueWithKInfo(StringBuilder s_Sb, string key, int value, bool newLine = true)
{
if (value >= 1000)
s_Sb.AppendFormat("{0} : {1:f1}k", key, value * 0.001f);
else
s_Sb.AppendFormat("{0} : {1}", key, value);
if (newLine)
s_Sb.Append("\n");
}
private static float GetAvg(List<float> list)
{
var total = 0f;
foreach (var v in list) total += v;
return total / list.Count;
}
private ChartLabel AddDebugInfoObject(string name, Transform parent, TextStyle textStyle,
ChartTheme theme)
{
var anchorMax = new Vector2(0, 1);
var anchorMin = new Vector2(0, 1);
var pivot = new Vector2(0, 1);
var sizeDelta = new Vector2(130, 150);
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
labelGameObject.transform.SetAsLastSibling();
labelGameObject.hideFlags = m_Chart.chartHideFlags;
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);
var image = ChartHelper.GetOrAddComponent<Image>(labelGameObject);
image.color = textStyle.backgroundColor;
var label = new ChartLabel();
label.gameObject = labelGameObject;
label.label = ChartHelper.AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax,
pivot, sizeDelta, textStyle, theme.common);
label.SetAutoSize(true);
label.label.SetActive(true);
label.label.SetAlignment(textStyle.GetAlignment(TextAnchor.UpperLeft));
label.label.SetLocalPosition(new Vector2(3, -3));
label.SetText("30");
label.SetLabelColor(textStyle.color);
return label;
}
}
}

View File

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

View File

@@ -78,6 +78,7 @@ namespace XCharts
[SerializeField] private float m_ItemHeight = 12.0f;
[SerializeField] private float m_ItemGap = 10f;
[SerializeField] private bool m_ItemAutoColor = true;
[SerializeField] private bool m_TextAutoColor = false;
[SerializeField] private string m_Formatter;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private List<string> m_Data = new List<string>();
@@ -176,6 +177,16 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether the legend text matches the color automatically.
/// 图例标记的文本是否自动匹配颜色。
/// [default:false]
/// </summary>
public bool textAutoColor
{
get { return m_TextAutoColor; }
set { if (PropertyUtil.SetStruct(ref m_TextAutoColor, value)) SetComponentDirty(); }
}
/// <summary>
/// Legend content string template formatter. Support for wrapping lines with \n. Template:{name}.
/// 图例内容字符串模版格式器。支持用 \n 换行。
/// 模板变量为图例名称 {name}。

View File

@@ -56,6 +56,7 @@ namespace XCharts
[SerializeField] private string m_Name;
[SerializeField] private double m_Max;
[SerializeField] private double m_Min;
[SerializeField] private double[] m_Range = new double[2] { 0, 0 };
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
/// <summary>
@@ -83,6 +84,24 @@ namespace XCharts
/// 指示器的文本组件。
/// </summary>
public Text text { get; set; }
/// <summary>
/// Normal range. When the value is outside this range, the display color is automatically changed.
/// 正常值范围。当数值不在这个范围时,会自动变更显示颜色。
/// </summary>
public double[] range
{
get { return m_Range; }
set { if (value != null && value.Length == 2) { m_Range = value; } }
}
public bool IsInRange(double value)
{
if (m_Range == null || m_Range.Length < 2) return true;
if (m_Range[0] != 0 || m_Range[1] != 0)
return value >= m_Range[0] && value <= m_Range[1];
else
return true;
}
}
[SerializeField] private bool m_Show;
[SerializeField] private Shape m_Shape;
@@ -97,6 +116,9 @@ namespace XCharts
[SerializeField] private float m_IndicatorGap = 10;
[SerializeField] private int m_CeilRate = 0;
[SerializeField] private bool m_IsAxisTooltip;
[SerializeField] private Color32 m_OutRangeColor = Color.red;
[SerializeField] private bool m_ConnectCenter = false;
[SerializeField] private bool m_LineGradient = true;
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
/// <summary>
/// [default:true]
@@ -214,6 +236,33 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
}
/// <summary>
/// The color displayed when data out of range.
/// 数值超出范围时显示的颜色。
/// </summary>
public Color32 outRangeColor
{
get { return m_OutRangeColor; }
set { if (PropertyUtil.SetStruct(ref m_OutRangeColor, value)) SetAllDirty(); }
}
/// <summary>
/// Whether serie data connect to radar center with line.
/// 数值是否连线到中心点。
/// </summary>
public bool connectCenter
{
get { return m_ConnectCenter; }
set { if (PropertyUtil.SetStruct(ref m_ConnectCenter, value)) SetAllDirty(); }
}
/// <summary>
/// Whether need gradient for data line.
/// 数值线段是否需要渐变。
/// </summary>
public bool lineGradient
{
get { return m_LineGradient; }
set { if (PropertyUtil.SetStruct(ref m_LineGradient, value)) SetAllDirty(); }
}
/// <summary>
/// the indicator list.
/// 指示器列表。
/// </summary>
@@ -276,6 +325,12 @@ namespace XCharts
return true;
}
public bool IsInIndicatorRange(int index, double value)
{
var indicator = GetIndicator(index);
return indicator == null ? true : indicator.IsInRange(value);
}
public double GetIndicatorMin(int index)
{
if (index >= 0 && index < m_IndicatorList.Count)

View File

@@ -327,6 +327,7 @@ namespace XCharts
[SerializeField] private bool m_Clip = false;
[SerializeField] private bool m_Ignore = false;
[SerializeField] private double m_IgnoreValue = 0;
[SerializeField] private bool m_IgnoreLineBreak = false;
[SerializeField] private bool m_ShowAsPositiveNumber = false;
[SerializeField] private bool m_Large = true;
[SerializeField] private int m_LargeThreshold = 200;
@@ -362,6 +363,7 @@ namespace XCharts
[NonSerialized] internal bool m_NeedUpdateFilterData;
[NonSerialized] internal List<SerieData> m_FilterData = new List<SerieData>();
[NonSerialized] internal List<SerieData> m_SortedData = new List<SerieData>();
[NonSerialized] internal List<SerieData> m_RootData = new List<SerieData>();
[NonSerialized] private Dictionary<int, List<Vector3>> m_UpSmoothPoints = new Dictionary<int, List<Vector3>>();
[NonSerialized] private Dictionary<int, List<Vector3>> m_DownSmoothPoints = new Dictionary<int, List<Vector3>>();
[NonSerialized] private List<Vector3> m_DataPoints = new List<Vector3>();
@@ -771,6 +773,15 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
}
/// <summary>
/// 忽略数据时折线是断开还是连接。默认false为连接。
/// </summary>
/// <value></value>
public bool ignoreLineBreak
{
get { return m_IgnoreLineBreak; }
set { if (PropertyUtil.SetStruct(ref m_IgnoreLineBreak, value)) SetVerticesDirty(); }
}
/// <summary>
/// 雷达图类型。
/// </summary>
public RadarType radarType
@@ -1131,12 +1142,12 @@ namespace XCharts
/// The index of serie,start at 0.
/// 系列的索引从0开始。
/// </summary>
public int index { get; internal set; }
public int index { get; set; }
/// <summary>
/// Whether the serie is highlighted.
/// 该系列是否高亮,一般由图例悬停触发。
/// </summary>
public bool highlighted { get; internal set; }
public bool highlighted { get; set; }
/// <summary>
/// the count of data list.
/// 数据项个数。
@@ -1149,27 +1160,27 @@ namespace XCharts
/// <summary>
/// 饼图的中心点位置。
/// </summary>
public Vector3 runtimeCenterPos { get; internal set; }
public Vector3 runtimeCenterPos { get; set; }
/// <summary>
/// 饼图的内径
/// </summary>
public float runtimeInsideRadius { get; internal set; }
public float runtimeInsideRadius { get; set; }
/// <summary>
/// 饼图的外径
/// </summary>
public float runtimeOutsideRadius { get; internal set; }
public float runtimeOutsideRadius { get; set; }
/// <summary>
/// 运行时的最大数据值
/// </summary>
public double runtimeDataMax { get; internal set; }
public double runtimeDataMax { get; set; }
/// <summary>
/// 运行时的最小数据值
/// </summary>
public double runtimeDataMin { get; internal set; }
public double runtimeDataMin { get; set; }
/// <summary>
/// 饼图的数据项之和
/// </summary>
public double runtimePieDataTotal { get; internal set; }
public double runtimePieDataTotal { get; set; }
public float runtimeWaveSpeed { get; internal set; }
public Painter runtimeCanvas { get; internal set; }
public double runtimeCheckValue { get; set; }
@@ -1178,7 +1189,10 @@ namespace XCharts
public float runtimeY { get; internal set; }
public float runtimeWidth { get; internal set; }
public float runtimeHeight { get; internal set; }
public Rect runtimeRect { get; internal set; }
public int runtimeVertCount { get; internal set; }
public List<SerieData> runtimeSortedData { get { return m_SortedData; } }
public List<SerieData> rootData { get { return m_RootData; } }
public bool nameDirty { get { return m_NameDirty; } }
private void SetNameDirty()
@@ -1245,7 +1259,7 @@ namespace XCharts
var max = double.MinValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[1] > max)
if (sdata.show && !IsIgnoreValue(sdata.data[1]) && sdata.data[1] > max)
{
max = sdata.data[1];
}
@@ -1264,7 +1278,7 @@ namespace XCharts
var max = double.MinValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[0] > max)
if (sdata.show && !IsIgnoreValue(sdata.data[0]) && sdata.data[0] > max)
{
max = sdata.data[0];
}
@@ -1283,7 +1297,7 @@ namespace XCharts
var min = double.MaxValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[1] < min)
if (sdata.show && !IsIgnoreValue(sdata.data[1]) && sdata.data[1] < min)
{
min = sdata.data[1];
}
@@ -1302,7 +1316,7 @@ namespace XCharts
var min = double.MaxValue;
foreach (var sdata in data)
{
if (sdata.show && sdata.data[0] < min)
if (sdata.show && !IsIgnoreValue(sdata.data[0]) && sdata.data[0] < min)
{
min = sdata.data[0];
}
@@ -1321,9 +1335,8 @@ namespace XCharts
double total = 0;
foreach (var sdata in data)
{
if (sdata.show)
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
total += sdata.GetCurrData(1, animation.GetUpdateAnimationDuration());
//total += sdata.GetData(1);
}
return total;
}
@@ -1339,7 +1352,7 @@ namespace XCharts
double total = 0;
foreach (var sdata in data)
{
if (sdata.show)
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
total += sdata.data[0];
}
return total;
@@ -1356,6 +1369,7 @@ namespace XCharts
RemoveData(0);
}
m_Data.Clear();
m_NeedUpdateFilterData = true;
SetVerticesDirty();
}
@@ -1389,6 +1403,7 @@ namespace XCharts
m_DownSmoothPoints.Remove(serieData.index);
}
m_Data.RemoveAt(index);
m_NeedUpdateFilterData = true;
}
}
@@ -1417,6 +1432,7 @@ namespace XCharts
{
if (m_InsertDataToHead) m_Data.Insert(0, serieData);
else m_Data.Add(serieData);
m_NeedUpdateFilterData = true;
}
private void CheckDataName(string dataName)
@@ -1517,6 +1533,32 @@ namespace XCharts
}
}
public SerieData AddChildData(SerieData parent, double value, string name = null)
{
var serieData = new SerieData();
serieData.name = name;
serieData.index = m_Data.Count;
serieData.data = new List<double>() { parent.children.Count, value };
serieData.parentIndex = parent.index;
serieData.runtimeParent = parent;
AddSerieDataHeadOrTail(serieData);
parent.children.Add(serieData.index);
parent.runtimeChildren.Add(serieData);
return serieData;
}
public SerieData AddChildData(SerieData parent, List<double> value, string name = null)
{
var serieData = new SerieData();
serieData.name = name;
serieData.index = m_Data.Count;
serieData.data = new List<double>(value);
serieData.parentIndex = parent.index;
serieData.runtimeParent = parent;
AddSerieDataHeadOrTail(serieData);
parent.children.Add(serieData.index);
parent.runtimeChildren.Add(serieData);
return serieData;
}
private void CheckMaxCache()
{
@@ -1633,6 +1675,31 @@ namespace XCharts
return null;
}
public SerieData GetSerieData(string id, DataZoom dataZoom = null)
{
var data = GetDataList(dataZoom);
foreach (var serieData in data)
{
var target = GetSerieData(serieData, id);
if (target != null) return target;
}
return null;
}
public SerieData GetSerieData(SerieData parent, string id)
{
if (id.Equals(parent.id)) return parent;
foreach (var child in parent.children)
{
var data = GetSerieData(GetSerieData(child), id);
if (data != null)
{
return data;
}
}
return null;
}
/// <summary>
/// 获得指定索引的维度X和维度Y的数据
/// </summary>

View File

@@ -98,6 +98,16 @@ namespace XCharts
SeriesHelper.ClearNameDirty(this);
}
public int GetAllSerieDataCount()
{
var count = 0;
foreach (var serie in list)
{
count += serie.dataCount;
}
return count;
}
/// <summary>
/// 清空所有系列的数据
/// </summary>
@@ -259,7 +269,7 @@ namespace XCharts
/// </summary>
public void RemoveAll()
{
foreach(var serie in m_Series) serie.AnimationFadeIn();
foreach (var serie in m_Series) serie.AnimationFadeIn();
m_Series.Clear();
}

View File

@@ -65,6 +65,7 @@ namespace XCharts
[SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
private DelegateTooltipPosition m_PositionFunction;
private GameObject m_GameObject;
private GameObject m_Content;
@@ -101,6 +102,7 @@ namespace XCharts
/// {b} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart).
/// {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.
/// {d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.
/// {e} is the name of the data item serieData that is currently indicated or whose index is 0.
/// {.1} represents a dot from serie corresponding color that specifies index as 1.
/// 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.
/// {c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).
@@ -115,6 +117,7 @@ namespace XCharts
/// {b}为当前所指示或index为0的serie的数据项serieData的name或者类目值如折线图的X轴
/// {c}为当前所指示或index为0的serie的y维dimesion为1的数值。
/// {d}为当前所指示或index为0的serie的y维dimesion为1百分比值注意不带%号。
/// {e}为当前所指示或index为0的serie的数据项serieData的name。
/// {.1}表示指定index为1的serie对应颜色的圆点。
/// {a1}、{b1}、{c1}中的1表示指定index为1的serie。
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据
@@ -298,6 +301,12 @@ namespace XCharts
public int runtimeGridIndex { get; internal set; }
public int runtimePolarIndex { get; internal set; }
public DelegateTooltipPosition positionFunction
{
get { return m_PositionFunction; }
set { m_PositionFunction = value; }
}
public static Tooltip defaultTooltip
{
get
@@ -447,7 +456,12 @@ namespace XCharts
public void UpdateContentPos(Vector2 pos)
{
if (m_Content)
m_Content.transform.localPosition = pos;
{
if (m_PositionFunction != null)
m_Content.transform.localPosition = m_PositionFunction(pos);
else
m_Content.transform.localPosition = pos;
}
}
/// <summary>

View File

@@ -262,7 +262,6 @@ namespace XCharts
{
public CoordinateChart chart;
private GameObject m_MarkLineLabelRoot;
private bool m_RefreshLabel = false;
public MarkLineHandler(CoordinateChart chart)
{
@@ -309,15 +308,16 @@ namespace XCharts
public void Update()
{
if (m_RefreshLabel)
foreach (var serie in chart.series.list)
{
m_RefreshLabel = false;
foreach (var serie in chart.series.list)
var show = serie.show && serie.markLine.show;
foreach (var data in serie.markLine.data)
{
if (!serie.show || !serie.markLine.show) continue;
foreach (var data in serie.markLine.data)
if (data.runtimeLabel != null)
{
if (data.runtimeLabel != null)
if (data.runtimeLabel.gameObject.activeSelf != show)
data.runtimeLabel.gameObject.SetActive(show);
if (show)
{
data.runtimeLabel.SetPosition(MarkLineHelper.GetLabelPosition(data));
data.runtimeLabel.SetText(MarkLineHelper.GetFormatterContent(serie, data));
@@ -514,13 +514,12 @@ namespace XCharts
data.runtimeCurrentEndPosition = ep;
if (sp != Vector3.zero || ep != Vector3.zero)
{
m_RefreshLabel = true;
chart.ClampInChart(ref sp);
chart.ClampInChart(ref ep);
var theme = chart.theme.axis;
var lineColor = ChartHelper.IsClearColor(data.lineStyle.color) ? serieColor : data.lineStyle.color;
var lineWidth = data.lineStyle.width == 0 ? theme.lineWidth : data.lineStyle.width;
ChartDrawer.DrawLineStyle(vh, data.lineStyle, sp, ep, lineColor, lineWidth, LineStyle.Type.Dashed);
ChartDrawer.DrawLineStyle(vh, data.lineStyle, sp, ep, lineWidth, LineStyle.Type.Dashed, lineColor, lineColor);
if (data.startSymbol != null && data.startSymbol.show)
{
DrawMarkLineSymbol(vh, data.startSymbol, serie, grid, chart.theme, sp, sp, lineColor);
@@ -539,7 +538,7 @@ namespace XCharts
var tickness = SerieHelper.GetSymbolBorder(serie, null, theme, false);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false);
chart.Internal_CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, tickness, pos, lineColor, lineColor,
symbol.gap, true, cornerRadius, grid, startPos);
ColorUtil.clearColor32, symbol.gap, true, cornerRadius, grid, startPos);
}
private void GetStartEndPos(Axis xAxis, Axis yAxis, Grid grid, double value, ref Vector3 sp, ref Vector3 ep)

View File

@@ -35,6 +35,7 @@ namespace XCharts
[SerializeField] private bool m_DataChangeEnable = true;
[SerializeField] private float m_DataChangeDuration = 500;
[SerializeField] private float m_ActualDuration;
[SerializeField] private bool m_AlongWithLinePath;
/// <summary>
/// 自定义渐入动画延时函数。返回ms值。
/// </summary>
@@ -101,6 +102,10 @@ namespace XCharts
/// </summary>
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
/// <summary>
/// 是否沿着线的轨迹进行匀速动画。
/// </summary>
public bool alongWithLinePath { get { return m_AlongWithLinePath; } set { m_AlongWithLinePath = value; } }
/// <summary>
/// 渐入动画完成回调
/// </summary>
public Action fadeInFinishCallback { get; set; }
@@ -123,6 +128,8 @@ namespace XCharts
[SerializeField] private float m_CurrDetailProgress;
[SerializeField] private float m_DestDetailProgress;
private float m_CurrSymbolProgress;
private Vector3 m_LinePathLastPos;
private float m_LinePathCurrTotalDist = 0f;
public void FadeIn()
{
@@ -343,11 +350,29 @@ namespace XCharts
return !IsFinish() && detail > m_CurrDetailProgress;
}
public void SetLinePathStartPos(Vector3 pos)
{
if (m_AlongWithLinePath)
{
m_LinePathLastPos = pos;
m_LinePathCurrTotalDist = 0;
}
}
public bool CheckDetailBreak(Vector3 pos, bool isYAxis)
{
if (IsFinish()) return false;
if (isYAxis) return pos.y > m_CurrDetailProgress;
else return pos.x > m_CurrDetailProgress;
if (m_AlongWithLinePath)
{
m_LinePathCurrTotalDist += Vector3.Distance(pos, m_LinePathLastPos);
m_LinePathLastPos = pos;
return CheckDetailBreak(m_LinePathCurrTotalDist);
}
else
{
if (isYAxis) return pos.y > m_CurrDetailProgress;
else return pos.x > m_CurrDetailProgress;
}
}
public bool NeedAnimation(int dataIndex)
@@ -358,7 +383,7 @@ namespace XCharts
else return dataIndex <= m_CurrDataProgress;
}
internal void CheckProgress(double total)
public void CheckProgress(double total)
{
if (IsFinish()) return;
if (!m_IsInit || m_IsPause || m_IsEnd) return;
@@ -386,7 +411,7 @@ namespace XCharts
}
}
internal float GetCurrAnimationDuration(int dataIndex = -1)
public float GetCurrAnimationDuration(int dataIndex = -1)
{
if (dataIndex >= 0)
{
@@ -397,7 +422,7 @@ namespace XCharts
else return m_FadeInDuration > 0 ? m_FadeInDuration / 1000 : 1f;
}
internal float CheckBarProgress(int dataIndex, float barHig, int dataCount, out bool isBarEnd)
public float CheckBarProgress(int dataIndex, float barHig, int dataCount, out bool isBarEnd)
{
isBarEnd = false;
var initHig = m_FadeOut ? barHig : 0;
@@ -443,7 +468,7 @@ namespace XCharts
End();
}
internal void CheckSymbol(float dest)
public void CheckSymbol(float dest)
{
if (!enable || m_IsEnd || m_IsPause || !m_IsInit) return;
if (IsInDelay()) return;

View File

@@ -18,7 +18,10 @@ namespace XCharts
[System.Serializable]
public class SerieData : SubComponent
{
[SerializeField] private int m_Index;
[SerializeField] private int m_ParentIndex = -1;
[SerializeField] private string m_Name;
[SerializeField] private string m_Id;
[SerializeField] private bool m_Selected;
[SerializeField] private bool m_Ignore = false;
[SerializeField] private float m_Radius;
@@ -33,19 +36,25 @@ namespace XCharts
[SerializeField] private bool m_EnableSymbol = false;
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
[SerializeField] private List<double> m_Data = new List<double>();
[SerializeField] private List<int> m_Children = new List<int>();
public ChartLabel labelObject { get; set; }
private bool m_Show = true;
private float m_RtPieOutsideRadius;
public int index { get; set; }
public int index { get { return m_Index; } set { m_Index = value; } }
public int parentIndex { get { return m_ParentIndex; } set { m_ParentIndex = value; } }
/// <summary>
/// the name of data item.
/// 数据项名称。
/// </summary>
public string name { get { return m_Name; } set { m_Name = value; } }
/// <summary>
/// 数据项的唯一id。唯一id不是必须设置的。
/// </summary>
public string id { get { return m_Id; } set { m_Id = value; } }
/// <summary>
/// 数据项图例名称。当数据项名称不为空时图例名称即为系列名称反之则为索引index。
/// </summary>
/// <value></value>
@@ -113,6 +122,7 @@ namespace XCharts
/// 可指定任意维数的数值列表。
/// </summary>
public List<double> data { get { return m_Data; } set { m_Data = value; } }
public List<int> children { get { return m_Children; } set { m_Children = value; } }
/// <summary>
/// [default:true] Whether the data item is showed.
/// 该数据项是否要显示。
@@ -133,23 +143,23 @@ namespace XCharts
/// <summary>
/// 饼图数据项的开始角度(运行时自动计算)
/// </summary>
public float runtimePieStartAngle { get; internal set; }
public float runtimePieStartAngle { get; set; }
/// <summary>
/// 饼图数据项的结束角度(运行时自动计算)
/// </summary>
public float runtimePieToAngle { get; internal set; }
public float runtimePieToAngle { get; set; }
/// <summary>
/// 饼图数据项的一半时的角度(运行时自动计算)
/// </summary>
public float runtimePieHalfAngle { get; internal set; }
public float runtimePieHalfAngle { get; set; }
/// <summary>
/// 饼图数据项的当前角度(运行时自动计算)
/// </summary>
public float runtimePieCurrAngle { get; internal set; }
public float runtimePieCurrAngle { get; set; }
/// <summary>
/// 饼图数据项的内半径
/// </summary>
public float runtimePieInsideRadius { get; internal set; }
public float runtimePieInsideRadius { get; set; }
/// <summary>
/// 饼图数据项的外半径
/// </summary>
@@ -160,7 +170,7 @@ namespace XCharts
if (radius > 0) return radius;
else return m_RtPieOutsideRadius;
}
internal set
set
{
m_RtPieOutsideRadius = value;
}
@@ -168,24 +178,34 @@ namespace XCharts
/// <summary>
/// 饼图数据项的偏移半径
/// </summary>
public float runtimePieOffsetRadius { get; internal set; }
public float runtimePieOffsetRadius { get; set; }
public Vector3 runtimePosition { get; set; }
/// <summary>
/// 绘制区域。
/// </summary>
public Rect runtimeRect { get; set; }
public Rect runtimeSubRect { get; set; }
public int runtimeLevel { get; set; }
public SerieData runtimeParent { get; set; }
public Color32 runtimeColor { get; set; }
public double runtimeArea { get; set; }
public float runtimeAngle { get; set; }
public Vector3 runtiemPieOffsetCenter { get; set; }
public float runtimeStackHig { get; set; }
public Image runtimeSymbol { get; set; }
public List<SerieData> runtimeChildren { get { return m_RuntimeChildren; } }
private List<double> m_PreviousData = new List<double>();
private List<float> m_DataUpdateTime = new List<float>();
private List<bool> m_DataUpdateFlag = new List<bool>();
private List<Vector2> m_PolygonPoints = new List<Vector2>();
[System.NonSerialized]
private List<SerieData> m_RuntimeChildren = new List<SerieData>();
public void Reset()
{
index = 0;
m_ParentIndex = -1;
labelObject = null;
highlighted = false;
m_Name = string.Empty;
@@ -200,6 +220,8 @@ namespace XCharts
m_Radius = 0;
m_Data.Clear();
m_PreviousData.Clear();
m_PolygonPoints.Clear();
m_RuntimeChildren.Clear();
m_DataUpdateTime.Clear();
m_DataUpdateFlag.Clear();
m_IconStyle.Reset();
@@ -350,6 +372,16 @@ namespace XCharts
return false;
}
public bool UpdateData(int dimension, double value)
{
if (dimension >= 0 && dimension < data.Count)
{
data[dimension] = value;
return true;
}
return false;
}
private void CheckLastData()
{
if (m_PreviousData.Count != m_Data.Count)

View File

@@ -48,7 +48,10 @@ namespace XCharts
/// <summary>
/// 自定义标记。
/// </summary>
Custom
Custom,
EmptyRect,
EmptyTriangle,
EmptyDiamond
}
/// <summary>

View File

@@ -227,6 +227,19 @@ namespace XCharts
else return Color.clear;
}
public void SetColorPalette(List<Color32> colorList)
{
m_ColorPalette = colorList;
SetVerticesDirty();
}
public void SetColorPalette(List<string> hexColorStringList)
{
m_ColorPalette.Clear();
foreach (var hexColor in hexColorStringList)
m_ColorPalette.Add(ColorUtil.GetColor(hexColor));
SetVerticesDirty();
}
public void CheckWarning(StringBuilder sb)
{
#if dUI_TextMeshPro

View File

@@ -35,8 +35,8 @@ namespace XCharts
m_YAxes[0].splitNumber = 10;
RemoveData();
var heatmapGridWid = 10f;
int xSplitNumber = (int)(grid.runtimeWidth / heatmapGridWid);
int ySplitNumber = (int)(grid.runtimeHeight / heatmapGridWid);
int xSplitNumber = (int) (grid.runtimeWidth / heatmapGridWid);
int ySplitNumber = (int) (grid.runtimeHeight / heatmapGridWid);
SerieTemplate.AddDefaultHeatmapSerie(this, "serie1");
@@ -49,8 +49,20 @@ namespace XCharts
visualMap.location.align = Location.Align.BottomLeft;
visualMap.location.bottom = 100;
visualMap.location.left = 30;
var colors = new List<string>{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
"#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
var colors = new List<string>
{
"#313695",
"#4575b4",
"#74add1",
"#abd9e9",
"#e0f3f8",
"#ffffbf",
"#fee090",
"#fdae61",
"#f46d43",
"#d73027",
"#a50026"
};
visualMap.inRange.Clear();
foreach (var str in colors)
{
@@ -80,11 +92,27 @@ namespace XCharts
#endif
protected override void UpdateTooltip()
{
var dataIndex = GetDataIndex();
if (dataIndex < 0) return;
var content = TooltipHelper.GetFormatterContent(tooltip, dataIndex, this);
TooltipHelper.SetContentAndPosition(tooltip, content, chartRect);
tooltip.SetActive(true);
for (int i = 0; i < m_XAxes.Count; i++)
{
UpdateAxisTooltipLabel(i, m_XAxes[i]);
}
for (int i = 0; i < m_YAxes.Count; i++)
{
UpdateAxisTooltipLabel(i, m_YAxes[i]);
}
}
private int GetDataIndex()
{
var xData = tooltip.runtimeXValues[0];
var yData = tooltip.runtimeYValues[0];
if (IsCategory() && (xData < 0 || yData < 0)) return;
sb.Length = 0;
if (IsCategory() && (xData < 0 || yData < 0)) return -1;
for (int i = 0; i < m_Series.Count; i++)
{
var serie = m_Series.GetSerie(i);
@@ -96,30 +124,11 @@ namespace XCharts
{
if (IsCategory())
{
string key = serie.name;
var serieData = serie.data[(int)xData * yCount + (int)yData];
var value = serieData.data[2];
var color = visualMap.enable ? visualMap.GetColor(value) :
m_Theme.GetColor(serie.index);
sb.Append("\n")
.Append(key).Append(!string.IsNullOrEmpty(key) ? "\n" : "")
.Append("<color=#").Append(ChartCached.ColorToStr(color)).Append(">● </color>")
.Append(xAxis.data[(int)xData]).Append(": ")
.Append(ChartCached.FloatToStr(value, string.Empty));
return (int) xData * yCount + (int) yData;
}
}
}
TooltipHelper.SetContentAndPosition(tooltip, sb.ToString().Trim(), chartRect);
tooltip.SetActive(true);
for (int i = 0; i < m_XAxes.Count; i++)
{
UpdateAxisTooltipLabel(i, m_XAxes[i]);
}
for (int i = 0; i < m_YAxes.Count; i++)
{
UpdateAxisTooltipLabel(i, m_YAxes[i]);
}
return -1;
}
}
}
}

View File

@@ -118,7 +118,8 @@ namespace XCharts
int split = GetSplitNumber(axis, coordinateWidth, dataZoom);
if (axis.type == Axis.AxisType.Value)
{
if (minValue == 0 && maxValue == 0) return string.Empty;
if (minValue == 0 && maxValue == 0)
maxValue = axis.max != 0 ? axis.max : 1;
double value = 0;
if (forcePercent) maxValue = 100;
if (axis.interval > 0)
@@ -213,17 +214,21 @@ namespace XCharts
if (splitNum == 0) return 0;
if (axis.IsCategory())
{
var data = axis.GetDataList(dataZoom);
var dataCount = axis.GetDataList(dataZoom).Count;
var scaleNum = 0;
if (axis.boundaryGap)
{
scaleNum = data.Count % splitNum == 0 ? splitNum + 1 : splitNum + 2;
scaleNum = dataCount > 2 && dataCount % splitNum == 0
? splitNum + 1
: splitNum + 2;
}
else
{
if (data.Count < splitNum) scaleNum = splitNum;
else scaleNum = data.Count % splitNum == 0 ? splitNum : splitNum + 1;
if (dataCount < splitNum) scaleNum = splitNum;
else scaleNum = dataCount > 2 && dataCount % splitNum == 0
? splitNum
: splitNum + 1;
}
return scaleNum;
}
@@ -396,7 +401,6 @@ namespace XCharts
{
if (!axis.show) return false;
if (axis.IsCategory() && axis.GetDataList().Count <= 0) return false;
else if (axis.IsValue() && axis.runtimeMinValue == 0 && axis.runtimeMaxValue == 0) return false;
else return true;
}

View File

@@ -18,12 +18,18 @@ namespace XCharts
public static string CheckChart(BaseGraph chart)
{
if (chart is BaseChart) return CheckChart((BaseChart)chart);
else return string.Empty;
if (chart == null)
return string.Empty;
if (chart is BaseChart)
return CheckChart((BaseChart)chart);
else
return string.Empty;
}
public static string CheckChart(BaseChart chart)
{
if (chart == null)
return string.Empty;
var sb = ChartHelper.sb;
sb.Length = 0;
CheckName(chart, sb);
@@ -39,10 +45,10 @@ namespace XCharts
private static void CheckName(BaseChart chart, StringBuilder sb)
{
if (string.IsNullOrEmpty(chart.chartName)) return;
var list = XChartsMgr.Instance.GetCharts(chart.chartName);
if (list.Count > 1)
if (XChartsMgr.Instance.IsRepeatChartName(chart))
{
sb.AppendFormat("warning:chart name is repeated: {0}\n", chart.chartName);
var info = XChartsMgr.Instance.GetRepeatChartNameInfo(chart, chart.chartName);
sb.AppendFormat("warning:chart name is repeated: {0}\n{1}", chart.chartName, info);
}
}

View File

@@ -15,7 +15,7 @@ namespace XCharts
public static class FormatterHelper
{
public const string PH_NN = "\n";
private static Regex s_Regex = new Regex(@"{([a-d|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase);
private static Regex s_Regex = new Regex(@"{([a-e|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase);
private static Regex s_RegexSub = new Regex(@"(0\.#*)|(\d+-\d+)|(\w+)|(\.)", RegexOptions.IgnoreCase);
private static Regex s_RegexN = new Regex(@"^\d+", RegexOptions.IgnoreCase);
private static Regex s_RegexN_N = new Regex(@"\d+-\d+", RegexOptions.IgnoreCase);
@@ -23,11 +23,11 @@ namespace XCharts
private static Regex s_RegexNewLine = new Regex(@"[\\|/]+n|</br>|<br>|<br/>", RegexOptions.IgnoreCase);
private static Regex s_RegexForAxisLabel = new Regex(@"{value(:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
private static Regex s_RegexSubForAxisLabel = new Regex(@"(value)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
private static Regex s_RegexForSerieLabel = new Regex(@"{[a-d|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-d])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
private static Regex s_RegexForSerieLabel = new Regex(@"{[a-e|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-e])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
/// <summary>
/// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}。
/// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}、{e}
/// </summary>
/// <param name="content">要替换的字符串</param>
/// <param name="dataIndex">选中的数据项serieData索引</param>
@@ -84,15 +84,16 @@ namespace XCharts
content = content.Replace(old, serie.name);
}
}
else if (p == 'b' || p == 'B')
else if (p == 'b' || p == 'B' || p == 'e' || p == 'E')
{
var bIndex = dataIndex;
if (argsCount >= 2)
{
var args1Str = args[1].ToString();
if (s_RegexN.IsMatch(args1Str)) bIndex = int.Parse(args1Str);
if (s_RegexN.IsMatch(args1Str))
bIndex = int.Parse(args1Str);
}
var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar;
var needCategory = (p != 'e' && p != 'E') && (serie.type == SerieType.Line || serie.type == SerieType.Bar);
if (needCategory)
{
var category = (chart as CoordinateChart).GetTooltipCategory(dataIndex, serie, dataZoom);
@@ -236,7 +237,7 @@ namespace XCharts
{
content = content.Replace(old, serieName);
}
else if (p == 'b' || p == 'B')
else if (p == 'b' || p == 'B' || p == 'e' || p == 'E')
{
content = content.Replace(old, dataName);
}
@@ -247,6 +248,8 @@ namespace XCharts
{
if (total != 0)
content = content.Replace(old, ChartCached.FloatToStr(value / total * 100, numericFormatter));
else
content = content.Replace(old, ChartCached.FloatToStr(0, numericFormatter));
}
else
{

View File

@@ -11,10 +11,14 @@ namespace XCharts
{
public static class LegendHelper
{
public static Color GetContentColor(Legend legend, ChartTheme theme, bool active)
public static Color GetContentColor(int legendIndex, Legend legend, ChartTheme theme, bool active)
{
var textStyle = legend.textStyle;
if (active) return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
if (active)
{
if (legend.textAutoColor) return theme.GetColor(legendIndex);
else return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
}
else return theme.legend.unableColor;
}
@@ -34,7 +38,7 @@ namespace XCharts
}
public static LegendItem AddLegendItem(Legend legend, int i, string legendName, Transform parent,
ChartTheme theme, string content, Color itemColor, bool active)
ChartTheme theme, string content, Color itemColor, bool active, int legendIndex)
{
var objName = i + "_" + legendName;
var anchorMin = new Vector2(0, 0.5f);
@@ -43,7 +47,7 @@ namespace XCharts
var sizeDelta = new Vector2(100, 30);
var iconSizeDelta = new Vector2(legend.itemWidth, legend.itemHeight);
var textStyle = legend.textStyle;
var contentColor = GetContentColor(legend, theme, active);
var contentColor = GetContentColor(legendIndex, legend, theme, active);
var objAnchorMin = new Vector2(0, 1);
var objAnchorMax = new Vector2(0, 1);

View File

@@ -23,7 +23,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value < min) min = value;
if (value < min && !serie.IsIgnoreValue(value)) min = value;
}
}
return min == double.MaxValue ? 0 : min;
@@ -39,7 +39,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value < min)
if (value < min && !serie.IsIgnoreValue(value))
{
min = value;
minData = serieData;
@@ -58,7 +58,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value > max) max = value;
if (value > max && !serie.IsIgnoreValue(value)) max = value;
}
}
return max == double.MinValue ? 0 : max;
@@ -74,7 +74,7 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value > max)
if (value > max && !serie.IsIgnoreValue(value))
{
max = value;
maxData = serieData;
@@ -93,7 +93,9 @@ namespace XCharts
var serieData = dataList[i];
if (serieData.show && serieData.data.Count > dimension)
{
total += serieData.data[dimension];
var value = serieData.data[dimension];
if (!serie.IsIgnoreValue(value))
total += value;
}
}
return total != 0 ? total / dataList.Count : 0;
@@ -109,7 +111,9 @@ namespace XCharts
var serieData = dataList[i];
if (serieData.show && serieData.data.Count > dimension)
{
s_TempList.Add(serieData.data[dimension]);
var value = serieData.data[dimension];
if (!serie.IsIgnoreValue(value))
s_TempList.Add(value);
}
}
s_TempList.Sort();
@@ -139,8 +143,11 @@ namespace XCharts
if (serieData.show && serieData.data.Count > dimension)
{
var value = serieData.data[dimension];
if (value > max) max = value;
if (value < min) min = value;
if (!serie.IsIgnoreValue(value))
{
if (value > max) max = value;
if (value < min) min = value;
}
}
}
}
@@ -171,8 +178,11 @@ namespace XCharts
for (int j = 0; j < count; j++)
{
var value = serieData.data[j];
if (value > max) max = value;
if (value < min) min = value;
if (!serie.IsIgnoreValue(value))
{
if (value > max) max = value;
if (value < min) min = value;
}
}
}
}
@@ -225,6 +235,7 @@ namespace XCharts
serie.runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
serie.runtimeCenterPos = new Vector3(serie.runtimeX + serie.runtimeWidth / 2,
serie.runtimeY + serie.runtimeHeight / 2);
serie.runtimeRect = new Rect(serie.runtimeX, serie.runtimeY, serie.runtimeWidth, serie.runtimeHeight);
}
else
{
@@ -233,6 +244,7 @@ namespace XCharts
serie.runtimeWidth = chartWidth;
serie.runtimeHeight = chartHeight;
serie.runtimeCenterPos = chartPosition + new Vector3(chartWidth / 2, chartHeight / 2);
serie.runtimeRect = new Rect(serie.runtimeX, serie.runtimeY, serie.runtimeWidth, serie.runtimeHeight);
}
}
@@ -419,9 +431,17 @@ namespace XCharts
}
}
public static SerieLabel GetSerieEmphasisLabel(Serie serie, SerieData serieData)
{
if (!serie.IsPerformanceMode() && serieData.enableEmphasis && serieData.emphasis.show)
return serieData.emphasis.label;
else if (serie.emphasis.show) return serie.emphasis.label;
else return null;
}
public static IconStyle GetIconStyle(Serie serie, SerieData serieData)
{
if(serieData.enableIconStyle) return serieData.iconStyle;
if (serieData.enableIconStyle) return serieData.iconStyle;
else return serie.iconStyle;
}
@@ -622,13 +642,13 @@ namespace XCharts
int start = 0, end = 0;
if (dataZoom.runtimeInvert)
{
end = Mathf.CeilToInt(data.Count * dataZoom.end / 100);
end = Mathf.RoundToInt(data.Count * dataZoom.end / 100);
start = end - range;
if (start < 0) start = 0;
}
else
{
start = Mathf.FloorToInt(data.Count * dataZoom.start / 100);
start = Mathf.RoundToInt(data.Count * dataZoom.start / 100);
end = start + range;
if (end > data.Count) end = data.Count;
}
@@ -646,6 +666,8 @@ namespace XCharts
if (dataZoom.minShowNum > data.Count) range = data.Count;
else range = dataZoom.minShowNum;
}
if (range > data.Count - start)
start = data.Count - range;
serie.m_FilterData = data.GetRange(start, range);
}
else
@@ -690,7 +712,6 @@ namespace XCharts
});
break;
case SerieDataSortType.None:
break;
}
}

View File

@@ -443,29 +443,31 @@ namespace XCharts
{
var serie = series.GetSerie(i);
if ((isPolar && serie.polarIndex != axisIndex)
|| (!isPolar && serie.yAxisIndex != axisIndex)) continue;
if (series.IsActive(i))
|| (!isPolar && serie.yAxisIndex != axisIndex)
|| !series.IsActive(i)) continue;
if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.name, SerieType.Bar))
{
if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.name, SerieType.Bar))
if (100 > max) max = 100;
if (0 < min) min = 0;
}
else
{
var showData = serie.GetDataList(dataZoom);
foreach (var data in showData)
{
if (100 > max) max = 100;
if (0 < min) min = 0;
}
else
{
var showData = serie.GetDataList(dataZoom);
foreach (var data in showData)
if (serie.type == SerieType.Candlestick)
{
if (serie.type == SerieType.Candlestick)
var dataMin = data.GetMinData(inverse);
var dataMax = data.GetMaxData(inverse);
if (dataMax > max) max = dataMax;
if (dataMin < min) min = dataMin;
}
else
{
var currData = data.GetData(yValue ? 1 : 0, inverse);
if (!serie.IsIgnoreValue(currData))
{
var dataMin = data.GetMinData(inverse);
var dataMax = data.GetMaxData(inverse);
if (dataMax > max) max = dataMax;
if (dataMin < min) min = dataMin;
}
else
{
var currData = data.GetData(yValue ? 1 : 0, inverse);
if (currData > max) max = currData;
if (currData < min) min = currData;
}
@@ -510,7 +512,8 @@ namespace XCharts
currData = yValue ? showData[j].GetData(1) : showData[j].GetData(0);
}
if (inverse) currData = -currData;
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
if (!serie.IsIgnoreValue(currData))
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
}
}
}

View File

@@ -33,7 +33,7 @@ namespace XCharts
if (!string.IsNullOrEmpty(serieData.name))
sb.Append(serieData.name).Append(": ");
sb.AppendFormat("({0},{1})", ChartCached.FloatToStr(xValue, numericFormatter),
ChartCached.FloatToStr(yValue, numericFormatter));
ChartCached.FloatToStr(yValue, numericFormatter));
if (i != dataIndexList.Count - 1)
{
sb.Append("\n");
@@ -41,7 +41,6 @@ namespace XCharts
}
}
private static void InitPieTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
ChartTheme theme)
{
@@ -72,7 +71,7 @@ namespace XCharts
if (!string.IsNullOrEmpty(serieData.name))
{
sb.Append("<color=#").Append(theme.GetColorStr(index)).Append(">● </color>")
.Append(serieData.name).Append(": ").Append(ChartCached.FloatToStr(value, numericFormatter));
.Append(serieData.name).Append(": ").Append(ChartCached.FloatToStr(value, numericFormatter));
}
else
{
@@ -196,7 +195,7 @@ namespace XCharts
double xValue, yValue;
serie.GetXYData(index, dataZoom, out xValue, out yValue);
var isIngore = serie.IsIgnorePoint(index);
if(isIngore) return;
if (isIngore) return;
var serieData = serie.GetSerieData(index, dataZoom);
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
if (isCartesian)
@@ -234,6 +233,35 @@ namespace XCharts
}
}
private static void InitHeatmapTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
CoordinateChart chart)
{
if (serie.type != SerieType.Heatmap) return;
var xData = tooltip.runtimeXValues[0];
var yData = tooltip.runtimeYValues[0];
if (chart.IsCategory() && (xData < 0 || yData < 0)) return;
sb.Length = 0;
var xAxis = chart.GetXAxis(serie.xAxisIndex);
var yAxis = chart.GetYAxis(serie.yAxisIndex);
var xCount = xAxis.data.Count;
var yCount = yAxis.data.Count;
var visualMap = chart.visualMap;
if (chart.IsCategory())
{
string key = serie.name;
var serieData = serie.data[(int) xData * yCount + (int) yData];
var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);
var value = serieData.data[2];
var color = visualMap.enable ? visualMap.GetColor(value) :
chart.theme.GetColor(serie.index);
sb.Append("\n")
.Append(key).Append(!string.IsNullOrEmpty(key) ? "\n" : "")
.Append("<color=#").Append(ChartCached.ColorToStr(color)).Append(">● </color>")
.Append(xAxis.data[(int) xData]).Append(": ")
.Append(ChartCached.FloatToStr(value, numericFormatter));
}
}
private static void InitDefaultContent(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index,
BaseChart chart, DataZoom dataZoom = null, bool isCartesian = false,
Radar radar = null)
@@ -259,6 +287,7 @@ namespace XCharts
InitRingTooltip(ref sb, tooltip, serie, index, chart.theme);
break;
case SerieType.Heatmap:
InitHeatmapTooltip(ref sb, tooltip, serie, index, chart as CoordinateChart);
break;
case SerieType.Gauge:
InitGaugeTooltip(ref sb, tooltip, serie, index, chart.theme);
@@ -335,8 +364,8 @@ namespace XCharts
{
string content = itemFormatter;
FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, chart, null);
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar
|| serie.type == SerieType.Ring ? dataIndex : serie.index;
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar ||
serie.type == SerieType.Ring ? dataIndex : serie.index;
sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(dotColorIndex)));
sb.Append(content);
}
@@ -449,8 +478,8 @@ namespace XCharts
string content = itemFormatter;
FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom);
if (!first) sb.Append(FormatterHelper.PH_NN);
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar
|| serie.type == SerieType.Ring ? dataIndex : i;
var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar ||
serie.type == SerieType.Ring ? dataIndex : i;
sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(dotColorIndex)));
sb.Append(content);
first = false;

View File

@@ -144,7 +144,7 @@ namespace XCharts
public static bool IsNeedGradient(VisualMap visualMap)
{
if (!visualMap.enable || visualMap.inRange.Count <= 0) return false;
if (!visualMap.enable || (visualMap.inRange.Count <= 0 && visualMap.pieces.Count <= 0)) return false;
return true;
}

View File

@@ -74,12 +74,17 @@ namespace XCharts
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieBeforeCallback;
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieAfterCallback;
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
protected Action<int, string, bool> m_OnLegendClick;
protected Action<int, string> m_OnLegendEnter;
protected Action<int, string> m_OnLegendExit;
protected bool m_RefreshLabel = false;
internal bool m_ReinitLabel = false;
internal bool m_ReinitTitle = false;
internal bool m_CheckAnimation = false;
internal bool m_IsPlayingAnimation = false;
internal int m_BasePainterVertCount;
internal int m_TopPainterVertCount;
internal protected List<string> m_LegendRealShowName = new List<string>();
protected List<Painter> m_PainterList = new List<Painter>();
internal Painter m_PainterTop;
@@ -109,6 +114,8 @@ namespace XCharts
m_ComponentHandlers.Add(new VisualMapHandler(this));
m_ComponentHandlers.Add(new DataZoomHandler(this));
foreach (var draw in m_ComponentHandlers) draw.Init();
m_DebugInfo.Init(this);
}
protected override void Awake()
@@ -161,6 +168,7 @@ namespace XCharts
Internal_CheckAnimation();
foreach (var draw in m_DrawSeries) draw.Update();
foreach (var draw in m_ComponentHandlers) draw.Update();
m_DebugInfo.Update();
}
public Painter GetPainter(int index)
@@ -224,6 +232,9 @@ namespace XCharts
{
m_CheckTheme = m_Theme.theme;
m_Theme.CopyTheme(m_CheckTheme);
#if UNITY_EDITOR
UnityEditor.EditorUtility.SetDirty(this);
#endif
SetAllComponentDirty();
OnThemeChanged();
}
@@ -450,7 +461,7 @@ namespace XCharts
var active = IsActiveByLegend(datas[i]);
var bgColor = LegendHelper.GetIconColor(this, readIndex, datas[i], active);
var item = LegendHelper.AddLegendItem(legend, i, datas[i], legendObject.transform, m_Theme,
legendName, bgColor, active);
legendName, bgColor, active, readIndex);
legend.SetButton(legendName, item, totalLegend);
ChartHelper.ClearEventListener(item.button.gameObject);
ChartHelper.AddEventListener(item.button.gameObject, EventTriggerType.PointerDown, (data) =>
@@ -517,32 +528,35 @@ namespace XCharts
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
m_SerieLabelRoot.hideFlags = chartHideFlags;
SerieLabelPool.ReleaseAll(m_SerieLabelRoot.transform);
int count = 0;
for (int i = 0; i < m_Series.Count; i++)
{
var serie = m_Series.list[i];
serie.index = i;
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
int count = 0;
for (int j = 0; j < serie.data.Count; j++)
{
var serieData = serie.data[j];
serieData.index = j;
serieData.index = count;
serieData.labelObject = null;
AddSerieLabel(serie, serieData, count);
AddSerieLabel(serie, serieData, ref count);
count++;
}
}
SerieLabelHelper.UpdateLabelText(m_Series, m_Theme, m_LegendRealShowName);
}
protected void AddSerieLabel(Serie serie, SerieData serieData, int count = -1)
protected void AddSerieLabel(Serie serie, SerieData serieData, ref int count)
{
if (m_SerieLabelRoot == null) return;
if (count == -1) count = serie.dataCount;
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var serieEmphasisLable = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
if (serie.IsPerformanceMode()) return;
if (!serieLabel.show && !iconStyle.show) return;
if (!serieLabel.show && (serieEmphasisLable == null || !serieEmphasisLable.show) && !iconStyle.show) return;
if (serie.animation.enable && serie.animation.HasFadeOut()) return;
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
var color = Color.grey;
if (serie.type == SerieType.Pie)
@@ -564,6 +578,12 @@ namespace XCharts
item.SetIcon(iconImage);
item.SetIconActive(iconStyle.show);
serieData.labelObject = item;
foreach (var dataIndex in serieData.children)
{
AddSerieLabel(serie, serie.GetSerieData(dataIndex), ref count);
count++;
}
}
private void InitSerieTitle()
@@ -779,6 +799,12 @@ namespace XCharts
{
}
public override void OnPointerClick(PointerEventData eventData)
{
m_DebugInfo.clickChartCount++;
base.OnPointerClick(eventData);
}
public override void OnPointerDown(PointerEventData eventData)
{
base.OnPointerDown(eventData);
@@ -824,6 +850,8 @@ namespace XCharts
}
OnYMaxValueChanged();
}
if(m_OnLegendClick != null)
m_OnLegendClick(index, legendName, show);
}
protected virtual void OnLegendButtonEnter(int index, string legendName)
@@ -839,6 +867,8 @@ namespace XCharts
RefreshPainter(serie);
}
}
if(m_OnLegendEnter != null)
m_OnLegendEnter(index, legendName);
}
protected virtual void OnLegendButtonExit(int index, string legendName)
@@ -854,6 +884,8 @@ namespace XCharts
RefreshPainter(serie);
}
}
if(m_OnLegendExit != null)
m_OnLegendExit(index, legendName);
}
protected virtual void UpdateTooltip()
@@ -871,6 +903,7 @@ namespace XCharts
{
m_OnCustomDrawBaseCallback(vh);
}
m_BasePainterVertCount = vh.currentVertCount;
}
protected virtual void OnDrawPainterSerie(VertexHelper vh, Painter painter)
@@ -880,6 +913,7 @@ namespace XCharts
var maxSeries = m_Series.Count;
var rate = Mathf.CeilToInt(maxSeries * 1.0f / maxPainter);
m_PainterTop.Refresh();
m_DebugInfo.refreshCount++;
for (int i = painter.index * rate; i < (painter.index + 1) * rate && i < maxSeries; i++)
{
var serie = m_Series.GetSerie(i);
@@ -892,6 +926,7 @@ namespace XCharts
{
m_OnCustomDrawSerieAfterCallback(vh, serie);
}
serie.runtimeVertCount = vh.currentVertCount;
}
m_RefreshLabel = true;
}
@@ -907,6 +942,7 @@ namespace XCharts
m_OnCustomDrawTopCallback(vh);
}
DrawTooltip(vh);
m_TopPainterVertCount = vh.currentVertCount;
}
protected virtual void DrawPainterSerie(VertexHelper vh, Serie serie)
@@ -1011,17 +1047,20 @@ namespace XCharts
}
public void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius)
float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 fillColor, float gap, float[] cornerRadius)
{
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius, Vector3.zero);
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, fillColor, gap, cornerRadius, Vector3.zero);
}
public void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius, Vector3 startPos)
float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 fillColor, float gap, float[] cornerRadius, Vector3 startPos)
{
var backgroundColor = ThemeHelper.GetBackgroundColor(m_Theme, m_Background);
if (ChartHelper.IsClearColor(fillColor))
fillColor = backgroundColor;
var smoothness = settings.cicleSmoothness;
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
cornerRadius, backgroundColor, smoothness, startPos);
cornerRadius, fillColor, backgroundColor, smoothness, startPos);
}
public void DrawLabelBackground(VertexHelper vh, Serie serie, SerieData serieData)

View File

@@ -22,6 +22,7 @@ namespace XCharts
[SerializeField] protected bool m_DebugMode = false;
[SerializeField] protected bool m_EnableTextMeshPro = false;
[SerializeField] protected Background m_Background = Background.defaultBackground;
protected DebugInfo m_DebugInfo = new DebugInfo();
protected Painter m_Painter;
protected int m_SiblingIndex;
@@ -57,7 +58,7 @@ namespace XCharts
protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } }
protected Vector2 graphPivot { get { return m_GraphPivot; } }
public HideFlags chartHideFlags { get { return m_DebugMode ? HideFlags.None : HideFlags.HideInHierarchy; } }
public DebugInfo debug { get { return m_DebugInfo; } }
private ScrollRect m_ScrollRect;
@@ -129,7 +130,7 @@ namespace XCharts
}
}
private void CheckTextMeshPro()
{

View File

@@ -728,12 +728,12 @@ namespace XCharts
var labelName = AxisHelper.GetLabelName(xAxis, grid.runtimeWidth, i, xAxis.runtimeMinValue,
xAxis.runtimeMaxValue, dataZoom, isPercentStack);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, ChartCached.GetXAxisName(xAxisIndex, i),
axisObj.transform, new Vector2(0, 1), new Vector2(0, 1), new Vector2(1, 0.5f),
axisObj.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
new Vector2(textWidth, textHeight), xAxis, theme.axis, labelName);
if (i == 0) xAxis.axisLabel.SetRelatedText(label.label, labelWidth);
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleCenter));
label.SetPosition(GetLabelXPosition(totalWidth + textWidth / 2 + gapWidth, i, xAxisIndex, xAxis));
label.SetPosition(GetLabelXPosition(totalWidth + gapWidth, i, xAxisIndex, xAxis));
xAxis.runtimeAxisLabelList.Add(label);
totalWidth += labelWidth;
}
@@ -848,7 +848,8 @@ namespace XCharts
private Vector3 GetLabelYPosition(float scaleWid, int i, int yAxisIndex, YAxis yAxis)
{
var grid = GetAxisGridOrDefault(yAxis);
var startX = yAxis.IsLeft() ? grid.runtimeX : grid.runtimeX + grid.runtimeWidth;
var startX = grid.runtimeX + (yAxis.axisLabel.onZero ? m_XAxes[yAxisIndex].runtimeZeroXOffset : 0);
if (yAxis.IsRight()) startX += grid.runtimeWidth;
var posX = 0f;
var inside = yAxis.axisLabel.inside;
if ((inside && yAxis.IsLeft()) || (!inside && yAxis.IsRight()))
@@ -1081,7 +1082,7 @@ namespace XCharts
new Vector2(grid.runtimeX, pY + scaleWidth),
yAxis.splitArea.GetColor(i, m_Theme.axis));
}
if (yAxis.splitLine.show)
if (yAxis.splitLine.show && pY >= grid.runtimeY)
{
if (!xAxis.axisLine.show || !xAxis.axisLine.onZero || zeroPos.y != pY)
{
@@ -1199,7 +1200,7 @@ namespace XCharts
new Vector2(pX + scaleWidth, grid.runtimeY),
xAxis.splitArea.GetColor(i, m_Theme.axis));
}
if (xAxis.splitLine.show)
if (xAxis.splitLine.show && pX >= grid.runtimeX)
{
if (!yAxis.axisLine.show || !yAxis.axisLine.onZero || zeroPos.x != pX)
{
@@ -1464,10 +1465,11 @@ namespace XCharts
if (!serie.show) continue;
if (serie.IsPerformanceMode()) continue;
if (!serie.IsCoordinateSerie()) continue;
for (int j = 0; j < serie.data.Count; j++)
DataZoomHelper.GetSerieRelatedDataZoom(serie, dataZooms, out var xDataZoom, out var yDataZoom);
var showData = serie.GetDataList(xDataZoom);
for (int j = 0; j < showData.Count; j++)
{
var serieData = serie.data[j];
var serieData = showData[j];
if (serieData.labelObject == null) continue;
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.highlighted);
serieData.index = j;
@@ -1546,9 +1548,13 @@ namespace XCharts
if (!serie.IsCoordinateSerie()) continue;
var total = serie.yTotal;
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
for (int j = 0; j < serie.data.Count; j++)
DataZoomHelper.GetSerieRelatedDataZoom(serie, dataZooms, out var xDataZoom, out var yDataZoom);
var showData = serie.GetDataList(xDataZoom);
if (xDataZoom != null)
ChartHelper.HideAllObject(m_SerieLabelRoot, "label_" + i);
for (int j = 0; j < showData.Count; j++)
{
var serieData = serie.data[j];
var serieData = showData[j];
if (serieData.labelObject == null) continue;
if (j >= serie.dataPoints.Count)
{
@@ -1556,6 +1562,7 @@ namespace XCharts
serieData.SetIconActive(false);
continue;
}
serieData.labelObject.SetActive(true);
var pos = serie.dataPoints[j];
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
@@ -1681,19 +1688,20 @@ namespace XCharts
}
public void Internal_CheckClipAndDrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, float gap, bool clip, float[] cornerRadius, Grid grid, Vector3 startPos)
Vector3 pos, Color32 color, Color32 toColor, Color32 backgroundColor, float gap, bool clip, float[] cornerRadius,
Grid grid, Vector3 startPos)
{
if (!IsInChart(pos)) return;
if (!clip || (clip && (IsInGrid(grid, pos))))
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius, startPos);
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, backgroundColor, gap, cornerRadius, startPos);
}
public void Internal_CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
float zebraGap, Color32 color, bool clip, Grid grid)
float zebraGap, Color32 color, Color32 toColor, bool clip, Grid grid, float maxDistance)
{
ClampInChart(ref p1);
ClampInChart(ref p2);
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color);
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor, maxDistance);
}
protected Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, Grid grid)

View File

@@ -329,17 +329,18 @@ namespace XCharts
var center = new Vector3((plt.x + prb.x) / 2, (prt.y + plb.y) / 2);
if (itemWidth > 0 && itemHeight > 0)
{
var invert = center.x < plb.x;
if (ItemStyleHelper.IsNeedCorner(itemStyle))
{
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
itemStyle.cornerRadius, isYAxis);
itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
}
else
{
Internal_CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
}
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
}
}
else
@@ -356,10 +357,11 @@ namespace XCharts
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
if (itemWidth > 0 && itemHeight > 0)
{
var invert = center.y < plb.y;
if (ItemStyleHelper.IsNeedCorner(itemStyle))
{
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
itemStyle.cornerRadius, isYAxis);
itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
}
else
{
@@ -367,7 +369,7 @@ namespace XCharts
serie.clip, grid);
}
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor,
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis);
itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis, m_Settings.cicleSmoothness, invert);
}
}
}
@@ -376,21 +378,22 @@ namespace XCharts
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
Vector3 prb, bool isYAxis, Grid grid)
{
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
var barColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
var barToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
if (isYAxis)
{
plt = (plb + plt) / 2;
prt = (prt + prb) / 2;
Internal_CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
areaColor, serie.clip, grid);
barColor, barToColor, serie.clip, grid, grid.runtimeWidth);
}
else
{
plb = (prb + plb) / 2;
plt = (plt + prt) / 2;
Internal_CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
areaColor, serie.clip, grid);
barColor, barToColor, serie.clip, grid, grid.runtimeHeight);
}
}

View File

@@ -40,13 +40,14 @@ namespace XCharts
? symbol.GetSelectedSize(serie.data[i].data, m_Theme.serie.lineSymbolSelectedSize)
: symbol.GetSize(serie.data[i].data, m_Theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, serie.index, highlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, serie.index, highlight);
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, serie.index, highlight, false);
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
Internal_CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serie.dataPoints[i], symbolColor,
symbolToColor, symbol.gap, clip, cornerRadius, grid, i > 0 ? serie.dataPoints[i - 1] : grid.runtimePosition);
symbolToColor, backgroundColor, symbol.gap, clip, cornerRadius, grid,
i > 0 ? serie.dataPoints[i - 1] : grid.runtimePosition);
}
}
@@ -167,15 +168,11 @@ namespace XCharts
}
var startIndex = 0;
var endIndex = serie.dataPoints.Count;
var startPos = GetStartPos(serie.dataPoints, ref startIndex);
var endPos = GetEndPos(serie.dataPoints, ref endIndex);
var startPos = GetStartPos(serie.dataPoints, ref startIndex, serie.ignoreLineBreak);
var endPos = GetEndPos(serie.dataPoints, ref endIndex, serie.ignoreLineBreak);
lp = startPos;
stPos1 = stPos2 = lastDir = lastDnPos = Vector3.zero;
smoothStartPosUp = smoothStartPosDn = Vector3.zero;
float currDetailProgress = lp.x;
float totalDetailProgress = endPos.x;
serie.animation.InitProgress(serie.dataPoints.Count, currDetailProgress, totalDetailProgress);
serie.animation.SetDataFinish(startIndex);
Vector3 firstLastPos = Vector3.zero, lastNextPos = Vector3.zero;
if (serie.minShow > 0 && serie.minShow < showData.Count)
@@ -215,14 +212,41 @@ namespace XCharts
lastNextPos = endPos;
}
VisualMapHelper.AutoSetLineMinMax(visualMap, serie, xAxis, yAxis);
float currDetailProgress = lp.x;
float totalDetailProgress = endPos.x;
if (serie.animation.alongWithLinePath)
{
currDetailProgress = 0;
totalDetailProgress = 0;
var tempLp = startPos;
for (i = startIndex + 1; i < serie.dataPoints.Count; i++)
{
np = serie.dataPoints[i];
if (np != Vector3.zero)
{
totalDetailProgress += Vector3.Distance(np, tempLp);
tempLp = np;
}
}
serie.animation.SetLinePathStartPos(startPos);
}
serie.animation.InitProgress(serie.dataPoints.Count, currDetailProgress, totalDetailProgress);
serie.animation.SetDataFinish(startIndex);
for (i = startIndex + 1; i < serie.dataPoints.Count; i++)
{
np = serie.dataPoints[i];
serie.ClearSmoothList(i);
var isIgnoreBreak = false;
if (np == Vector3.zero)
{
serie.animation.SetDataFinish(i);
continue;
if (serie.ignoreLineBreak)
isIgnoreBreak = true;
else
{
serie.animation.SetDataFinish(i);
continue;
}
}
if (!serie.animation.NeedAnimation(i)) break;
bool isFinish = true;
@@ -239,34 +263,54 @@ namespace XCharts
switch (serie.lineType)
{
case LineType.Normal:
lp = GetLastPos(serie.dataPoints, i, np);
nnp = GetNNPos(serie.dataPoints, i, np);
isFinish = DrawNormalLine(vh, serie, xAxis, lp, np, nnp, i, lineColor,
areaColor, areaToColor, zeroPos, startIndex);
lp = GetLastPos(serie.dataPoints, i, np, serie.ignoreLineBreak);
nnp = GetNNPos(serie.dataPoints, i, np, serie.ignoreLineBreak);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
isFinish = DrawNormalLine(vh, serie, xAxis, lp, np, nnp, i,
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
zeroPos, startIndex);
break;
case LineType.Smooth:
case LineType.SmoothDash:
llp = GetLLPos(serie.dataPoints, i, firstLastPos);
nnp = GetNNPos(serie.dataPoints, i, lastNextPos);
llp = GetLLPos(serie.dataPoints, i, firstLastPos, serie.ignoreLineBreak);
nnp = GetNNPos(serie.dataPoints, i, lastNextPos, serie.ignoreLineBreak);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
isFinish = DrawSmoothLine(vh, serie, xAxis, lp, np, llp, nnp, i,
lineColor, areaColor, areaToColor, isStack, zeroPos, startIndex);
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
isStack, zeroPos, startIndex);
break;
case LineType.StepStart:
case LineType.StepMiddle:
case LineType.StepEnd:
nnp = GetNNPos(serie.dataPoints, i, np);
isFinish = DrawStepLine(vh, serie, xAxis, lp, np, nnp, i, lineColor,
areaColor, areaToColor, zeroPos);
nnp = GetNNPos(serie.dataPoints, i, np, serie.ignoreLineBreak);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
isFinish = DrawStepLine(vh, serie, xAxis, lp, np, nnp, i,
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
zeroPos);
break;
case LineType.Dash:
case LineType.Dot:
case LineType.DashDot:
case LineType.DashDotDot:
DrawOtherLine(vh, serie, xAxis, lp, np, i, lineColor, areaColor, areaToColor, zeroPos);
if (lp == Vector3.zero && serie.ignoreLineBreak) isIgnoreBreak = true;
DrawOtherLine(vh, serie, xAxis, lp, np, i,
isIgnoreBreak ? ColorUtil.clearColor32 : lineColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaColor,
isIgnoreBreak ? ColorUtil.clearColor32 : areaToColor,
zeroPos);
break;
}
if (isFinish) serie.animation.SetDataFinish(i);
if (np != Vector3.zero) lp = np;
if (np != Vector3.zero || serie.ignoreLineBreak)
{
lp = np;
}
}
if (!serie.animation.IsFinish())
{
@@ -277,22 +321,22 @@ namespace XCharts
}
}
private Vector3 GetNNPos(List<Vector3> dataPoints, int index, Vector3 np)
private Vector3 GetNNPos(List<Vector3> dataPoints, int index, Vector3 np, bool ignoreLineBreak)
{
int size = dataPoints.Count;
if (index >= size) return np;
for (int i = index + 1; i < size; i++)
{
if (dataPoints[i] != Vector3.zero) return dataPoints[i];
if (dataPoints[i] != Vector3.zero || ignoreLineBreak) return dataPoints[i];
}
return np;
}
private Vector3 GetStartPos(List<Vector3> dataPoints, ref int start)
private Vector3 GetStartPos(List<Vector3> dataPoints, ref int start, bool ignoreLineBreak)
{
for (int i = 0; i < dataPoints.Count; i++)
{
if (dataPoints[i] != Vector3.zero)
if (dataPoints[i] != Vector3.zero || ignoreLineBreak)
{
start = i;
return dataPoints[i];
@@ -301,11 +345,11 @@ namespace XCharts
return Vector3.zero;
}
private Vector3 GetEndPos(List<Vector3> dataPoints, ref int end)
private Vector3 GetEndPos(List<Vector3> dataPoints, ref int end, bool ignoreLineBreak)
{
for (int i = dataPoints.Count - 1; i >= 0; i--)
{
if (dataPoints[i] != Vector3.zero)
if (dataPoints[i] != Vector3.zero || ignoreLineBreak)
{
end = i;
return dataPoints[i];
@@ -314,22 +358,22 @@ namespace XCharts
return Vector3.zero;
}
private Vector3 GetLastPos(List<Vector3> dataPoints, int index, Vector3 pos)
private Vector3 GetLastPos(List<Vector3> dataPoints, int index, Vector3 pos, bool ignoreLineBreak)
{
if (index <= 0) return pos;
for (int i = index - 1; i >= 0; i--)
{
if (dataPoints[i] != Vector3.zero) return dataPoints[i];
if (dataPoints[i] != Vector3.zero || ignoreLineBreak) return dataPoints[i];
}
return pos;
}
private Vector3 GetLLPos(List<Vector3> dataPoints, int index, Vector3 lp)
private Vector3 GetLLPos(List<Vector3> dataPoints, int index, Vector3 lp, bool ignoreLineBreak)
{
if (index <= 1) return lp;
for (int i = index - 2; i >= 0; i--)
{
if (dataPoints[i] != Vector3.zero) return dataPoints[i];
if (dataPoints[i] != Vector3.zero || ignoreLineBreak) return dataPoints[i];
}
return lp;
}
@@ -618,7 +662,7 @@ namespace XCharts
case LineType.Normal:
nnp = i < serie.dataPoints.Count - 1 ? serie.dataPoints[i + 1] : np;
isFinish = DrawNormalLine(vh, serie, yAxis, lp, np, nnp, i, lineColor,
areaColor, areaToColor, zeroPos);
areaColor, areaToColor, zeroPos, 0);
break;
case LineType.Smooth:
case LineType.SmoothDash:
@@ -635,11 +679,11 @@ namespace XCharts
areaColor, areaToColor, zeroPos);
break;
case LineType.Dash:
UGL.DrawDashLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor);
UGL.DrawDashLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, lineColor);
isFinish = true;
break;
case LineType.Dot:
UGL.DrawDotLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor);
UGL.DrawDotLine(vh, lp, np, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, lineColor);
isFinish = true;
break;
case LineType.DashDot:
@@ -678,7 +722,7 @@ namespace XCharts
private bool lastIsDown;
private bool DrawNormalLine(VertexHelper vh, Serie serie, Axis axis, Vector3 lp, Vector3 np, Vector3 nnp,
int dataIndex, Color32 lineColor, Color32 areaColor, Color32 areaToColor,
Vector3 zeroPos, int startIndex = 0)
Vector3 zeroPos, int startIndex)
{
var defaultLineColor = lineColor;
var isSecond = dataIndex == startIndex + 1;
@@ -789,7 +833,8 @@ namespace XCharts
(!lastIsDown && IsInRightOrUp(isYAxis, lastDnPos, tp1)))
{
isStart = true;
Internal_CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid);
if (stPos1 != Vector3.zero && stPos2 != Vector3.zero)
Internal_CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid);
}
}
else
@@ -941,8 +986,8 @@ namespace XCharts
Vector3 aep = isYAxis ? new Vector3(zeroPos.x, zeroPos.y + grid.runtimeHeight) : new Vector3(zeroPos.x + grid.runtimeWidth, zeroPos.y);
var sindex = 0;
var eindex = 0;
var sp = GetStartPos(points, ref sindex);
var ep = GetEndPos(points, ref eindex);
var sp = GetStartPos(points, ref sindex, serie.ignoreLineBreak);
var ep = GetEndPos(points, ref eindex, serie.ignoreLineBreak);
var cross = ChartHelper.GetIntersection(lp, np, zeroPos, aep);
if (cross == Vector3.zero || smoothDownPoints.Count <= 3)
{
@@ -1172,10 +1217,10 @@ namespace XCharts
switch (serie.lineType)
{
case LineType.Dash:
UGL.DrawDashLine(vh, lp, np, lineWidth, lineColor, 0, 0, posList);
UGL.DrawDashLine(vh, lp, np, lineWidth, lineColor, lineColor, 0, 0, posList);
break;
case LineType.Dot:
UGL.DrawDotLine(vh, lp, np, lineWidth, lineColor, 0, 0, posList);
UGL.DrawDotLine(vh, lp, np, lineWidth, lineColor, lineColor, 0, 0, posList);
break;
case LineType.DashDot:
UGL.DrawDashDotLine(vh, lp, np, lineWidth, lineColor, 0, 0, 0, posList);

View File

@@ -36,6 +36,7 @@ namespace XCharts
var highlight = serie.highlighted || serieData.highlighted;
var color = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
var toColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, colorIndex, highlight, false);
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
@@ -67,13 +68,13 @@ namespace XCharts
{
var nowSize = symbol.animationSize[count];
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, backgroundColor, symbol.gap, cornerRadius);
}
RefreshPainter(serie);
}
else
{
DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, backgroundColor, symbol.gap, cornerRadius);
}
}
if (!serie.animation.IsFinish())

View File

@@ -9,6 +9,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using XUGL;
using System.Collections.Generic;
namespace XCharts
{
@@ -20,6 +21,7 @@ namespace XCharts
private static readonly string s_AxisLabelObjectName = "axis_label";
private bool m_UpdateTitleText = false;
private bool m_UpdateLabelText = false;
private Dictionary<int, int> m_LastSplitNumber = new Dictionary<int, int>();
public DrawSerieGauge(BaseChart chart)
{
@@ -61,6 +63,21 @@ namespace XCharts
}
}
}
foreach (var serie in chart.series.list)
{
if (serie.type == SerieType.Gauge)
{
if (!m_LastSplitNumber.TryGetValue(serie.index, out var lastSplitNumber))
{
m_LastSplitNumber[serie.index] = lastSplitNumber;
}
else if (serie.splitNumber != lastSplitNumber)
{
m_LastSplitNumber[serie.index] = serie.splitNumber;
InitAxisLabel();
}
}
}
}
public void DrawBase(VertexHelper vh)

View File

@@ -413,6 +413,7 @@ namespace XCharts
private void DrawPieLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color)
{
if (serie.animation.enable && serie.animation.HasFadeOut()) return;
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
if (serieLabel.show
&& serieLabel.position == SerieLabel.Position.Outside
@@ -496,6 +497,7 @@ namespace XCharts
private void DrawPieLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
{
if (serieData.labelObject == null) return;
if (serie.animation.enable && serie.animation.HasFadeOut()) return;
var currAngle = serieData.runtimePieHalfAngle;
var isHighlight = (serieData.highlighted && serie.emphasis.label.show);
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);

View File

@@ -266,6 +266,8 @@ namespace XCharts
var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
}
if(chart.tooltip.gameObject != null)
chart.tooltip.gameObject.transform.SetSiblingIndex(chart.transform.childCount-1);
chart.RefreshBasePainter();
};
radar.refreshComponent.Invoke();
@@ -312,9 +314,9 @@ namespace XCharts
serieIndex = serieNameCount;
}
else if (!serieNameSet.ContainsKey(dataName))
{
serieNameSet.Add(dataName, serieNameCount);
{
serieNameCount++;
serieNameSet.Add(dataName, serieNameCount);
serieIndex = serieNameCount;
}
else
@@ -387,10 +389,11 @@ namespace XCharts
: serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
symbolToColor, serie.symbol.gap, cornerRadius);
symbolToColor, backgroundColor, serie.symbol.gap, cornerRadius);
}
}
}
@@ -439,6 +442,8 @@ namespace XCharts
var startPoint = Vector3.zero;
var toPoint = Vector3.zero;
var firstPoint = Vector3.zero;
var lastColor = ColorUtil.clearColor32;
var firstColor = ColorUtil.clearColor32;
var radar = chart.radars[serie.radarIndex];
var indicatorNum = radar.indicatorList.Count;
@@ -479,8 +484,8 @@ namespace XCharts
}
else if (!serieNameSet.ContainsKey(dataName))
{
serieNameSet.Add(dataName, serieNameCount);
serieNameCount++;
serieNameSet.Add(dataName, serieNameCount);
serieIndex = serieNameCount;
}
else
@@ -503,8 +508,10 @@ namespace XCharts
var value = serieData.GetCurrData(1, dataChangeDuration);
if (serieData.IsDataChanged()) dataChanging = true;
if (max == 0)
{
max = serie.runtimeDataMax;
if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
{
lineColor = radar.outRangeColor;
}
var radius = (float)(max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
: radar.runtimeDataRadius * value / max);
@@ -515,6 +522,8 @@ namespace XCharts
startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
p.y + radius * Mathf.Cos(currAngle));
firstPoint = startPoint;
lastColor = lineColor;
firstColor = lineColor;
}
else
{
@@ -526,22 +535,28 @@ namespace XCharts
}
if (serie.lineStyle.show)
{
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor,
chart.theme.serie.lineWidth, LineStyle.Type.Solid);
if (radar.connectCenter)
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, centerPos,
chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, chart.theme.serie.lineWidth,
LineStyle.Type.Solid, radar.lineGradient ? lastColor : lineColor, lineColor);
}
startPoint = toPoint;
lastColor = lineColor;
}
serieData.labelPosition = startPoint;
pointList.Add(startPoint);
if (serie.areaStyle.show && j == endIndex)
{
UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
}
if (serie.lineStyle.show && j == endIndex)
{
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor,
chart.theme.serie.lineWidth, LineStyle.Type.Solid);
if (radar.connectCenter)
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, centerPos,
chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, chart.theme.serie.lineWidth,
LineStyle.Type.Solid, lineColor, radar.lineGradient ? firstColor : lineColor);
}
}
if (serie.symbol.show && serie.symbol.type != SerieSymbolType.None)
@@ -558,10 +573,16 @@ namespace XCharts
: serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
{
symbolColor = radar.outRangeColor;
symbolToColor = radar.outRangeColor;
}
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.labelPosition, symbolColor,
symbolToColor, serie.symbol.gap, cornerRadius);
symbolToColor, backgroundColor, serie.symbol.gap, cornerRadius);
}
}
if (!serie.animation.IsFinish())
@@ -602,22 +623,19 @@ namespace XCharts
: serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
foreach (var point in pointList)
{
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
symbolToColor, serie.symbol.gap, cornerRadius);
symbolToColor, backgroundColor, serie.symbol.gap, cornerRadius);
}
}
}
private void DrawRadar(VertexHelper vh, Radar radar)
{
if (!radar.splitLine.show && !radar.splitArea.show)
{
return;
}
float insideRadius = 0, outsideRadius = 0;
float block = radar.runtimeRadius / radar.splitNumber;
int indicatorNum = radar.indicatorList.Count;
@@ -632,7 +650,6 @@ namespace XCharts
var splitLineType = radar.splitLine.GetType(chart.theme.radar.splitLineType);
for (int i = 0; i < radar.splitNumber; i++)
{
var isLast = i == radar.splitNumber - 1;
var color = radar.splitArea.GetColor(i, chart.theme.radar);
outsideRadius = insideRadius + block;
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0));
@@ -650,34 +667,27 @@ namespace XCharts
}
if (radar.splitLine.NeedShow(i))
{
if (isLast)
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p2, p3, lineColor);
else
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
}
p1 = p4;
p2 = p3;
}
insideRadius = outsideRadius;
}
for (int j = 0; j <= indicatorNum; j++)
if (radar.axisLine.show)
{
float currAngle = j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
if (radar.splitLine.show)
for (int j = 0; j <= indicatorNum; j++)
{
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p, p3, splitLineColor);
float currAngle = j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor);
}
}
}
private void DrawCricleRadar(VertexHelper vh, Radar radar)
{
if (!radar.splitLine.show && !radar.splitArea.show)
{
return;
}
float insideRadius = 0, outsideRadius = 0;
float block = radar.runtimeRadius / radar.splitNumber;
int indicatorNum = radar.indicatorList.Count;
@@ -685,7 +695,10 @@ namespace XCharts
Vector3 p1;
float angle = 2 * Mathf.PI / indicatorNum;
var lineColor = radar.axisLine.GetColor(chart.theme.radar.lineColor);
var lineWidth = radar.splitLine.GetWidth(chart.theme.radar.splitLineWidth);
var lineWidth = radar.axisLine.GetWidth(chart.theme.radar.lineWidth);
var lineType = radar.axisLine.GetType(chart.theme.radar.lineType);
var splitLineColor = radar.splitLine.GetColor(chart.theme.radar.splitLineColor);
var splitLineWidth = radar.splitLine.GetWidth(chart.theme.radar.splitLineWidth);
for (int i = 0; i < radar.splitNumber; i++)
{
var color = radar.splitArea.GetColor(i, chart.theme.radiusAxis);
@@ -697,19 +710,19 @@ namespace XCharts
}
if (radar.splitLine.show)
{
UGL.DrawEmptyCricle(vh, p, outsideRadius, lineWidth, lineColor,
UGL.DrawEmptyCricle(vh, p, outsideRadius, splitLineWidth, splitLineColor,
Color.clear, chart.settings.cicleSmoothness);
}
insideRadius = outsideRadius;
}
for (int j = 0; j <= indicatorNum; j++)
if (radar.axisLine.show)
{
float currAngle = j * angle;
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
if (radar.splitLine.show)
for (int j = 0; j <= indicatorNum; j++)
{
UGL.DrawLine(vh, p, p1, lineWidth / 2, lineColor);
float currAngle = j * angle;
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p1, lineColor);
}
}
}

View File

@@ -104,6 +104,14 @@ namespace XCharts
itemStyle.backgroundColor, Color.clear, 0, 360, borderWidth, borderColor, 0,
chart.settings.cicleSmoothness, false, serie.clockwise);
}
var isGradient = !UGLHelper.IsValueEqualsColor(itemColor, itemToColor);
if (isGradient)
{
if (serie.clockwise)
itemToColor = Color.Lerp(itemColor, itemToColor, toDegree / (startDegree + 360));
else
itemToColor = Color.Lerp(itemToColor, itemColor, toDegree / (startDegree + 360));
}
UGL.DrawDoughnut(vh, serie.runtimeCenterPos, insideRadius, outsideRadius, itemColor, itemToColor,
Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
roundCap, serie.clockwise);
@@ -128,7 +136,6 @@ namespace XCharts
public bool CheckTootipArea(Vector2 local)
{
if (!chart.series.Contains(SerieType.Ring)) return false;
if (!PointerIsInRingSerie(chart.series, local)) return false;
if (m_IsEnterLegendButtom) return false;
bool selected = false;
chart.tooltip.runtimeDataIndex.Clear();

View File

@@ -6,11 +6,13 @@
/* */
/************************************************/
using UnityEngine;
namespace XCharts
{
/// <summary>
/// The delegate function for AxisLabel's formatter. |
/// AxisLabel的formatter自定义委托。
/// AxisLabel的formatter自定义委托函数
/// </summary>
/// <param name="labelIndex">label索引</param>
/// <param name="value">当前label对应的数值数据Value轴或Time轴有效</param>
@@ -19,10 +21,16 @@ namespace XCharts
public delegate string DelegateAxisLabelFormatter(int labelIndex, double value, string category);
/// <summary>
/// The delegate function for SerieLabels formatter.
/// SerieLabel的formatter自定义委托。
/// SerieLabel的formatter自定义委托函数
/// </summary>
/// <param name="dataIndex">数据索引</param>
/// <param name="value">数值</param>
/// <returns>最终显示的文本内容</returns>
public delegate string DelegateSerieLabelFormatter(int dataIndex, double value);
/// <summary>
/// Tooltip的position自定义委托函数。
/// </summary>
/// <param name="pos">Tooltip的当前坐标</param>
/// <returns>Tooltip的最终坐标</returns>
public delegate Vector3 DelegateTooltipPosition(Vector3 pos);
}

View File

@@ -246,7 +246,12 @@ namespace XCharts
#if dUI_TextMeshPro
if (m_TMPText != null) return 0; // TODO:
#else
if (m_Text != null) return m_Text.cachedTextGenerator.GetPreferredWidth(content, m_RelatedTextSettings);
if (m_Text != null)
{
var tg = m_Text.cachedTextGeneratorForLayout;
var setting = m_Text.GetGenerationSettings(Vector2.zero);
return tg.GetPreferredWidth(content, setting) / m_Text.pixelsPerUnit;
}
#endif
return 0;
}
@@ -270,6 +275,30 @@ namespace XCharts
return 0;
}
public string GetPreferredText(string content, string suffix, float maxWidth)
{
#if dUI_TextMeshPro
if (m_TMPText != null) return content; // TODO:
#else
if (m_Text != null)
{
var sourWid = GetPreferredWidth(content);
if (sourWid < maxWidth) return content;
var suffixWid = GetPreferredWidth(suffix);
var textWid = maxWidth - 1.3f * suffixWid;
for (int i = content.Length; i > 0; i--)
{
var temp = content.Substring(0, i);
if (GetPreferredWidth(temp) < textWid)
{
return temp + suffix;
}
}
}
#endif
return string.Empty;
}
#if dUI_TextMeshPro
public void SetFont(TMP_FontAsset font)

View File

@@ -18,7 +18,7 @@ namespace XCharts
public static void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
Color32 backgroundColor, float smoothness, Vector3 startPos)
Color32 centerFillColor, Color32 backgroundColor, float smoothness, Vector3 startPos)
{
switch (type)
{
@@ -38,11 +38,11 @@ namespace XCharts
if (gap > 0)
{
UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, centerFillColor, smoothness);
}
else
{
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, centerFillColor, smoothness);
}
break;
case SerieSymbolType.Rect:
@@ -56,6 +56,17 @@ namespace XCharts
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
}
break;
case SerieSymbolType.EmptyRect:
if (gap > 0)
{
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
UGL.DrawBorder(vh, pos, symbolSize / 2, symbolSize / 2, tickness, color);
}
else
{
UGL.DrawBorder(vh, pos, symbolSize / 2, symbolSize / 2, tickness, color);
}
break;
case SerieSymbolType.Triangle:
if (gap > 0)
{
@@ -67,6 +78,19 @@ namespace XCharts
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
}
break;
case SerieSymbolType.EmptyTriangle:
if (gap > 0)
{
UGL.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
UGL.DrawTriangle(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
}
else
{
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
UGL.DrawTriangle(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
}
break;
case SerieSymbolType.Diamond:
if (gap > 0)
{
@@ -78,6 +102,19 @@ namespace XCharts
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
}
break;
case SerieSymbolType.EmptyDiamond:
if (gap > 0)
{
UGL.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
UGL.DrawDiamond(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
}
else
{
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
UGL.DrawDiamond(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
}
break;
case SerieSymbolType.Arrow:
var arrowWidth = symbolSize * 2;
var arrowHeight = arrowWidth * 1.5f;
@@ -89,28 +126,44 @@ namespace XCharts
}
}
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle,
Vector3 startPos, Vector3 endPos, Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, Vector3 startPos, Vector3 endPos,
Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
{
var type = lineStyle.GetType(themeType);
var width = lineStyle.GetWidth(themeWidth);
var color = lineStyle.GetColor(defaultColor);
DrawLineStyle(vh, type, width, startPos, endPos, color);
DrawLineStyle(vh, type, width, startPos, endPos, color, color);
}
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, Vector3 startPos, Vector3 endPos,
float themeWidth, LineStyle.Type themeType, Color32 defaultColor, Color32 defaultToColor)
{
var type = lineStyle.GetType(themeType);
var width = lineStyle.GetWidth(themeWidth);
var color = lineStyle.GetColor(defaultColor);
var toColor = ChartHelper.IsClearColor(defaultToColor) ? color : defaultToColor;
DrawLineStyle(vh, type, width, startPos, endPos, color, toColor);
}
public static void DrawLineStyle(VertexHelper vh, LineStyle.Type lineType, float lineWidth,
Vector3 startPos, Vector3 endPos, Color32 color)
{
DrawLineStyle(vh, lineType, lineWidth, startPos, endPos, color, color);
}
public static void DrawLineStyle(VertexHelper vh, LineStyle.Type lineType, float lineWidth,
Vector3 startPos, Vector3 endPos, Color32 color, Color32 toColor)
{
switch (lineType)
{
case LineStyle.Type.Dashed:
UGL.DrawDashLine(vh, startPos, endPos, lineWidth, color);
UGL.DrawDashLine(vh, startPos, endPos, lineWidth, color, toColor);
break;
case LineStyle.Type.Dotted:
UGL.DrawDotLine(vh, startPos, endPos, lineWidth, color);
UGL.DrawDotLine(vh, startPos, endPos, lineWidth, color, toColor);
break;
case LineStyle.Type.Solid:
UGL.DrawLine(vh, startPos, endPos, lineWidth, color);
UGL.DrawLine(vh, startPos, endPos, lineWidth, color, toColor);
break;
case LineStyle.Type.DashDot:
UGL.DrawDashDotLine(vh, startPos, endPos, lineWidth, color);

View File

@@ -510,11 +510,12 @@ namespace XCharts
: symbol.GetSize(serieData.data, m_Theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, n, highlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, n, highlight);
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, n, highlight, false);
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.runtimePosition, symbolColor,
symbolToColor, symbol.gap, cornerRadius);
symbolToColor, backgroundColor, symbol.gap, cornerRadius);
}
}
}

View File

@@ -33,8 +33,8 @@ namespace XCharts
[ExecuteInEditMode]
public class XChartsMgr : MonoBehaviour
{
internal static string _version = "2.3.0";
internal static int _versionDate = 20210724;
internal static string _version = "2.8.2";
internal static int _versionDate = 20220815;
public static string version { get { return _version; } }
public static int versionDate { get { return _versionDate; } }
public static string fullVersion { get { return version + "-" + versionDate; } }
@@ -57,7 +57,9 @@ namespace XCharts
{
var obj = GameObject.Find("_xcharts_");
if (obj == null) obj = new GameObject("_xcharts_");
obj.SetActive(false);
m_XCharts = obj.AddComponent<XChartsMgr>();
obj.SetActive(true);
}
m_XCharts.m_NowVersion = fullVersion;
}
@@ -279,7 +281,7 @@ namespace XCharts
public List<BaseChart> GetCharts(string chartName)
{
if (string.IsNullOrEmpty(chartName)) return null;
return m_ChartList.FindAll(chart => chartName.Equals(chartName));
return m_ChartList.FindAll(chart => chartName.Equals(chart.chartName));
}
public void RemoveChart(string chartName)
@@ -299,6 +301,33 @@ namespace XCharts
return m_ChartList.Contains(chart);
}
public bool IsRepeatChartName(BaseChart chart, string chartName = null)
{
if(chartName == null)
chartName = chart.chartName;
if (string.IsNullOrEmpty(chartName))
return false;
foreach (var temp in m_ChartList)
{
if (temp != chart && chartName.Equals(temp.chartName))
return true;
}
return false;
}
public string GetRepeatChartNameInfo(BaseChart chart, string chartName)
{
if (string.IsNullOrEmpty(chartName))
return string.Empty;
string result = "";
foreach (var temp in m_ChartList)
{
if (temp != chart && chartName.Equals(temp.chartName))
result += ChartHelper.GetFullName(temp.transform) + "\n";
}
return result;
}
public static void RemoveAllChartObject()
{
if (Instance.m_ChartList.Count == 0)
@@ -337,7 +366,7 @@ namespace XCharts
// Search for potential alternative locations in the user project
string[] matchingPaths = Directory.GetDirectories(packagePath, "XCharts", SearchOption.AllDirectories);
string path = ValidateLocation(matchingPaths, packagePath);
if (path != null) return packagePath + path;
if (path != null) return Path.Combine(packagePath, path);
}
return null;
@@ -487,4 +516,4 @@ namespace XCharts
}
#endif
}
}
}

View File

@@ -34,10 +34,14 @@ namespace XCharts
GUI.enabled = !m_EssentialResourcesImported;
if (GUILayout.Button("Import XCharts Essentials"))
{
AssetDatabase.importPackageCompleted += ImportCallback;
string packageFullPath = GetPackageFullPath();
AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/XCharts Essential Resources.unitypackage", false);
var sourPath = Path.Combine(packageFullPath, "Resources");
var destPath = Path.Combine(Application.dataPath, "XCharts/Resources");
if (CopyFolder(sourPath, destPath))
{
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}
GUILayout.Space(5f);
GUI.enabled = true;
@@ -45,35 +49,40 @@ namespace XCharts
GUILayout.EndVertical();
}
GUILayout.EndVertical();
GUILayout.BeginVertical();
{
GUILayout.BeginVertical(EditorStyles.helpBox);
{
GUILayout.Label("TextMeshPro", EditorStyles.boldLabel);
#if dUI_TextMeshPro
GUILayout.Label("TextMeshPro is now enabled. You can turn it off by clicking the button below.", new GUIStyle(EditorStyles.label) { wordWrap = true });
GUILayout.Space(5f);
if (GUILayout.Button("Disable TextMeshPro"))
{
XChartsMgr.DisableTextMeshPro();
}
#else
GUILayout.Label("TextMeshPro is not active. You can activate it by clicking the button below. Make sure TextMeshPro is already in your project before activating it.", new GUIStyle(EditorStyles.label) { wordWrap = true });
GUILayout.Space(5f);
if (GUILayout.Button("Enable TextMeshPro"))
{
XChartsMgr.EnableTextMeshPro();
}
#endif
GUILayout.Space(5f);
}
GUILayout.EndVertical();
}
GUILayout.EndVertical();
GUILayout.Space(5f);
}
private static bool CopyFolder(string sourPath, string destPath)
{
try
{
if (!Directory.Exists(destPath))
{
Directory.CreateDirectory(destPath);
}
var files = Directory.GetFiles(sourPath);
foreach (var file in files)
{
var name = Path.GetFileName(file);
var path = Path.Combine(destPath, name);
File.Copy(file, path);
}
var folders = Directory.GetDirectories(sourPath);
foreach (var folder in folders)
{
var name = Path.GetFileName(folder);
var path = Path.Combine(destPath, name);
CopyFolder(folder, path);
}
return true;
}
catch (Exception e)
{
Debug.LogError("CopyFolder:" + e.Message);
return false;
}
}
internal void RegisterResourceImportCallback()
{
AssetDatabase.importPackageCompleted += ImportCallback;

View File

@@ -34,7 +34,7 @@ namespace XUGL
/// <param name="dent">箭头凹度</param>
/// <param name="color">颜色</param>
public static void DrawArrow(VertexHelper vh, Vector3 startPoint, Vector3 arrowPoint, float width,
float height, float offset, float dent, Color32 color)
float height, float offset, float dent, Color32 color)
{
var dir = (arrowPoint - startPoint).normalized;
var sharpPos = arrowPoint + (offset + height / 4) * dir;
@@ -55,6 +55,20 @@ namespace XUGL
/// <param name="width">线宽</param>
/// <param name="color">颜色</param>
public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color)
{
DrawLine(vh, startPoint, endPoint, width, color, color);
}
/// <summary>
/// Draw a line. 画直线
/// </summary>
/// <param name="vh"></param>
/// <param name="startPoint">起点</param>
/// <param name="endPoint">终点</param>
/// <param name="width">线宽</param>
/// <param name="color">颜色</param>
/// <param name="toColor">渐变颜色</param>
public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color, Color32 toColor)
{
if (startPoint == endPoint) return;
Vector3 v = Vector3.Cross(endPoint - startPoint, Vector3.forward).normalized * width;
@@ -65,7 +79,7 @@ namespace XUGL
for (int j = 0; j < 4; j++)
{
s_Vertex[j].color = color;
s_Vertex[j].color = j == 0 || j == 3 ? color : toColor;
s_Vertex[j].uv0 = s_ZeroVector2;
}
vh.AddUIVertexQuad(s_Vertex);
@@ -119,12 +133,13 @@ namespace XUGL
/// <param name="startPoint">起始点</param>
/// <param name="endPoint">结束点</param>
/// <param name="width">线宽</param>
/// <param name="color">颜色</param>
/// <param name="color">起始颜色</param>
/// <param name="toColor">结束颜色</param>
/// <param name="lineLength">实线部分长度默认为线宽的12倍</param>
/// <param name="gapLength">间隙部分长度默认为线宽的3倍</param>
/// <param name="posList">可选,输出的关键点</param>
public static void DrawDashLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
Color32 color, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
Color32 color, Color32 toColor, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
{
float dist = Vector3.Distance(startPoint, endPoint);
if (dist < 0.1f) return;
@@ -133,17 +148,18 @@ namespace XUGL
int segment = Mathf.CeilToInt(dist / (lineLength + gapLength));
Vector3 dir = (endPoint - startPoint).normalized;
Vector3 sp = startPoint, np;
var isGradient = !color.Equals(toColor);
if (posList != null) posList.Clear();
for (int i = 1; i <= segment; i++)
{
if (posList != null) posList.Add(sp);
np = startPoint + dir * dist * i / segment;
var dashep = np - dir * gapLength;
DrawLine(vh, sp, dashep, width, color);
DrawLine(vh, sp, dashep, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / segment) : color);
sp = np;
}
if (posList != null) posList.Add(endPoint);
DrawLine(vh, sp, endPoint, width, color);
DrawLine(vh, sp, endPoint, width, toColor);
}
/// <summary>
@@ -153,31 +169,34 @@ namespace XUGL
/// <param name="startPoint">起始点</param>
/// <param name="endPoint">结束点</param>
/// <param name="width">线宽</param>
/// <param name="color">颜色</param>
/// <param name="color">起始颜色</param>
/// <param name="toColor">结束颜色</param>
/// <param name="lineLength">实线部分长度默认为线宽的3倍</param>
/// <param name="gapLength">间隙部分长度默认为线宽的3倍</param>
/// <param name="posList">可选,输出的关键点</param>
public static void DrawDotLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
Color32 color, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
Color32 color, Color32 toColor, float lineLength = 0f, float gapLength = 0f, List<Vector3> posList = null)
{
float dist = Vector3.Distance(startPoint, endPoint);
var dist = Vector3.Distance(startPoint, endPoint);
if (dist < 0.1f) return;
if (lineLength == 0) lineLength = 3 * width;
if (gapLength == 0) gapLength = 3 * width;
int segment = Mathf.CeilToInt(dist / (lineLength + gapLength));
Vector3 dir = (endPoint - startPoint).normalized;
Vector3 sp = startPoint, np;
var segment = Mathf.CeilToInt(dist / (lineLength + gapLength));
var dir = (endPoint - startPoint).normalized;
var sp = startPoint;
var np = Vector3.zero;
var isGradient = !color.Equals(toColor);
if (posList != null) posList.Clear();
for (int i = 1; i <= segment; i++)
{
if (posList != null) posList.Add(sp);
np = startPoint + dir * dist * i / segment;
var dashep = np - dir * gapLength;
DrawLine(vh, sp, dashep, width, color);
DrawLine(vh, sp, dashep, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / segment) : color);
sp = np;
}
if (posList != null) posList.Add(endPoint);
DrawLine(vh, sp, endPoint, width, color);
DrawLine(vh, sp, endPoint, width, toColor);
}
/// <summary>
@@ -277,11 +296,28 @@ namespace XUGL
/// <param name="width">线宽</param>
/// <param name="zebraWidth">斑马条纹宽</param>
/// <param name="zebraGap">间隙宽</param>
/// <param name="color">颜色</param>
/// <param name="color">起始颜色</param>
/// <param name="toColor">结束颜色</param>
public static void DrawZebraLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
float zebraWidth, float zebraGap, Color32 color)
float zebraWidth, float zebraGap, Color32 color, Color32 toColor, float maxDistance)
{
DrawDotLine(vh, startPoint, endPoint, width, color, zebraWidth, zebraGap);
var dist = Vector3.Distance(startPoint, endPoint);
if (dist < 0.1f) return;
if (zebraWidth == 0) zebraWidth = 3 * width;
if (zebraGap == 0) zebraGap = 3 * width;
var allSegment = Mathf.CeilToInt(maxDistance / (zebraWidth + zebraGap));
var segment = Mathf.CeilToInt(dist / maxDistance * allSegment);
var dir = (endPoint - startPoint).normalized;
var sp = startPoint;
var np = Vector3.zero;
var isGradient = !color.Equals(toColor);
zebraWidth = (maxDistance - zebraGap * (allSegment - 1)) / allSegment;
for (int i = 1; i <= segment; i++)
{
np = sp + dir * zebraWidth;
DrawLine(vh, sp, np, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / allSegment) : color);
sp = np + dir * zebraGap;
}
}
/// <summary>
@@ -399,7 +435,7 @@ namespace XUGL
/// <param name="color">颜色</param>
/// <param name="vertical">是否垂直方向</param>
public static void DrawRectangle(VertexHelper vh, Vector3 p, float xRadius, float yRadius,
Color32 color, bool vertical = true)
Color32 color, bool vertical = true)
{
DrawRectangle(vh, p, xRadius, yRadius, color, color, vertical);
}
@@ -436,6 +472,20 @@ namespace XUGL
DrawQuadrilateral(vh, p1, p2, p3, p4, color, toColor);
}
public static void DrawRectangle(VertexHelper vh, Rect rect, Color32 color)
{
DrawRectangle(vh, rect, 0, color);
}
public static void DrawRectangle(VertexHelper vh, Rect rect, float border, Color32 color)
{
DrawRectangle(vh, rect, border, color, color);
}
public static void DrawRectangle(VertexHelper vh, Rect rect, float border, Color32 color, Color32 toColor)
{
DrawRectangle(vh, rect.center, rect.width / 2 - border, rect.height / 2 - border, color, toColor, true);
}
/// <summary>
/// Draw a quadrilateral. 画任意的四边形
/// </summary>
@@ -477,13 +527,34 @@ namespace XUGL
}
private static void InitCornerRadius(float[] cornerRadius, float width, float height, bool horizontal,
ref float brLt, ref float brRt, ref float brRb, ref float brLb, ref bool needRound)
bool invert, ref float brLt, ref float brRt, ref float brRb, ref float brLb, ref bool needRound)
{
if (cornerRadius == null) return;
brLt = cornerRadius.Length > 0 ? cornerRadius[0] : 0;
brRt = cornerRadius.Length > 1 ? cornerRadius[1] : 0;
brRb = cornerRadius.Length > 2 ? cornerRadius[2] : 0;
brLb = cornerRadius.Length > 3 ? cornerRadius[3] : 0;
if (invert)
{
if (horizontal)
{
brLt = cornerRadius.Length > 0 ? cornerRadius[1] : 0;
brRt = cornerRadius.Length > 1 ? cornerRadius[0] : 0;
brRb = cornerRadius.Length > 2 ? cornerRadius[3] : 0;
brLb = cornerRadius.Length > 3 ? cornerRadius[2] : 0;
}
else
{
brLt = cornerRadius.Length > 0 ? cornerRadius[3] : 0;
brRt = cornerRadius.Length > 1 ? cornerRadius[2] : 0;
brRb = cornerRadius.Length > 2 ? cornerRadius[1] : 0;
brLb = cornerRadius.Length > 3 ? cornerRadius[0] : 0;
}
}
else
{
brLt = cornerRadius.Length > 0 ? cornerRadius[0] : 0;
brRt = cornerRadius.Length > 1 ? cornerRadius[1] : 0;
brRb = cornerRadius.Length > 2 ? cornerRadius[2] : 0;
brLb = cornerRadius.Length > 3 ? cornerRadius[3] : 0;
}
needRound = brLb != 0 || brRt != 0 || brRb != 0 || brLb != 0;
if (needRound)
{
@@ -562,18 +633,22 @@ namespace XUGL
/// <param name="rectWidth"></param>
/// <param name="rectHeight"></param>
/// <param name="color"></param>
/// <param name="toColor"></param>
/// <param name="rotate"></param>
/// <param name="cornerRadius"></param>
/// <param name="isYAxis"></param>
/// <param name="smoothness"></param>
/// <param name="invertCorner"></param>
public static void DrawRoundRectangle(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null, bool isYAxis = false,
float smoothness = 2)
float smoothness = 2, bool invertCorner = false)
{
var isGradient = !UGLHelper.IsValueEqualsColor(color, toColor);
var halfWid = rectWidth / 2;
var halfHig = rectHeight / 2;
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
bool needRound = false;
InitCornerRadius(cornerRadius, rectWidth, rectHeight, isYAxis, ref brLt, ref brRt, ref brRb,
InitCornerRadius(cornerRadius, rectWidth, rectHeight, isYAxis, invertCorner, ref brLt, ref brRt, ref brRb,
ref brLb, ref needRound);
var tempCenter = Vector3.zero;
var lbIn = new Vector3(center.x - halfWid, center.y - halfHig);
@@ -805,12 +880,33 @@ namespace XUGL
/// <param name="color"></param>
/// <param name="rotate"></param>
/// <param name="cornerRadius"></param>
/// <param name="invertCorner"></param>
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
float borderWidth, Color32 color, float rotate = 0, float[] cornerRadius = null,
bool horizontal = false, float smoothness = 1f)
bool horizontal = false, float smoothness = 1f, bool invertCorner = false)
{
DrawBorder(vh, center, rectWidth, rectHeight, borderWidth, color, s_ClearColor32, rotate,
cornerRadius, horizontal, smoothness);
cornerRadius, horizontal, smoothness, invertCorner);
}
/// <summary>
/// 绘制(圆角)边框
/// </summary>
/// <param name="vh"></param>
/// <param name="rect"></param>
/// <param name="borderWidth"></param>
/// <param name="color"></param>
/// <param name="rotate"></param>
/// <param name="cornerRadius"></param>
/// <param name="horizontal"></param>
/// <param name="smoothness"></param>
/// <param name="invertCorner"></param>
public static void DrawBorder(VertexHelper vh, Rect rect,
float borderWidth, Color32 color, float rotate = 0, float[] cornerRadius = null,
bool horizontal = false, float smoothness = 1f, bool invertCorner = false)
{
DrawBorder(vh, rect.center, rect.width, rect.height, borderWidth, color, s_ClearColor32, rotate,
cornerRadius, horizontal, smoothness, invertCorner);
}
/// <summary>
@@ -825,9 +921,12 @@ namespace XUGL
/// <param name="toColor"></param>
/// <param name="rotate"></param>
/// <param name="cornerRadius"></param>
/// <param name="horizontal"></param>
/// <param name="smoothness"></param>
/// <param name="invertCorner"></param>
public static void DrawBorder(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
float borderWidth, Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null,
bool horizontal = false, float smoothness = 1f)
bool horizontal = false, float smoothness = 1f, bool invertCorner = false)
{
if (borderWidth == 0 || UGLHelper.IsClearColor(color)) return;
var halfWid = rectWidth / 2;
@@ -842,7 +941,7 @@ namespace XUGL
var rbOt = new Vector3(center.x + halfWid + borderWidth, center.y - halfHig - borderWidth);
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
bool needRound = false;
InitCornerRadius(cornerRadius, rectWidth, rectHeight, horizontal, ref brLt, ref brRt, ref brRb,
InitCornerRadius(cornerRadius, rectWidth, rectHeight, horizontal, invertCorner, ref brLt, ref brRt, ref brRb,
ref brLb, ref needRound);
var tempCenter = Vector3.zero;
if (UGLHelper.IsClearColor(toColor))
@@ -964,7 +1063,7 @@ namespace XUGL
}
public static void DrawTriangle(VertexHelper vh, Vector3 p1,
Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3)
Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3)
{
UIVertex v1 = new UIVertex();
v1.position = p1;
@@ -992,7 +1091,7 @@ namespace XUGL
}
public static void DrawCricle(VertexHelper vh, Vector3 center, float radius, Color32 color,
Color32 toColor, float smoothness = 2f)
Color32 toColor, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, toColor, 0, 360, 0, s_ClearColor32, smoothness);
}
@@ -1039,13 +1138,13 @@ namespace XUGL
}
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color,
float startDegree, float toDegree, float smoothness = 2f)
float startDegree, float toDegree, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, color, startDegree, toDegree, 0, s_ClearColor32, smoothness);
}
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, Color32 toColor,
float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f)
float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, toColor, startDegree, toDegree, 0, s_ClearColor32, 0, smoothness,
gradientType, isYAxis);
@@ -1084,10 +1183,11 @@ namespace XUGL
float smoothness, int gradientType = 0, bool isYAxis = false)
{
if (radius == 0) return;
if (space > 0 && Mathf.Abs(toDegree - startDegree) >= 360) space = 0;
var isCircle = Mathf.Abs(toDegree - startDegree) >= 360;
if (space > 0 && isCircle) space = 0;
radius -= borderWidth;
smoothness = (smoothness < 0 ? 2f : smoothness);
int segments = (int)((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
int segments = (int) ((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
if (segments < 1) segments = 1;
float startAngle = startDegree * Mathf.Deg2Rad;
float toAngle = toDegree * Mathf.Deg2Rad;
@@ -1124,7 +1224,7 @@ namespace XUGL
if (realToAngle < realStartAngle) realToAngle = realStartAngle;
p2 = UGLHelper.GetPos(center, radius, realStartAngle);
}
if (needBorder)
if (needBorder && !isCircle)
{
borderDiff = borderLineWidth / Mathf.Sin(halfAngle);
realCenter += borderDiff * middleDire;
@@ -1160,9 +1260,9 @@ namespace XUGL
{
p4 = new Vector3(p3.x, realCenter.y);
var dist = p4.x - realCenter.x;
var tcolor = Color32.Lerp(color, toColor, dist >= 0
? dist / radius
: Mathf.Min(radius + dist, radius) / radius);
var tcolor = Color32.Lerp(color, toColor, dist >= 0 ?
dist / radius :
Mathf.Min(radius + dist, radius) / radius);
if (isLeft && (i == segments || i == 0)) tcolor = toColor;
DrawQuadrilateral(vh, lastP4, p2, p3, p4, lastColor, tcolor);
lastP4 = p4;
@@ -1275,11 +1375,12 @@ namespace XUGL
insideRadius += borderWidth;
smoothness = smoothness < 0 ? 2f : smoothness;
Vector3 p1, p2, p3, p4, e1, e2;
var isCircle = Mathf.Abs(toDegree - startDegree) >= 360;
var needBorder = borderWidth != 0;
var needSpace = space != 0;
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
int segments = (int)((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
int segments = (int) ((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
if (segments < 1) segments = 1;
float startAngle = startDegree * Mathf.Deg2Rad;
float toAngle = toDegree * Mathf.Deg2Rad;
@@ -1342,7 +1443,7 @@ namespace XUGL
p2 = UGLHelper.GetPos(center, outsideRadius, realStartOutAngle, false);
e2 = UGLHelper.GetPos(center, outsideRadius, realToOutAngle, false);
}
if (needBorder)
if (needBorder && !isCircle)
{
var borderDiff = borderWidth / Mathf.Sin(halfAngle);
realCenter += Mathf.Abs(borderDiff) * middleDire;
@@ -1525,7 +1626,7 @@ namespace XUGL
float lineWidth, Color32 lineColor, float smoothness)
{
var dist = Vector3.Distance(sp, ep);
var segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness));
var segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
UGLHelper.GetBezierList2(ref s_CurvesPosList, sp, ep, segment, cp1, cp2);
if (s_CurvesPosList.Count > 1)
{
@@ -1549,4 +1650,4 @@ namespace XUGL
}
}
}
}
}

View File

@@ -1,9 +1,9 @@
{
"name": "com.monitor1394.xcharts",
"displayName": "XCharts",
"version": "2.3.0",
"date": "20210724",
"checkdate": "20210724",
"version": "2.8.2",
"date": "20220815",
"checkdate": "20220815",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"unity": "2018.3",
"description": "A charting and data visualization library for Unity.",

View File

@@ -1,7 +1,7 @@
{
"version": "2.3.0",
"date": "20210724",
"checkdate": "20210724",
"version": "2.8.2",
"date": "20220815",
"checkdate": "20220815",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
}

View File

@@ -1,9 +1,9 @@
# Get start with XCharts in 5 minute
[Return homepage](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
[XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-api-EN.md)
[XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
[XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
[XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-api-EN.md)
[XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
## Installing XCharts
@@ -116,9 +116,9 @@ See the complete code in `Examples``Example13_LineSimple.cs`
You can also use the code to control more parameters. There are many more examples under `Examples`. All parameters in [XCharts Configuration](xcharts-configuration-EN.md) or `Inspector` can be controlled by code.
In addition, unless customized, it is recommended to call the interfaces in the [XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-api-EN.md), which do some internal correlation processing, such as refreshing the chart, etc. If you call the interface of an internal component, you'll need to handle other issues like refresh yourself.
In addition, unless customized, it is recommended to call the interfaces in the [XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-api-EN.md), which do some internal correlation processing, such as refreshing the chart, etc. If you call the interface of an internal component, you'll need to handle other issues like refresh yourself.
[Return homepage](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
[XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-api-EN.md)
[XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-configuration-EN.md)
[XCharts Q&A](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md)
[XCharts API](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-api-EN.md)
[XCharts Configuration](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/xcharts-configuration-EN.md)

View File

@@ -1,9 +1,9 @@
# 教程5分钟上手XCharts
# 教程5分钟上手 XCharts 2.0
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md)
[XChartsAPI接口](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XChartsAPI.md)
[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts配置项手册.md)
[XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts问答.md)
[XChartsAPI接口](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XChartsAPI.md)
[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts配置项手册.md)
## 获取和引入 XCharts
@@ -121,7 +121,7 @@ for (int i = 0; i < 10; i++)
你还可以用代码控制更多的参数,`Examples`下还有更多的其他例子,凡是`Inspector`上看到的可配置的参数,都可以通过代码来设置。[XCharts配置项手册](XCharts配置项手册.md)里面的所有参数都是可以通过代码控制的。
另外,除非定制,建议调用[XChartsAPI接口](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XChartsAPI.md) 里面的接口,这些接口内部会做一些关联处理,比如刷新图表等。如果自己调用了内部组件的接口,需要自己处理刷新等其他问题。
另外,除非定制,建议调用[XChartsAPI接口](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XChartsAPI.md) 里面的接口,这些接口内部会做一些关联处理,比如刷新图表等。如果自己调用了内部组件的接口,需要自己处理刷新等其他问题。
## 使用TextMeshPro
@@ -172,6 +172,6 @@ serieData.itemStyle.color = Color.blue;
```
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md)
[XChartsAPI接口](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XChartsAPI.md)
[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts配置项手册.md)
[XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts问答.md)
[XChartsAPI接口](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XChartsAPI.md)
[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts配置项手册.md)

View File

@@ -9,15 +9,15 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 0}
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier: UnityEditor:UnityEditor.PackageManager.UI:PackageManagerProjectSettings
m_EditorClassIdentifier:
m_ScopedRegistriesSettingsExpanded: 1
oneTimeWarningShown: 0
m_Registries:
- m_Id: main
m_Name:
m_Url: https://packages.unity.cn
m_Url: https://packages.unity.com
m_Scopes: []
m_IsDefault: 1
m_UserSelectedRegistryName:

View File

@@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.13f1c1
m_EditorVersionWithRevision: 2019.4.13f1c1 (ddecf0c37a3b)
m_EditorVersion: 2019.4.39f1
m_EditorVersionWithRevision: 2019.4.39f1 (78d14dfa024b)

View File

@@ -12,7 +12,7 @@
<a href="Assets/XCharts/README.md">English Doc</a>
</p>
<p align="center">
<a href="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/LICENSE">
<a href="https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/LICENSE">
<img src="https://img.shields.io/github/license/monitor1394/unity-ugui-XCharts">
</a>
<a href="https://github.com/monitor1394/unity-ugui-XCharts/releases">
@@ -45,11 +45,11 @@
一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图、仪表盘、环形图、极坐标、水位图、K线图等常见图表。
[XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md)
[XChartsAPI手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XChartsAPI.md)
[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts配置项手册.md)
[XCharts更新日志](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG.md)
[教程5分钟上手XCharts](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/教程5分钟上手XCharts.md)
[XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts问答.md)
[XChartsAPI手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XChartsAPI.md)
[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts配置项手册.md)
[XCharts更新日志](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/CHANGELOG.md)
[教程5分钟上手 XCharts 2.0](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/教程5分钟上手XCharts.md)
## XCharts 2.0
@@ -182,25 +182,25 @@ XCharts的图表由组件和数据组成。不同的组件和数据可以组合
* 在Editor上快速创建一个图表
1. 在`Hierarchy`试图下右键或菜单栏`GameObject`下拉:`XCharts->LineChart`,即可快速创建一个简单的折线图出来。
2. `Inspector` 视图下可以调整各个组件的参数,`Game` 视图会实时反馈调整的效果。各个组件的详细参数说明可查阅[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts配置项手册.md)。
2. `Inspector` 视图下可以调整各个组件的参数,`Game` 视图会实时反馈调整的效果。各个组件的详细参数说明可查阅[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts配置项手册.md)。
* 更多的代码动态控制的例子请参考[教程5分钟上手XCharts](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/教程5分钟上手XCharts.md) 。
* 更多的代码动态控制的例子请参考[教程5分钟上手XCharts](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/教程5分钟上手XCharts.md) 。
## 文档
* 常见问题看这里☞ [XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md)
* 接口文档看这里☞ [XChartsAPI手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XChartsAPI.md)
* 参数配置看这里☞ [XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts配置项手册.md)
* 更新日志看这里☞ [XCharts更新日志](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG.md)
* 新手教程看这里☞ [教程5分钟上手XCharts](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/教程5分钟上手XCharts.md)
* 常见问题看这里☞ [XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts问答.md)
* 接口文档看这里☞ [XChartsAPI手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XChartsAPI.md)
* 参数配置看这里☞ [XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Documentation/XCharts配置项手册.md)
* 更新日志看这里☞ [XCharts更新日志](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/CHANGELOG.md)
* 新手教程看这里☞ [教程5分钟上手XCharts](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Doc/教程5分钟上手XCharts.md)
## 日志
[更新日志](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/CHANGELOG.md)
[更新日志](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/CHANGELOG.md)
## Licenses
[MIT License](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/LICENSE.md)
[MIT License](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/LICENSE.md)
## 其他