mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 19:50:10 +00:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7ac0277a7 | ||
|
|
3f36c27384 | ||
|
|
e4da5e30dc | ||
|
|
bfa68fd037 | ||
|
|
c002ac071b | ||
|
|
5c2ea52118 | ||
|
|
0e25a23ed2 | ||
|
|
41a9606bee | ||
|
|
6f6248be77 | ||
|
|
2b5275b15d | ||
|
|
ca26fd7c21 | ||
|
|
a2e790561e | ||
|
|
f0e94d35b6 | ||
|
|
76f640f64d | ||
|
|
9d8dc80494 | ||
|
|
bc1d2ac095 | ||
|
|
913c8e1fb2 | ||
|
|
634bb45dc4 | ||
|
|
e4827ac262 | ||
|
|
9ad8a86ffc | ||
|
|
23a8ce52d1 | ||
|
|
38584f618b | ||
|
|
84c47e0d84 | ||
|
|
7ff1405de5 | ||
|
|
acae09bf28 | ||
|
|
b304bd2033 | ||
|
|
72c29235d8 | ||
|
|
5f18f060e3 | ||
|
|
a281028a22 | ||
|
|
fe702f3447 | ||
|
|
6888ba96e3 | ||
|
|
b261ef0573 | ||
|
|
64d0b047b3 | ||
|
|
5c395ade25 | ||
|
|
5149376806 | ||
|
|
d8f739cbdf | ||
|
|
71fb45af9f | ||
|
|
ca63d041b9 | ||
|
|
8fccfdb5fc | ||
|
|
f08ae794ae | ||
|
|
8efa8145b1 | ||
|
|
e247ad9e71 | ||
|
|
645506a6fd | ||
|
|
c5ef7e765b | ||
|
|
3949018555 | ||
|
|
34b0a97198 | ||
|
|
de3e482687 | ||
|
|
8dbbbd7405 | ||
|
|
3316fce8a5 | ||
|
|
f85f96a560 | ||
|
|
8f6f5790b6 |
@@ -1,7 +1,11 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
[master](#master)
|
||||
[branch-2.0](#branch-2.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 +41,64 @@
|
||||
[v0.5.0](#v0.5.0)
|
||||
[v0.1.0](#v0.1.0)
|
||||
|
||||
## master
|
||||
## branch-2.0
|
||||
|
||||
## 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 +267,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
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
[master](#master)
|
||||
[branch-2.0](#branch-2.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 +41,64 @@
|
||||
[v0.5.0](#v0.5.0)
|
||||
[v0.1.0](#v0.1.0)
|
||||
|
||||
## master
|
||||
## branch-2.0
|
||||
|
||||
## 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 +269,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
|
||||
|
||||
@@ -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`
|
||||
|
||||
|
||||
@@ -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`下,由于旧版本可能不存在某些新版本才有的图表或者属性配置,可能会编译错误,需要处理按3,4步骤处理一下。
|
||||
2. 先不升级`XCharts`,只下载或拷贝脚本[UpgradeChartColor.cs](https://github.com/monitor1394/unity-ugui-XCharts/blob/2.0/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)放到旧项目的`Editor`下,由于旧版本可能不存在某些新版本才有的图表或者属性配置,可能会编译错误,需要处理按3,4步骤处理一下。
|
||||
3. 若是由`itemStyle.toColor2`引起的编译报错,可将导出地方的`itemStyle.toColor2`改为`Color.clear`;导入的地方注释掉即可。
|
||||
4. 若是由`LiquidChart`引起的编译报错,将所有涉及`LiquidChart`的地方都注释掉即可。
|
||||
5. 编译通过后,通过`菜单栏->XCharts->ExportColorConfig`导出旧版本的颜色配置文件(配置文件默认保存到`Assets`下的`color.config`)。
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace XCharts
|
||||
PropertyField(prop, "m_DataChangeEnable");
|
||||
PropertyField(prop, "m_DataChangeDuration");
|
||||
PropertyField(prop, "m_ActualDuration");
|
||||
PropertyField(prop, "m_AlongWithLinePath");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Cheat Sheet
|
||||
|
||||

|
||||

|
||||
|
||||
`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
|
||||
|
||||
|
||||
@@ -543,7 +543,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 +643,9 @@ namespace XCharts
|
||||
{
|
||||
m_Theme.CopyTheme(theme);
|
||||
SetAllComponentDirty();
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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}。
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,9 @@ 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 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 +1258,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 +1277,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 +1296,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 +1315,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 +1334,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 +1351,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 +1368,7 @@ namespace XCharts
|
||||
RemoveData(0);
|
||||
}
|
||||
m_Data.Clear();
|
||||
m_NeedUpdateFilterData = true;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
@@ -1389,6 +1402,7 @@ namespace XCharts
|
||||
m_DownSmoothPoints.Remove(serieData.index);
|
||||
}
|
||||
m_Data.RemoveAt(index);
|
||||
m_NeedUpdateFilterData = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1417,6 +1431,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 +1532,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 +1674,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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -48,7 +48,10 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 自定义标记。
|
||||
/// </summary>
|
||||
Custom
|
||||
Custom,
|
||||
EmptyRect,
|
||||
EmptyTriangle,
|
||||
EmptyDiamond
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -690,7 +710,6 @@ namespace XCharts
|
||||
});
|
||||
break;
|
||||
case SerieDataSortType.None:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +224,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 +453,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) =>
|
||||
@@ -526,23 +529,26 @@ namespace XCharts
|
||||
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 +570,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()
|
||||
@@ -1011,17 +1023,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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -387,10 +387,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 +440,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;
|
||||
@@ -503,8 +506,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 +520,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 +533,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 +571,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 +621,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 +648,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 +665,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 +693,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 +708,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 SerieLabel‘s 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);
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.7.0";
|
||||
internal static int _versionDate = 20220320;
|
||||
public static string version { get { return _version; } }
|
||||
public static int versionDate { get { return _versionDate; } }
|
||||
public static string fullVersion { get { return version + "-" + versionDate; } }
|
||||
@@ -279,7 +279,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 +299,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 +364,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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
@@ -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))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "com.monitor1394.xcharts",
|
||||
"displayName": "XCharts",
|
||||
"version": "2.3.0",
|
||||
"date": "20210724",
|
||||
"checkdate": "20210724",
|
||||
"version": "2.7.0",
|
||||
"date": "20220320",
|
||||
"checkdate": "20220320",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"unity": "2018.3",
|
||||
"description": "A charting and data visualization library for Unity.",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "2.3.0",
|
||||
"date": "20210724",
|
||||
"checkdate": "20210724",
|
||||
"version": "2.7.0",
|
||||
"date": "20220320",
|
||||
"checkdate": "20220320",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
30
README.md
30
README.md
@@ -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)
|
||||
|
||||
## 其他
|
||||
|
||||
|
||||
Reference in New Issue
Block a user