Compare commits

...

135 Commits

Author SHA1 Message Date
monitor1394
1a0412a984 发布v1.4.0版本 2020-04-11 22:44:50 +08:00
monitor1394
0dde0217f9 整理代码 2020-04-11 20:41:39 +08:00
monitor1394
cc0187291e 增加Check warning检测功能 2020-04-11 15:18:34 +08:00
monitor1394
90f5c1ef8a 优化Legend初始化,防止出现预设下删除异常的问题 2020-04-10 07:32:59 +08:00
monitor1394
b3e9e8833c 优化版本检测 2020-04-09 08:02:46 +08:00
monitor1394
772701a549 修复Legend初始化异常的问题 2020-04-09 07:26:40 +08:00
monitor1394
bef00f18e1 修复仪表盘绘制异常的问题 2020-04-08 12:59:35 +08:00
monitor1394
72cf428bd9 增加饼图边框相关demo 2020-04-08 09:04:39 +08:00
monitor1394
e64486079d 增加PieChart通过ItemStyle设置边框的支持 2020-04-08 09:02:46 +08:00
monitor1394
9a295d674f 增加AxisceilRate设置最大最小值的取整倍率 2020-03-29 15:46:01 +08:00
monitor1394
af8127ef2c 增加圆角柱图 2020-03-29 11:14:34 +08:00
monitor1394
0d63c23493 增加itemStylecornerRadius支持圆角矩形 2020-03-29 10:57:59 +08:00
monitor1394
4c2a5a76ce 优化Editor参数编辑,兼容Unity2019.3及以上版本 2020-03-26 09:13:46 +08:00
monitor1394
99d78549c2 更新Demo 2020-03-24 09:08:31 +08:00
monitor1394
ca1e6957a8 增加Serieinspector上可进行调整顺序、添加和删除操作 2020-03-24 09:08:14 +08:00
monitor1394
25941d2050 修复TitletextStylesubTextStyle无效的问题 2020-03-23 07:58:09 +08:00
monitor1394
0d361555f3 增加BarChart通过barType参数设置胶囊柱状图 2020-03-22 22:50:35 +08:00
monitor1394
d50db7b16c 整理代码,去除warning 2020-03-22 08:45:05 +08:00
monitor1394
27c2c88e26 增加BarChartHeatmapChart可通过ignore参数设置忽略数据的支持 2020-03-21 22:01:47 +08:00
monitor1394
46ecdf430e 更新Demo 2020-03-21 11:28:23 +08:00
monitor1394
0e22dcbcdb 增加ItemStyletooltipFormatter参数可单独配置SerieTooltip显示 2020-03-21 11:26:50 +08:00
monitor1394
a0f20f696e 修复X Axis 1Y Axis 1配置变更时不会自动刷新的问题 2020-03-20 08:59:39 +08:00
monitor1394
541bc421b7 增加AxisTickwidth参数可单独设置坐标轴刻度的宽度 2020-03-20 08:47:34 +08:00
monitor1394
a1018801d4 增加SerieradarType参数设置多圈单圈雷达图 2020-03-20 08:31:22 +08:00
monitor1394
2a3d8dc5b2 增加BarChart可用ItemStylebackgroundColor设置柱条背景颜色 2020-03-17 09:13:55 +08:00
monitor1394
b6c206c299 增加SerieDataItemStyleEmphasis可单独配置数据项样式的支持 2020-03-17 08:37:48 +08:00
monitor1394
cc065edb0f 发布v1.3.1版本 2020-03-14 18:26:20 +08:00
monitor1394
2db035a9e1 修复LineChart开启ingore时部分数据可能绘制异常的问题 2020-03-14 11:52:22 +08:00
monitor1394
78c76878d3 修复LineChartlabel偏移显示异常的问题 2020-03-13 08:37:11 +08:00
monitor1394
f130c8378a 发布v1.3.0版本 2020-03-11 22:04:40 +08:00
monitor1394
43c323153c 优化LineChartlabel偏移显示 2020-03-11 21:53:45 +08:00
monitor1394
64636b1f0f 优化清空并重新添加数据后的自动刷新问题 2020-03-11 08:41:42 +08:00
monitor1394
c42a46b1a9 增加LineChart的普通折线图可通过ignore参数设置忽略数据的支持 2020-03-10 12:35:19 +08:00
monitor1394
11f639ba8d 增加LineChart的普通折线图可通过设置ingore参数过滤数据的支持 2020-03-10 09:15:55 +08:00
monitor1394
7c0534098a 增加LineChart的普通折线图可通过设置ingore参数过滤数据的支持 2020-03-10 09:12:47 +08:00
monitor1394
9118fdb660 增加BarChart可通过ItemStyle配置边框的支持 2020-03-09 22:10:48 +08:00
monitor1394
1cf107f47b 增加RingChart环形图 2020-03-08 10:47:48 +08:00
monitor1394
16f7781e49 调整SeriearcShaped参数重命名为roundCap 2020-03-06 07:09:15 +08:00
monitor1394
ca5839576a 增加运行时和非运行时参数变更自动刷新图表 2020-03-05 20:25:19 +08:00
monitor1394
3ef5f9653a Merge branch 'master' of https://github.com/monitor1394/unity-ugui-XCharts 2020-03-02 18:00:05 +08:00
monitor1394
d6df474182 适配Unity2019版本 2020-03-02 17:59:57 +08:00
monitor1394
5cf7b5d571 重构Legend图例,改变样式,增加自定义图标等设置 2020-02-26 22:52:57 +08:00
monitor1394
8c1cc28776 修复快速添加的图表不响应事件的问题 2020-02-23 14:15:06 +08:00
monitor1394
d4426776b7 渐出动画 2020-02-23 11:17:46 +08:00
monitor1394
2468393f14 增加BaseChart.AnimationFadeOut()渐入动画,重构动画系统 2020-02-23 11:06:16 +08:00
monitor1394
70a303cb12 增加TextStylelineSpacing参数配置行间距 2020-02-13 09:23:30 +08:00
monitor1394
e5f136c954 增加RadarsplitLine参数配置分割线,去掉lineStyle参数 2020-02-12 19:13:44 +08:00
monitor1394
dd72e773e7 new feature 2020-02-11 21:33:58 +08:00
monitor1394
8459bccb1e 增加TooltipbackgroundImage参数配置背景图 2020-02-11 21:30:20 +08:00
monitor1394
c73e1d6e3f 增加TooltippaddingLeftRightpaddingTopBottom参数配置文字和边框的间距 2020-02-11 21:01:01 +08:00
monitor1394
695c2fe311 增加TooltiplineStyle参数配置指示线样式 2020-02-11 20:37:48 +08:00
monitor1394
29598de9b7 增加AxissplitLine参数控制分割线 2020-02-11 20:37:34 +08:00
monitor1394
d60ae1a5cf 增加Serieclip参数控制是否超出坐标系外裁剪 2020-02-10 18:30:05 +08:00
monitor1394
5443e4931a 修复报错 2020-02-08 15:16:28 +08:00
monitor1394
3cee08c434 newfeature 2020-02-08 14:51:31 +08:00
monitor1394
5246d59173 更新demo 2020-02-08 14:51:23 +08:00
monitor1394
5b923f9990 更新文档 2020-02-08 14:14:39 +08:00
monitor1394
c458d4c27c 优化TextLimit文本长度自适应 2020-02-08 14:14:24 +08:00
monitor1394
49ed5ac153 增加SerieSymbolgap参数控制图形标记的外留白距离 2020-02-08 14:13:45 +08:00
monitor1394
616d63a4de 增加TextLimit组件可以设置AxisLabel的文本自适应 2020-01-26 22:34:57 +08:00
monitor1394
8043b116a2 优化Tooltip设置itemFormatter时显示系列颜色 2020-01-20 19:25:08 +08:00
monitor1394
8b7955f498 增加Radar雷达图在inspector配置areaStyle的支持 2020-01-20 19:13:49 +08:00
monitor1394
ce11222784 发布v1.2.0版本 2020-01-15 22:05:53 +08:00
monitor1394
87059b2e7f newfeature 2020-01-15 22:02:32 +08:00
monitor1394
4e7bcceda3 增加AxisLabel格式化为整数的支持 2020-01-15 19:49:09 +08:00
monitor1394
c4f95d3c4f 增加折线图对数轴Log的支持 2020-01-15 19:41:21 +08:00
monitor1394
892b84829d 优化Demo 2020-01-09 21:49:02 +08:00
monitor1394
519063e5e0 修复当设置DataZoomminShowNum时可能异常的问题 2020-01-09 19:30:15 +08:00
monitor1394
9dea742254 修复当设置AxisLineonZero时刻度显示异常的问题 2020-01-08 19:33:30 +08:00
monitor1394
5b9652e48d 增加Mask遮罩遮挡支持 2020-01-08 19:05:56 +08:00
monitor1394
02915db85b 更新版本日期 2019-12-21 20:17:59 +08:00
monitor1394
db36d68788 增加Tooltip的单个数据项和标题的字符串模版格式器 2019-12-21 20:12:27 +08:00
monitor1394
0dbc2e1c5c 增加DataZoom的最小显示数据个数minShowNum 2019-12-21 20:00:58 +08:00
monitor1394
4c27359cc0 更新最新版本日期 2019-12-20 09:19:20 +08:00
monitor1394
44ebca4a39 更新雷达图API接口 2019-12-20 09:18:05 +08:00
monitor1394
c7272f1817 增加Demo40_Radar.cs雷达图代码操作Demo 2019-12-20 09:17:37 +08:00
monitor1394
4898b0060f 添加RadarChart相关API接口 2019-12-20 09:17:15 +08:00
monitor1394
3147eb156e 优化serie的name为空时的tooltip显示问题 2019-12-19 22:15:12 +08:00
monitor1394
6f8017f0bf 优化warning 2019-12-19 22:10:36 +08:00
monitor1394
7e6d7d72d7 优化Grid引起的warning问题 2019-12-19 22:10:19 +08:00
monitor1394
3df991e5c0 发布v1.1.0版本 2019-12-17 09:01:00 +08:00
monitor1394
5d885e190b new feature 2019-12-16 09:45:30 +08:00
monitor1394
be0bdd0248 修复Overlay模式下不显示Tooltip的问题 2019-12-16 09:44:52 +08:00
monitor1394
78cf3dafa7 增加Title的TextStyle支持 2019-12-15 21:36:59 +08:00
monitor1394
03aaa61e91 Merge branch 'master' of https://github.com/monitor1394/unity-ugui-XCharts 2019-12-11 02:15:04 +08:00
monitor1394
44ed434e13 更新文档 2019-12-11 02:14:58 +08:00
monitor1394
067a70e385 修复Legend都隐藏时Value轴还显示数值的问题 2019-12-11 02:14:37 +08:00
monitor1394
ac61213db3 修复Series->Data->Size重置为0后设置无效的问题 2019-12-11 01:39:27 +08:00
monitor1394
59d8b7fb52 修复Series->Data->Size重置为0后设置无效的问题 2019-12-11 01:38:29 +08:00
monitor1394
1a52a8e098 修复数据过小时AxisLabel直接科学计数法显示的问题 2019-12-06 10:08:48 +08:00
monitor1394
9e51e16e9c 优化和完善数据更新UpdateData接口 2019-12-04 09:44:59 +08:00
monitor1394
b29fc0ed02 增加圆环饼图的圆角支持 2019-12-03 09:34:18 +08:00
monitor1394
74b304a72d 增加数据更新动画 2019-12-03 07:49:37 +08:00
monitor1394
ab057cb623 增加GaugeChart仪表盘 2019-11-30 21:28:54 +08:00
monitor1394
3a478c2abc 增加GaugeChart仪表盘 2019-11-30 21:24:04 +08:00
monitor1394
d8a8b5e50e 更新文档链接 2019-11-22 09:55:50 +08:00
monitor1394
8b5ddc725d 更新版本日期 2019-11-22 09:49:09 +08:00
monitor1394
55807ac941 更新版本日期 2019-11-22 09:48:37 +08:00
monitor1394
110f4ee5f8 修复BarChart清空数据重新赋值后SerieLabel显示异常的问题 2019-11-22 09:46:30 +08:00
monitor1394
5aaa53c503 修复Label字体样式参数设置无效的问题 2019-11-16 21:16:43 +08:00
monitor1394
dc3168747c 修复SerieLabel设置color不生效的问题 2019-11-16 20:15:35 +08:00
monitor1394
38d9232136 发布v1.0.5版本 2019-11-12 19:54:39 +08:00
monitor1394
b661c8e3d1 使用Unity2017.4.27f1作为开发版本,更好的支持低版本 2019-11-12 12:49:07 +08:00
monitor1394
1a949ecb50 整理代码 2019-11-12 12:47:25 +08:00
monitor1394
27dca7c67b Merge pull request #23 from jrapoport/master
support standard c# string formatters in axis labels
2019-11-12 12:39:37 +08:00
Jacob Rapoport
a19a917941 support standard c# string formatters on axis labels 2019-11-11 18:21:30 -08:00
Jacob Rapoport
fb08b62839 Merge branch 'master' of ssh://github.com/monitor1394/unity-ugui-XCharts 2019-11-11 18:12:06 -08:00
monitor1394
bd75f43b2a 修复Label坐标显示异常的问题 2019-11-12 09:49:25 +08:00
monitor1394
668aa4ef0f 修复2018.3以下版本打开项目报错的问题 2019-11-12 08:00:47 +08:00
monitor1394
837658ddcc 增加忽略文件 2019-11-12 08:00:36 +08:00
monitor1394
6503ac2e24 修复2018.3以下版本打开报错的问题 2019-11-12 07:59:46 +08:00
monitor1394
eae0afe659 修复Demo脚本丢失问题 2019-11-12 07:57:10 +08:00
monitor1394
ddb526fb42 增加IconStyle子组件,优化SerieData的图标配置 2019-11-12 07:38:02 +08:00
monitor1394
db50c8ffbe 修复图标显示在上覆盖Label的问题 2019-11-11 09:41:21 +08:00
monitor1394
7198734083 修复饼图当数据过小时视觉引导线会穿透的的问题 2019-11-11 09:24:24 +08:00
monitor1394
6cfcf84b5d 修复饼图添加数据时Label异常的问题 2019-11-09 16:34:16 +08:00
monitor1394
70bcebe9ea 更新文档 2019-11-09 07:51:37 +08:00
monitor1394
d45e2695a5 优化结构,分离为XCharts和XChartsDemo两部分 2019-11-09 07:00:58 +08:00
monitor1394
aef05a53ef 发布1.0.4版本 2019-11-05 19:20:06 +08:00
monitor1394
70c9dafda3 增加Radar雷达组件更多样式配置参数支持 2019-11-05 18:58:32 +08:00
monitor1394
6491660432 修复Unity2018.3以下版本代码不兼容的问题 2019-11-04 18:54:05 +08:00
monitor1394
31b0a385de 优化SerieLabel引起的性能问题 2019-11-04 13:09:06 +08:00
monitor1394
301a507c9b 发布1.0.3版本 2019-11-03 08:46:46 +08:00
monitor1394
322a1bd9d6 发布1.0.3版本 2019-11-03 08:43:39 +08:00
monitor1394
fde0b3e242 增加Editor快捷添加图表 2019-11-03 08:33:06 +08:00
monitor1394
6b1fb386f1 优化组件非配置参数变量的命名和访问权限 2019-11-02 08:24:37 +08:00
monitor1394
759b3f22f9 发布1.0.2版本 2019-11-01 04:23:10 +08:00
monitor1394
ec9277c0d8 发布1.0.2版本 2019-11-01 04:14:16 +08:00
monitor1394
a4d91b3c4e 发布1.0.2版本 2019-10-31 09:49:08 +08:00
monitor1394
00996b92d0 优化DestroyAllChildren接口 2019-10-31 09:46:18 +08:00
monitor1394
8ba251d5be 修复拖出制作预设时异常的问题 2019-10-31 09:40:12 +08:00
Jacob Rapoport
773cfe6c7d fix destroying a gameobject inside a prefab 2019-10-31 09:06:53 +08:00
Jacob Rapoport
e01c55c3ca add themeInfo property 2019-10-31 08:56:47 +08:00
Jacob Rapoport
e58fb2b31f add UpdateThemeInfo API 2019-10-31 08:56:24 +08:00
Jacob Rapoport
d4e7fdbb9c add UpdateThemeInfo API 2019-10-26 17:19:09 -07:00
201 changed files with 1399242 additions and 603736 deletions

8
.gitignore vendored
View File

@@ -11,10 +11,10 @@
/Assets/Package
/Assets/Package.meta
/Assets/XCharts/Demo/demo_test.unity
/Assets/XCharts/Demo/demo_test.unity.meta
/Assets/XCharts/Demo/empty.unity
/Assets/XCharts/Demo/empty.unity.meta
/Assets/XChartsDemo/demo_test.unity
/Assets/XChartsDemo/demo_test.unity.meta
/Assets/XChartsDemo/empty.unity
/Assets/XChartsDemo/empty.unity.meta
*.sln
*.csproj

View File

@@ -1,6 +1,91 @@
# 更新日志
* (2020.04.11) 发布`v1.4.0`版本
* (2020.04.11) 增加`Check warning`检测功能
* (2020.04.09) 修复`Legend`初始化异常的问题
* (2020.04.08) 增加`PieChart`通过`ItemStyle`设置边框的支持
* (2020.03.29) 增加`Axis``ceilRate`设置最大最小值的取整倍率
* (2020.03.29) 增加`BarChart`可通过`itemStyle``cornerRadius`设置`圆角柱图`
* (2020.03.29) 增加`itemStyle``cornerRadius`支持圆角矩形
* (2020.03.24) 优化`Editor`参数编辑,兼容`Unity2019.3`及以上版本
* (2020.03.24) 增加`Serie``inspector`上可进行调整顺序、添加和删除操作
* (2020.03.23) 修复`Title``textStyle``subTextStyle`无效的问题
* (2020.03.22) 增加`BarChart`通过`barType`参数设置`胶囊柱状图`
* (2020.03.21) 增加`BarChart``HeatmapChart`可通过`ignore`参数设置忽略数据的支持
* (2020.03.21) 增加`ItemStyle``tooltipFormatter`参数可单独配置`Serie``Tooltip`显示
* (2020.03.20) 修复`X Axis 1``Y Axis 1`配置变更时不会自动刷新的问题
* (2020.03.20) 增加`AxisTick``width`参数可单独设置坐标轴刻度的宽度
* (2020.03.20) 增加`Serie``radarType`参数设置`多圈``单圈`雷达图
* (2020.03.17) 增加`BarChart`可用`ItemStyle``backgroundColor`设置数据项背景颜色
* (2020.03.17) 增加`SerieData``ItemStyle``Emphasis`可单独配置数据项样式的支持
* (2020.03.15) 重构`EmptyCricle`类型的`Symbol`边宽取自`ItemStyle``borderWidth`参数
* (2020.03.15) 重构`SerieSymbol`,去掉`color``opacity`参数,取自`ItemStyle`
* (2020.03.14) 发布`v1.3.1`版本
* (2020.03.14) 修复`LineChart`开启`ingore`时部分数据可能绘制异常的问题
* (2020.03.13) 修复`LineChart``label`偏移显示异常的问题
* (2020.03.11) 发布`v1.3.0`版本
* (2020.03.11) 优化`LineChart``label`偏移显示
* (2020.03.11) 优化清空并重新添加数据后的自动刷新问题
* (2020.03.10) 增加`LineChart`的普通折线图可通过`ignore`参数设置忽略数据的支持
* (2020.03.09) 增加`BarChart`可通过`ItemStyle`配置边框的支持
* (2020.03.08) 增加`RingChart`环形图
* (2020.03.05) 调整`Serie``arcShaped`参数重命名为`roundCap`
* (2020.03.05) 增加运行时和非运行时参数变更自动刷新图表
* (2020.02.26) 重构`Legend`图例,改变样式,增加自定义图标等设置
* (2020.02.23) 增加`BaseChart.AnimationFadeOut()`渐出动画,重构动画系统
* (2020.02.13) 增加`BaseChart.RefreshTooltip()`接口立即重新初始化`Tooltip`组件
* (2020.02.13) 增加`Tooltip``textStyle`参数配置内容文本样式,去掉`fontSize``fontStyle`参数
* (2020.02.13) 增加`TextStyle``lineSpacing`参数配置行间距
* (2020.02.11) 增加`Radar``splitLine`参数配置分割线,去掉`lineStyle`参数
* (2020.02.11) 增加`Tooltip``backgroundImage`参数配置背景图
* (2020.02.11) 增加`Tooltip``paddingLeftRight``paddingTopBottom`参数配置文字和边框的间距
* (2020.02.11) 增加`Tooltip``lineStyle`参数配置指示线样式
* (2020.02.11) 增加`Axis``splitLine`参数控制分割线,去掉`showSplitLine``splitLineType`参数(更新时需要重新设置分割线相关设置)
* (2020.02.10) 增加`Serie``clip`参数控制是否超出坐标系外裁剪(只适用于折线图、柱状图、散点图)
* (2020.02.08) 增加`SerieSymbol``gap`参数控制图形标记的外留白距离
* (2020.01.26) 增加`TextLimit`组件可以设置`AxisLabel`的文本自适应
* (2020.01.20) 优化`Tooltip`设置`itemFormatter`时显示系列颜色
* (2020.01.20) 增加`Radar`雷达图在`inspector`配置`areaStyle`的支持
* (2020.01.15) 发布`v1.2.0`版本
* (2020.01.15) 增加`AxisLabel`格式化为整数的支持(`{value:f0}`
* (2020.01.15) 增加折线图对数轴`Log`的支持
* (2020.01.09) 修复当设置`DataZoom``minShowNum`时可能异常的问题
* (2020.01.08) 修复当设置`AxisLine``onZero`时刻度显示异常的问题
* (2020.01.08) 增加`Mask`遮罩遮挡支持
* (2019.12.21) 增加`Tooltip`的单个数据项和标题的字符串模版格式器
* (2019.12.21) 增加`DataZoom`的最小显示数据个数`minShowNum`
* (2019.12.20) 增加`Demo40_Radar.cs`雷达图代码操作`Demo`
* (2019.12.20) 添加`RadarChart`相关API接口
* (2019.12.17) 发布`v1.1.0`版本
* (2019.12.16) 修复`Overlay`模式下不显示`Tooltip`的问题
* (2019.12.15) 增加`Title``TextStyle`支持
* (2019.12.11) 修复`Legend`都隐藏时`Value轴`还显示数值的问题
* (2019.12.11) 修复`Series->Data->Size`重置为0后设置无效的问题
* (2019.12.06) 修复数据过小时`AxisLabel`直接科学计数法显示的问题
* (2019.12.04) 优化和完善数据更新`UpdateData`接口
* (2019.12.03) 增加圆环饼图的圆角支持,参数:`serie.arcShaped`
* (2019.12.03) 增加数据更新动画,参数:`serie.animation.dataChangeEnable`
* (2019.11.30) 增加`GaugeChart`仪表盘
* (2019.11.22) 修复`BarChart`清空数据重新赋值后`SerieLabel`显示异常的问题
* (2019.11.16) 修复`SerieLabel`设置`color`等参数不生效的问题
* (2019.11.12) 发布`v1.0.5`版本
* (2019.11.12) 修复`2018.3`以下版本打开项目报错的问题
* (2019.11.12) 增加`IconStyle`子组件,优化`SerieData`的图标配置
* (2019.11.11) 修复`Serie`的图标显示在上层遮挡`Label`的问题
* (2019.11.11) 修复饼图当数据过小时视觉引导线会穿透的的问题
* (2019.11.09) 修复饼图添加数据时`Label`异常的问题
* (2019.11.09) 优化结构,分离为`XCharts``XChartsDemo`两部分
* (2019.11.05) 发布`v1.0.4`版本
* (2019.11.05) 增加`Radar`雷达组件文本样式参数配置支持
* (2019.11.04) 修复`Unity2018.3`以下版本代码不兼容的问题
* (2019.11.04) 优化`SerieLabel`过多时引起的性能问题
* (2019.11.03) 发布`v1.0.3`版本
* (2019.11.03) 增加`Editor`快捷添加图表:`Hierarchy`试图下右键`XCharts->LineChart`
* (2019.11.02) 优化非配置参数变量命名和访问权限,简化`API`
* (2019.10.31) 发布`v1.0.2`版本
* (2019.10.31) 修复`prefab`预设制作报错的问题
* (2019.10.31) 增加访问主题组件API`BaseChart.themeInfo`
* (2019.10.26) 发布`v1.0.1`版本
* (2019.10.26) 修复版本检查功能在非运行时异常的问题
* (2019.10.26) 增加科学计数法显示数值的支持(查阅`forceENotation`参数)

View File

@@ -1,8 +1,6 @@
fileFormatVersion: 2
guid: 5e6b0fb015bc6524d8bab146b6f2ba3a
folderAsset: yes
timeCreated: 1553641866
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:

View File

@@ -1,17 +0,0 @@
{
"name": "XCharts.Editor.Demo",
"references": [
"XCharts.Demo.Runtime",
"XCharts.Runtime"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@@ -0,0 +1,52 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo01_UpdateData : MonoBehaviour
{
private float updateTime = 0;
BaseChart chart;
void Awake()
{
chart = gameObject.GetComponent<BaseChart>();
}
void Update()
{
updateTime += Time.deltaTime;
if (chart && updateTime > 2)
{
updateTime = 0;
var serie = chart.series.GetSerie(0);
//serie.animation.dataChangeEnable = true;
var dataCount = serie.dataCount;
if (chart is RadarChart)
{
var dimension = serie.GetSerieData(0).data.Count - 1;
chart.UpdateData(0, 0, Random.Range(0, dimension + 1), Random.Range(0, 100));
}
else if (chart is HeatmapChart)
{
var dimension = serie.GetSerieData(0).data.Count - 1;
for (int i = 0; i < dataCount; i++)
{
chart.UpdateData(0, i, dimension, Random.Range(0, 10));
}
}
else
{
chart.UpdateData(0, Random.Range(0, dataCount), Random.Range(10, 90));
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5420ab107823641e49c2df9e3556ea30
guid: e6faaaf3d4a8444b4b2736825e237fcf
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -38,10 +38,12 @@ namespace XCharts
chart.RemoveData();
chart.AddSerie(SerieType.Line);
chart.AddSerie(SerieType.Line);
for (int i = 0; i < 10; i++)
{
chart.AddXAxisData("x" + i);
chart.AddData(0, Random.Range(10, 20));
chart.AddData(1, Random.Range(10, 20));
}
}
}

View File

@@ -66,10 +66,10 @@ namespace XCharts
chart.RemoveData();
serie = chart.AddSerie(SerieType.Pie, "访问来源");
serie.pieRadius[0] = 0;
serie.pieRadius[1] = 110;
serie.pieCenter[0] = 0.5f;
serie.pieCenter[1] = 0.4f;
serie.radius[0] = 0;
serie.radius[1] = 110;
serie.center[0] = 0.5f;
serie.center[1] = 0.4f;
chart.AddData(0, 335, "直接访问");
chart.AddData(0, 310, "邮件营销");
chart.AddData(0, 243, "联盟广告");
@@ -105,10 +105,10 @@ namespace XCharts
IEnumerator Doughnut()
{
chart.title.subText = "圆环图";
serie.pieRadius[0] = 2f;
while (serie.pieRadius[0] < serie.pieRadius[1] * 0.7f)
serie.radius[0] = 2f;
while (serie.radius[0] < serie.radius[1] * 0.7f)
{
serie.pieRadius[0] += m_RadiusSpeed * Time.deltaTime;
serie.radius[0] += m_RadiusSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
@@ -134,14 +134,14 @@ namespace XCharts
chart.AddData(1, 335, "直达");
chart.AddData(1, 679, "营销广告");
chart.AddData(1, 1548, "搜索引擎");
serie1.pieRadius[0] = 0;
serie1.pieRadius[1] = 2f;
serie1.pieCenter[0] = 0.5f;
serie1.pieCenter[1] = 0.4f;
serie1.radius[0] = 0;
serie1.radius[1] = 2f;
serie1.center[0] = 0.5f;
serie1.center[1] = 0.4f;
chart.RefreshChart();
while (serie1.pieRadius[1] < serie.pieRadius[0] * 0.75f)
while (serie1.radius[1] < serie.radius[0] * 0.75f)
{
serie1.pieRadius[1] += m_RadiusSpeed * Time.deltaTime;
serie1.radius[1] += m_RadiusSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
@@ -163,7 +163,7 @@ namespace XCharts
chart.legend.show = false;
serie1.ClearData();
serie.ClearData();
serie1.pieRadius = serie.pieRadius = new float[2] { 0, 80 };
serie1.radius = serie.radius = new float[2] { 0, 80 };
serie1.label.position = SerieLabel.Position.Outside;
serie1.label.lineType = SerieLabel.LineType.Curves;
serie1.label.color = Color.clear;
@@ -179,24 +179,24 @@ namespace XCharts
chart.AddData(i, 40, "rose8");
}
while (serie.pieCenter[0] > 0.25f || serie1.pieCenter[0] < 0.7f)
while (serie.center[0] > 0.25f || serie1.center[0] < 0.7f)
{
if (serie.pieCenter[0] > 0.25f) serie.pieCenter[0] -= m_CenterSpeed * Time.deltaTime;
if (serie1.pieCenter[0] < 0.7f) serie1.pieCenter[0] += m_CenterSpeed * Time.deltaTime;
if (serie.center[0] > 0.25f) serie.center[0] -= m_CenterSpeed * Time.deltaTime;
if (serie1.center[0] < 0.7f) serie1.center[0] += m_CenterSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
yield return new WaitForSeconds(1);
while (serie.pieRadius[0] > 3f)
while (serie.radius[0] > 3f)
{
serie.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
serie1.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
serie.radius[0] -= m_RadiusSpeed * Time.deltaTime;
serie1.radius[0] -= m_RadiusSpeed * Time.deltaTime;
chart.RefreshChart();
yield return null;
}
serie.pieRadius[0] = 0;
serie1.pieRadius[0] = 0;
serie.radius[0] = 0;
serie1.radius[0] = 0;
serie.pieRoseType = RoseType.Area;
serie1.pieRoseType = RoseType.Radius;
chart.RefreshChart();

View File

@@ -0,0 +1,124 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
public class Demo40_Radar : MonoBehaviour
{
private RadarChart chart;
private Serie serie, serie1;
void Awake()
{
LoopDemo();
}
private void OnEnable()
{
LoopDemo();
}
void LoopDemo()
{
StopAllCoroutines();
StartCoroutine(RadarDemo());
}
IEnumerator RadarDemo()
{
StartCoroutine(RadarAdd());
yield return new WaitForSeconds(2);
StartCoroutine(RadarUpdate());
yield return new WaitForSeconds(2);
StartCoroutine(RadarAddMultiple());
yield return new WaitForSeconds(2);
LoopDemo();
}
IEnumerator RadarAdd()
{
chart = gameObject.GetComponent<RadarChart>();
if (chart == null) chart = gameObject.AddComponent<RadarChart>();
chart.RemoveRadar();
chart.RemoveData();
chart.title.text = "RadarChart - 雷达图";
chart.title.subText = "";
chart.legend.show = true;
chart.legend.location.align = Location.Align.TopLeft;
chart.legend.location.top = 60;
chart.legend.location.left = 2;
chart.legend.itemWidth = 70;
chart.legend.itemHeight = 20;
chart.legend.orient = Orient.Vertical;
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.5f, 0.4f), 0.4f);
chart.AddIndicator(0, "indicator1", 0, 100);
chart.AddIndicator(0, "indicator2", 0, 100);
chart.AddIndicator(0, "indicator3", 0, 100);
chart.AddIndicator(0, "indicator4", 0, 100);
chart.AddIndicator(0, "indicator5", 0, 100);
serie = chart.AddSerie(SerieType.Radar, "test");
serie.radarIndex = 0;
chart.AddData(0, new List<float> { 10, 20, 60, 40, 20 }, "data1");
chart.AddData(0, new List<float> { 40, 60, 90, 80, 70 }, "data2");
yield return new WaitForSeconds(1);
}
IEnumerator RadarUpdate()
{
chart.UpdateIndicator(0, 0, "new1", 0, 100);
chart.UpdateData(0, 0, new List<float> { 15, 30, 50, 60, 50 });
chart.UpdateDataName(0, 0, "new1");
yield return new WaitForSeconds(1);
}
IEnumerator RadarAddMultiple()
{
chart.RemoveRadar();
chart.RemoveData();
chart.title.text = "RadarChart - 多雷达图";
chart.title.subText = "";
chart.legend.show = true;
chart.legend.location.align = Location.Align.TopLeft;
chart.legend.location.top = 60;
chart.legend.location.left = 2;
chart.legend.itemWidth = 70;
chart.legend.itemHeight = 20;
chart.legend.orient = Orient.Vertical;
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.25f, 0.4f), 0.25f);
for (int i = 1; i <= 5; i++)
{
chart.AddIndicator(0, "radar1" + i, 0, 100);
}
chart.AddRadar(Radar.Shape.Circle, new Vector2(0.75f, 0.4f), 0.25f);
for (int i = 1; i <= 5; i++)
{
chart.AddIndicator(1, "radar2" + i, 0, 100);
}
serie = chart.AddSerie(SerieType.Radar, "test1");
serie.radarIndex = 0;
chart.AddData(0, new List<float> { 10, 20, 60, 40, 20 }, "data1");
serie1 = chart.AddSerie(SerieType.Radar, "test2");
serie1.radarIndex = 1;
chart.AddData(1, new List<float> { 10, 20, 60, 40, 20 }, "data2");
yield return new WaitForSeconds(1);
}
}
}

View File

@@ -1,7 +1,5 @@
fileFormatVersion: 2
guid: 73e326ed8a76f90408bfa9feb1797433
timeCreated: 1555379601
licenseType: Free
guid: cb56350d2a2b24960a7174a1d3f2ea56
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,70 @@
using System.Runtime.InteropServices;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo70_Gauge : MonoBehaviour
{
private GaugeChart chart;
private float updateTime;
void Awake()
{
chart = gameObject.GetComponent<GaugeChart>();
if (chart == null)
{
chart = gameObject.AddComponent<GaugeChart>();
}
chart.title.text = "GaugeChart";
chart.RemoveData();
var serie = chart.AddSerie(SerieType.Gauge, "速度");
serie.min = 0;
serie.max = 220;
serie.startAngle = -125;
serie.endAngle = 125;
serie.center[0] = 0.5f;
serie.center[1] = 0.5f;
serie.radius[0] = 80;
serie.splitNumber = 5;
serie.animation.dataChangeEnable = true;
serie.roundCap = true;
serie.titleStyle.show = true;
serie.titleStyle.textStyle.offset = new Vector2(0, 20);
serie.label.show = true;
serie.label.offset = new Vector3(0, -20);
serie.gaugeAxis.show = true;
serie.gaugeAxis.axisLine.width = 15;
serie.gaugePointer.show = true;
serie.gaugePointer.width = 15;
var value = UnityEngine.Random.Range(serie.min, serie.max);
chart.AddData(0, value, "km/h");
}
void Update()
{
updateTime += Time.deltaTime;
if (updateTime > 2)
{
updateTime = 0;
var value = UnityEngine.Random.Range(0, 220);
chart.UpdateData(0, 0, value);
}
}
}
}

View File

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

View File

@@ -14,27 +14,41 @@ namespace XCharts
[ExecuteInEditMode]
public class Demo_Test : MonoBehaviour
{
LineChart chart;
BaseChart chart;
void Awake()
{
chart = gameObject.GetComponent<LineChart>();
if (chart == null)
chart = gameObject.GetComponent<BaseChart>();
var btnTrans = transform.parent.Find("Button");
if (btnTrans)
{
chart = gameObject.AddComponent<LineChart>();
btnTrans.gameObject.GetComponent<Button>().onClick.AddListener(OnTestBtn);
}
}
var buttom = transform.parent.gameObject.GetComponentInChildren<Button>();
buttom.onClick.AddListener(AddData);
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
AddData();
}
}
void OnTestBtn()
{
chart.ClearData();
}
void AddData()
{
chart.series.list[0].ClearData();
chart.series.list[1].ClearData();
for (int i = 0; i < 5; i++)
chart.ClearData();
int count = Random.Range(5, 100);
for (int i = 0; i < count; i++)
{
chart.AddData(0, Random.Range(20, 100));
chart.AddData(1, Random.Range(1, 10));
(chart as CoordinateChart).AddXAxisData("x" + i);
if (Random.Range(1, 3) == 2)
chart.AddData(0, Random.Range(-110, 200));
else
chart.AddData(0, Random.Range(-100, 100));
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -6,8 +6,7 @@
## `BaseChart`
---
* `BaseChart.themeInfo`:主题组件`ThemeInfo`
* `BaseChart.title`:标题组件`Title`
* `BaseChart.legend`:图例组件`Legend`
* `BaseChart.tooltip`:提示框组件`Tooltip`
@@ -28,6 +27,10 @@
* `BaseChart.AddData(int serieIndex, float xValue, float yValue, string dataName = null)`:添加`x,y`数据到指定系列中。
* `BaseChart.UpdateData(string serieName,int dataIndex, float value)`:更新指定系列中的指定索引数据。
* `BaseChart.UpdateData(int serieIndex,int dataIndex, float value)`:更新指定系列中的指定索引数据。
* `BaseChart.UpdateData(string serieName, int dataIndex, List<float> multidimensionalData)`:更新指定系列指定索引的数据项的多维数据。
* `BaseChart.UpdateData(int serieIndex, int dataIndex, List<float> multidimensionalData)`:更新指定系列指定索引的数据项的多维数据。
* `BaseChart.UpdateData(string serieName, int dataIndex, int dimension, float value)`更新指定系列指定索引指定维数的数据。维数从0开始。
* `BaseChart.UpdateData(int serieIndex, int dataIndex, int dimension, float value)`更新指定系列指定索引指定维数的数据。维数从0开始。
* `BaseChart.UpdateDataName(string serieName,int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
* `BaseChart.UpdateDataName(int serieIndex, int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
* `BaseChart.SetActive(string serieName, bool active)`:设置指定系列是否显示。
@@ -37,17 +40,18 @@
* `BaseChart.IsActiveByLegend(string legendName)`:获得指定图例名字的系列是否显示。
* `BaseChart.RefreshChart()`:在下一帧刷新图表。
* `BaseChart.RefreshLabel()`:在下一帧刷新文本标签。
* `BaseChart.RefreshTooltip()`:立即刷新`Tooltip`组件。
* `BaseChart.UpdateTheme(Theme theme)`:切换图表主题。
* `BaseChart.AnimationEnable(bool flag)`:启用或关闭起始动画。
* `BaseChart.AnimationStart()`开始初始动画。
* `BaseChart.AnimationStop()`:停止初始化动画。
* `BaseChart.AnimationReset()`重置初始动画,重新播放
* `BaseChart.AnimationEnable(bool flag)`:启用或关闭动画。
* `BaseChart.AnimationFadeIn()`渐入动画。
* `BaseChart.AnimationFadeOut()`:渐出动画。
* `BaseChart.AnimationPause()`暂停动画
* `BaseChart.AnimationResume()`:继续动画。
* `BaseChart.AnimationReset()`:重置动画。
* `BaseChart.ClickLegendButton(int legendIndex, string legendName, bool show)`:点击图例按钮。
## `CoordinateChart`
---
* `CoordinateChart.grid`:网格组件 `Grid`
* `CoordinateChart.xAxises`:左右两个 `X` 轴组件 `XAxis`
* `CoordinateChart.yAxises`:左右两个 `Y` 轴组件 `YAxis`
@@ -69,45 +73,48 @@
## `LineChart`
---
* 继承 `BaseChart`
* 继承自 `CoordinateChart`
## `BarChart`
---
* 继承自 `BaseChart`
* 继承自 `CoordinateChart`
## `PieChart`
---
* 继承自 `BaseChart`
## `RadarChart`
---
* 继承自 `BaseChart`
* `radars`:雷达组件列表 `Radar`
* `RadarChart.radars`:雷达坐标系组件列表 `Radar`
* `RadarChart.RemoveRadar()`:移除所有雷达坐标系组件。
* `RadarChart.AddRadar(Radar radar)`:添加雷达坐标系组件。
* `RadarChart.AddRadar(Radar.Shape shape, Vector2 center, float radius, int splitNumber = 5,float lineWidth = 0.6f, bool showIndicator = true, bool showSplitArea = true)`:添加雷达坐标系组件。
* `RadarChart.AddIndicator(int radarIndex, string name, float min, float max)`:添加指示器。
* `RadarChart.UpdateIndicator(int radarIndex, int indicatorIndex, string name, float min, float max)`:更新指示器。
* `RadarChart.GetRadar(int radarIndex)`:获得指定索引的雷达坐标系组件。
* `RadarChart.GetIndicator(int radarIndex, int indicatorIndex)`:获得指定雷达坐标系组件指定索引的指示器。
## `ScatterChart`
---
* 继承自 `BaseChart`
* 继承自 `CoordinateChart`
## `HeatmapChart`
---
* 继承自 `BaseChart`
* 继承自 `CoordinateChart`
## `RingChart`
* 继承自 `BaseChart`
* `RingChart.UpdateMax(int serieIndex, int dataIndex, float value)`:更新指定系列执行数据项的最大值。
* `RingChart.UpdateMax(int serieIndex, float value)`:更新指定系列的所有数据项的最大值。
* `RingChart.UpdateMax(float value)`:更新第一个系列第一个数据项的最大值。
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
[XCharts配置项手册](XCharts配置项手册.md)
[XCharts问答](XCharts问答.md)

View File

@@ -10,7 +10,16 @@
* [DataZoom 区域缩放](#DataZoom)
* [Grid 网格](#Grid)
* [Legend 图例](#Legend)
* [Radar 雷达](#Radar)
* [Series 系列](#Series)
* [Serie-Line 折线图](#Serie-Line)
* [Serie-Bar 柱形图](#Serie-Bar)
* [Serie-Pie 饼图](#Serie-Pie)
* [Serie-Radar 雷达图](#Serie-Radar)
* [Serie-Scatter 散点图](#Serie-Scatter)
* [Serie-Heatmap 热力图](#Serie-Heatmap)
* [Serie-Gauge 仪表盘](#Serie-Gauge)
* [Serie-Ring 环形图](#Serie-Ring)
* [Settings 设置](#Settings)
* [Theme 主题](#Theme)
* [Tooltip 提示框](#Tooltip)
@@ -23,10 +32,11 @@
* [AxisLabel 坐标轴刻度标签](#AxisLabel)
* [AxisLine 坐标轴轴线](#AxisLine)
* [AxisName 坐标轴名称](#AxisName)
* [AxisSplitLine 坐标轴分割线条](#AxisSplitLine)
* [AxisSplitArea 坐标轴分割区域](#AxisSplitArea)
* [AxisTick 坐标轴刻度](#AxisTick)
* [Emphasis 高亮样式](#Emphasis)
* [ItemStyle 图形样式](#ItemStyle)
* [ItemStyle 数据项样式](#ItemStyle)
* [LineArrow 折线图箭头](#LineArrow)
* [LineStyle 折线图样式](#LineStyle)
* [Location 位置](#Location)
@@ -34,10 +44,11 @@
* [SerieData 数据项](#SerieData)
* [SerieLabel 图形上的文本标签](#SerieLabel)
* [SerieSymbol 图形标记](#SerieSymbol)
* [TextLimit 文本自适应](#TextLimit)
* [TextStyle 文本样式](#TextStyle)
## `Theme`
---
主题组件。主题用来配置图表的全局配色等其他参数。
相关参数:
@@ -70,22 +81,31 @@
## `Title`
---
标题组件,包含主标题和副标题。
相关参数:
* `show`:是否显示标题组件。
* `text`:主标题文本,支持使用 `\n` 换行。
* `textFontSize`:主标题文字的字体大小
* `textStyle`:主标题文本样式 [TextStyle](#TextStyle)
* `subText`:副标题文本,支持使用 `\n` 换行。
* `subTextFontSize`:副标题文字的字体大小
* `subTextStyle`:副标题文本样式 [TextStyle](#TextStyle)
* `itemGap`:主副标题之间的间距。
* `location`:标题显示位置 [Location](#Location)。
## `TitleStyle`
标题样式。
* `show`:是否显示标题组件。
* `rotate`:旋转。
* `offset`:偏移。
* `color`:颜色。
* `fontSize`:字体大小。
* `fontStyle`:字体风格。
## `Legend`
---
图例组件。图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
相关参数:
@@ -99,12 +119,14 @@
* `Horizonal`:水平。
* `Vertical`:垂直。
* `location`:图例的显示位置 [Location](#Location)。
* `itemWidth`每个图例项的宽度。
* `itemHeight`每个图例项的高度。
* `itemWidth`图例标记的图形宽度。
* `itemHeight`图例标记的图形高度。
* `itemGap`:图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
* `itemFontSize`:图例项的字体大小
* `itemAutoColor`:图例标记的图形是否自动匹配颜色
* `formatter`:图例内容字符串模版格式器。支持用 `\n` 换行。模板变量为图例名称 `{name}`
* `data`:图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 `name`(如果是饼图,也可以是饼图单个数据的 `name`)。如果 `data` 没有被指定,会自动从当前系列中获取。指定 `data` 时里面的数据项和 `serie` 匹配时才会生效。
* `icons`:自定义的图例标记图形。
* `textStyle`:图例的内容文本样式 [TextStyle](#TextStyle)。
相关接口:
@@ -115,9 +137,48 @@
* `GetData(int index)`:获得指定索引的图例。
* `GetIndex(string legendName)`:获得指定图例的索引。
## `Tooltip`
## `Radar`
---
* `shape`:雷达图绘制类型。
* `Polygon`:多边形。
* `Circle`:圆形。
* `positionType`:显示位置类型。
* `Vertice`:显示在顶点处。
* `Between`:显示在顶点之间。
* `radius`:雷达图的半径。
* `center`雷达图的中心点。数组的第一项是横坐标第二项是纵坐标。当值为0-1之间时表示百分比设置成百分比时第一项是相对于容器宽度第二项是相对于容器高度。
* `splitLine`:分割线条 [AxisSplitLine](#AxisSplitLine)。
* `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。
* `indicator`:是否显示指示器。
* `indicatorGap`:指示器和雷达的间距。
* `indicatorList`指示器列表 [Radar.Indicator](#Radar.Indicator)。
## `Radar.Indicator`
* `name`:指示器名称。
* `max`:指示器的最大值,默认为 0 无限制。
* `min`:指示器的最小值,默认为 0 无限制。
* `textStyle`:文本样式 [TextStyle](#TextStyle)。
## `TextLimit`
* `enable`:是否启用文本自适应。默认为`true`
* `maxWidth`:设定最大宽度。默认为`0`表示自动获取,否则表示自定义。当文本的宽度大于该值进行裁剪。
* `gap`:两边留白像素距离。默认为`10`
* `suffix` 长度超出被裁剪后附加的后缀。默认为`...`
## `TextStyle`
* `rotate`:旋转。
* `offset`:偏移。
* `color`:颜色。
* `backgroundColor`:背景颜色。
* `font`:字体。
* `fontSize`:字体大小。
* `fontStyle`:字体风格。
* `lineSpacing`:行间距。
## `Tooltip`
提示框组件。
@@ -129,23 +190,27 @@
* `Shadow`:阴影指示器。
* `None`:无指示器。
* `Corss`十字准星指示器。坐标轴显示Label和交叉线。
* `formatter`:提示框内容字符串模版格式器。支持用 `\n``<br/>` 换行。其中变量 `{a}`, `{b}`, `{c}`, `{d}` 在不同图表类型下代表数据含义为:
* `formatter`:提示框内容字符串模版格式器。支持用 `\n``<br/>` 换行。`formatter`不为空时,优先使用`formatter`,否则使用`itemFormatter`。示例:`{a}:{c}``{a1}:{c1:f1}`其中变量 `{a}`, `{b}`, `{c}`, `{d}` 在不同图表类型下代表数据含义为:
* 折线区域图、柱状条形图、K线图 : `{a}`(系列名称),`{b}`(类目值),`{c}`(数值), `{d}`(无)。
* 散点图(气泡)图 : `{a}`(系列名称),`{b}`(数据名称),`{c}`(数值数组), `{d}`(无)。
* 地图 : `{a}`(系列名称),`{b}`(区域名称),`{c}`(合并数值), `{d}`(无)。
* 饼图、仪表盘、漏斗图: `{a}`(系列名称),`{b}`(数据项名称),`{c}`(数值), `{d}`(百分比)。
* `titleFormatter`:提示框标题内容的字符串模版格式器。支持用 `\n``<br/>` 换行。仅当`itemFormatter`生效时才有效。
* `itemFormatter`:提示框单个`serie`或数据项内容的字符串模版格式器。支持用 `\n``<br/>` 换行。当`formatter`不为空时,优先使用`formatter`,否则使用`itemFormatter`
* `fixedWidth`:固定宽度。当同时设置 `fixedWidth``minWidth` 时,`fixedWidth``minWidth` 优先级高。
* `fixedHeight`:固定高度。当同时设置 `fixedHeight``minHeight` 时,`fixedHeight``minHeight` 优先级高。
* `minWidth`:最小宽度。当同时设置 `fixedWidth``minWidth` 时,`fixedWidth``minWidth` 优先级高。
* `minHeight`:最小高度。当同时设置 f`ixedHeight``minHeight` 时,`fixedHeight``minHeight` 优先级高。
* `fontSize`:文字的字体大小
* `fontStyle`:文字的字体风格
* `paddingLeftRight`:文字和边框的左右边距
* `paddingTopBottom`:文字和边框的上下边距
* `backgroundImage`:提示框的背景图。
* `forceENotation`是否强制使用科学计数法格式化显示数值。默认为false当小数精度大于3时才采用科学计数法。
* `ignoreDataDefaultContent`:被忽略数据的默认显示字符信息。
* `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。
* `textStyle`:显示内容文本样式 [TextStyle](#TextStyle)。
## `DataZoom`
---
区域缩放组件。用于区域缩放,从而能自由关注细节的数据信息,或者概览数据整体,或者去除离群点的影响。
目前只支持控制 `X` 轴。
@@ -175,11 +240,10 @@
* `scrollSensitivity`:缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
* `fontSize`:字体大小。
* `fontStyle`:字体样式。
* `minShowNum`最小显示数据个数。当DataZoom放大到最大时最小显示的数据个数。
## `VisualMap`
---
视觉映射组件。用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)。
* `enable`:开启或关闭视觉映射功能。
@@ -210,8 +274,6 @@
## `Grid`
---
网格组件。直角坐标系内绘图网格,单个 `grid` 内最多可以放置上下两个 `X` 轴,左右两个 `Y` 轴。可以在网格上绘制折线图,柱状图,散点图(气泡图)。目前最多只能存在一个 `grid` 组件。
相关参数:
@@ -223,33 +285,45 @@
* `bottom`:组件离容器底部的距离。
* `backgroundColor`:背景颜色。
## `XAxis`
## `GaugeAxis`
---
仪表盘坐标轴。
* `axisLine`:坐标轴轴线样式。
* `splitLine`:坐标轴分割线样式。
* `axisTick`:坐标轴刻度样式。
* `axisLabel`:坐标轴刻度标签样式。
* `axisLabelText`坐标轴刻度标签自定义内容。当内容为空时axisLabel根据刻度自动显示内容否则取自该列表定义的内容。
## `GaugePointer`
仪表盘指针。
* `width`:指针宽度。
* `length`指针长度。当为0-1的浮点数时表示相对仪表盘半径的百分比。
## `XAxis`
直角坐标系 `grid` 中的 `X` 轴。单个 `grid` 组件最多只能放上下两个 `X` 轴。两个 `X` 轴存储在 `xAxises` 中。
相关参数:
* `show`:是否显示 `X` 轴。默认 `xAxises[0]``true``xAxises[1]``false`
* `type`:坐标轴类型。默认为 `Category`有以下两种类型:
* `type`:坐标轴类型。默认为 `Category`支持以下类型:
* `Value`:数值轴,用于连续数据。
* `Category`:类目轴,适用于离散的类目数据,为该类型时必须通过 `data` 设置类目数据。
* `Log`:对数轴,适用于对数数据。
* `logBaseE`:对数轴是否以自然数 `e` 为底数,为 `true``logBase` 失效,只在对数轴(`type:'Log'`)中有效。
* `logBase`:对数轴的底数,只在对数轴(`type:'Log'`)中有效。
* `minMaxType`:坐标轴刻度最大最小值显示类型。默认为 `Default`。有以下三种类型:
* `Default`0-最大值。
* `MinMax`:最小值-最大值。
* `Custom`:自定义的最小值-最大值。
* `min`:设定的坐标轴刻度最小值,当 `minMaxType``Custom` 时有效。
* `max`:设定的坐标轴刻度最大值,当 `minMaxType``Custom` 时有效。
* `ceilRate`最大最小值向上取整的倍率。默认为0时自动计算。
* `splitNumber`:坐标轴的分割段数。默认为 `5`。当 `splitNumber` 设为 `0` 时,表示绘制所有的类目数据。
* `interval`:强制设置坐标轴分割间隔。无法在类目轴中使用。设置改值时 `splitNumber` 无效。
* `splitLineType`:分割线类型。默认为 `Dashed`。有以下五种类型:
* `None`:不显示分割线。
* `Solid`:实线。
* `Dashed`:虚线。
* `Dotted`:点线。
* `DashDot`:点划线。
* `DashDotDot`:双点划线。
* `boundaryGap`:坐标轴两边是否留白。默认为 `true`
* `maxCache`类目数据中可缓存的最大数据量。默认为0没有限制大于0时超过指定值会移除旧数据再插入新数据。
* `data`:类目数据,在类目轴(`type: 'Category'`)中有效。
@@ -257,7 +331,8 @@
* `axisName`:坐标轴名称相关配置 [AxisName](#AxisName)。
* `axisTick`:坐标轴刻度相关配置 [AxisTick](#AxisTick)。
* `axisLabel`:坐标轴刻度标签 [AxisLabel](#AxisLabel)。
* `splitArea`:坐标轴轴线坐标轴分割区域 [SplitArea](#SplitArea)。
* `splitLine`:坐标轴轴线坐标轴分割线 [AxisSplitLine](#SplitLine)。
* `splitArea`:坐标轴轴线坐标轴分割区域 [AxisSplitArea](#AxisSplitArea)。
相关接口:
@@ -268,8 +343,6 @@
## `YAxis`
---
直角坐标系 `grid` 中的 `Y` 轴。单个 `grid` 组件最多只能放左右两个 `Y` 轴。两个 `Y` 轴存储在 `yAxises` 中。
相关参数:
@@ -310,8 +383,6 @@
## `Series`
---
系列列表。每个系列通过 type 决定自己的图表类型。
相关参数:
@@ -368,18 +439,205 @@
* `pieSpace`:饼图项间的空隙留白。
* `pieCenter`:饼图的中心点。
* `pieRadius`:饼图的半径。`radius[0]` 表示内径,`radius[1]` 表示外径。
* `roundCap`:启用圆弧效果。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `lineArrow`:折线图的箭头 [LineArrow](#LineArrow)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。
相关接口:
## `Serie-Line`
折线图系列。
* `show`:系列是否显示在图表上。
* `type``Line`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `stack`:数据堆叠。同个类目轴上系列配置相同的 `stack` 值后,后一个系列的值会在前一个系列的值上相加。
* `axisIndex`:使用的坐标轴轴的 `index`,在单个图表实例中存在多个坐标轴轴的时候有用。
* `minShow`:系列显示数据的最小索引。
* `maxShow`:系列显示数据的最大索引。
* `maxCache`:系列中可缓存的最大数据量。默认为`0`没有限制大于0时超过指定值会移除旧数据再插入新数据。
* `sampleDist`采样的最小水平像素距离,默认为`0`时不采样。当两个数据点间的水平像素距离小于该值时,开启采样,保证两点间的水平像素距离不小于该值。
* `sampleType`:采样类型。当`sampleDist`大于`0`时有效。支持以下五种采样类型:
* `Peak`:取峰值。当过滤点的平均值大于等于`sampleAverage`时,取最大值;反之取最小值。
* `Average`:取过滤点的平均值。
* `Max`:取过滤点的最大值。
* `Min`:取过滤点的最小值。
* `Sum`:取过滤点之和。
* `sampleAverage`:设定的采样平均值。当 `sampleType``Peak` 时,用于和过滤数据的平均值做对比是取最大值还是最小值。默认为`0`时会实时计算所有数据的平均值。
* `clip`:是否裁剪超出坐标系部分的图形。
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
* `ignoreValue`忽略数据的默认值。默认值默认为0`ignore``true` 才有效。
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
* `lineType`:折线图样式类型。支持以下十种类型:
* `Normal`:普通折线图。
* `Smooth`:平滑曲线。
* `SmoothDash`:平滑虚线。
* `StepStart`:阶梯线图:当前点。
* `StepMiddle`:阶梯线图:当前点和下一个点的中间。
* `StepEnd`:阶梯线图:下一个拐点。
* `Dash`:虚线。
* `Dot`:点线。
* `DashDot`:点划线。
* `DashDotDot`:双点划线。
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `lineArrow`:折线图的箭头 [LineArrow](#LineArrow)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。
## `Serie-Bar`
折线图系列。
* `show`:系列是否显示在图表上。
* `type``Bar`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `stack`:数据堆叠。同个类目轴上系列配置相同的 `stack` 值后,后一个系列的值会在前一个系列的值上相加。
* `axisIndex`:使用的坐标轴轴的 `index`,在单个图表实例中存在多个坐标轴轴的时候有用。
* `minShow`:系列显示数据的最小索引。
* `maxShow`:系列显示数据的最大索引。
* `maxCache`:系列中可缓存的最大数据量。默认为`0`没有限制大于0时超过指定值会移除旧数据再插入新数据。
* `barType`:柱状图类型。以下几种类型:
* `Normal`:普通柱状图。
* `Zebra`:斑马柱状图。
* `Capsule`:胶囊柱状图。
* `barPercentStack`:是否百分比堆叠柱状图,相同 `stack``serie` 只要有一个 `barPercentStack``true`,则就显示成百分比堆叠柱状图。
* `barWidth`:柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。
* `barGap`:不同系列的柱间距离。为百分比(如 `'0.3f'`,表示柱子宽度的 `30%`)。如果想要两个系列的柱子重叠,可以设置 `barGap``'-1f'`。这在用柱子做背景的时候有用。在同一坐标系上,此属性会被多个 `'bar'` 系列共享。此属性应设置于此坐标系中最后一个 `'bar'` 系列上才会生效,并且是对此坐标系中所有 `'bar'` 系列生效。
* `barCategoryGap`同一系列的柱间距离默认为类目间距的20%,可设固定值。在同一坐标系上,此属性会被多个 `'bar'` 系列共享。此属性应设置于此坐标系中最后一个 `'bar'` 系列上才会生效,并且是对此坐标系中所有 `'bar'` 系列生效。
* `barZebraWidth`:斑马线的粗细。`barType``Zebra` 时有效。
* `barZebraGap`:斑马线的间距。`barType``Zebra` 时有效。
* `clip`:是否裁剪超出坐标系部分的图形。
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
* `ignoreValue`忽略数据的默认值。默认值默认为0`ignore``true` 才有效。
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
* `itemStyle`:柱条样式 [ItemStyle](#ItemStyle)。
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。
## `Serie-Pie`
饼图系列。
* `show`:系列是否显示在图表上。
* `type``Pie`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `pieRoseType`:南丁格尔玫瑰图类型,支持以下类型:
* `None`:不展示成南丁格尔玫瑰图。
* `Radius`:扇区圆心角展现数据的百分比,半径展现数据的大小。
* `Area`:所有扇区圆心角相同,仅通过半径展现数据大小。
* `space`:扇区间隙。
* `center`中心点坐标。当值为0-1的浮点数时表示百分比。
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
* `roundCap`:是否启用圆弧效果。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。
## `Serie-Radar`
雷达图系列。
* `show`:系列是否显示在图表上。
* `type``Radar`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `radarType`:雷达图类型`RadarType`,支持以下类型:
* `Multiple`多圈雷达图。此时可一个雷达里绘制多个圈一个serieData就可组成一个圈多维数据
* `Single`单圈雷达图。此时一个雷达只能绘制一个圈多个serieData组成一个圈数据取自`data[1]`
* `radarIndex`:雷达图所使用的 `radar` 组件的 `index`
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
* `itemStyle`:标记样式 [ItemStyle](#ItemStyle)。
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。
## `Serie-Scatter`
散点图系列。
* `show`:系列是否显示在图表上。
* `type``Scatter`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `clip`:是否裁剪超出坐标系部分的图形。
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。
## `Serie-Heatmap`
热力图系列。
* `show`:系列是否显示在图表上。
* `type``Scatter`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
* `ignoreValue`忽略数据的默认值。默认值默认为0`ignore``true` 才有效。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。
## `Serie-Gauge`
仪表盘系列。
* `show`:系列是否显示在图表上。
* `type``Gauge`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `gaugeType`:仪表盘类型,支持以下类型:
* `Pointer`:指针类型。
* `ProgressBar`:进度条类型。
* `center`中心点坐标。当值为0-1的浮点数时表示百分比。
* `radius`:仪表盘半径。
* `min`最小的数据值。映射到startAngle。
* `max`最大的数据值。映射到endAngle。
* `startAngle`仪表盘起始角度。和时钟一样12点钟位置是0度顺时针到360度。
* `endAngle`仪表盘结束角度。和时钟一样12点钟位置是0度顺时针到360度。
* `splitNumber`:仪表盘刻度分割段数。
* `roundCap`:是否启用圆弧效果。
* `titleStyle`:仪表盘标题 [TitleStyle](#TitleStyle)。
* `gaugeAxis` 仪表盘坐标轴 [GaugeAxis](#GaugeAxis)。
* `gaugePointer`:仪表盘指针 [GaugePointer](#GaugePointer)。
* `itemStyle`:仪表盘指针样式 [ItemStyle](#ItemStyle)。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。仪表盘的数据一般只有一个,值通过`label`样式显示,`name`通过`titleStyle`样式显示。
## `Serie-Ring`
环形图系列。
* `show`:系列是否显示在图表上。
* `type``Ring`
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
* `center`中心点坐标。当值为0-1的浮点数时表示百分比。
* `radius`:仪表盘半径。
* `startAngle`仪表盘起始角度。和时钟一样12点钟位置是0度顺时针到360度。
* `ringGap`:环形图的环间隙。
* `roundCap`:是否启用圆弧效果。
* `clockwise`:是否顺时针,默认为`true`
* `titleStyle`:环形图中心标题 [TitleStyle](#TitleStyle)。
* `itemStyle`:环形图的圆环样式,包括设置背景颜色和边框等 [ItemStyle](#ItemStyle)。
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1``n`维数据。环形图的数据只有二维,`data[0]`表示当前值,`data[1]`表示最大值。
## `Settings`
---
全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
* `lineSmoothStyle`:曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
@@ -387,21 +645,18 @@
* `lineSegmentDistance` 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
* `cicleSmoothness`:圆形(包括扇形、环形等)的平滑度。数越小圆越平滑,但顶点数也会随之增加。
## `Animation`
## `SerieAnimation`
---
* `enable`:是否开起始画效果
* `easing`:动画的缓动效果。支持以下动画效果:
* `Linear`:线性效果
* `duration`:设定的动画时长,单位毫秒
* `threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画
* `delay`:动画延时,单位毫秒。
* `enable`:是否开启动画系统。
* ~~`threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。~~
* `fadeInDelay`:设定的渐入动画延时,单位毫秒
* `fadeInDuration`:设定的渐入动画时长,单位毫秒。
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒
* `dataChangeEnable`:是否开启数据变更动画
* `dataChangeDuration`:数据变更动画时长,单位毫秒
## `AreaStyle`
---
* `show`:是否显示区域填充。
* `origin`:区域填充的起始位置 `AreaOrigin`。有以下三种填充方式:
* `Auto`:填充坐标轴轴线到数据间的区域。
@@ -416,8 +671,6 @@
## `AxisLabel`
---
* `show`:是否显示刻度标签。
* `interval`坐标轴刻度标签的显示间隔在类目轴中有效。0表示显示所有标签1表示隔一个隔显示一个标签以此类推。
* `inside`:刻度标签是否朝内,默认朝外。
@@ -426,13 +679,12 @@
* `color`刻度标签文字的颜色默认取主题Theme的axisTextColor。
* `fontSize`:文字的字体大小。
* `fontStyle`:文字字体的风格。
* `formatter`:图例内容字符串模版格式器。支持用 \n 换行。模板变量为图例名称 {value}{value:f1} 表示取1为小数
* `formatter`:图例内容字符串模版格式器。支持用 \n 换行。模板变量为图例名称 {value}支持{value:f0}{value:f1}{value:f2}。
* `forceENotation`是否强制使用科学计数法格式化显示数值。默认为false当小数精度大于3时才采用科学计数法。
* `textLimit`:文本自适应 [TextLimit](#TextLimit)。只在类目轴中有效。
## `AxisLine`
---
* `show`:是否显示坐标轴轴线。
* `onZero`X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
* `width`:坐标轴线线宽。
@@ -444,8 +696,6 @@
## `AxisName`
---
* `show`:是否显示坐标名称。
* `name`:坐标轴名称。
* `location`:坐标轴名称的位置。支持以下类型:
@@ -458,45 +708,48 @@
* `fontSize`:坐标轴名称的文字大小。
* `fontStyle`:坐标轴名称的文字风格。
## `AxisSplitArea`
## `AxisSplitLine`
---
* `show`:是否显示坐标分割线。
* `interval`分割线的显示间隔。0表示显示所有分割线1表示隔一个隔显示一个分割线以此类推。
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
## `AxisSplitArea`
* `show`:是否显示坐标分割区域。
* `color`:分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
## `AxisTick`
---
* `show`:是否显示坐标轴刻度。
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
* `inside`:坐标轴刻度是否朝内,默认朝外。
* `length`:坐标轴刻度的长度。
* `width`坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
## `Emphasis`
---
* `show`:是否启用高亮样式。
* `label`:图形文本标签样式 [SerieLabel](#SerieLabel)。
* `itemStyle`:图形样式 [ItemStyle](#ItemStyle)。
## `ItemStyle`
---
* `show`:是否启用。
* `color`:颜色。
* `backgroundColor`:背景颜色。
* `backgroundWidth`:背景的宽。
* `centerColor`:中心区域的颜色。如环形图的中心区域。
* `centerGap`:中心区域的间隙。如环形图的中心区域于最内环的间隙。
* `borderType`:边框的类型。
* `borderColor`:边框的颜色。
* `borderWidth`:边框宽。
* `borderWidth`opacity。
* `opacity`:透明度
* `tooltipFormatter`:提示框单项的字符串模版格式器。具体配置参考`Tooltip``formatter`
* `cornerRadius`圆角半径。用数组分别指定4个圆角半径顺时针左上右上右下左下
## `LineArrow`
---
* `show`:是否显示箭头。
* `position`:箭头显示位置。支持以下两种位置:
* `End`:末端显示。最后一个数据上显示箭头。
@@ -508,9 +761,7 @@
## `LineStyle`
---
* `show`:是否显示线条。在折线图中无效。
* `show`:是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。
* `type`:线条类型。支持以下五种类型:
* `None`:不显示分割线。
* `Solid`:实线。
@@ -524,8 +775,6 @@
## `Location`
---
* `align`:对齐方式。有以下对齐方式。
* `TopLeft`:左上角对齐。
* `TopRight`:右上角对齐。
@@ -543,8 +792,6 @@
## `SerieData`
---
* `name`:数据项名称。
* `selected`:该数据项是否被选中。
* `radius`:自定义半径。可用在饼图中自定义某个数据项的半径。
@@ -557,8 +804,6 @@
## `SerieLabel`
---
* `show`:是否显示文本标签。
* `position`:标签的位置。折线图时强制默认为 `Center`,支持以下 `5` 种位置:
* `Outside`:饼图扇区外侧,通过视觉引导线连到相应的扇区。只在饼图种可用。
@@ -593,15 +838,14 @@
## `SerieSymbol`
---
* `type`:标记类型。支持以下六种类型:
* `EmptyCircle`:空心圆。
* `Circle`:实心圆。
* `Rect`:正方形。
* `Rect`:正方形。可通过设置`itemStyle``cornerRadius`变成圆角矩形。
* `Triangle`:三角形。
* `Diamond`:菱形。
* `None`:不显示标记。
* `gap`:图形标记的外留白距离。
* `sizeType`:标记图形的大小获取方式。支持以下三种类型:
* `Custom`:自定义大小。
* `FromData`:通过 `dataIndex` 从数据中获取,再乘以一个比例系数 `dataScale`

View File

@@ -27,6 +27,7 @@
[QA 21如何显示图例](#如何显示图例)
[QA 22如何做成预设](#如何做成预设)
[QA 23如何在图表上画点画线等自定义内容](#如何在图表上画点画线等自定义内容)
[QA 24如何实现心电图类似的数据移动效果](#如何实现心电图类似的数据移动效果)
## 如何调整坐标轴与背景的边距
@@ -120,6 +121,10 @@
xcharts有自定义绘制回调`customDrawCallback`,具体可参考`Demo12_CustomDrawing.cs`
## 如何实现心电图类似的数据移动效果
axis和serie都设置相同的maxCache。maxCache可固定数据个数当数据超过设定时会先删除第一个在添加新数据实现数据移动效果。
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
[XChartsAPI接口](XChartsAPI.md)
[XCharts配置项手册](XCharts配置项手册.md)

View File

@@ -6,6 +6,7 @@
/******************************************/
using UnityEditor;
using UnityEngine;
namespace XCharts
{
@@ -32,6 +33,8 @@ namespace XCharts
protected float m_DefaultLabelWidth;
protected float m_DefaultFieldWidth;
private int m_SeriesSize;
private Vector2 scrollPos;
private bool m_CheckWarning = false;
protected virtual void OnEnable()
{
@@ -65,6 +68,7 @@ namespace XCharts
OnMiddleInspectorGUI();
OnEndInspectorGUI();
CheckWarning();
serializedObject.ApplyModifiedProperties();
}
@@ -88,5 +92,50 @@ namespace XCharts
protected virtual void OnEndInspectorGUI()
{
}
private void CheckWarning()
{
EditorGUILayout.Space();
EditorGUILayout.Space();
if (m_CheckWarning)
{
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Check warning"))
{
m_CheckWarning = true;
m_Target.CheckWarning();
}
if (GUILayout.Button("Hide warning"))
{
m_CheckWarning = false;
}
EditorGUILayout.EndHorizontal();
var version = string.Format("version:{0}_{1}\n", XChartsMgr.version, XChartsMgr.date);
EditorGUILayout.LabelField(version);
if (!string.IsNullOrEmpty(m_Target.warningInfo))
{
var infos = m_Target.warningInfo.Split('\n');
foreach (var info in infos)
{
EditorGUILayout.LabelField(info);
}
}
else
{
EditorGUILayout.LabelField("Perfect! No warning!");
}
}
else
{
if (GUILayout.Button("Check warning"))
{
m_CheckWarning = true;
m_Target.CheckWarning();
}
}
EditorGUILayout.Space();
EditorGUILayout.Space();
}
}
}

View File

@@ -35,6 +35,7 @@ namespace XCharts
GUILayout.BeginHorizontal();
GUILayout.Label("最新版本:" + mgr.newVersion);
if (mgr.isCheck) GUILayout.Label("检测中...");
else if (mgr.isNetworkError) GUILayout.Label("检测失败:" + mgr.networkError);
else GUILayout.Label("有更新!");
if (GUILayout.Button("去Github主页"))
{
@@ -56,22 +57,27 @@ namespace XCharts
else
{
if (mgr.isCheck) GUILayout.Label("最新版本:检测中...");
else if (mgr.isNetworkError) GUILayout.Label("检测失败:" + mgr.networkError);
else GUILayout.Label("最新版本:" + mgr.newVersion);
if (!mgr.needUpdate && !mgr.isCheck)
GUILayout.Label("");
if (!mgr.isNetworkError && !mgr.needUpdate && !mgr.isCheck)
{
GUILayout.Label("");
GUILayout.Label("已是最新版本!");
}
GUILayout.Label("");
if (!string.IsNullOrEmpty(mgr.desc))
{
GUILayout.Label(mgr.desc);
GUILayout.Label("");
if (!string.IsNullOrEmpty(mgr.desc))
{
GUILayout.Label(mgr.desc);
GUILayout.Label("");
}
if (GUILayout.Button("去Github主页"))
{
Application.OpenURL(mgr.homepage);
}
}
if (GUILayout.Button("去Github主页"))
{
Application.OpenURL(mgr.homepage);
}
if (mgr.isNetworkError && GUILayout.Button("重新检测"))
{
XChartsMgr.Instance.CheckVersion();
}
}
}

View File

@@ -0,0 +1,33 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
namespace XCharts
{
/// <summary>
/// Editor class used to edit UI GaugeChart.
/// </summary>
[CustomEditor(typeof(GaugeChart), false)]
public class GaugeChartEditor : BaseChartEditor
{
protected SerializedProperty m_Radar;
protected SerializedProperty m_Radars;
protected override void OnEnable()
{
base.OnEnable();
m_Target = (GaugeChart)target;
}
protected override void OnEndInspectorGUI()
{
base.OnEndInspectorGUI();
}
}
}

View File

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

View File

@@ -22,35 +22,47 @@ namespace XCharts
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Enable = prop.FindPropertyRelative("m_Enable");
SerializedProperty m_Easting = prop.FindPropertyRelative("m_Easting");
SerializedProperty m_Duration = prop.FindPropertyRelative("m_Duration");
SerializedProperty m_Delay = prop.FindPropertyRelative("m_Delay");
//SerializedProperty m_Easting = prop.FindPropertyRelative("m_Easting");
SerializedProperty m_FadeInDuration = prop.FindPropertyRelative("m_FadeInDuration");
SerializedProperty m_FadeOutDuration = prop.FindPropertyRelative("m_FadeOutDuration");
SerializedProperty m_DataChangeEnable = prop.FindPropertyRelative("m_DataChangeEnable");
SerializedProperty m_DataChangeDuration = prop.FindPropertyRelative("m_DataChangeDuration");
SerializedProperty m_FadeInDelay = prop.FindPropertyRelative("m_FadeInDelay");
SerializedProperty m_Threshold = prop.FindPropertyRelative("m_Threshold");
SerializedProperty m_ActualDuration = prop.FindPropertyRelative("m_ActualDuration");
SerializedProperty m_CurrDetailProgress = prop.FindPropertyRelative("m_CurrDetailProgress");
SerializedProperty m_DestDetailProgress = prop.FindPropertyRelative("m_DestDetailProgress");
// SerializedProperty m_CurrDetailProgress = prop.FindPropertyRelative("m_CurrDetailProgress");
// SerializedProperty m_DestDetailProgress = prop.FindPropertyRelative("m_DestDetailProgress");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AnimationModuleToggle, prop, null, m_Enable, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_AnimationModuleToggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Easting);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Duration);
if (m_Duration.intValue < 0) m_Duration.intValue = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Delay);
if (m_Delay.intValue < 0) m_Delay.intValue = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
//EditorGUI.PropertyField(drawRect, m_Easting);
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Threshold);
if (m_Threshold.intValue < 0) m_Threshold.intValue = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.LabelField(drawRect, "CurrDetailProgress:" + m_CurrDetailProgress.floatValue);
EditorGUI.PropertyField(drawRect, m_FadeInDelay);
if (m_FadeInDelay.floatValue < 0) m_FadeInDelay.floatValue = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.LabelField(drawRect, "DestDetailProgress:" + m_DestDetailProgress.floatValue);
EditorGUI.PropertyField(drawRect, m_FadeInDuration);
if (m_FadeInDuration.floatValue < 0) m_FadeInDuration.floatValue = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.LabelField(drawRect, "Actual duration:" + m_ActualDuration.intValue + " ms");
EditorGUI.PropertyField(drawRect, m_FadeOutDuration);
if (m_FadeOutDuration.floatValue < 0) m_FadeOutDuration.floatValue = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_DataChangeEnable);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_DataChangeDuration);
if (m_DataChangeDuration.floatValue < 0) m_DataChangeDuration.floatValue = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
// EditorGUI.LabelField(drawRect, "CurrDetailProgress:" + m_CurrDetailProgress.floatValue);
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
// EditorGUI.LabelField(drawRect, "DestDetailProgress:" + m_DestDetailProgress.floatValue);
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.LabelField(drawRect, "Actual duration:" + m_ActualDuration.floatValue + " ms");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel;
}

View File

@@ -33,20 +33,22 @@ namespace XCharts
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
SerializedProperty m_LogBaseE = prop.FindPropertyRelative("m_LogBaseE");
SerializedProperty m_LogBase = prop.FindPropertyRelative("m_LogBase");
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
SerializedProperty m_ShowSplitLine = prop.FindPropertyRelative("m_ShowSplitLine");
SerializedProperty m_SplitLineType = prop.FindPropertyRelative("m_SplitLineType");
SerializedProperty m_BoundaryGap = prop.FindPropertyRelative("m_BoundaryGap");
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
SerializedProperty m_AxisLine = prop.FindPropertyRelative("m_AxisLine");
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
SerializedProperty m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
SerializedProperty m_CeilRate = prop.FindPropertyRelative("m_CeilRate");
int index = InitToggle(prop);
bool toggle = m_AxisModuleToggle[index];
@@ -59,6 +61,13 @@ namespace XCharts
EditorGUI.indentLevel++;
EditorGUI.PropertyField(drawRect, m_Type);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (type == Axis.AxisType.Log)
{
EditorGUI.PropertyField(drawRect, m_LogBaseE);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LogBase);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
if (type == Axis.AxisType.Value)
{
EditorGUI.PropertyField(drawRect, m_MinMaxType);
@@ -79,28 +88,13 @@ namespace XCharts
EditorGUI.indentLevel--;
break;
}
EditorGUI.PropertyField(drawRect, m_CeilRate);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
EditorGUI.PropertyField(drawRect, m_SplitNumber);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Interval);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_ShowSplitLine.boolValue)
{
drawRect.width = EditorGUIUtility.labelWidth + 10;
EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.x = EditorGUIUtility.labelWidth + 35;
drawRect.width = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 55;
EditorGUI.PropertyField(drawRect, m_SplitLineType, GUIContent.none);
drawRect.x = pos.x;
drawRect.width = pos.width;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
else
{
EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
EditorGUI.PropertyField(drawRect, m_BoundaryGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_AxisLine);
@@ -115,6 +109,8 @@ namespace XCharts
EditorGUI.PropertyField(drawRect, m_AxisLabel);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLabel);
EditorGUI.PropertyField(drawRect, m_SplitLine);
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
EditorGUI.PropertyField(drawRect, m_SplitArea);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
@@ -149,8 +145,9 @@ namespace XCharts
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
SerializedProperty m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
float height = 0;
height += 11 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
if (type == Axis.AxisType.Category)
{
@@ -173,7 +170,16 @@ namespace XCharts
}
else if (type == Axis.AxisType.Value)
{
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
height += 2 * EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
if (m_MinMaxType.enumValueIndex == (int)Axis.AxisMinMaxType.Custom)
{
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
}
}
else if (type == Axis.AxisType.Log)
{
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
if (m_MinMaxType.enumValueIndex == (int)Axis.AxisMinMaxType.Custom)
{
@@ -185,6 +191,7 @@ namespace XCharts
height += EditorGUI.GetPropertyHeight(m_AxisTick);
height += EditorGUI.GetPropertyHeight(m_AxisLabel);
height += EditorGUI.GetPropertyHeight(m_SplitArea);
height += EditorGUI.GetPropertyHeight(m_SplitLine);
return height;
}
}
@@ -192,7 +199,7 @@ namespace XCharts
private int InitToggle(SerializedProperty prop)
{
int index = 0;
int.TryParse(prop.displayName.Split(' ')[1],out index);
int.TryParse(prop.displayName.Split(' ')[1], out index);
if (index >= m_DataFoldout.Count)
{
m_DataFoldout.Add(false);

View File

@@ -30,6 +30,7 @@ namespace XCharts
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
SerializedProperty m_TextLimit = prop.FindPropertyRelative("m_TextLimit");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLabelToggle, prop, "Axis Label", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -54,6 +55,8 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ForceENotation);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TextLimit);
drawRect.y += EditorGUI.GetPropertyHeight(m_TextLimit);
--EditorGUI.indentLevel;
}
}
@@ -63,7 +66,8 @@ namespace XCharts
float height = 0;
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
{
height += 9 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextLimit"));
}
return height;
}

View File

@@ -0,0 +1,55 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(AxisSplitLine), true)]
public class AxisSplitLineDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_AxisSplitLineToggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisSplitLineToggle, prop, "Split Line", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_AxisSplitLineToggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Interval);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
if (ChartEditorHelper.IsToggle(m_AxisSplitLineToggle, prop))
{
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
}
else
{
height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
}
}

View File

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

View File

@@ -23,6 +23,7 @@ namespace XCharts
SerializedProperty m_AlignWithLabel = prop.FindPropertyRelative("m_AlignWithLabel");
SerializedProperty m_Inside = prop.FindPropertyRelative("m_Inside");
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisTickToggle, "Axis Tick", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -35,6 +36,8 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Length);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Width);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel;
}
}
@@ -44,7 +47,7 @@ namespace XCharts
float height = 0;
if (m_AxisTickToggle)
{
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
}
return height;
}

View File

@@ -35,6 +35,7 @@ namespace XCharts
SerializedProperty m_RangeMode = prop.FindPropertyRelative("m_RangeMode");
SerializedProperty m_Start = prop.FindPropertyRelative("m_Start");
SerializedProperty m_End = prop.FindPropertyRelative("m_End");
SerializedProperty m_MinShowNum = prop.FindPropertyRelative("m_MinShowNum");
SerializedProperty m_ScrollSensitivity = prop.FindPropertyRelative("m_ScrollSensitivity");
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
@@ -79,8 +80,11 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_End);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MinShowNum);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_Start.floatValue < 0) m_Start.floatValue = 0;
if (m_End.floatValue > 100) m_End.floatValue = 100;
if (m_MinShowNum.intValue < 0) m_MinShowNum.intValue = 0;
--EditorGUI.indentLevel;
}
}
@@ -91,7 +95,7 @@ namespace XCharts
int num = 1;
if (m_DataZoomModuleToggle)
{
num += 7;
num += 8;
if (prop.FindPropertyRelative("m_SupportSlider").boolValue) num += 6;
}

View File

@@ -0,0 +1,82 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(GaugeAxis), true)]
public class GaugeAxisDrawer : PropertyDrawer
{
private bool m_DataFoldout = false;
private int m_DataSize = 0;
private Dictionary<string, bool> m_AxisLineToggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_AxisLine = prop.FindPropertyRelative("m_AxisLine");
SerializedProperty m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
SerializedProperty m_AxisLabelText = prop.FindPropertyRelative("m_AxisLabelText");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLineToggle, prop, "Gauge Axis", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_AxisLineToggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_AxisLine);
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLine);
EditorGUI.PropertyField(drawRect, m_SplitLine);
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
EditorGUI.PropertyField(drawRect, m_AxisTick);
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisTick);
EditorGUI.PropertyField(drawRect, m_AxisLabel);
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLabel);
drawRect.width = EditorGUIUtility.labelWidth + 10;
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Axis Label Text");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.width = pos.width;
if (m_DataFoldout)
{
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_AxisLabelText);
}
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
if (ChartEditorHelper.IsToggle(m_AxisLineToggle, prop))
{
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AxisLine"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitLine"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AxisTick"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AxisLabel"));
if (m_DataFoldout)
{
SerializedProperty m_Data = prop.FindPropertyRelative("m_AxisLabelText");
int num = m_Data.arraySize + 1;
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
else
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
}

View File

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

View File

@@ -0,0 +1,76 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(GaugeAxis.AxisLine), true)]
public class GaugeAxisLineDrawer : PropertyDrawer
{
private bool m_DataFoldout = false;
private int m_DataSize = 0;
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
SerializedProperty m_BarBackgroundColor = prop.FindPropertyRelative("m_BarBackgroundColor");
SerializedProperty m_BarColor = prop.FindPropertyRelative("m_BarColor");
SerializedProperty m_StageColor = prop.FindPropertyRelative("m_StageColor");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Axis Line", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Width);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Opacity);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarBackgroundColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Stage Color");
drawRect.width = pos.width;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_DataFoldout)
{
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_StageColor);
}
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
float height = 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
if (m_DataFoldout)
{
var arraySize = prop.FindPropertyRelative("m_StageColor").arraySize + 1;
height += arraySize * EditorGUIUtility.singleLineHeight + (arraySize) * EditorGUIUtility.standardVerticalSpacing;
height += 2 * EditorGUIUtility.standardVerticalSpacing;
return height;
}
return height;
}
else
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
}

View File

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

View File

@@ -0,0 +1,33 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(GaugeAxis.AxisLine.StageColor), true)]
public class GaugeAxisLineStageColorDrawer : PropertyDrawer
{
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Percent = prop.FindPropertyRelative("m_Percent");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
ChartEditorHelper.MakeTwoField(ref drawRect, drawRect.width, m_Percent, m_Color, "Stage");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
}

View File

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

View File

@@ -0,0 +1,54 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(GaugeAxis.SplitLine), true)]
public class GaugeAxisSplitDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Split Line", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Length);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
float height = 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
return height;
}
else
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
}

View File

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

View File

@@ -0,0 +1,57 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(GaugeAxis.AxisTick), true)]
public class GaugeAxisTickDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Axis Tick", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Length);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SplitNumber);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
float height = 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
return height;
}
else
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
}

View File

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

View File

@@ -0,0 +1,51 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(GaugePointer), true)]
public class GaugePointerDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Gauge Pointer", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Width);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Length);
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
{
return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
else
{
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
}
}
}

View File

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

View File

@@ -0,0 +1,67 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(IconStyle), true)]
public class IconStyleDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_IconStyleToggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Layer = prop.FindPropertyRelative("m_Layer");
SerializedProperty m_Sprite = prop.FindPropertyRelative("m_Sprite");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
SerializedProperty m_Height = prop.FindPropertyRelative("m_Height");
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_IconStyleToggle, prop, null, m_Show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_IconStyleToggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Layer);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Sprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Color);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Width);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Height);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Offset);
drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (ChartEditorHelper.IsToggle(m_IconStyleToggle, prop))
{
var hight = 6 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
hight += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
hight += EditorGUIUtility.standardVerticalSpacing;
return hight;
}
else
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
}
}
}

View File

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

View File

@@ -14,7 +14,9 @@ namespace XCharts
[CustomPropertyDrawer(typeof(ItemStyle), true)]
public class ItemStyleDrawer : PropertyDrawer
{
private int m_CornerRadius = 0;
private Dictionary<string, bool> m_ItemStyleToggle = new Dictionary<string, bool>();
private Dictionary<string, bool> m_CornerRadiusToggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
@@ -22,10 +24,17 @@ namespace XCharts
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
SerializedProperty m_ToColor = prop.FindPropertyRelative("m_ToColor");
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
SerializedProperty m_BackgroundWidth = prop.FindPropertyRelative("m_BackgroundWidth");
SerializedProperty m_CenterColor = prop.FindPropertyRelative("m_CenterColor");
SerializedProperty m_CenterGap = prop.FindPropertyRelative("m_CenterGap");
SerializedProperty m_BorderType = prop.FindPropertyRelative("m_BorderType");
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
SerializedProperty m_TooltipFormatter = prop.FindPropertyRelative("m_TooltipFormatter");
SerializedProperty m_CornerRadius = prop.FindPropertyRelative("m_CornerRadius");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_ItemStyleToggle, prop, "Item Style", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_ItemStyleToggle, prop))
@@ -33,6 +42,16 @@ namespace XCharts
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Color);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ToColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BackgroundWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_CenterColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_CenterGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BorderType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BorderWidth);
@@ -41,6 +60,14 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Opacity);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TooltipFormatter);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_CornerRadiusToggle, m_CornerRadius, "Corner Radius", null, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_CornerRadiusToggle, m_CornerRadius))
{
ChartEditorHelper.MakeList(ref drawRect, ref this.m_CornerRadius, m_CornerRadius, false, false);
}
--EditorGUI.indentLevel;
}
}
@@ -50,7 +77,12 @@ namespace XCharts
float height = 0;
if (ChartEditorHelper.IsToggle(m_ItemStyleToggle, prop))
{
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
height += 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing;
var m_CornerRadius = prop.FindPropertyRelative("m_CornerRadius");
if (ChartEditorHelper.IsToggle(m_CornerRadiusToggle, m_CornerRadius))
{
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
}
}
else
{

View File

@@ -14,7 +14,9 @@ namespace XCharts
public class LegendDrawer : PropertyDrawer
{
private bool m_DataFoldout = false;
private bool m_IconsFoldout = false;
private int m_DataSize = 0;
private int m_IconsSize = 0;
private bool m_ShowJsonDataArea = false;
private string m_JsonDataAreaText;
private bool m_LegendModuleToggle = false;
@@ -30,9 +32,11 @@ namespace XCharts
SerializedProperty itemWidth = prop.FindPropertyRelative("m_ItemWidth");
SerializedProperty itemHeight = prop.FindPropertyRelative("m_ItemHeight");
SerializedProperty itemGap = prop.FindPropertyRelative("m_ItemGap");
SerializedProperty itemFontSize = prop.FindPropertyRelative("m_ItemFontSize");
SerializedProperty m_ItemAutoColor = prop.FindPropertyRelative("m_ItemAutoColor");
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
SerializedProperty m_Icons = prop.FindPropertyRelative("m_Icons");
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_LegendModuleToggle, "Legend", show);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -45,7 +49,7 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, itemGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, itemFontSize);
EditorGUI.PropertyField(drawRect, m_ItemAutoColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SelectedMode);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -57,12 +61,20 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.width = EditorGUIUtility.labelWidth + 10;
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Data");
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop,pos.width);
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop, pos.width);
drawRect.width = pos.width;
if (m_DataFoldout)
{
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
}
m_IconsFoldout = EditorGUI.Foldout(drawRect, m_IconsFoldout, "Icons");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_IconsFoldout)
{
ChartEditorHelper.MakeList(ref drawRect, ref m_IconsSize, m_Icons);
}
EditorGUI.PropertyField(drawRect, m_TextStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
--EditorGUI.indentLevel;
}
}
@@ -73,7 +85,7 @@ namespace XCharts
if (m_LegendModuleToggle)
{
SerializedProperty location = prop.FindPropertyRelative("m_Location");
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(location);
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_DataFoldout)
@@ -83,6 +95,14 @@ namespace XCharts
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUIUtility.standardVerticalSpacing;
}
if (m_IconsFoldout)
{
SerializedProperty m_Icons = prop.FindPropertyRelative("m_Icons");
int num = m_Icons.arraySize + 1;
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUIUtility.standardVerticalSpacing;
}
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
}
if (m_ShowJsonDataArea)
{

View File

@@ -15,12 +15,14 @@ namespace XCharts
public class RadarDrawer : PropertyDrawer
{
SerializedProperty m_Shape;
SerializedProperty m_PositionType;
SerializedProperty m_Radius;
SerializedProperty m_SplitNumber;
SerializedProperty m_Center;
SerializedProperty m_LineStyle;
SerializedProperty m_SplitLine;
SerializedProperty m_SplitArea;
SerializedProperty m_Indicator;
SerializedProperty m_IndicatorGap;
SerializedProperty m_IndicatorList;
private Dictionary<string, bool> m_RadarModuleToggle = new Dictionary<string, bool>();
@@ -33,12 +35,14 @@ namespace XCharts
private void InitProperty(SerializedProperty prop)
{
m_Shape = prop.FindPropertyRelative("m_Shape");
m_PositionType = prop.FindPropertyRelative("m_PositionType");
m_Radius = prop.FindPropertyRelative("m_Radius");
m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
m_Center = prop.FindPropertyRelative("m_Center");
m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
m_Indicator = prop.FindPropertyRelative("m_Indicator");
m_IndicatorGap = prop.FindPropertyRelative("m_IndicatorGap");
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
}
@@ -50,9 +54,9 @@ namespace XCharts
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
drawRect.height = EditorGUIUtility.singleLineHeight;
int index = ChartEditorHelper.GetIndexFromPath(prop);
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Radar " + index, null, false);
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Radar " + index, null, true);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
{
++EditorGUI.indentLevel;
@@ -60,6 +64,8 @@ namespace XCharts
EditorGUIUtility.fieldWidth = defaultFieldWidth;
EditorGUI.PropertyField(drawRect, m_Shape);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_PositionType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.LabelField(drawRect, "Center");
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
@@ -79,8 +85,8 @@ namespace XCharts
EditorGUI.PropertyField(drawRect, m_SplitNumber);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
EditorGUI.PropertyField(drawRect, m_SplitLine);
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
EditorGUI.PropertyField(drawRect, m_SplitArea);
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -90,6 +96,8 @@ namespace XCharts
drawRect.x = pos.x;
if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop))
{
EditorGUI.PropertyField(drawRect, m_IndicatorGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
ChartEditorHelper.MakeList(ref drawRect, ref m_IndicatorSize, m_IndicatorList);
}
--EditorGUI.indentLevel;
@@ -99,18 +107,18 @@ namespace XCharts
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
int propNum = 1;
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
{
propNum += 6;
propNum += 7;
if (m_IndicatorJsonAreaToggle) propNum += 4;
float height = propNum * EditorGUIUtility.singleLineHeight + (propNum - 1) * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitLine"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitArea"));
if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop))
{
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
for (int i = 0; i < m_IndicatorList.arraySize; i++)
{

View File

@@ -21,7 +21,7 @@ namespace XCharts
SerializedProperty m_Name = prop.FindPropertyRelative("m_Name");
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
Rect drawRect = pos;
float defaultLabelWidth = EditorGUIUtility.labelWidth;
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
@@ -30,7 +30,7 @@ namespace XCharts
int index = ChartEditorHelper.GetIndexFromPath(prop);
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Indicator " + index, m_Name, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
{
++EditorGUI.indentLevel;
@@ -40,8 +40,8 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Max);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Color);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TextStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
--EditorGUI.indentLevel;
}
@@ -49,9 +49,11 @@ namespace XCharts
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
{
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
var height = 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
return height;
}
else
{

View File

@@ -28,6 +28,7 @@ namespace XCharts
SerializedProperty name = prop.FindPropertyRelative("m_Name");
SerializedProperty stack = prop.FindPropertyRelative("m_Stack");
SerializedProperty m_AxisIndex = prop.FindPropertyRelative("m_AxisIndex");
SerializedProperty m_RadarType = prop.FindPropertyRelative("m_RadarType");
SerializedProperty m_RadarIndex = prop.FindPropertyRelative("m_RadarIndex");
SerializedProperty m_MinShow = prop.FindPropertyRelative("m_MinShow");
SerializedProperty m_MaxShow = prop.FindPropertyRelative("m_MaxShow");
@@ -58,6 +59,21 @@ namespace XCharts
SerializedProperty m_DataDimension = prop.FindPropertyRelative("m_ShowDataDimension");
SerializedProperty m_ShowDataName = prop.FindPropertyRelative("m_ShowDataName");
SerializedProperty m_ShowDataIcon = prop.FindPropertyRelative("m_ShowDataIcon");
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
SerializedProperty m_StartAngle = prop.FindPropertyRelative("m_StartAngle");
SerializedProperty m_EndAngle = prop.FindPropertyRelative("m_EndAngle");
SerializedProperty m_RingGap = prop.FindPropertyRelative("m_RingGap");
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
SerializedProperty m_Clockwise = prop.FindPropertyRelative("m_Clockwise");
SerializedProperty m_RoundCap = prop.FindPropertyRelative("m_RoundCap");
SerializedProperty m_GaugeType = prop.FindPropertyRelative("m_GaugeType");
SerializedProperty m_GaugeAxis = prop.FindPropertyRelative("m_GaugeAxis");
SerializedProperty m_GaugePointer = prop.FindPropertyRelative("m_GaugePointer");
SerializedProperty m_TitleStyle = prop.FindPropertyRelative("m_TitleStyle");
SerializedProperty m_Clip = prop.FindPropertyRelative("m_Clip");
SerializedProperty m_Ignore = prop.FindPropertyRelative("m_Ignore");
SerializedProperty m_IgnoreValue = prop.FindPropertyRelative("m_IgnoreValue");
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
int index = InitToggle(prop);
@@ -65,8 +81,10 @@ namespace XCharts
var toggle = ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieModuleToggle, prop, moduleName, show);
if (!toggle)
{
drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2 + 20;
drawRect.width = pos.width - drawRect.x + 15;
var orderButton = 46;
var gap = 4;
drawRect.x += EditorGUIUtility.labelWidth + gap;
drawRect.width = pos.width - drawRect.x + ChartEditorHelper.BOOL_WIDTH - orderButton;
EditorGUI.PropertyField(drawRect, type, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
@@ -82,87 +100,207 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, name);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, stack);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (serieType == SerieType.Radar)
{
EditorGUI.PropertyField(drawRect, m_RadarIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
else
{
EditorGUI.PropertyField(drawRect, m_AxisIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
EditorGUI.PropertyField(drawRect, m_MinShow);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MaxShow);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MaxCache);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0;
if (serieType == SerieType.Line)
{
EditorGUI.PropertyField(drawRect, m_LineType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SampleDist);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SampleType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SampleAverage);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
if (serieType == SerieType.Line
|| serieType == SerieType.Scatter
|| serieType == SerieType.EffectScatter
|| serieType == SerieType.Radar)
{
EditorGUI.PropertyField(drawRect, m_Symbol);
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
}
if (serieType == SerieType.Bar)
{
EditorGUI.PropertyField(drawRect, m_BarType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarPercentStack);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarZebraWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarZebraGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
if (serieType == SerieType.Pie)
{
EditorGUI.PropertyField(drawRect, m_RoseType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Space);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
}
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
if (serieType == SerieType.Line)
switch (serieType)
{
EditorGUI.PropertyField(drawRect, m_LineArrow);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineArrow);
case SerieType.Line:
EditorGUI.PropertyField(drawRect, stack);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_AxisIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MinShow);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MaxShow);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MaxCache);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0;
EditorGUI.PropertyField(drawRect, m_LineType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SampleDist);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SampleType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SampleAverage);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Clip);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Ignore);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Symbol);
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
EditorGUI.PropertyField(drawRect, m_LineArrow);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineArrow);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_AreaStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
case SerieType.Bar:
EditorGUI.PropertyField(drawRect, stack);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_AxisIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MinShow);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MaxShow);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MaxCache);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0;
EditorGUI.PropertyField(drawRect, m_BarType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarPercentStack);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarZebraWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BarZebraGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Clip);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Ignore);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
case SerieType.Pie:
EditorGUI.PropertyField(drawRect, m_RoseType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Space);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
EditorGUI.PropertyField(drawRect, m_RoundCap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
case SerieType.Ring:
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
EditorGUI.PropertyField(drawRect, m_StartAngle);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_RingGap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_RoundCap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Clockwise);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TitleStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TitleStyle);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
case SerieType.Radar:
EditorGUI.PropertyField(drawRect, m_RadarType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_RadarIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Symbol);
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_AreaStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
case SerieType.Scatter:
case SerieType.EffectScatter:
EditorGUI.PropertyField(drawRect, m_Clip);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Symbol);
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
case SerieType.Heatmap:
EditorGUI.PropertyField(drawRect, m_Ignore);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
case SerieType.Gauge:
EditorGUI.PropertyField(drawRect, m_GaugeType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
//ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
EditorGUI.PropertyField(drawRect, m_Radius.GetArrayElementAtIndex(0), new GUIContent("Radius"));
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Min);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Max);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_StartAngle);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_EndAngle);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SplitNumber);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_SplitNumber.intValue > 36)
{
m_SplitNumber.intValue = 36;
}
EditorGUI.PropertyField(drawRect, m_RoundCap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TitleStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TitleStyle);
EditorGUI.PropertyField(drawRect, m_GaugeAxis);
drawRect.y += EditorGUI.GetPropertyHeight(m_GaugeAxis);
EditorGUI.PropertyField(drawRect, m_GaugePointer);
drawRect.y += EditorGUI.GetPropertyHeight(m_GaugePointer);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
break;
}
EditorGUI.PropertyField(drawRect, m_ItemStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_AreaStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
EditorGUI.PropertyField(drawRect, m_Label);
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_Emphasis);
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
EditorGUI.PropertyField(drawRect, m_Animation);
drawRect.y += EditorGUI.GetPropertyHeight(m_Animation);
drawRect.width = EditorGUIUtility.labelWidth + 10;
@@ -173,15 +311,22 @@ namespace XCharts
{
EditorGUI.indentLevel++;
float nameWid = 40;
float nameWid = 45;
#if UNITY_2019_3_OR_NEWER
var gap = 2;
var namegap = 3;
#else
var gap = 0;
var namegap = 0;
#endif
EditorGUI.PropertyField(new Rect(drawRect.x, drawRect.y, pos.width - 2 * nameWid - 2, pos.height), m_DataDimension);
var nameRect = new Rect(pos.width - 2 * nameWid + 14, drawRect.y, nameWid, pos.height);
var nameRect = new Rect(pos.width - 2 * nameWid + 14 + gap, drawRect.y, nameWid - gap, pos.height);
if (GUI.Button(nameRect, new GUIContent("Name")))
{
m_ShowDataName.boolValue = !m_ShowDataName.boolValue;
}
var iconRect = new Rect(pos.width - nameWid + 14, drawRect.y, nameWid, pos.height);
if (GUI.Button(iconRect, new GUIContent("Icon")))
var iconRect = new Rect(pos.width - nameWid + 14, drawRect.y, nameWid + namegap, pos.height);
if (GUI.Button(iconRect, new GUIContent("More...")))
{
m_ShowDataIcon.boolValue = !m_ShowDataIcon.boolValue;
}
@@ -225,6 +370,7 @@ namespace XCharts
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
}
}
drawRect.y += EditorGUIUtility.standardVerticalSpacing;
EditorGUI.indentLevel--;
}
--EditorGUI.indentLevel;
@@ -232,7 +378,7 @@ namespace XCharts
}
private void DrawDataElement(ref Rect drawRect, int dimension, SerializedProperty m_Datas, bool showName,
bool showIconDetail, bool showSelected, int index, float currentWidth)
bool showDetail, bool showSelected, int index, float currentWidth)
{
var lastX = drawRect.x;
var lastWid = drawRect.width;
@@ -253,7 +399,7 @@ namespace XCharts
if (showSelected)
{
drawRect.width = drawRect.width - 18;
EditorGUI.PropertyField(drawRect, element);
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index));
drawRect.x = currentWidth - 45;
EditorGUI.PropertyField(drawRect, selected, GUIContent.none);
drawRect.x = lastX;
@@ -261,20 +407,27 @@ namespace XCharts
}
else
{
EditorGUI.PropertyField(drawRect, element);
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index));
}
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
}
else
{
#if UNITY_2019_3_OR_NEWER
var gap = 2;
var namegap = 3;
#else
var gap = 0;
var namegap = 0;
#endif
EditorGUI.LabelField(drawRect, "Element " + index);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
var dataWidTotal = (currentWidth - (startX + 20.5f + 1));
var dataWid = dataWidTotal / fieldCount;
var xWid = dataWid - 4;
for (int i = 0; i < dimension; i++)
{
if (i >= data.arraySize - 1)
while (i >= data.arraySize - 1)
{
data.InsertArrayElementAtIndex(data.arraySize);
}
@@ -286,7 +439,7 @@ namespace XCharts
if (showName)
{
drawRect.x = startX + (fieldCount - 1) * xWid;
drawRect.width = dataWid + 40;
drawRect.width = dataWid + 40 + dimension * namegap;
EditorGUI.PropertyField(drawRect, sereName, GUIContent.none);
}
@@ -296,37 +449,29 @@ namespace XCharts
EditorGUIUtility.fieldWidth = lastFieldWid;
EditorGUIUtility.labelWidth = lastLabelWid;
}
if (showIconDetail)
if (showDetail)
{
EditorGUI.indentLevel++;
var m_ShowIcon = serieData.FindPropertyRelative("m_ShowIcon");
var m_IconImage = serieData.FindPropertyRelative("m_IconImage");
var m_IconColor = serieData.FindPropertyRelative("m_IconColor");
var m_IconWidth = serieData.FindPropertyRelative("m_IconWidth");
var m_IconHeight = serieData.FindPropertyRelative("m_IconHeight");
var m_IconOffset = serieData.FindPropertyRelative("m_IconOffset");
EditorGUI.PropertyField(drawRect, m_ShowIcon);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IconImage);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IconColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IconWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IconHeight);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.indentLevel += 2;
var m_Icon = serieData.FindPropertyRelative("m_IconStyle");
var m_EnableLabel = serieData.FindPropertyRelative("m_EnableLabel");
var m_Label = serieData.FindPropertyRelative("m_Label");
var m_EnableItemStyle = serieData.FindPropertyRelative("m_EnableItemStyle");
var m_ItemStyle = serieData.FindPropertyRelative("m_ItemStyle");
var m_EnableEmphasis = serieData.FindPropertyRelative("m_EnableEmphasis");
var m_Emphasis = serieData.FindPropertyRelative("m_Emphasis");
EditorGUI.PropertyField(drawRect, m_Icon);
drawRect.y += EditorGUI.GetPropertyHeight(m_Icon);
EditorGUI.PropertyField(drawRect, m_Label);
ChartEditorHelper.MakeBool(drawRect, m_EnableLabel, 1, "(enable)");
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
EditorGUI.PropertyField(drawRect, m_ItemStyle);
ChartEditorHelper.MakeBool(drawRect, m_EnableItemStyle, 1, "(enable)");
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
EditorGUI.PropertyField(drawRect, m_Emphasis);
ChartEditorHelper.MakeBool(drawRect, m_EnableEmphasis, 1, "(enable)");
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
EditorGUI.LabelField(drawRect, "Icon Offset");
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
var tempWidth = (drawRect.width - startX + 72) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
var centerYRect = new Rect(centerXRect.x + tempWidth - 58, drawRect.y, tempWidth, drawRect.height);
var x = EditorGUI.FloatField(centerXRect, m_IconOffset.vector3Value.x);
var y = EditorGUI.FloatField(centerYRect, m_IconOffset.vector3Value.y);
m_IconOffset.vector3Value = new Vector3(x, y);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.indentLevel--;
EditorGUI.indentLevel -= 2;
}
}
@@ -334,54 +479,112 @@ namespace XCharts
{
float height = 0;
int index = InitToggle(prop);
if (!m_SerieModuleToggle[prop.propertyPath])
if (!m_SerieModuleToggle.ContainsKey(prop.propertyPath) || !m_SerieModuleToggle[prop.propertyPath])
{
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
else
{
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
SerializedProperty type = prop.FindPropertyRelative("m_Type");
var serieType = (SerieType)type.enumValueIndex;
if (serieType == SerieType.Line
|| serieType == SerieType.Scatter
|| serieType == SerieType.EffectScatter
|| serieType == SerieType.Radar)
switch (serieType)
{
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
}
if (serieType == SerieType.Pie)
{
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
}
if (serieType == SerieType.Line)
{
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
}
if (serieType == SerieType.Bar)
{
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
case SerieType.Line:
height += 16 * EditorGUIUtility.singleLineHeight + 15 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Bar:
height += 18 * EditorGUIUtility.singleLineHeight + 17 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Pie:
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Ring:
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TitleStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Radar:
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Scatter:
case SerieType.EffectScatter:
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Heatmap:
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
case SerieType.Gauge:
height += 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TitleStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_GaugeAxis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_GaugePointer"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
break;
}
if (m_DataFoldout[index])
{
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
int num = m_Data.arraySize + 2;
if (num > 30) num = 15;
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
int num = m_Data.arraySize;
if (num > 30)
{
num = 11;
height += (num + 1) * EditorGUIUtility.singleLineHeight + (num) * EditorGUIUtility.standardVerticalSpacing;
}
else
{
height += (num) * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
}
height += EditorGUIUtility.standardVerticalSpacing;
if (prop.FindPropertyRelative("m_ShowDataIcon").boolValue)
{
num *= 5;
num += 2;
for (int i = 0; i < num; i++)
{
var item = m_Data.GetArrayElementAtIndex(i);
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_IconStyle"));
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Label"));
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_ItemStyle"));
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Emphasis"));
}
}
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
}
if (m_ShowJsonDataArea)
{

View File

@@ -24,6 +24,7 @@ namespace XCharts
SerializedProperty m_Position = prop.FindPropertyRelative("m_Position");
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
SerializedProperty m_Margin = prop.FindPropertyRelative("m_Margin");
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
@@ -52,19 +53,14 @@ namespace XCharts
EditorGUI.PropertyField(drawRect, m_Position);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.LabelField(drawRect, "Offset");
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
var tempWidth = (drawRect.width - startX + 52) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
var centerYRect = new Rect(centerXRect.x + tempWidth - 38, drawRect.y, tempWidth, drawRect.height);
var x = EditorGUI.FloatField(centerXRect, m_Offset.vector3Value.x);
var y = EditorGUI.FloatField(centerYRect, m_Offset.vector3Value.y);
m_Offset.vector3Value = new Vector3(x, y);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Offset);
drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
EditorGUI.PropertyField(drawRect, m_Margin);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Formatter);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Color);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
@@ -113,6 +109,7 @@ namespace XCharts
if (ChartEditorHelper.IsToggle(m_SerieLabelToggle, prop))
{
height += 23 * EditorGUIUtility.singleLineHeight + 22 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
}
else
{

View File

@@ -27,11 +27,10 @@ namespace XCharts
SerializedProperty m_DataIndex = prop.FindPropertyRelative("m_DataIndex");
SerializedProperty m_DataScale = prop.FindPropertyRelative("m_DataScale");
SerializedProperty m_SelectedDataScale = prop.FindPropertyRelative("m_SelectedDataScale");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
SerializedProperty m_StartIndex = prop.FindPropertyRelative("m_StartIndex");
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
SerializedProperty m_ForceShowLast = prop.FindPropertyRelative("m_ForceShowLast");
SerializedProperty m_Gap = prop.FindPropertyRelative("m_Gap");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieSymbolToggle, prop, null, m_Type, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -39,6 +38,8 @@ namespace XCharts
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Gap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SizeType);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
SerieSymbolSizeType sizeType = (SerieSymbolSizeType)m_SizeType.enumValueIndex;
@@ -61,10 +62,6 @@ namespace XCharts
case SerieSymbolSizeType.Callback:
break;
}
EditorGUI.PropertyField(drawRect, m_Color);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Opacity);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_StartIndex);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Interval);
@@ -84,13 +81,13 @@ namespace XCharts
switch (sizeType)
{
case SerieSymbolSizeType.Custom:
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
return 8 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
case SerieSymbolSizeType.FromData:
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
case SerieSymbolSizeType.Callback:
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
case SerieSymbolSizeType.Callback:
return 8 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
}
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
return 8 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
}
else
{

View File

@@ -27,11 +27,10 @@ namespace XCharts
drawRect.width = EditorGUIUtility.labelWidth + 10;
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SeriesModuleToggle, "Series");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
//ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop);
drawRect.width = pos.width;
if (m_SeriesModuleToggle)
{
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Series);
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Series, true);
}
}

View File

@@ -29,7 +29,6 @@ namespace XCharts
SerializedProperty m_PieSelectedOffset = prop.FindPropertyRelative("m_PieSelectedOffset");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SettingsModuleToggle, "Settings");
EditorGUI.LabelField(drawRect, "Settings", EditorStyles.boldLabel);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_SettingsModuleToggle)
{

View File

@@ -0,0 +1,53 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(TextLimit), true)]
public class TextLimitDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_TextLimitToggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Enable = prop.FindPropertyRelative("m_Enable");
SerializedProperty m_MaxWidth = prop.FindPropertyRelative("m_MaxWidth");
SerializedProperty m_Gap = prop.FindPropertyRelative("m_Gap");
SerializedProperty m_LimitSuffix = prop.FindPropertyRelative("m_Suffix");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextLimitToggle, prop, "Text Limit", m_Enable, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_TextLimitToggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_MaxWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Gap);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LimitSuffix);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
if (ChartEditorHelper.IsToggle(m_TextLimitToggle, prop))
{
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
}
}

View File

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

View File

@@ -0,0 +1,71 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(TextStyle), true)]
public class TextStyleDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_TextStyleToggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Font = prop.FindPropertyRelative("m_Font");
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
SerializedProperty m_LineSpacing = prop.FindPropertyRelative("m_LineSpacing");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextStyleToggle, prop, null,null,false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Font);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Rotate);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Offset);
drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
EditorGUI.PropertyField(drawRect, m_Color);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_FontSize);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_FontStyle);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LineSpacing);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop))
{
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
}
else
{
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
}
}

View File

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

View File

@@ -67,14 +67,16 @@ namespace XCharts
SerializedProperty m_CustomVisualMapBorderColor = prop.FindPropertyRelative("m_CustomVisualMapBorderColor");
SerializedProperty m_CustomColorPalette = prop.FindPropertyRelative("m_CustomColorPalette");
var btnWidth = 45;
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_ThemeModuleToggle, "Theme");
drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2;
drawRect.width = defaultWidth - EditorGUIUtility.labelWidth - (m_ThemeModuleToggle ? 45 : 0);
drawRect.x += EditorGUIUtility.labelWidth + ChartEditorHelper.GAP_WIDTH;
drawRect.width = defaultWidth - EditorGUIUtility.labelWidth - ChartEditorHelper.GAP_WIDTH
- (m_ThemeModuleToggle ? btnWidth + 3 : 0);
EditorGUI.PropertyField(drawRect, m_Theme, GUIContent.none);
if (m_ThemeModuleToggle)
{
drawRect.x = defaultWidth - 30;
drawRect.width = 45;
drawRect.x = defaultX + defaultWidth - btnWidth;
drawRect.width = btnWidth;
if (GUI.Button(drawRect, new GUIContent("Reset", "Reset to theme default color")))
{
m_CustomFont.objectReferenceValue = null;
@@ -139,7 +141,7 @@ namespace XCharts
++EditorGUI.indentLevel;
EditorGUI.BeginChangeCheck();
var font =m_CustomFont.objectReferenceValue != null?m_CustomFont: m_Font;
var font = m_CustomFont.objectReferenceValue != null ? m_CustomFont : m_Font;
EditorGUI.PropertyField(drawRect, font);
if (EditorGUI.EndChangeCheck())
{

View File

@@ -21,9 +21,9 @@ namespace XCharts
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty text = prop.FindPropertyRelative("m_Text");
SerializedProperty m_TextFontSize = prop.FindPropertyRelative("m_TextFontSize");
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
SerializedProperty subText = prop.FindPropertyRelative("m_SubText");
SerializedProperty m_SubTextFontSize = prop.FindPropertyRelative("m_SubTextFontSize");
SerializedProperty m_SubTextStyle = prop.FindPropertyRelative("m_SubTextStyle");
SerializedProperty m_ItemGap = prop.FindPropertyRelative("m_ItemGap");
SerializedProperty location = prop.FindPropertyRelative("m_Location");
@@ -34,19 +34,16 @@ namespace XCharts
{
EditorGUI.PropertyField(drawRect, text);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_TextFontSize, new GUIContent("Font Size"));
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, subText);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_SubTextFontSize, new GUIContent("Font Size"));
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemGap, new GUIContent("Item Gap"));
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, location);
drawRect.y += EditorGUI.GetPropertyHeight(location);
EditorGUI.PropertyField(drawRect, m_TextStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
EditorGUI.PropertyField(drawRect, m_SubTextStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_SubTextStyle);
}
--EditorGUI.indentLevel;
}
@@ -56,9 +53,10 @@ namespace XCharts
float height = 0;
if (m_TitleModuleToggle)
{
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
SerializedProperty location = prop.FindPropertyRelative("m_Location");
height += EditorGUI.GetPropertyHeight(location);
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SubTextStyle"));
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Location"));
}
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
return height;

View File

@@ -0,0 +1,51 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(TitleStyle), true)]
public class TitleStyleDrawer : PropertyDrawer
{
private Dictionary<string, bool> m_TitleStyleToggle = new Dictionary<string, bool>();
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TitleStyleToggle, prop, "Title Style", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (ChartEditorHelper.IsToggle(m_TitleStyleToggle, prop))
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_TextStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
if (ChartEditorHelper.IsToggle(m_TitleStyleToggle, prop))
{
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
}
else
{
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
}
}

View File

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

View File

@@ -22,22 +22,33 @@ namespace XCharts
SerializedProperty show = prop.FindPropertyRelative("m_Show");
SerializedProperty type = prop.FindPropertyRelative("m_Type");
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
SerializedProperty m_TitleFormatter = prop.FindPropertyRelative("m_TitleFormatter");
SerializedProperty m_ItemFormatter = prop.FindPropertyRelative("m_ItemFormatter");
SerializedProperty m_FixedWidth = prop.FindPropertyRelative("m_FixedWidth");
SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight");
SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth");
SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight");
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
SerializedProperty m_BackgroundImage = prop.FindPropertyRelative("m_BackgroundImage");
SerializedProperty m_IgnoreDataDefaultContent = prop.FindPropertyRelative("m_IgnoreDataDefaultContent");
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_TooltipModuleToggle)
{
EditorGUI.indentLevel++;
EditorGUI.PropertyField(drawRect, type);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_Formatter);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TitleFormatter);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ItemFormatter);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_FixedWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_FixedHeight);
@@ -46,19 +57,30 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_MinHeight);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_FontSize);
EditorGUI.PropertyField(drawRect, m_PaddingLeftRight);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_FontStyle);
EditorGUI.PropertyField(drawRect, m_PaddingTopBottom);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BackgroundImage);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ForceENotation);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_IgnoreDataDefaultContent);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LineStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
EditorGUI.PropertyField(drawRect, m_TextStyle);
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
EditorGUI.indentLevel--;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
if (m_TooltipModuleToggle)
return 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
return 14 * EditorGUIUtility.singleLineHeight + 13 * EditorGUIUtility.standardVerticalSpacing +
EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")) +
EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
else
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}

View File

@@ -4,6 +4,17 @@ using System.Collections.Generic;
public class ChartEditorHelper
{
#if UNITY_2019_3_OR_NEWER
public const float INDENT_WIDTH = 15;
public const float BOOL_WIDTH = 15;
public const float ARROW_WIDTH = 20;
public const float GAP_WIDTH =2;
#else
public const float INDENT_WIDTH = 15;
public const float BOOL_WIDTH = 15;
public const float ARROW_WIDTH = 13;
public const float GAP_WIDTH = 0;
#endif
public static GUIStyle headerStyle = EditorStyles.boldLabel;
public static GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout)
{
@@ -28,12 +39,38 @@ public class ChartEditorHelper
MakeTwoField(ref drawRect, rectWidth, arrayProp.GetArrayElementAtIndex(0), arrayProp.GetArrayElementAtIndex(1), name);
}
public static void MakeDivideList(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp, string name, int showNum)
{
while (arrayProp.arraySize < showNum)
{
arrayProp.InsertArrayElementAtIndex(arrayProp.arraySize);
}
EditorGUI.LabelField(drawRect, name);
#if UNITY_2019_3_OR_NEWER
var gap = 2;
#else
var gap = 0;
#endif
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + gap;
var dataWidTotal = (rectWidth - (startX + INDENT_WIDTH + 1));
EditorGUI.DrawRect(new Rect(startX, drawRect.y, dataWidTotal, drawRect.height), Color.grey);
var dataWid = dataWidTotal / showNum;
var xWid = dataWid - gap;
for (int i = 0; i < 1; i++)
{
drawRect.x = startX + i * xWid;
drawRect.width = dataWid + (EditorGUI.indentLevel - 2) * 40.5f;
EditorGUI.PropertyField(drawRect, arrayProp.GetArrayElementAtIndex(i), GUIContent.none);
}
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty prop1, SerializedProperty prop2, string name)
{
EditorGUI.LabelField(drawRect, name);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var diff = 14 + EditorGUI.indentLevel * 14;
var offset = diff - 15;
var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height);
@@ -42,14 +79,29 @@ public class ChartEditorHelper
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
public static void MakeVector2(ref Rect drawRect, float rectWidth, SerializedProperty prop, string name)
{
EditorGUI.LabelField(drawRect, name);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var diff = 14 + EditorGUI.indentLevel * 14;
var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height);
var x = EditorGUI.FloatField(centerXRect, prop.vector3Value.x);
var y = EditorGUI.FloatField(centerYRect, prop.vector3Value.y);
prop.vector3Value = new Vector3(x, y);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
public static void MakeJsonData(ref Rect drawRect, ref bool showTextArea, ref string inputString,
SerializedProperty prop, float currentWidth, float diff = 0)
{
SerializedProperty stringDataProp = prop.FindPropertyRelative("m_JsonData");
SerializedProperty needParseProp = prop.FindPropertyRelative("m_DataFromJson");
float defalutX = drawRect.x;
drawRect.x = EditorGUIUtility.labelWidth + 14 + diff;
drawRect.width = currentWidth - EditorGUIUtility.labelWidth - diff;
drawRect.x = EditorGUIUtility.labelWidth + ARROW_WIDTH + diff;
drawRect.width = currentWidth - EditorGUIUtility.labelWidth - GAP_WIDTH - diff;
if (GUI.Button(drawRect, new GUIContent("Parse JsonData", "Parse data from input json")))
{
showTextArea = !showTextArea;
@@ -77,19 +129,35 @@ public class ChartEditorHelper
{
float defaultWidth = drawRect.width;
float defaultX = drawRect.x;
drawRect.width = EditorGUIUtility.labelWidth;
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH;
moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? foldoutStyle : EditorStyles.foldout);
drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2;
drawRect.width = 40;
if (prop != null)
{
EditorGUI.PropertyField(drawRect, prop, GUIContent.none);
}
MakeBool(drawRect, prop);
drawRect.width = defaultWidth;
drawRect.x = defaultX;
return moduleToggle;
}
public static void MakeBool(Rect drawRect, SerializedProperty boolProp, int index = 0, string name = null)
{
float defaultWidth = drawRect.width;
float defaultX = drawRect.x;
float boolWidth = index * (BOOL_WIDTH + GAP_WIDTH);
drawRect.x = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + ARROW_WIDTH + boolWidth;
drawRect.width = (EditorGUI.indentLevel + 1) * BOOL_WIDTH + index * 110;
if (boolProp != null)
{
EditorGUI.PropertyField(drawRect, boolProp, GUIContent.none);
if (!string.IsNullOrEmpty(name))
{
drawRect.x += BOOL_WIDTH;
drawRect.width = 200;
EditorGUI.LabelField(drawRect, name);
}
}
drawRect.width = defaultWidth;
drawRect.x = defaultX;
}
public static bool MakeFoldout(ref Rect drawRect, ref Dictionary<string, bool> moduleToggle, SerializedProperty prop,
string moduleName, SerializedProperty showProp = null, bool bold = true)
{
@@ -102,23 +170,28 @@ public class ChartEditorHelper
float defaultWidth = drawRect.width;
float defaultX = drawRect.x;
#if UNITY_2019_3_OR_NEWER
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH;
#else
drawRect.width = EditorGUIUtility.labelWidth;
#endif
var displayName = string.IsNullOrEmpty(moduleName) ? prop.displayName : moduleName;
toggle = EditorGUI.Foldout(drawRect, toggle, displayName, bold ? foldoutStyle : EditorStyles.foldout);
if (moduleToggle[key] != toggle)
{
moduleToggle[key] = toggle;
}
drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2;
if (showProp != null)
{
drawRect.x = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + ARROW_WIDTH;
if (showProp.propertyType == SerializedPropertyType.Boolean)
{
drawRect.width = 60;
drawRect.width = (EditorGUI.indentLevel + 1) * BOOL_WIDTH;
}
else
{
drawRect.width = defaultWidth - drawRect.x + 15;
drawRect.width = defaultWidth - drawRect.x + ARROW_WIDTH - GAP_WIDTH;
}
EditorGUI.PropertyField(drawRect, showProp, GUIContent.none);
}
@@ -127,20 +200,39 @@ public class ChartEditorHelper
return toggle;
}
public static void MakeList(ref Rect drawRect, ref int listSize, SerializedProperty listProp, SerializedProperty large = null)
public static void MakeList(ref Rect drawRect, ref int listSize, SerializedProperty listProp, bool showOrder = false, bool showSize = true)
{
EditorGUI.indentLevel++;
listSize = listProp.arraySize;
listSize = EditorGUI.IntField(drawRect, "Size", listSize);
if (listSize < 0) listSize = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (listSize != listProp.arraySize)
if (showSize)
{
while (listSize > listProp.arraySize)
listProp.InsertArrayElementAtIndex(listProp.arraySize);
while (listSize < listProp.arraySize)
listProp.DeleteArrayElementAtIndex(listProp.arraySize - 1);
if (showOrder)
{
var nameWid = 15;
var temp = INDENT_WIDTH + GAP_WIDTH;
var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - nameWid - 1, drawRect.height);
var iconRect = new Rect(drawRect.width - nameWid + temp, drawRect.y, nameWid, drawRect.height);
if (GUI.Button(iconRect, new GUIContent("+", "add")))
{
listProp.InsertArrayElementAtIndex(listProp.arraySize);
}
listSize = listProp.arraySize;
listSize = EditorGUI.IntField(elementRect, "Size", listSize);
}
else
{
listSize = EditorGUI.IntField(drawRect, "Size", listSize);
}
if (listSize < 0) listSize = 0;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (listSize != listProp.arraySize)
{
while (listSize > listProp.arraySize)
listProp.InsertArrayElementAtIndex(listProp.arraySize);
while (listSize < listProp.arraySize)
listProp.DeleteArrayElementAtIndex(listProp.arraySize - 1);
}
}
if (listSize > 30)
{
@@ -166,8 +258,38 @@ public class ChartEditorHelper
for (int i = 0; i < listProp.arraySize; i++)
{
SerializedProperty element = listProp.GetArrayElementAtIndex(i);
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i));
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
if (showOrder)
{
var nameWid = 15;
var temp = INDENT_WIDTH + GAP_WIDTH;
var isSerie = "Serie".Equals(element.type);
var elementRect = isSerie ? drawRect : new Rect(drawRect.x, drawRect.y, drawRect.width - 2 * nameWid, drawRect.height);
EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i));
var iconRect = new Rect(drawRect.width - 3 * nameWid + temp, drawRect.y, nameWid, drawRect.height);
if (GUI.Button(iconRect, new GUIContent("↑", "up")))
{
if (i > 0) listProp.MoveArrayElement(i, i - 1);
}
iconRect = new Rect(drawRect.width - 2 * nameWid + temp, drawRect.y, nameWid, drawRect.height);
if (GUI.Button(iconRect, new GUIContent("↓", "down")))
{
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
}
iconRect = new Rect(drawRect.width - nameWid + temp, drawRect.y, nameWid, drawRect.height);
if (GUI.Button(iconRect, new GUIContent("-", "delete")))
{
if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
}
else
{
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
}
}
else
{
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + i));
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
}
}
}
EditorGUI.indentLevel--;

View File

@@ -0,0 +1,119 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace XCharts
{
public class XChartEditor : EditorWindow
{
private static Transform GetParent()
{
GameObject selectObj = Selection.activeGameObject;
if (selectObj == null)
{
var canvas = GameObject.FindObjectOfType<Canvas>();
if (canvas != null) return canvas.transform;
else
{
var canvasObject = new GameObject();
canvasObject.name = "Canvas";
canvas = canvasObject.AddComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
canvasObject.AddComponent<CanvasScaler>();
canvasObject.AddComponent<GraphicRaycaster>();
var eventSystem = new GameObject();
eventSystem.name = "EventSystem";
eventSystem.AddComponent<EventSystem>();
eventSystem.AddComponent<StandaloneInputModule>();
return canvas.transform;
}
}
else
{
return selectObj.transform;
}
}
private static string GetName(Transform parent, string name)
{
if (parent.Find(name) == null) return name;
for (int i = 1; i <= 10; i++)
{
var newName = string.Format("{0} ({1})", name, i);
if (parent.Find(newName) == null)
{
return newName;
}
}
return name;
}
private static void AddChart<T>(string chartName) where T : BaseChart
{
var parent = GetParent();
if (parent == null) return;
var chart = new GameObject();
chart.name = GetName(parent, chartName);
chart.AddComponent<T>();
chart.transform.SetParent(parent);
chart.transform.localScale = Vector3.one;
chart.transform.localPosition = Vector3.zero;
}
[MenuItem("GameObject/XCharts/LineChart", priority = 44)]
public static void AddLineChart()
{
AddChart<LineChart>("LineChart");
}
[MenuItem("GameObject/XCharts/BarChart", priority = 45)]
public static void AddBarChart()
{
AddChart<BarChart>("BarChart");
}
[MenuItem("GameObject/XCharts/PieChart", priority = 46)]
public static void AddPieChart()
{
AddChart<PieChart>("PieChart");
}
[MenuItem("GameObject/XCharts/RadarChart", priority = 47)]
public static void AddRadarChart()
{
AddChart<RadarChart>("RadarChart");
}
[MenuItem("GameObject/XCharts/ScatterChart", priority = 48)]
public static void AddScatterChart()
{
AddChart<ScatterChart>("ScatterChart");
}
[MenuItem("GameObject/XCharts/HeatmapChart", priority = 49)]
public static void AddHeatmapChart()
{
AddChart<HeatmapChart>("HeatmapChart");
}
[MenuItem("GameObject/XCharts/GaugeChart", priority = 50)]
public static void AddGaugeChart()
{
AddChart<GaugeChart>("GaugeChart");
}
[MenuItem("GameObject/XCharts/RingChart", priority = 51)]
public static void AddRingChart()
{
AddChart<RingChart>("RingChart");
}
}
}

View File

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

View File

@@ -1,24 +1,22 @@
# XCharts
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
A powerful, easy-to-use, configurable charting and data visualization library for Unity. Support line charts, bar charts, pie charts, radar charts, scatter charts, heatmaps, gauge, ring charts and other common charts.
一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图等常见图表。
## Features
## 特性
* Rich built-in examples and templates, parameter visualization configuration, effect real-time preview, pure code drawing.
* Support line charts, bar charts, pie charts, radar charts, scatter charts, heatmaps, gauge charts, ring charts and other common charts.
* Support line graph, curve graph, area graph, step graph, etc.
* Support parallel bar chart, stack bar chart, stack percentage bar chart, zebra bar chart, etc.
* Support for ring chart, rose chart and other pie chart.
* Support broken line graph - bar graph, scatter graph - broken line graph, etc.
* Support solid line, curve, ladder line, dotted line, dot line, dot line, double point line and other lines.
* Support custom theme, built-in theme switching.
* support custom chart content drawing, drawing points, line, curve, triangle, quadrilateral, circle, ring, sector, border, arrow and other drawing API.
* support interactive operations such as data filtering, view zooming and detail display on PC and mobile terminals.
* support 10,000-level big data rendering.
* 内置丰富示例和模板,参数可视化配置,效果实时预览,纯代码绘制。
* 支持折线图、柱状图、饼图、雷达图、散点图、热力图等常见图表。
* 支持直线图、曲线图、面积图、阶梯线图等折线图。
* 支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图等柱状图。
* 支持环形图、玫瑰图等饼图。
* 支持折线图—柱状图、散点图-折线图等组合图。
* 支持实线、曲线、阶梯线、虚线、点线、点划线、双点划线等线条。
* 支持自定义主题,内置主题切换。
* 支持自定义图表内容绘制提供绘制点、直线、曲线、三角形、四边形、圆形、环形、扇形、边框、箭头等绘图API。
* 支持PC端和手机端上的数据筛选、视图缩放、细节展示等交互操作。
* 支持万级大数据绘制。
## 使用
## Usage
* 本项目在`Unity 2018.3.14f1``.Net 3.5`下开发,在 `Unity 5``Unity 2017``Unity 2019`上测试正常。理论上可运行于任何支持`UGUI``Unity`版本。
* 通过下载源码或`unitypackage`包导入到你的项目中。如果你是`2018.3`及以上版本,强烈建议通过`Package Manager``Git`来导入包:

View File

@@ -18,6 +18,10 @@ namespace XCharts
/// </summary>
public partial class BaseChart
{
/// <summary>
/// The theme info.
/// </summary>
public ThemeInfo themeInfo { get { return m_ThemeInfo; } set { m_ThemeInfo = value; } }
/// <summary>
/// The title setting of chart.
/// 标题组件
@@ -63,6 +67,10 @@ namespace XCharts
/// </summary>
public Action<VertexHelper> customDrawCallback { set { m_CustomDrawCallback = value; } }
/// <summary>
/// 警告信息。
/// </summary>
public string warningInfo { get; protected set; }
/// <summary>
/// Set the size of chart.
/// 设置图表的大小。
/// </summary>
@@ -88,7 +96,9 @@ namespace XCharts
{
m_Series.ClearData();
m_Legend.ClearData();
m_Tooltip.ClearValue();
m_CheckAnimation = false;
m_ReinitLabel = true;
RefreshChart();
}
@@ -101,7 +111,9 @@ namespace XCharts
{
m_Legend.ClearData();
m_Series.RemoveAll();
m_Tooltip.ClearValue();
m_CheckAnimation = false;
m_ReinitLabel = true;
RefreshChart();
}
@@ -216,7 +228,7 @@ namespace XCharts
/// <param name="yValue">y data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public virtual SerieData AddData(string serieName, float xValue, float yValue, string dataName)
public virtual SerieData AddData(string serieName, float xValue, float yValue, string dataName = null)
{
var serieData = m_Series.AddXYData(serieName, xValue, yValue, dataName);
if (serieData != null)
@@ -254,10 +266,14 @@ namespace XCharts
/// <param name="serieName">the name of serie</param>
/// <param name="dataIndex">the index of data</param>
/// <param name="value">the data will be update</param>
public virtual void UpdateData(string serieName, int dataIndex, float value)
public virtual bool UpdateData(string serieName, int dataIndex, float value)
{
m_Series.UpdateData(serieName, dataIndex, value);
RefreshChart();
if (m_Series.UpdateData(serieName, dataIndex, value))
{
RefreshChart();
return true;
}
return false;
}
/// <summary>
@@ -267,10 +283,80 @@ namespace XCharts
/// <param name="serieIndex">the index of serie</param>
/// <param name="dataIndex">the index of data</param>
/// <param name="value">the data will be update</param>
public virtual void UpdateData(int serieIndex, int dataIndex, float value)
public virtual bool UpdateData(int serieIndex, int dataIndex, float value)
{
m_Series.UpdateData(serieIndex, dataIndex, value);
RefreshChart();
if (m_Series.UpdateData(serieIndex, dataIndex, value))
{
RefreshChart();
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引的数据项的多维数据。
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
public virtual bool UpdateData(string serieName, int dataIndex, List<float> multidimensionalData)
{
if (m_Series.UpdateData(serieName, dataIndex, multidimensionalData))
{
RefreshChart();
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引的数据项的多维数据。
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
public virtual bool UpdateData(int serieIndex, int dataIndex, List<float> multidimensionalData)
{
if (m_Series.UpdateData(serieIndex, dataIndex, multidimensionalData))
{
RefreshChart();
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引指定维数的数据。维数从0开始。
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dimension">指定维数从0开始</param>
/// <param name="value"></param>
public virtual bool UpdateData(string serieName, int dataIndex, int dimension, float value)
{
if (m_Series.UpdateData(serieName, dataIndex, dimension, value))
{
RefreshChart();
return true;
}
return false;
}
/// <summary>
/// 更新指定系列指定索引指定维数的数据。维数从0开始。
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="dimension">指定维数从0开始</param>
/// <param name="value"></param>
public virtual bool UpdateData(int serieIndex, int dataIndex, int dimension, float value)
{
if (m_Series.UpdateData(serieIndex, dataIndex, dimension, value))
{
RefreshChart();
return true;
}
return false;
}
/// <summary>
@@ -280,9 +366,9 @@ namespace XCharts
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dataName"></param>
public virtual void UpdateDataName(string serieName, int dataIndex, string dataName)
public virtual bool UpdateDataName(string serieName, int dataIndex, string dataName)
{
m_Series.UpdateDataName(serieName, dataIndex, dataName);
return m_Series.UpdateDataName(serieName, dataIndex, dataName);
}
/// <summary>
@@ -292,9 +378,9 @@ namespace XCharts
/// <param name="serieIndex"></param>
/// <param name="dataName"></param>
/// <param name="dataIndex"></param>
public virtual void UpdateDataName(int serieIndex, int dataIndex, string dataName)
public virtual bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
{
m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
return m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
}
/// <summary>
@@ -324,9 +410,19 @@ namespace XCharts
var serie = m_Series.GetSerie(serieIndex);
if (serie != null && !string.IsNullOrEmpty(serie.name))
{
var legendIndex = m_LegendRealShowName.IndexOf(serie.name);
var bgColor1 = active ? m_ThemeInfo.GetColor(legendIndex) : m_ThemeInfo.legendUnableColor;
m_Legend.UpdateButtonColor(serie.name, bgColor1);
UpdateLegendColor(serie.name, active);
}
}
protected virtual void UpdateLegendColor(string legendName, bool active)
{
var legendIndex = m_LegendRealShowName.IndexOf(legendName);
if (legendIndex >= 0)
{
var iconColor = LegendHelper.GetIconColor(legend, legendIndex, m_ThemeInfo, active);
var contentColor = LegendHelper.GetContentColor(legend, m_ThemeInfo, active);
m_Legend.UpdateButtonColor(legendName, iconColor);
m_Legend.UpdateContentColor(legendName, contentColor);
}
}
@@ -404,6 +500,14 @@ namespace XCharts
m_ReinitLabel = true;
}
/// <summary>
/// 刷新Tooltip组件。
/// </summary>
public void RefreshTooltip()
{
InitTooltip();
}
/// <summary>
/// Update chart theme.
/// 切换图表主题。
@@ -416,6 +520,17 @@ namespace XCharts
RefreshChart();
}
/// <summary>
/// Update chart theme info.
/// 切换图表主题。
/// </summary>
/// <param name="themeInfo">themeInfo</param>
public void UpdateThemeInfo(ThemeInfo themeInfo)
{
m_ThemeInfo = themeInfo;
UpdateTheme(m_ThemeInfo.theme);
}
/// <summary>
/// Whether series animation enabel.
/// 启用或关闭起始动画。
@@ -426,32 +541,62 @@ namespace XCharts
m_Series.AnimationEnable(flag);
}
/// <summary>
/// Start play animation.
/// 开始初始动画。
/// </summary>
[Obsolete("Use BaseChart.AnimationFadeIn() instead.", true)]
public void AnimationStart()
{
m_Series.AnimationStart();
}
[Obsolete("Use BaseChart.AnimationFadeOut() instead.", true)]
public void MissAnimationStart()
{
}
/// <summary>
/// fadeIn animation.
/// 开始渐入动画。
/// </summary>
public void AnimationFadeIn()
{
m_Series.AnimationFadeIn();
RefreshChart();
}
/// <summary>
/// fadeIn animation.
/// 开始渐出动画。
/// </summary>
public void AnimationFadeOut()
{
m_Series.AnimationFadeOut();
RefreshChart();
}
/// <summary>
/// Pause animation.
/// 暂停动画。
/// </summary>
public void AnimationPause()
{
m_Series.AnimationPause();
RefreshChart();
}
/// <summary>
/// Stop play animation.
/// 停止初始化动画。
/// 继续动画。
/// </summary>
public void AnimationStop()
public void AnimationResume()
{
m_CheckAnimation = false;
m_Series.AnimationStop();
m_Series.AnimationResume();
RefreshChart();
}
/// <summary>
/// Reset animation to play.
/// 重置初始动画,重新播放
/// Reset animation.
/// 重置动画
/// </summary>
public void AnimationReset()
{
m_CheckAnimation = false;
m_Series.AnimationReset();
RefreshChart();
}
@@ -467,5 +612,44 @@ namespace XCharts
OnLegendButtonClick(legendIndex, legendName, show);
RefreshChart();
}
/// <summary>
/// 坐标是否在图表范围内
/// </summary>
/// <param name="local"></param>
/// <returns></returns>
public bool IsInChart(Vector2 local)
{
if (local.x < 0 || local.x > chartWidth ||
local.y < 0 || local.y > chartHeight)
{
return false;
}
return true;
}
public Vector3 ClampInChart(Vector3 pos)
{
if (IsInChart(pos)) return pos;
else
{
var np = new Vector3(pos.x, pos.y);
if (np.x < 0) np.x = 0;
if (np.x > chartWidth) np.x = chartWidth;
if (np.y < 0) np.y = 0;
if (np.y > chartHeight) np.y = chartHeight;
return np;
}
}
/// <summary>
/// 检测警告信息。
/// </summary>
/// <returns></returns>
public string CheckWarning()
{
warningInfo = CheckHelper.CheckChart(this);
return warningInfo;
}
}
}

View File

@@ -129,7 +129,6 @@ namespace XCharts
public void AddXAxisData(string category, int xAxisIndex = 0)
{
m_XAxises[xAxisIndex].AddData(category);
m_XAxisChanged = true;
}
/// <summary>
@@ -141,23 +140,22 @@ namespace XCharts
public void AddYAxisData(string category, int yAxisIndex = 0)
{
m_YAxises[yAxisIndex].AddData(category);
m_YAxisChanged = true;
}
/// <summary>
/// reutrn true when all the show axis is `Value` type.
/// 纯数值坐标。
/// 纯数值坐标轴(数值轴或对数轴)
/// </summary>
/// <returns></returns>
public bool IsValue()
{
foreach (var axis in m_XAxises)
{
if (axis.show && !axis.IsValue()) return false;
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
}
foreach (var axis in m_YAxises)
{
if (axis.show && !axis.IsValue()) return false;
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
}
return true;
}
@@ -200,6 +198,20 @@ namespace XCharts
{
CheckMinMaxValue();
}
public Vector3 ClampInCoordinate(Vector3 pos)
{
if (IsInCooridate(pos)) return pos;
else
{
var np = new Vector3(pos.x, pos.y);
if (np.x < coordinateX) np.x = coordinateX;
if (np.x > coordinateX + coordinateWidth) np.x = coordinateX + coordinateWidth;
if (np.y < coordinateY) np.y = coordinateY;
if (np.y > coordinateY + coordinateHeight) np.y = coordinateY + coordinateHeight;
return np;
}
}
}
}

View File

@@ -0,0 +1,130 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
public partial class RadarChart
{
/// <summary>
/// 雷达坐标系组件列表。
/// </summary>
public List<Radar> radars { get { return m_Radars; } }
/// <summary>
/// 移除所有数据,包含雷达坐标系指示器数据。
/// </summary>
public override void RemoveData()
{
base.RemoveData();
foreach (var radar in m_Radars)
{
radar.indicatorList.Clear();
}
}
/// <summary>
/// 移除所有雷达坐标系组件。
/// </summary>
public void RemoveRadar()
{
m_Radars.Clear();
}
/// <summary>
/// 添加雷达坐标系组件。
/// </summary>
public void AddRadar(Radar radar)
{
m_Radars.Add(radar);
}
/// <summary>
/// 添加雷达坐标系组件。
/// </summary>
/// <param name="shape">形状,圆形还是多边形</param>
/// <param name="center">中心点0-1浮点数时表示百分比</param>
/// <param name="radius">半径0-1浮点数时表示百分比</param>
/// <param name="splitNumber">指示器轴的分割段数</param>
/// <param name="lineWidth">线条宽</param>
/// <param name="showIndicator">是否显示指示器名称</param>
/// <param name="showSplitArea">是否显示分割区域</param>
/// <returns></returns>
public Radar AddRadar(Radar.Shape shape, Vector2 center, float radius, int splitNumber = 5,
float lineWidth = 0.6f, bool showIndicator = true, bool showSplitArea = true)
{
var radar = new Radar();
radar.shape = shape;
radar.splitNumber = splitNumber;
radar.radius = radius;
radar.indicator = showIndicator;
radar.center[0] = center.x;
radar.center[1] = center.y;
radar.splitArea.show = showSplitArea;
radar.splitLine.lineStyle.width = lineWidth;
m_Radars.Add(radar);
return radar;
}
/// <summary>
/// 添加指示器。
/// </summary>
/// <param name="radarIndex">雷达坐标系组件索引从0开始</param>
/// <param name="name">指示器名称</param>
/// <param name="min">指示器最小值</param>
/// <param name="max">指示器最大值</param>
/// <returns></returns>
public Radar.Indicator AddIndicator(int radarIndex, string name, float min, float max)
{
var radar = GetRadar(radarIndex);
if (radar == null) return null;
return radar.AddIndicator(name, min, max);
}
/// <summary>
/// 更新指示器。
/// </summary>
/// <param name="radarIndex">雷达坐标系组件的索引从0开始</param>
/// <param name="indicatorIndex">指示器索引从0开始</param>
/// <param name="name">指示器名称</param>
/// <param name="min">指示器最小值</param>
/// <param name="max">指示器最大值</param>
/// <returns></returns>
public bool UpdateIndicator(int radarIndex, int indicatorIndex, string name, float min, float max)
{
var radar = GetRadar(radarIndex);
if (radar == null) return false;
return radar.UpdateIndicator(indicatorIndex, name, min, max);
}
/// <summary>
/// 获得指定索引的雷达坐标系组件。
/// </summary>
/// <param name="radarIndex"></param>
/// <returns></returns>
public Radar GetRadar(int radarIndex)
{
if (radarIndex < 0 || radarIndex > m_Radars.Count - 1) return null;
return m_Radars[radarIndex];
}
/// <summary>
/// 获得指定雷达坐标系组件指定索引的指示器。
/// </summary>
/// <param name="radarIndex"></param>
/// <param name="indicatorIndex"></param>
/// <returns></returns>
public Radar.Indicator GetIndicator(int radarIndex, int indicatorIndex)
{
var radar = GetRadar(radarIndex);
if (radar != null) return radar.GetIndicator(indicatorIndex);
else return null;
}
}
}

View File

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

View File

@@ -0,0 +1,95 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
public partial class RingChart
{
/// <summary>
/// 更新指定系列执行数据项的最大值
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="value"></param>
/// <returns></returns>
public bool UpdateMax(int serieIndex, int dataIndex, float value)
{
var serie = m_Series.GetSerie(serieIndex);
if (serie != null)
{
var serieData = serie.GetSerieData(dataIndex);
if (serieData != null)
{
return serieData.UpdateData(1, value);
}
}
return false;
}
/// <summary>
/// 更新指定系列的所有数据项的最大值
/// </summary>
/// <param name="serieIndex"></param>
/// <param name="value"></param>
/// <returns></returns>
public bool UpdateMax(int serieIndex, float value)
{
var serie = m_Series.GetSerie(serieIndex);
if (serie != null)
{
var flag = true;
foreach (var serieData in serie.data)
{
if (!serieData.UpdateData(1, value)) flag = false;
}
return flag;
}
return false;
}
/// <summary>
/// 更新第一个系列第一个数据项的最大值
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool UpdateMax(float value)
{
return UpdateMax(0, 0, value);
}
/// <summary>
/// Adds the data with the specified maximum value to the specified serie.
/// 添加指定最大值的数据到指定系列中。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="value">the data</param>
/// <param name="max">the max data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public override SerieData AddData(string serieName, float value, float max, string dataName = null)
{
return base.AddData(serieName, value, max, dataName);
}
/// <summary>
/// Adds the data with the specified maximum value to the specified serie.
/// 添加指定最大值的数据到指定系列中。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="value">the data</param>
/// <param name="max">the max data</param>
/// <param name="dataName">the name of data</param>
/// <returns>Returns True on success</returns>
public override SerieData AddData(int serieIndex, float value, float max, string dataName = null)
{
return base.AddData(serieIndex, value, max, dataName);
}
}
}

View File

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

View File

@@ -15,13 +15,27 @@ namespace XCharts
[SerializeField] protected string m_JsonData;
[SerializeField] protected bool m_DataFromJson;
[NonSerialized] protected bool m_VertsDirty;
[NonSerialized] protected bool m_ComponentDirty;
/// <summary>
/// json格式的字符串数据
/// </summary>
/// <returns></returns>
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
public void OnAfterDeserialize()
/// <summary>
/// 图表重绘标记。
/// </summary>
public virtual bool vertsDirty { get { return m_VertsDirty; } }
/// <summary>
/// 组件重新初始化标记。
/// </summary>
public virtual bool componentDirty { get { return m_ComponentDirty; } }
/// <summary>
/// 需要重绘图表或重新初始化组件。
/// </summary>
public bool anyDirty { get { return vertsDirty || componentDirty; } }
internal void OnAfterDeserialize()
{
if (m_DataFromJson)
{
@@ -30,7 +44,7 @@ namespace XCharts
}
}
public void OnBeforeSerialize()
internal void OnBeforeSerialize()
{
}
@@ -38,5 +52,37 @@ namespace XCharts
{
throw new Exception("no support yet");
}
internal virtual void SetVerticesDirty()
{
m_VertsDirty = true;
}
internal virtual void ClearVerticesDirty()
{
m_VertsDirty = false;
}
internal virtual void SetComponentDirty()
{
m_ComponentDirty = true;
}
internal virtual void ClearComponentDirty()
{
m_ComponentDirty = false;
}
public virtual void ClearDirty()
{
ClearVerticesDirty();
ClearComponentDirty();
}
public virtual void SetAllDirty()
{
SetVerticesDirty();
SetComponentDirty();
}
}
}

View File

@@ -17,7 +17,7 @@ namespace XCharts
/// 直角坐标系的坐标轴组件。
/// </summary>
[System.Serializable]
public class Axis : MainComponent, IEquatable<Axis>
public class Axis : MainComponent
{
/// <summary>
/// the type of axis.
@@ -27,14 +27,19 @@ namespace XCharts
{
/// <summary>
/// Numerical axis, suitable for continuous data.
/// 数值轴适用于连续数据。
/// 数值轴适用于连续数据。
/// </summary>
Value,
/// <summary>
/// Category axis, suitable for discrete category data. Data should only be set via data for this type.
/// 类目轴适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
/// 类目轴适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
/// </summary>
Category
Category,
/// <summary>
/// Log axis, suitable for log data.
/// 对数轴。适用于对数数据。
/// </summary>
Log
}
/// <summary>
@@ -60,38 +65,6 @@ namespace XCharts
Custom
}
/// <summary>
/// the type of split line.
/// 分割线类型
/// </summary>
public enum SplitLineType
{
/// <summary>
/// 不显示分割线
/// </summary>
None,
/// <summary>
/// 实线
/// </summary>
Solid,
/// <summary>
/// 虚线
/// </summary>
Dashed,
/// <summary>
/// 点线
/// </summary>
Dotted,
/// <summary>
/// 点划线
/// </summary>
DashDot,
/// <summary>
/// 双点划线
/// </summary>
DashDotDot
}
[SerializeField] protected bool m_Show = true;
[SerializeField] protected AxisType m_Type;
[SerializeField] protected AxisMinMaxType m_MinMaxType;
@@ -99,15 +72,17 @@ namespace XCharts
[SerializeField] protected float m_Max;
[SerializeField] protected int m_SplitNumber = 5;
[SerializeField] protected float m_Interval = 0;
[SerializeField] protected bool m_ShowSplitLine = false;
[SerializeField] protected SplitLineType m_SplitLineType = SplitLineType.Dashed;
[SerializeField] protected bool m_BoundaryGap = true;
[SerializeField] protected int m_MaxCache = 0;
[SerializeField] protected float m_LogBase = 10;
[SerializeField] protected bool m_LogBaseE = false;
[SerializeField] protected int m_CeilRate = 0;
[SerializeField] protected List<string> m_Data = new List<string>();
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
[SerializeField] protected AxisTick m_AxisTick = AxisTick.defaultTick;
[SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
[SerializeField] protected AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
[NonSerialized] private float m_ValueRange;
@@ -117,88 +92,195 @@ namespace XCharts
/// Set this to false to prevent the axis from showing.
/// 是否显示坐标轴。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
}
/// <summary>
/// the type of axis.
/// 坐标轴类型。
/// </summary>
public AxisType type { get { return m_Type; } set { m_Type = value; } }
public AxisType type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
}
/// <summary>
/// the type of axis minmax.
/// 坐标轴刻度最大最小值显示类型。
/// </summary>
public AxisMinMaxType minMaxType { get { return m_MinMaxType; } set { m_MinMaxType = value; } }
public AxisMinMaxType minMaxType
{
get { return m_MinMaxType; }
set { if (PropertyUtility.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
}
/// <summary>
/// The minimun value of axis.
/// 设定的坐标轴刻度最小值当minMaxType为Custom时有效。
/// </summary>
public float min { get { return m_Min; } set { m_Min = value; } }
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetAllDirty(); }
}
/// <summary>
/// The maximum value of axis.
/// 设定的坐标轴刻度最大值当minMaxType为Custom时有效。
/// </summary>
public float max { get { return m_Max; } set { m_Max = value; } }
public float max
{
get { return m_Max; }
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetAllDirty(); }
}
/// <summary>
/// Number of segments that the axis is split into.
/// 坐标轴的分割段数。
/// </summary>
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
/// <summary>
/// 强制设置坐标轴分割间隔。无法在类目轴中使用。
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
/// </summary>
public float interval { get { return m_Interval; } set { m_Interval = value; } }
/// <summary>
/// showSplitLineSet this to false to prevent the splitLine from showing. value type axes are shown by default, while category type axes are hidden.
/// 是否显示分隔线。默认数值轴显示,类目轴不显示。
/// </summary>
public bool showSplitLine { get { return m_ShowSplitLine; } set { m_ShowSplitLine = value; } }
/// <summary>
/// the type of split line.
/// 分割线类型。
/// </summary>
public SplitLineType splitLineType { get { return m_SplitLineType; } set { m_SplitLineType = value; } }
public float interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetAllDirty(); }
}
/// <summary>
/// The boundary gap on both sides of a coordinate axis.
/// 坐标轴两边是否留白。
/// </summary>
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
public bool boundaryGap
{
get { return m_BoundaryGap; }
set { if (PropertyUtility.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
}
/// <summary>
/// Base of logarithm, which is valid only for numeric axes with type: 'Log'.
/// 对数轴的底数只在对数轴type:'Log')中有效。
/// </summary>
public float logBase
{
get { return m_LogBase; }
set { if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty(); }
}
/// <summary>
/// 对数轴是否以自然数 e 为底数,为 true 时 logBase 失效。
/// </summary>
public bool logBaseE
{
get { return m_LogBaseE; }
set { if (PropertyUtility.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
}
/// <summary>
/// The max number of axis data cache.
/// The first data will be remove when the size of axis data is larger then maxCache.
/// 可缓存的最大数据量。默认为0没有限制大于0时超过指定值会移除旧数据再插入新数据。
/// </summary>
public int maxCache { get { return m_MaxCache; } set { m_MaxCache = value < 0 ? 0 : value; } }
public int maxCache
{
get { return m_MaxCache; }
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
}
/// <summary>
/// 最大最小值向上取整的倍率。默认为0时自动计算。
/// </summary>
public int ceilRate
{
get { return m_CeilRate; }
set { if (PropertyUtility.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
}
/// <summary>
/// Category data, available in type: 'Category' axis.
/// 类目数据在类目轴type: 'category')中有效。
/// </summary>
public List<string> data { get { return m_Data; } set { if (value != null) m_Data = value; } }
public List<string> data
{
get { return m_Data; }
set { if (value != null) { m_Data = value; SetAllDirty(); } }
}
/// <summary>
/// axis Line.
/// 坐标轴轴线。
/// </summary>
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
/// /// </summary>
public AxisLine axisLine
{
get { return m_AxisLine; }
set { if (value != null) { m_AxisLine = value; SetVerticesDirty(); } }
}
/// <summary>
/// axis name.
/// 坐标轴名称。
/// </summary>
public AxisName axisName { get { return m_AxisName; } set { m_AxisName = value; } }
public AxisName axisName
{
get { return m_AxisName; }
set { if (value != null) { m_AxisName = value; SetComponentDirty(); } }
}
/// <summary>
/// axis tick.
/// 坐标轴刻度。
/// </summary>
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
public AxisTick axisTick
{
get { return m_AxisTick; }
set { if (value != null) { m_AxisTick = value; SetVerticesDirty(); } }
}
/// <summary>
/// axis label.
/// 坐标轴刻度标签。
/// </summary>
public AxisLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
public AxisLabel axisLabel
{
get { return m_AxisLabel; }
set { if (value != null) { m_AxisLabel = value; SetComponentDirty(); } }
}
/// <summary>
/// axis split line.
/// 坐标轴分割线。
/// </summary>
public AxisSplitLine splitLine
{
get { return m_SplitLine; }
set { if (value != null) { m_SplitLine = value; SetVerticesDirty(); } }
}
/// <summary>
/// axis split area.
/// 坐标轴分割区域。
/// </summary>
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
public AxisSplitArea splitArea
{
get { return m_SplitArea; }
set { if (value != null) { m_SplitArea = value; SetVerticesDirty(); } }
}
public override bool vertsDirty
{
get { return m_VertsDirty || axisLine.anyDirty || axisTick.anyDirty || splitLine.anyDirty || splitArea.anyDirty; }
}
public override bool componentDirty
{
get { return m_ComponentDirty || axisName.anyDirty || axisLabel.anyDirty; }
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
axisName.ClearComponentDirty();
axisLabel.ClearComponentDirty();
}
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
axisLine.ClearVerticesDirty();
axisTick.ClearVerticesDirty();
splitLine.ClearVerticesDirty();
splitArea.ClearVerticesDirty();
}
/// <summary>
/// the axis label text list.
/// 坐标轴刻度标签的Text列表。
@@ -208,49 +290,63 @@ namespace XCharts
/// the current minimun value.
/// 当前最小值。
/// </summary>
public float minValue { get; set; }
public float runtimeMinValue
{
get { return m_RuntimeMinValue; }
internal set
{
m_RuntimeMinValue = value;
m_RuntimeLastMinValue = value;
m_RuntimeMinValueUpdateTime = Time.time;
m_RuntimeMinValueChanged = true;
}
}
/// <summary>
/// the current maximum value.
/// 当前最大值。
/// </summary>
public float maxValue { get; set; }
public float runtimeMaxValue
{
get { return m_RuntimeMaxValue; }
internal set
{
m_RuntimeMaxValue = value;
m_RuntimeLastMaxValue = value;
m_RuntimeMaxValueUpdateTime = Time.time;
m_RuntimeMaxValueChanged = false;
}
}
/// <summary>
/// the x offset of zero position.
/// 坐标轴原点在X轴的偏移。
/// </summary>
public float zeroXOffset { get; set; }
public float runtimeZeroXOffset { get; internal set; }
/// <summary>
/// the y offset of zero position.
/// 坐标轴原点在Y轴的偏移。
/// </summary>
public float zeroYOffset { get; set; }
public float runtimeZeroYOffset { get; internal set; }
public int runtimeMinLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMinValue) : (int)Mathf.Log(runtimeMinValue, logBase); } }
public int runtimeMaxLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMaxValue) : (int)Mathf.Log(runtimeMaxValue, logBase); } }
private int filterStart;
private int filterEnd;
private int filterMinShow;
private List<string> filterData;
private List<Text> m_AxisLabelTextList = new List<Text>();
private GameObject m_TooltipLabel;
private Text m_TooltipLabelText;
private RectTransform m_TooltipLabelRect;
public void Copy(Axis other)
{
m_Show = other.show;
m_Type = other.type;
m_Min = other.min;
m_Max = other.max;
m_SplitNumber = other.splitNumber;
m_Interval = other.interval;
m_ShowSplitLine = other.showSplitLine;
m_SplitLineType = other.splitLineType;
m_BoundaryGap = other.boundaryGap;
m_AxisName.Copy(other.axisName);
m_AxisLabel.Copy(other.axisLabel);
m_Data.Clear();
m_Data.Capacity = m_Data.Count;
foreach (var d in other.data) m_Data.Add(d);
}
private float m_RuntimeMinValue;
private float m_RuntimeLastMinValue;
private bool m_RuntimeMinValueChanged;
private float m_RuntimeMinValueUpdateTime;
private float m_RuntimeMaxValue;
private float m_RuntimeLastMaxValue;
private bool m_RuntimeMaxValueChanged;
private float m_RuntimeMaxValueUpdateTime;
private bool m_RuntimeMinValueFirstChanged = true;
private bool m_RuntimeMaxValueFirstChanged = true;
/// <summary>
/// 清空类目数据
@@ -258,10 +354,11 @@ namespace XCharts
public void ClearData()
{
m_Data.Clear();
SetAllDirty();
}
/// <summary>
/// 当前坐标轴是否类目轴
/// 是否类目轴
/// </summary>
/// <returns></returns>
public bool IsCategory()
@@ -270,7 +367,7 @@ namespace XCharts
}
/// <summary>
/// 当前坐标轴是否数值轴
/// 是否数值轴
/// </summary>
/// <returns></returns>
public bool IsValue()
@@ -278,6 +375,15 @@ namespace XCharts
return type == AxisType.Value;
}
/// <summary>
/// 是否为对数轴。
/// </summary>
/// <returns></returns>
public bool IsLog()
{
return type == AxisType.Log;
}
/// <summary>
/// 添加一个类目到类目数据列表
/// </summary>
@@ -293,6 +399,7 @@ namespace XCharts
}
}
m_Data.Add(category);
SetAllDirty();
}
/// <summary>
@@ -301,7 +408,7 @@ namespace XCharts
/// <param name="index">类目数据索引</param>
/// <param name="dataZoom">区域缩放</param>
/// <returns></returns>
public string GetData(int index, DataZoom dataZoom)
internal string GetData(int index, DataZoom dataZoom)
{
var showData = GetDataList(dataZoom);
if (index >= 0 && index < showData.Count)
@@ -315,7 +422,7 @@ namespace XCharts
/// </summary>
/// <param name="dataZoom">区域缩放</param>
/// <returns></returns>
public List<string> GetDataList(DataZoom dataZoom)
internal List<string> GetDataList(DataZoom dataZoom)
{
if (dataZoom != null && dataZoom.enable)
{
@@ -333,21 +440,33 @@ namespace XCharts
/// 更新dataZoom对应的类目数据列表
/// </summary>
/// <param name="dataZoom"></param>
public void UpdateFilterData(DataZoom dataZoom)
internal void UpdateFilterData(DataZoom dataZoom)
{
if (dataZoom != null && dataZoom.enable)
{
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
if (startIndex != filterStart || endIndex != filterEnd || m_NeedUpdateFilterData)
if (endIndex < startIndex) endIndex = startIndex;
if (startIndex != filterStart || endIndex != filterEnd || dataZoom.minShowNum != filterMinShow || m_NeedUpdateFilterData)
{
filterStart = startIndex;
filterEnd = endIndex;
filterMinShow = dataZoom.minShowNum;
m_NeedUpdateFilterData = false;
if (m_Data.Count > 0)
{
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
filterData = m_Data.GetRange(startIndex, count);
if (count < dataZoom.minShowNum)
{
if (dataZoom.minShowNum > m_Data.Count) count = m_Data.Count;
else count = dataZoom.minShowNum;
}
if (startIndex + count > m_Data.Count)
{
int start = endIndex - count;
filterData = m_Data.GetRange(start < 0 ? 0 : start, count);
}
else filterData = m_Data.GetRange(startIndex, count);
}
else
{
@@ -366,7 +485,7 @@ namespace XCharts
/// </summary>
/// <param name="dataZoom"></param>
/// <returns></returns>
public int GetSplitNumber(float coordinateWid, DataZoom dataZoom)
internal int GetSplitNumber(float coordinateWid, DataZoom dataZoom)
{
if (type == AxisType.Value)
{
@@ -384,6 +503,10 @@ namespace XCharts
}
else return m_SplitNumber;
}
else if (type == AxisType.Log)
{
return m_SplitNumber;
}
int dataCount = GetDataList(dataZoom).Count;
if (m_SplitNumber <= 0) return dataCount;
if (dataCount > 2 * m_SplitNumber || dataCount <= 0)
@@ -398,7 +521,7 @@ namespace XCharts
/// <param name="coordinateWidth"></param>
/// <param name="dataZoom"></param>
/// <returns></returns>
public float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
internal float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
{
int split = GetSplitNumber(coordinateWidth, dataZoom);
int segment = (m_BoundaryGap ? split : split - 1);
@@ -411,7 +534,7 @@ namespace XCharts
/// </summary>
/// <param name="dataZoom"></param>
/// <returns></returns>
public int GetDataNumber(DataZoom dataZoom)
internal int GetDataNumber(DataZoom dataZoom)
{
return GetDataList(dataZoom).Count;
}
@@ -422,7 +545,7 @@ namespace XCharts
/// <param name="coordinateWidth"></param>
/// <param name="dataZoom"></param>
/// <returns></returns>
public float GetDataWidth(float coordinateWidth, int dataCount, DataZoom dataZoom)
internal float GetDataWidth(float coordinateWidth, int dataCount, DataZoom dataZoom)
{
if (dataCount < 1) dataCount = 1;
var categoryCount = GetDataNumber(dataZoom);
@@ -439,12 +562,14 @@ namespace XCharts
/// <param name="maxValue"></param>
/// <param name="dataZoom"></param>
/// <returns></returns>
public string GetLabelName(float coordinateWidth, int index, float minValue, float maxValue,
internal string GetLabelName(float coordinateWidth, int index, float minValue, float maxValue,
DataZoom dataZoom, bool forcePercent)
{
int split = GetSplitNumber(coordinateWidth, dataZoom);
if (m_Type == AxisType.Value)
{
if (minValue == 0 && maxValue == 0) return string.Empty;
float value = 0;
if (forcePercent) maxValue = 100;
if (m_Interval > 0)
@@ -459,6 +584,12 @@ namespace XCharts
if (forcePercent) return string.Format("{0}%", (int)value);
else return m_AxisLabel.GetFormatterContent(value, minValue, maxValue);
}
else if (m_Type == AxisType.Log)
{
float value = m_LogBaseE ? Mathf.Exp(runtimeMinLogIndex + index) :
Mathf.Pow(m_LogBase, runtimeMinLogIndex + index);
return m_AxisLabel.GetFormatterContent(value, minValue, maxValue, true);
}
var showData = GetDataList(dataZoom);
int dataCount = showData.Count;
if (dataCount <= 0) return "";
@@ -483,9 +614,9 @@ namespace XCharts
/// </summary>
/// <param name="dataZoom"></param>
/// <returns></returns>
public int GetScaleNumber(float coordinateWidth, DataZoom dataZoom)
internal int GetScaleNumber(float coordinateWidth, DataZoom dataZoom)
{
if (type == AxisType.Value)
if (type == AxisType.Value || type == AxisType.Log)
{
int splitNum = GetSplitNumber(coordinateWidth, dataZoom);
return m_BoundaryGap ? splitNum + 1 : splitNum;
@@ -508,7 +639,7 @@ namespace XCharts
/// <param name="coordinateWidth"></param>
/// <param name="dataZoom"></param>
/// <returns></returns>
public float GetScaleWidth(float coordinateWidth, int index, DataZoom dataZoom)
internal float GetScaleWidth(float coordinateWidth, int index, DataZoom dataZoom)
{
int num = GetScaleNumber(coordinateWidth, dataZoom) - 1;
if (num <= 0) num = 1;
@@ -528,8 +659,10 @@ namespace XCharts
/// 更新刻度标签文字
/// </summary>
/// <param name="dataZoom"></param>
public void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent)
internal void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent, float duration)
{
var minValue = GetCurrMinValue(duration);
var maxValue = GetCurrMaxValue(duration);
for (int i = 0; i < axisLabelTextList.Count; i++)
{
if (axisLabelTextList[i] != null)
@@ -539,7 +672,7 @@ namespace XCharts
}
}
public void SetTooltipLabel(GameObject label)
internal void SetTooltipLabel(GameObject label)
{
m_TooltipLabel = label;
m_TooltipLabelRect = label.GetComponent<RectTransform>();
@@ -547,13 +680,13 @@ namespace XCharts
m_TooltipLabel.SetActive(true);
}
public void SetTooltipLabelColor(Color bgColor, Color textColor)
internal void SetTooltipLabelColor(Color bgColor, Color textColor)
{
m_TooltipLabel.GetComponent<Image>().color = bgColor;
m_TooltipLabelText.color = textColor;
}
public void SetTooltipLabelActive(bool flag)
internal void SetTooltipLabelActive(bool flag)
{
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
{
@@ -561,7 +694,7 @@ namespace XCharts
}
}
public void UpdateTooptipLabelText(string text)
internal void UpdateTooptipLabelText(string text)
{
if (m_TooltipLabelText)
{
@@ -571,7 +704,7 @@ namespace XCharts
}
}
public void UpdateTooltipLabelPos(Vector2 pos)
internal void UpdateTooltipLabelPos(Vector2 pos)
{
if (m_TooltipLabel)
{
@@ -583,6 +716,7 @@ namespace XCharts
{
if (!show) return false;
if (IsCategory() && data.Count <= 0) return false;
else if (IsValue() && m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return false;
else return true;
}
@@ -591,8 +725,17 @@ namespace XCharts
/// </summary>
/// <param name="minValue"></param>
/// <param name="maxValue"></param>
public void AdjustMinMaxValue(ref float minValue, ref float maxValue)
internal void AdjustMinMaxValue(ref float minValue, ref float maxValue, bool needFormat)
{
if (m_Type == AxisType.Log)
{
int minSplit = 0;
int maxSplit = 0;
maxValue = ChartHelper.GetMaxLogValue(maxValue, m_LogBase, m_LogBaseE, out maxSplit);
minValue = ChartHelper.GetMinLogValue(minValue, m_LogBase, m_LogBaseE, out minSplit);
splitNumber = (minSplit > 0 && maxSplit > 0) ? (maxSplit + minSplit - 1) : (maxSplit + minSplit);
return;
}
if (minMaxType == Axis.AxisMinMaxType.Custom)
{
if (min != 0 || max != 0)
@@ -606,40 +749,136 @@ namespace XCharts
switch (minMaxType)
{
case Axis.AxisMinMaxType.Default:
if (minValue > 0 && maxValue > 0)
if (minValue == 0 && maxValue == 0)
{
}
else if (minValue > 0 && maxValue > 0)
{
minValue = 0;
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue,m_CeilRate) : maxValue;
}
else if (minValue < 0 && maxValue < 0)
{
minValue = ChartHelper.GetMinDivisibleValue(minValue);
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue,m_CeilRate) : minValue;
maxValue = 0;
}
else
{
minValue = ChartHelper.GetMinDivisibleValue(minValue);
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue,m_CeilRate) : minValue;
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue,m_CeilRate) : maxValue;
}
break;
case Axis.AxisMinMaxType.MinMax:
minValue = ChartHelper.GetMinDivisibleValue(minValue);
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue,m_CeilRate) : minValue;
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue,m_CeilRate) : maxValue;
break;
}
}
m_ValueRange = maxValue - minValue;
}
public override bool Equals(object obj)
internal void UpdateMinValue(float value, bool check)
{
if (ReferenceEquals(null, obj))
if (value != m_RuntimeMaxValue)
{
return false;
if (check && Application.isPlaying)
{
if (m_RuntimeMinValueFirstChanged)
{
m_RuntimeMinValueFirstChanged = false;
}
else
{
m_RuntimeLastMinValue = m_RuntimeMinValue;
m_RuntimeMinValueChanged = true;
m_RuntimeMinValueUpdateTime = Time.time;
}
m_RuntimeMinValue = value;
}
else
{
m_RuntimeMinValue = value;
m_RuntimeLastMinValue = value;
m_RuntimeMinValueUpdateTime = Time.time;
m_RuntimeMinValueChanged = true;
}
}
else if (obj is Axis)
}
internal void UpdateMaxValue(float value, bool check)
{
if (value != m_RuntimeMaxValue)
{
return Equals((Axis)obj);
if (check && Application.isPlaying)
{
if (m_RuntimeMaxValueFirstChanged)
{
m_RuntimeMaxValueFirstChanged = false;
}
else
{
m_RuntimeLastMaxValue = m_RuntimeMaxValue;
m_RuntimeMaxValueChanged = true;
m_RuntimeMaxValueUpdateTime = Time.time;
}
m_RuntimeMaxValue = value;
}
else
{
m_RuntimeMaxValue = value;
m_RuntimeLastMaxValue = value;
m_RuntimeMaxValueUpdateTime = Time.time;
m_RuntimeMaxValueChanged = false;
}
}
}
internal float GetCurrMinValue(float duration)
{
if (!Application.isPlaying) return m_RuntimeMinValue;
if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
if (!m_RuntimeMinValueChanged) return m_RuntimeMinValue;
var time = Time.time - m_RuntimeMinValueUpdateTime;
if (time == 0) return m_RuntimeMinValue;
var total = duration / 1000;
if (duration > 0 && time <= total)
{
var curr = Mathf.Lerp(m_RuntimeLastMinValue, m_RuntimeMinValue, time / total);
return curr;
}
else
{
m_RuntimeMinValueChanged = false;
return m_RuntimeMinValue;
}
}
internal float GetCurrMaxValue(float duration)
{
if (!Application.isPlaying) return m_RuntimeMaxValue;
if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
if (!m_RuntimeMaxValueChanged) return m_RuntimeMaxValue;
var time = Time.time - m_RuntimeMaxValueUpdateTime;
if (time == 0) return m_RuntimeMaxValue;
var total = duration / 1000;
if (duration > 0 && time < total)
{
var curr = Mathf.Lerp(m_RuntimeLastMaxValue, m_RuntimeMaxValue, time / total);
return curr;
}
else
{
m_RuntimeMaxValueChanged = false;
return m_RuntimeMaxValue;
}
}
public bool IsValueChanging(float duration)
{
if (!Application.isPlaying) return false;
if (GetCurrMinValue(duration) != m_RuntimeMinValue || GetCurrMaxValue(duration) != m_RuntimeMaxValue)
{
return true;
}
else
{
@@ -647,49 +886,10 @@ namespace XCharts
}
}
public bool Equals(Axis other)
public float GetLogValue(float value)
{
if (ReferenceEquals(null, other))
{
return false;
}
return show == other.show &&
type == other.type &&
min == other.min &&
max == other.max &&
splitNumber == other.splitNumber &&
interval == other.interval &&
showSplitLine == other.showSplitLine &&
m_AxisLabel.Equals(other.axisLabel) &&
splitLineType == other.splitLineType &&
boundaryGap == other.boundaryGap &&
minValue == other.minValue &&
maxValue == other.maxValue &&
axisName.Equals(other.axisName) &&
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
}
public static bool operator ==(Axis left, Axis right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Axis left, Axis right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
if (value <= 0) return 0;
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
}
public override void ParseJsonData(string jsonData)
@@ -707,27 +907,6 @@ namespace XCharts
[System.Serializable]
public class XAxis : Axis
{
public XAxis Clone()
{
var axis = XAxisPool.Get();
axis.show = show;
axis.type = type;
axis.min = min;
axis.max = max;
axis.splitNumber = splitNumber;
axis.interval = interval;
axis.showSplitLine = showSplitLine;
axis.splitLineType = splitLineType;
axis.boundaryGap = boundaryGap;
axis.axisName.Copy(axisName);
axis.axisLabel.Copy(axisLabel);
axis.data.Clear();
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
foreach (var d in data) axis.data.Add(d);
return axis;
}
public static XAxis defaultXAxis
{
get
@@ -739,14 +918,15 @@ namespace XCharts
m_Min = 0,
m_Max = 0,
m_SplitNumber = 5,
m_ShowSplitLine = false,
m_SplitLineType = SplitLineType.Dashed,
m_BoundaryGap = true,
m_Data = new List<string>()
{
"x1","x2","x3","x4","x5"
}
};
axis.splitLine.show = false;
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
axis.axisLabel.textLimit.enable = true;
return axis;
}
}
@@ -760,27 +940,6 @@ namespace XCharts
[System.Serializable]
public class YAxis : Axis
{
public YAxis Clone()
{
var axis = YAxisPool.Get();
axis.show = show;
axis.type = type;
axis.min = min;
axis.max = max;
axis.splitNumber = splitNumber;
axis.interval = interval;
axis.showSplitLine = showSplitLine;
axis.splitLineType = splitLineType;
axis.boundaryGap = boundaryGap;
axis.axisName.Copy(axisName);
axis.axisLabel.Copy(axisLabel);
axis.data.Clear();
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
foreach (var d in data) axis.data.Add(d);
return axis;
}
public static YAxis defaultYAxis
{
get
@@ -792,11 +951,12 @@ namespace XCharts
m_Min = 0,
m_Max = 0,
m_SplitNumber = 5,
m_ShowSplitLine = true,
m_SplitLineType = SplitLineType.Dashed,
m_BoundaryGap = false,
m_Data = new List<string>(5),
};
axis.splitLine.show = true;
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
axis.axisLabel.textLimit.enable = false;
return axis;
}
}

View File

@@ -80,6 +80,7 @@ namespace XCharts
[SerializeField] private float m_End;
[SerializeField] private float m_StartValue;
[SerializeField] private float m_EndValue;
[SerializeField] private int m_MinShowNum = 1;
[Range(1f, 20f)]
[SerializeField] private float m_ScrollSensitivity = 1.1f;
[SerializeField] private int m_FontSize = 18;
@@ -89,52 +90,92 @@ namespace XCharts
/// Whether to show dataZoom.
/// 是否显示缩放区域。
/// </summary>
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// The mode of data filter.
/// 数据过滤类型。
/// </summary>
public FilterMode filterMode { get { return m_FilterMode; } set { m_FilterMode = value; } }
public FilterMode filterMode
{
get { return m_FilterMode; }
set { if (PropertyUtility.SetStruct(ref m_FilterMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify which xAxis is controlled by the dataZoom.
/// 控制哪一个 x 轴。
/// </summary>
public int xAxisIndex { get { return m_XAxisIndex; } set { m_XAxisIndex = value; } }
public int xAxisIndex
{
get { return m_XAxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify which yAxis is controlled by the dataZoom.
/// 控制哪一个 y 轴。
/// </summary>
public int yAxisIndex { get { return m_YAxisIndex; } set { m_YAxisIndex = value; } }
public int yAxisIndex
{
get { return m_YAxisIndex; }
set { if (PropertyUtility.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否支持内置。内置于坐标系中,使用户可以在坐标系上通过鼠标拖拽、鼠标滚轮、手指滑动(触屏上)来缩放或漫游坐标系。
/// </summary>
public bool supportInside { get { return m_SupportInside; } set { m_SupportInside = value; } }
public bool supportInside
{
get { return m_SupportInside; }
set { if (PropertyUtility.SetStruct(ref m_SupportInside, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否支持滑动条。有单独的滑动条,用户在滑动条上进行缩放或漫游。
/// </summary>
public bool supportSlider { get { return m_SupportSlider; } set { m_SupportSlider = value; } }
public bool supportSlider
{
get { return m_SupportSlider; }
set { if (PropertyUtility.SetStruct(ref m_SupportSlider, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否支持框选。提供一个选框进行数据区域缩放。
/// </summary>
private bool supportSelect { get { return m_SupportSelect; } set { m_SupportSelect = value; } }
private bool supportSelect
{
get { return m_SupportSelect; }
set { if (PropertyUtility.SetStruct(ref m_SupportSelect, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show data shadow, to indicate the data tendency in brief.
/// default:true
/// 是否显示数据阴影。数据阴影可以简单地反应数据走势。
/// </summary>
public bool showDataShadow { get { return m_ShowDataShadow; } set { m_ShowDataShadow = value; } }
public bool showDataShadow
{
get { return m_ShowDataShadow; }
set { if (PropertyUtility.SetStruct(ref m_ShowDataShadow, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show detail, that is, show the detailed data information when dragging.
/// 是否显示detail即拖拽时候显示详细数值信息。
/// </summary>
public bool showDetail { get { return m_ShowDetail; } set { m_ShowDetail = value; } }
public bool showDetail
{
get { return m_ShowDetail; }
set { if (PropertyUtility.SetStruct(ref m_ShowDetail, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify whether to lock the size of window (selected area).
/// default:false
/// 是否锁定选择区域(或叫做数据窗口)的大小。
/// 如果设置为 true 则锁定选择区域的大小,也就是说,只能平移,不能缩放。
/// </summary>
public bool zoomLock { get { return m_ZoomLock; } set { m_ZoomLock = value; } }
public bool zoomLock
{
get { return m_ZoomLock; }
set { if (PropertyUtility.SetStruct(ref m_ZoomLock, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show data shadow in dataZoom-silder component, to indicate the data tendency in brief.
/// default:true
@@ -145,27 +186,43 @@ namespace XCharts
/// The background color of the component.
/// 组件的背景颜色。
/// </summary>
private Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
private Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between dataZoom component and the bottom side of the container.
/// bottom value is a instant pixel value like 10.
/// default:10
/// 组件离容器下侧的距离。
/// </summary>
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of dataZoom component.
/// height value is a instant pixel value like 10.
/// default:50
/// 组件高度。
/// </summary>
public float height { get { return m_Height; } set { m_Height = value; } }
public float height
{
get { return m_Height; }
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
}
/// <summary>
/// Use absolute value or percent value in DataZoom.start and DataZoom.end.
/// default:RangeMode.Percent.
/// 取绝对值还是百分比。
/// </summary>
public RangeMode rangeMode { get { return m_RangeMode; } set { m_RangeMode = value; } }
public RangeMode rangeMode
{
get { return m_RangeMode; }
set { if (PropertyUtility.SetStruct(ref m_RangeMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// The start percentage of the window out of the data extent, in the range of 0 ~ 100.
/// default:30
@@ -174,7 +231,7 @@ namespace XCharts
public float start
{
get { return m_Start; }
set { m_Start = value; if (m_Start < 0) m_Start = 0; if (m_Start > 100) m_Start = 100; }
set { m_Start = value; if (m_Start < 0) m_Start = 0; if (m_Start > 100) m_Start = 100; SetVerticesDirty(); }
}
/// <summary>
/// The end percentage of the window out of the data extent, in the range of 0 ~ 100.
@@ -184,7 +241,15 @@ namespace XCharts
public float end
{
get { return m_End; }
set { m_End = value; if (m_End < 0) m_End = 0; if (m_End > 100) m_End = 100; }
set { m_End = value; if (m_End < 0) m_End = 0; if (m_End > 100) m_End = 100; SetVerticesDirty(); }
}
/// <summary>
/// 最小显示数据个数。当DataZoom放大到最大时最小显示的数据个数。
/// </summary>
public int minShowNum
{
get { return m_MinShowNum; }
set { if (PropertyUtility.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
}
/// <summary>
/// The sensitivity of dataZoom scroll.
@@ -192,28 +257,40 @@ namespace XCharts
/// default:10
/// 缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
/// </summary>
public float scrollSensitivity { get { return m_ScrollSensitivity; } set { m_ScrollSensitivity = value; } }
public float scrollSensitivity
{
get { return m_ScrollSensitivity; }
set { if (PropertyUtility.SetStruct(ref m_ScrollSensitivity, value)) SetVerticesDirty(); }
}
/// <summary>
/// font size.
/// 文字的字体大小。
/// </summary>
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
}
/// <summary>
/// font style.
/// 文字字体的风格。
/// </summary>
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// The start label.
/// 组件的开始信息文本。
/// </summary>
public Text startLabel { get; set; }
private Text m_StartLabel { get; set; }
/// <summary>
/// The end label.
/// 组件的结束信息文本。
/// </summary>
public Text endLabel { get; set; }
private Text m_EndLabel { get; set; }
public static DataZoom defaultDataZoom
{
@@ -297,15 +374,15 @@ namespace XCharts
/// 是否显示文本
/// </summary>
/// <param name="flag"></param>
public void SetLabelActive(bool flag)
internal void SetLabelActive(bool flag)
{
if (startLabel && startLabel.gameObject.activeInHierarchy != flag)
if (m_StartLabel && m_StartLabel.gameObject.activeInHierarchy != flag)
{
startLabel.gameObject.SetActive(flag);
m_StartLabel.gameObject.SetActive(flag);
}
if (endLabel && endLabel.gameObject.activeInHierarchy != flag)
if (m_EndLabel && m_EndLabel.gameObject.activeInHierarchy != flag)
{
endLabel.gameObject.SetActive(flag);
m_EndLabel.gameObject.SetActive(flag);
}
}
@@ -313,18 +390,18 @@ namespace XCharts
/// 设置开始文本内容
/// </summary>
/// <param name="text"></param>
public void SetStartLabelText(string text)
internal void SetStartLabelText(string text)
{
if (startLabel) startLabel.text = text;
if (m_StartLabel) m_StartLabel.text = text;
}
/// <summary>
/// 设置结束文本内容
/// </summary>
/// <param name="text"></param>
public void SetEndLabelText(string text)
internal void SetEndLabelText(string text)
{
if (endLabel) endLabel.text = text;
if (m_EndLabel) m_EndLabel.text = text;
}
/// <summary>
@@ -332,7 +409,7 @@ namespace XCharts
/// </summary>
/// <param name="gridBottom"></param>
/// <returns></returns>
public float GetHeight(float gridBottom)
internal float GetHeight(float gridBottom)
{
if (height <= 0)
{
@@ -342,5 +419,25 @@ namespace XCharts
}
else return height;
}
internal void SetStartLabel(Text startLabel)
{
m_StartLabel = startLabel;
}
internal void SetEndLabel(Text endLabel)
{
m_EndLabel = endLabel;
}
internal void UpdateStartLabelPosition(Vector3 pos)
{
m_StartLabel.transform.localPosition = pos;
}
internal void UpdateEndLabelPosition(Vector3 pos)
{
m_EndLabel.transform.localPosition = pos;
}
}
}

View File

@@ -5,10 +5,8 @@
/* */
/******************************************/
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
@@ -17,7 +15,7 @@ namespace XCharts
/// 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
/// </summary>
[System.Serializable]
public class Legend : MainComponent, IPropertyChanged, IEquatable<Legend>
public class Legend : MainComponent, IPropertyChanged
{
/// <summary>
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
@@ -43,61 +41,108 @@ namespace XCharts
[SerializeField] private SelectedMode m_SelectedMode;
[SerializeField] private Orient m_Orient = Orient.Horizonal;
[SerializeField] private Location m_Location = Location.defaultRight;
[SerializeField] private float m_ItemWidth = 50.0f;
[SerializeField] private float m_ItemHeight = 20.0f;
[SerializeField] private float m_ItemGap = 5;
[SerializeField] private int m_ItemFontSize = 18;
[SerializeField] private float m_ItemWidth = 24.0f;
[SerializeField] private float m_ItemHeight = 12.0f;
[SerializeField] private float m_ItemGap = 10f;
[SerializeField] private bool m_ItemAutoColor = true;
[SerializeField] private string m_Formatter;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18);
[SerializeField] private List<string> m_Data = new List<string>();
[SerializeField] private List<Sprite> m_Icons = new List<Sprite>();
private Dictionary<string, Button> m_DataBtnList = new Dictionary<string, Button>();
private Dictionary<string, LegendItem> m_DataBtnList = new Dictionary<string, LegendItem>();
/// <summary>
/// Whether to show legend component.
/// 是否显示图例组件。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
/// 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
/// </summary>
/// <value></value>
public SelectedMode selectedMode { get { return m_SelectedMode; } set { m_SelectedMode = value; } }
public SelectedMode selectedMode
{
get { return m_SelectedMode; }
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
}
/// <summary>
/// Specify whether the layout of legend component is horizontal or vertical.
/// 布局方式是横还是竖。
/// </summary>
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
public Orient orient
{
get { return m_Orient; }
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
}
/// <summary>
/// The location of legend.
/// 图例显示的位置。
/// </summary>
public Location location { get { return m_Location; } set { m_Location = value; } }
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
}
/// <summary>
/// the width of legend item.
/// 每个图例项的宽度。
/// Image width of legend symbol.
/// 图例标记的图形宽度。
/// </summary>
public float itemWidth { get { return m_ItemWidth; } set { m_ItemWidth = value; } }
public float itemWidth
{
get { return m_ItemWidth; }
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
}
/// <summary>
/// the height of legend item.
/// 每个图例项的高度。
/// Image height of legend symbol.
/// 图例标记的图形高度。
/// </summary>
public float itemHeight { get { return m_ItemHeight; } set { m_ItemHeight = value; } }
public float itemHeight
{
get { return m_ItemHeight; }
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
}
/// <summary>
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
/// 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
/// </summary>
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
public float itemGap
{
get { return m_ItemGap; }
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
}
/// <summary>
/// font size of item text.
/// 图例项的字体大小
/// Whether the legend symbol matches the color automatically.
/// 图例标记的图形是否自动匹配颜色
/// </summary>
public int itemFontSize { get { return m_ItemFontSize; } set { m_ItemFontSize = value; } }
public bool itemAutoColor
{
get { return m_ItemAutoColor; }
set { if (PropertyUtility.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
}
/// <summary>
/// 图例内容字符串模版格式器。支持用 \n 换行。
/// 模板变量为图例名称 {name}
/// </summary>
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
}
/// <summary>
/// the style of text.
/// 文本样式。
/// </summary>
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,
/// it could also be the name of a single data in the pie chart) of a series.
@@ -105,13 +150,76 @@ namespace XCharts
/// 图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 name如果是饼图也可以是饼图单个数据的 name
/// 如果 data 没有被指定会自动从当前系列中获取。指定data时里面的数据项和serie匹配时才会生效。
/// </summary>
public List<string> data { get { return m_Data; } }
public List<string> data
{
get { return m_Data; }
set { if (value != null) { m_Data = value; SetComponentDirty(); } }
}
/// <summary>
/// 自定义的图例标记图形。
/// </summary>
public List<Sprite> icons
{
get { return m_Icons; }
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
}
/// <summary>
/// 图表是否需要刷新(图例组件不需要刷新图表)
/// </summary>
public override bool vertsDirty { get { return false; } }
/// <summary>
/// 组件是否需要刷新
/// </summary>
public override bool componentDirty
{
get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty; }
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
location.ClearComponentDirty();
textStyle.ClearComponentDirty();
}
/// <summary>
/// the button list of legend.
/// 图例按钮列表。
/// </summary>
/// <value></value>
public Dictionary<string, Button> buttonList { get { return m_DataBtnList; } }
public Dictionary<string, LegendItem> buttonList { get { return m_DataBtnList; } }
public float runtimeWidth
{
get
{
var width = 0f;
foreach (var kv in buttonList)
{
if (orient == Orient.Horizonal)
width += kv.Value.width + m_ItemGap;
else if (kv.Value.width > width)
width = kv.Value.width;
}
return orient == Orient.Horizonal ? width - m_ItemGap : width;
}
}
public float runtimeHeight
{
get
{
var height = 0f;
foreach (var kv in buttonList)
{
if (orient == Orient.Vertical)
height += kv.Value.height + m_ItemGap;
else if (kv.Value.height > height)
height = kv.Value.height;
}
return orient == Orient.Vertical ? height - m_ItemGap : height;
}
}
/// <summary>
/// 一个在顶部居中显示的默认图例。
@@ -126,84 +234,16 @@ namespace XCharts
m_SelectedMode = SelectedMode.Multiple,
m_Orient = Orient.Horizonal,
m_Location = Location.defaultTop,
m_ItemWidth = 60.0f,
m_ItemHeight = 20.0f,
m_ItemGap = 5,
m_ItemFontSize = 16
m_ItemWidth = 24.0f,
m_ItemHeight = 12.0f,
m_ItemGap = 10f,
};
legend.location.top = 30;
legend.textStyle.offset = new Vector2(2, 0);
legend.textStyle.fontSize = 18;
return legend;
}
}
public void Copy(Legend legend)
{
m_Show = legend.show;
m_SelectedMode = legend.selectedMode;
m_Orient = legend.orient;
m_Location.Copy(legend.location);
m_ItemWidth = legend.itemWidth;
m_ItemHeight = legend.itemHeight;
m_ItemGap = legend.itemGap;
m_ItemFontSize = legend.itemFontSize;
m_Data.Clear();
foreach (var d in legend.data) m_Data.Add(d);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Legend)
{
return Equals((Legend)obj);
}
else
{
return false;
}
}
public bool Equals(Legend other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return show == other.show &&
selectedMode == other.selectedMode &&
orient == other.orient &&
location == other.location &&
itemWidth == other.itemWidth &&
itemHeight == other.itemHeight &&
itemGap == other.itemGap &&
itemFontSize == other.itemFontSize &&
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
}
public static bool operator ==(Legend left, Legend right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Legend left, Legend right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
/// <summary>
/// 清空
@@ -211,6 +251,7 @@ namespace XCharts
public void ClearData()
{
m_Data.Clear();
SetComponentDirty();
}
/// <summary>
@@ -232,6 +273,7 @@ namespace XCharts
if (m_Data.Contains(name))
{
m_Data.Remove(name);
SetComponentDirty();
}
}
@@ -244,6 +286,7 @@ namespace XCharts
if (!m_Data.Contains(name) && !string.IsNullOrEmpty(name))
{
m_Data.Add(name);
SetComponentDirty();
}
}
@@ -285,13 +328,11 @@ namespace XCharts
/// <param name="name"></param>
/// <param name="btn"></param>
/// <param name="total"></param>
public void SetButton(string name, Button btn, int total)
public void SetButton(string name, LegendItem item, int total)
{
m_DataBtnList[name] = item;
int index = m_DataBtnList.Values.Count;
btn.transform.localPosition = GetButtonLocationPosition(total, index);
m_DataBtnList[name] = btn;
btn.gameObject.SetActive(show);
btn.GetComponentInChildren<Text>().text = name;
item.SetActive(show);
}
/// <summary>
@@ -303,7 +344,27 @@ namespace XCharts
{
if (m_DataBtnList.ContainsKey(name))
{
m_DataBtnList[name].GetComponent<Image>().color = color;
m_DataBtnList[name].SetIconColor(color);
}
}
public void UpdateContentColor(string name, Color color)
{
if (m_DataBtnList.ContainsKey(name))
{
m_DataBtnList[name].SetContentColor(color);
}
}
public Sprite GetIcon(int index)
{
if (index >= 0 && index < m_Icons.Count)
{
return m_Icons[index];
}
else
{
return null;
}
}
@@ -315,62 +376,6 @@ namespace XCharts
m_Location.OnChanged();
}
/// <summary>
/// 根据图例的布局和位置类型获得具体位置
/// </summary>
/// <param name="size"></param>
/// <param name="index"></param>
/// <returns></returns>
private Vector2 GetButtonLocationPosition(int size, int index)
{
switch (m_Orient)
{
case Orient.Vertical:
switch (m_Location.align)
{
case Location.Align.TopCenter:
case Location.Align.TopLeft:
case Location.Align.TopRight:
return new Vector2(0, -index * (itemHeight + itemGap));
case Location.Align.Center:
case Location.Align.CenterLeft:
case Location.Align.CenterRight:
float totalHeight = size * itemHeight + (size - 1) * itemGap;
float startY = totalHeight / 2;
return new Vector2(0, startY - index * (itemHeight + itemGap));
case Location.Align.BottomCenter:
case Location.Align.BottomLeft:
case Location.Align.BottomRight:
return new Vector2(0, (size - index - 1) * (itemHeight + itemGap));
}
return Vector2.zero;
case Orient.Horizonal:
switch (m_Location.align)
{
case Location.Align.TopLeft:
case Location.Align.CenterLeft:
case Location.Align.BottomLeft:
return new Vector2(index * (itemWidth + itemGap), 0);
case Location.Align.TopCenter:
case Location.Align.Center:
case Location.Align.BottomCenter:
float totalWidth = size * itemWidth + (size - 1) * itemGap;
float startX = totalWidth / 2;
return new Vector2(-startX + itemWidth / 2 + index * (itemWidth + itemGap), 0);
case Location.Align.TopRight:
case Location.Align.CenterRight:
case Location.Align.BottomRight:
return new Vector2(-(size - index - 1) * (itemWidth + itemGap), 0);
}
return Vector2.zero;
}
return Vector2.zero;
}
/// <summary>
/// 从json字符串解析数据json格式如['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
/// </summary>
@@ -379,6 +384,7 @@ namespace XCharts
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
m_Data = ChartHelper.ParseStringFromString(jsonData);
SetComponentDirty();
}
public string GetFormatterContent(string category)

View File

@@ -18,7 +18,7 @@ namespace XCharts
/// 雷达图坐标系组件,只适用于雷达图。
/// </summary>
[System.Serializable]
public class Radar : MainComponent, IEquatable<Radar>
public class Radar : MainComponent
{
/// <summary>
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
@@ -30,16 +30,31 @@ namespace XCharts
Circle
}
/// <summary>
/// 显示位置。
/// </summary>
public enum PositionType
{
/// <summary>
/// 显示在顶点处。
/// </summary>
Vertice,
/// <summary>
/// 显示在两者之间。
/// </summary>
Between,
}
/// <summary>
/// Indicator of radar chart, which is used to assign multiple variables(dimensions) in radar chart.
/// 雷达图的指示器,用来指定雷达图中的多个变量(维度)。
/// </summary>
[System.Serializable]
public class Indicator : IEquatable<Indicator>
public class Indicator
{
[SerializeField] private string m_Name;
[SerializeField] private float m_Max;
[SerializeField] private float m_Min;
[SerializeField] private Color m_Color;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
/// <summary>
/// 指示器名称。
/// </summary>
@@ -55,103 +70,107 @@ namespace XCharts
/// </summary>
public float min { get { return m_Min; } set { m_Min = value; } }
/// <summary>
/// Specfy a color the the indicator.
/// 标签特定的颜色。默认取自主题的axisTextColor
/// the style of text.
/// 文本样式
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; } }
public TextStyle textStyle { get { return m_TextStyle; } set { m_TextStyle = value; } }
/// <summary>
/// the text conponent of indicator.
/// 指示器的文本组件。
/// </summary>
public Text text { get; set; }
public Indicator Clone()
{
return new Indicator()
{
m_Name = name,
m_Max = max,
m_Min = min,
m_Color = color
};
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Indicator)
{
return Equals((Indicator)obj);
}
else
{
return false;
}
}
public bool Equals(Indicator other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Name.Equals(other.name) &&
ChartHelper.IsValueEqualsColor(m_Color, other.color);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
[SerializeField] private Shape m_Shape;
[SerializeField] private float m_Radius = 100;
[SerializeField] private int m_SplitNumber = 5;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
[SerializeField] private AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
[SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
[SerializeField] private bool m_Indicator = true;
[SerializeField] private PositionType m_PositionType = PositionType.Vertice;
[SerializeField] private float m_IndicatorGap = 10;
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
/// <summary>
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
/// </summary>
/// <value></value>
public Shape shape { get { return m_Shape; } set { m_Shape = value; } }
public Shape shape
{
get { return m_Shape; }
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetAllDirty(); }
}
/// <summary>
/// the radius of radar.
/// 雷达图的半径。
/// </summary>
public float radius { get { return m_Radius; } set { m_Radius = value; } }
public float radius
{
get { return m_Radius; }
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// Segments of indicator axis.
/// 指示器轴的分割段数。
/// </summary>
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
/// <summary>
/// the center of radar chart.
/// 雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。
/// 当值为0-1之间时表示百分比设置成百分比时第一项是相对于容器宽度第二项是相对于容器高度。
/// </summary>
public float[] center { get { return m_Center; } set { m_Center = value; } }
public float[] center
{
get { return m_Center; }
set { if (value != null) { m_Center = value; SetAllDirty(); } }
}
/// <summary>
/// the line style of radar.
/// 线条样式
/// split line.
/// 分割线。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
public AxisSplitLine splitLine
{
get { return m_SplitLine; }
set { if (PropertyUtility.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
}
/// <summary>
/// Split area of axis in grid area.
/// 分割区域。
/// </summary>
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
public AxisSplitArea splitArea
{
get { return m_SplitArea; }
set { if (PropertyUtility.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
}
/// <summary>
/// Whether to show indicator.
/// 是否显示指示器。
/// </summary>
public bool indicator { get { return m_Indicator; } set { m_Indicator = value; } }
public bool indicator
{
get { return m_Indicator; }
set { if (PropertyUtility.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
}
/// <summary>
/// 指示器和雷达的间距。
/// </summary>
public float indicatorGap
{
get { return m_IndicatorGap; }
set { if (PropertyUtility.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
}
/// <summary>
/// /// 显示位置类型。
/// </summary>
public PositionType positionType
{
get { return m_PositionType; }
set { if (PropertyUtility.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
}
/// <summary>
/// the indicator list.
/// 指示器列表。
@@ -162,20 +181,18 @@ namespace XCharts
/// the center position of radar in container.
/// 雷达图在容器中的具体中心点。
/// </summary>
/// <value></value>
public Vector2 centerPos { get; set; }
public Vector3 runtimeCenterPos { get; internal set; }
/// <summary>
/// the true radius of radar.
/// 雷达图的运行时实际半径。
/// </summary>
/// <value></value>
public float actualRadius { get; set; }
public float runtimeRadius { get; internal set; }
public float runtimeDataRadius { get; internal set; }
/// <summary>
/// the data position list of radar.
/// 雷达图的所有数据坐标点列表。
/// </summary>
/// <returns></returns>
public Dictionary<int, List<Vector3>> dataPosList = new Dictionary<int, List<Vector3>>();
public Dictionary<int, List<Vector3>> runtimeDataPosList = new Dictionary<int, List<Vector3>>();
public static Radar defaultRadar
{
@@ -184,7 +201,7 @@ namespace XCharts
var radar = new Radar
{
m_Shape = Shape.Polygon,
m_Radius = 0.4f,
m_Radius = 0.35f,
m_SplitNumber = 5,
m_Indicator = true,
m_IndicatorList = new List<Indicator>(5){
@@ -196,70 +213,14 @@ namespace XCharts
}
};
radar.center[0] = 0.5f;
radar.center[1] = 0.45f;
radar.center[1] = 0.4f;
radar.splitLine.show = true;
radar.splitArea.show = true;
radar.lineStyle.width = 0.6f;
radar.splitLine.lineStyle.width = 0.6f;
return radar;
}
}
public void Copy(Radar other)
{
m_Shape = other.shape;
m_Radius = other.radius;
m_SplitNumber = other.splitNumber;
m_Center[0] = other.center[0];
m_Center[1] = other.center[1];
m_Indicator = other.indicator;
indicatorList.Clear();
foreach (var d in other.indicatorList) indicatorList.Add(d.Clone());
}
public Radar Clone()
{
var radar = new Radar();
radar.shape = shape;
radar.radius = radius;
radar.splitNumber = splitNumber;
radar.center[0] = center[0];
radar.center[1] = center[1];
radar.indicatorList.Clear();
radar.indicator = indicator;
foreach (var d in indicatorList) radar.indicatorList.Add(d.Clone());
return radar;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Radar)
{
return Equals((Radar)obj);
}
else
{
return false;
}
}
public bool Equals(Radar other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return radius == other.radius &&
shape == other.shape &&
splitNumber == other.splitNumber &&
center[0] == other.center[0] &&
center[1] == other.center[1] &&
indicator == other.indicator &&
IsEqualsIndicatorList(indicatorList, other.indicatorList);
}
private bool IsEqualsIndicatorList(List<Indicator> indicators1, List<Indicator> indicators2)
{
if (indicators1.Count != indicators2.Count) return false;
@@ -272,29 +233,6 @@ namespace XCharts
return true;
}
public static bool operator ==(Radar left, Radar right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Radar left, Radar right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override void ParseJsonData(string jsonData)
{
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
@@ -344,33 +282,79 @@ namespace XCharts
return 0;
}
public void UpdateRadarCenter(float chartWidth, float chartHeight)
internal void UpdateRadarCenter(float chartWidth, float chartHeight)
{
if (center.Length < 2) return;
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
centerPos = new Vector2(centerX, centerY);
runtimeCenterPos = new Vector2(centerX, centerY);
if (radius <= 0)
{
actualRadius = 0;
runtimeRadius = 0;
}
else if (radius <= 1)
{
actualRadius = Mathf.Min(chartWidth, chartHeight) * radius;
runtimeRadius = Mathf.Min(chartWidth, chartHeight) * radius;
}
else
{
actualRadius = radius;
runtimeRadius = radius;
}
if (shape == Radar.Shape.Polygon && positionType == PositionType.Between)
{
var angle = Mathf.PI / indicatorList.Count;
runtimeDataRadius = runtimeRadius * Mathf.Cos(angle);
}
else
{
runtimeDataRadius = runtimeRadius;
}
}
public Vector3 GetIndicatorPosition(int index)
{
int indicatorNum = indicatorList.Count;
var angle = 2 * Mathf.PI / indicatorNum * index;
var x = centerPos.x + actualRadius * Mathf.Sin(angle);
var y = centerPos.y + actualRadius * Mathf.Cos(angle);
var angle = 0f;
switch (positionType)
{
case PositionType.Vertice:
angle = 2 * Mathf.PI / indicatorNum * index;
break;
case PositionType.Between:
angle = 2 * Mathf.PI / indicatorNum * (index + 0.5f);
break;
}
var x = runtimeCenterPos.x + (runtimeRadius + indicatorGap) * Mathf.Sin(angle);
var y = runtimeCenterPos.y + (runtimeRadius + indicatorGap) * Mathf.Cos(angle);
return new Vector3(x, y);
}
public Radar.Indicator AddIndicator(string name, float min, float max)
{
var indicator = new Radar.Indicator();
indicator.name = name;
indicator.min = min;
indicator.max = max;
indicatorList.Add(indicator);
SetAllDirty();
return indicator;
}
public bool UpdateIndicator(int indicatorIndex, string name, float min, float max)
{
var indicator = GetIndicator(indicatorIndex);
if (indicator == null) return false;
indicator.name = name;
indicator.min = min;
indicator.max = max;
SetAllDirty();
return true;
}
public Radar.Indicator GetIndicator(int indicatorIndex)
{
if (indicatorIndex < 0 || indicatorIndex > indicatorList.Count - 1) return null;
return indicatorList[indicatorIndex];
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -18,12 +18,13 @@ namespace XCharts
[System.Serializable]
public class Series : MainComponent
{
[SerializeField] protected List<Serie> m_Series;
[NonSerialized] private bool m_LabelDirty;
[Obsolete("Use Series.list instead.", true)]
public List<Serie> series { get { return m_Series; } }
/// <summary>
/// the list of serie
/// 系列列表。
@@ -51,12 +52,80 @@ namespace XCharts
}
}
public override bool vertsDirty
{
get
{
if (m_VertsDirty) return true;
foreach (var serie in m_Series)
{
if (serie.vertsDirty) return true;
}
return false;
}
}
public bool labelDirty
{
get
{
if (m_LabelDirty) return true;
foreach (var serie in m_Series)
{
if (serie.label.componentDirty) return true;
}
return false;
}
}
public bool labelUpdate
{
get
{
foreach (var serie in m_Series)
{
if (serie.label.vertsDirty) return true;
}
return false;
}
}
public void SetLabelDirty()
{
m_LabelDirty = true;
}
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
foreach (var serie in m_Series)
{
serie.ClearVerticesDirty();
}
}
internal void ClearLabelDirty()
{
m_LabelDirty = false;
foreach (var serie in m_Series)
{
serie.label.ClearVerticesDirty();
}
}
public override void SetAllDirty()
{
base.SetAllDirty();
SetLabelDirty();
}
/// <summary>
/// 清空所有系列的数据
/// </summary>
public void ClearData()
{
AnimationStop();
AnimationFadeIn();
foreach (var serie in m_Series)
{
serie.ClearData();
@@ -81,6 +150,18 @@ namespace XCharts
}
}
public float GetCurrData(int serieIndex, int dataIndex)
{
if (serieIndex >= 0 && serieIndex < Count)
{
return m_Series[serieIndex].GetYCurrData(dataIndex);
}
else
{
return 0;
}
}
/// <summary>
/// 获得指定系列名的第一个系列
/// </summary>
@@ -143,7 +224,7 @@ namespace XCharts
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public Serie GetLastStackSerie(int index)
internal Serie GetLastStackSerie(int index)
{
var serie = GetSerie(index);
return GetLastStackSerie(serie);
@@ -154,7 +235,7 @@ namespace XCharts
/// </summary>
/// <param name="stack"></param>
/// <returns></returns>
public bool IsAnyGradientSerie(string stack)
internal bool IsAnyGradientSerie(string stack)
{
if (string.IsNullOrEmpty(stack)) return false;
foreach (var serie in m_Series)
@@ -167,12 +248,37 @@ namespace XCharts
return false;
}
/// <summary>
/// 是否有需裁剪的serie。
/// </summary>
/// <returns></returns>
internal bool IsAnyClipSerie()
{
foreach (var serie in m_Series)
{
if (serie.clip) return true;
}
return false;
}
internal bool IsAnyUpdateAnimationSerie()
{
foreach (var serie in m_Series)
{
if (serie.animation.enable && serie.animation.dataChangeEnable)
{
return true;
}
}
return false;
}
/// <summary>
/// 获得上一个同堆叠且显示的serie。
/// </summary>
/// <param name="serie"></param>
/// <returns></returns>
public Serie GetLastStackSerie(Serie serie)
internal Serie GetLastStackSerie(Serie serie)
{
if (serie == null || string.IsNullOrEmpty(serie.stack)) return null;
for (int i = serie.index - 1; i >= 0; i--)
@@ -220,7 +326,7 @@ namespace XCharts
/// </summary>
public void RemoveAll()
{
AnimationStop();
AnimationFadeIn();
m_Series.Clear();
}
@@ -255,8 +361,9 @@ namespace XCharts
{
serie.symbol.type = SerieSymbolType.None;
}
serie.animation.Reset();
serie.animation.Restart();
m_Series.Add(serie);
SetVerticesDirty();
return serie;
}
@@ -370,13 +477,14 @@ namespace XCharts
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="dataIndex"></param>
public void UpdateData(string serieName, int dataIndex, float value)
public bool UpdateData(string serieName, int dataIndex, float value)
{
var serie = GetSerie(serieName);
if (serie != null)
{
serie.UpdateYData(dataIndex, value);
return serie.UpdateYData(dataIndex, value);
}
return false;
}
/// <summary>
@@ -385,13 +493,14 @@ namespace XCharts
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dataName"></param>
public void UpdateDataName(string serieName, int dataIndex, string dataName)
public bool UpdateDataName(string serieName, int dataIndex, string dataName)
{
var serie = GetSerie(serieName);
if (serie != null)
{
serie.UpdateDataName(dataIndex, dataName);
return serie.UpdateDataName(dataIndex, dataName);
}
return false;
}
/// <summary>
@@ -400,13 +509,14 @@ namespace XCharts
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="dataName"></param>
public void UpdateDataName(int serieIndex, int dataIndex, string dataName)
public bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
serie.UpdateDataName(dataIndex, dataName);
return serie.UpdateDataName(dataIndex, dataName);
}
return false;
}
/// <summary>
@@ -415,13 +525,67 @@ namespace XCharts
/// <param name="serieIndex"></param>
/// <param name="dataIndex"></param>
/// <param name="value"></param>
public void UpdateData(int serieIndex, int dataIndex, float value)
public bool UpdateData(int serieIndex, int dataIndex, float value)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
serie.UpdateYData(dataIndex, value);
return serie.UpdateYData(dataIndex, value);
}
return false;
}
public bool UpdateData(string serieName, int dataIndex, List<float> values)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.UpdateData(dataIndex, values);
}
return false;
}
public bool UpdateData(int serieIndex, int dataIndex, List<float> values)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateData(dataIndex, values);
}
return false;
}
/// <summary>
/// 更新指定系列指定数据项指定维度的数据值
/// </summary>
/// <param name="serieIndex">系列</param>
/// <param name="dataIndex">数据项</param>
/// <param name="dimension">数据维数从0开始</param>
/// <param name="value">值</param>
public bool UpdateData(int serieIndex, int dataIndex, int dimension, float value)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
return serie.UpdateData(dataIndex, dimension, value);
}
return false;
}
/// <summary>
/// 更新指定系列指定数据项指定维度的数据值
/// </summary>
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dimension">数据维数从0开始</param>
/// <param name="value"></param>
public bool UpdateData(string serieName, int dataIndex, int dimension, float value)
{
var serie = GetSerie(serieName);
if (serie != null)
{
return serie.UpdateData(dataIndex, dimension, value);
}
return false;
}
@@ -432,13 +596,14 @@ namespace XCharts
/// <param name="dataIndex"></param>
/// <param name="xValue"></param>
/// <param name="yValue"></param>
public void UpdateXYData(string serieName, int dataIndex, float xValue, float yValue)
public bool UpdateXYData(string serieName, int dataIndex, float xValue, float yValue)
{
var serie = GetSerie(serieName);
if (serie != null)
{
serie.UpdateXYData(dataIndex, xValue, yValue);
return serie.UpdateXYData(dataIndex, xValue, yValue);
}
return false;
}
/// <summary>
@@ -448,20 +613,21 @@ namespace XCharts
/// <param name="dataIndex"></param>
/// <param name="xValue"></param>
/// <param name="yValue"></param>
public void UpdateXYData(int serieIndex, int dataIndex, float xValue, float yValue)
public bool UpdateXYData(int serieIndex, int dataIndex, float xValue, float yValue)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
serie.UpdateXYData(dataIndex, xValue, yValue);
return serie.UpdateXYData(dataIndex, xValue, yValue);
}
return false;
}
/// <summary>
/// dataZoom由变化是更新系列的缓存数据
/// </summary>
/// <param name="dataZoom"></param>
public void UpdateFilterData(DataZoom dataZoom)
internal void UpdateFilterData(DataZoom dataZoom)
{
if (dataZoom != null && dataZoom.enable)
{
@@ -519,6 +685,8 @@ namespace XCharts
if (serie != null)
{
serie.show = active;
serie.animation.Reset();
if (active) serie.animation.FadeIn();
}
}
@@ -527,7 +695,7 @@ namespace XCharts
/// </summary>
/// <param name="axisIndex"></param>
/// <returns></returns>
public bool IsUsedAxisIndex(int axisIndex)
internal bool IsUsedAxisIndex(int axisIndex)
{
foreach (var serie in list)
{
@@ -555,7 +723,7 @@ namespace XCharts
/// <param name="axisIndex"></param>
/// <param name="minVaule"></param>
/// <param name="maxValue"></param>
public void GetXMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
internal void GetXMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
out float minVaule, out float maxValue)
{
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, false, out minVaule, out maxValue);
@@ -568,7 +736,7 @@ namespace XCharts
/// <param name="axisIndex"></param>
/// <param name="minVaule"></param>
/// <param name="maxValue"></param>
public void GetYMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
internal void GetYMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
out float minVaule, out float maxValue)
{
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, true, out minVaule, out maxValue);
@@ -576,7 +744,7 @@ namespace XCharts
private Dictionary<int, List<Serie>> _stackSeriesForMinMax = new Dictionary<int, List<Serie>>();
private Dictionary<int, float> _serieTotalValueForMinMax = new Dictionary<int, float>();
public void GetMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool yValue,
internal void GetMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool yValue,
out float minVaule, out float maxValue)
{
float min = int.MaxValue;
@@ -603,8 +771,9 @@ namespace XCharts
{
if (yValue)
{
if (data.data[1] > max) max = data.data[1];
if (data.data[1] < min) min = data.data[1];
var currData = data.GetData(1);
if (currData > max) max = currData;
if (currData < min) min = currData;
}
else
{
@@ -641,7 +810,7 @@ namespace XCharts
if (!_serieTotalValueForMinMax.ContainsKey(j))
_serieTotalValueForMinMax[j] = 0;
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] +
(yValue ? showData[j].data[1] : showData[i].data[0]);
(yValue ? showData[j].GetData(1) : showData[i].data[0]);
}
}
@@ -664,14 +833,8 @@ namespace XCharts
}
else
{
if (max > 1)
{
minVaule = Mathf.FloorToInt(min);
maxValue = Mathf.CeilToInt(max);
}else{
minVaule = min;
maxValue = max;
}
minVaule = min > 1 ? Mathf.FloorToInt(min) : min;
maxValue = max > 1 ? Mathf.CeilToInt(max) : max;
}
}
@@ -680,7 +843,7 @@ namespace XCharts
/// 是否由数据堆叠
/// </summary>
/// <returns></returns>
public bool IsStack()
internal bool IsStack()
{
_setForStack.Clear();
foreach (var serie in m_Series)
@@ -701,7 +864,7 @@ namespace XCharts
/// <param name="stackName"></param>
/// <param name="type"></param>
/// <returns></returns>
public bool IsStack(string stackName, SerieType type)
internal bool IsStack(string stackName, SerieType type)
{
if (string.IsNullOrEmpty(stackName)) return false;
int count = 0;
@@ -721,7 +884,7 @@ namespace XCharts
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public bool IsPercentStack(SerieType type)
internal bool IsPercentStack(SerieType type)
{
int count = 0;
bool isPercentStack = false;
@@ -746,7 +909,7 @@ namespace XCharts
/// <param name="stackName"></param>
/// <param name="type"></param>
/// <returns></returns>
public bool IsPercentStack(string stackName, SerieType type)
internal bool IsPercentStack(string stackName, SerieType type)
{
if (string.IsNullOrEmpty(stackName)) return false;
int count = 0;
@@ -770,7 +933,7 @@ namespace XCharts
/// 获得堆叠系列列表
/// </summary>
/// <returns></returns>
public Dictionary<int, List<Serie>> GetStackSeries()
internal Dictionary<int, List<Serie>> GetStackSeries()
{
int count = 0;
Dictionary<string, int> sets = new Dictionary<string, int>();
@@ -810,7 +973,7 @@ namespace XCharts
/// </summary>
/// <param name="Dictionary<int"></param>
/// <param name="stackSeries"></param>
public void GetStackSeries(ref Dictionary<int, List<Serie>> stackSeries)
internal void GetStackSeries(ref Dictionary<int, List<Serie>> stackSeries)
{
int count = 0;
sets.Clear();
@@ -860,7 +1023,7 @@ namespace XCharts
/// 获得所有系列名,不包含空名字。
/// </summary>
/// <returns></returns>
public List<string> GetSerieNameList()
internal List<string> GetSerieNameList()
{
serieNameList.Clear();
for (int n = 0; n < m_Series.Count; n++)
@@ -870,6 +1033,7 @@ namespace XCharts
{
case SerieType.Pie:
case SerieType.Radar:
case SerieType.Ring:
for (int i = 0; i < serie.data.Count; i++)
{
if (string.IsNullOrEmpty(serie.data[i].name))
@@ -889,6 +1053,33 @@ namespace XCharts
return serieNameList;
}
internal List<string> GetLegalSerieNameList()
{
var list = new List<string>();
for (int n = 0; n < m_Series.Count; n++)
{
var serie = m_Series[n];
switch (serie.type)
{
case SerieType.Pie:
case SerieType.Radar:
case SerieType.Ring:
for (int i = 0; i < serie.data.Count; i++)
{
var dataName = serie.data[i].name;
if (!string.IsNullOrEmpty(dataName) && IsLegalLegendName(dataName) && !list.Contains(dataName))
list.Add(dataName);
}
break;
default:
if (!string.IsNullOrEmpty(serie.name) && !list.Contains(serie.name) && IsLegalLegendName(serie.name))
list.Add(serie.name);
break;
}
}
return list;
}
/// <summary>
/// 设置获得标志图形大小的回调
/// </summary>
@@ -915,32 +1106,54 @@ namespace XCharts
}
/// <summary>
/// 开始初始动画
/// 渐入动画
/// </summary>
public void AnimationStart()
public void AnimationFadeIn()
{
foreach (var serie in m_Series)
{
if (serie.animation.enable)
{
serie.animation.Start();
serie.animation.FadeIn();
}
}
}
/// <summary>
/// 停止初始动画
/// 渐出动画
/// </summary>
public void AnimationStop()
public void AnimationFadeOut()
{
foreach (var serie in m_Series)
{
if (serie.animation.enable) serie.animation.Stop();
if (serie.animation.enable) serie.animation.FadeOut();
}
}
/// <summary>
/// 重置初始动画
/// 暂停动画
/// </summary>
public void AnimationPause()
{
foreach (var serie in m_Series)
{
if (serie.animation.enable) serie.animation.Pause();
}
}
/// <summary>
/// 继续动画
/// </summary>
public void AnimationResume()
{
foreach (var serie in m_Series)
{
if (serie.animation.enable) serie.animation.Resume();
}
}
/// <summary>
/// 重置动画
/// </summary>
public void AnimationReset()
{

View File

@@ -30,14 +30,22 @@ namespace XCharts
/// and different curves with slightly different appearance can be obtained.
/// 曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
/// </summary>
public float lineSmoothStyle { get { return m_LineSmoothStyle; } set { m_LineSmoothStyle = value <= 0 ? 1f : value; } }
public float lineSmoothStyle
{
get { return m_LineSmoothStyle; }
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// Smoothness of curve. The smaller the value, the smoother the curve, but the number of vertices will increase.
/// When the area with gradient is filled, the larger the value, the worse the transition effect.
/// 曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
/// </summary>
/// <value></value>
public float lineSmoothness { get { return m_LineSmoothness; } set { m_LineSmoothness = value <= 0 ? 1f : value; } }
public float lineSmoothness
{
get { return m_LineSmoothness; }
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// The partition distance of a line segment. A line in a normal line chart is made up of many segments,
/// the number of which is determined by the change in value. The smaller the number of segments,
@@ -45,25 +53,44 @@ namespace XCharts
/// 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
/// </summary>
/// <value></value>
public float lineSegmentDistance { get { return m_LineSegmentDistance; } set { m_LineSegmentDistance = value <= 0 ? 1f : value; } }
public float lineSegmentDistance
{
get { return m_LineSegmentDistance; }
set { if (PropertyUtility.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// the smoothess of cricle.
/// 圆形的平滑度。数越小圆越平滑,但顶点数也会随之增加。
/// </summary>
public float cicleSmoothness { get { return m_CicleSmoothness; } set { m_CicleSmoothness = value <= 0 ? 1f : value; } }
public float cicleSmoothness
{
get { return m_CicleSmoothness; }
set { if (PropertyUtility.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// 可视化组件的调节三角形长。
/// 可视化组件的调节三角形长。
/// </summary>
/// <value></value>
public float visualMapTriangeLen { get { return m_VisualMapTriangeLen; } set { m_VisualMapTriangeLen = value <= 0 ? 1f : value; } }
public float visualMapTriangeLen
{
get { return m_VisualMapTriangeLen; }
set { if (PropertyUtility.SetStruct(ref m_VisualMapTriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
}
/// <summary>
/// 饼图鼠标移到高亮时的额外半径
/// </summary>
public float pieTooltipExtraRadius { get { return m_PieTooltipExtraRadius; } set { m_PieTooltipExtraRadius = value <= 0 ? 0 : value; } }
public float pieTooltipExtraRadius
{
get { return m_PieTooltipExtraRadius; }
set { if (PropertyUtility.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
}
/// <summary>
/// 饼图选中时的中心点偏移
/// </summary>
public float pieSelectedOffset { get { return m_PieSelectedOffset; } set { m_PieSelectedOffset = value <= 0 ? 0 : value; } }
public float pieSelectedOffset
{
get { return m_PieSelectedOffset; }
set { if (PropertyUtility.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
}
}
}

View File

@@ -1,4 +1,5 @@
/******************************************/
using System.Text;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
@@ -36,7 +37,7 @@ namespace XCharts
/// Theme.
/// 主题相关配置。
/// </summary>
public class ThemeInfo : MainComponent, IEquatable<ThemeInfo>
public class ThemeInfo : MainComponent
{
[SerializeField] private Theme m_Theme = Theme.Default;
[SerializeField] private Font m_Font;
@@ -86,7 +87,11 @@ namespace XCharts
/// the theme of chart.
/// 主题类型。
/// </summary>
public Theme theme { get { return m_Theme; } set { m_Theme = value; } }
public Theme theme
{
get { return m_Theme; }
set { if (PropertyUtility.SetStruct(ref m_Theme, value)) SetComponentDirty(); }
}
/// <summary>
/// the font of chart text。
/// 字体。
@@ -94,7 +99,7 @@ namespace XCharts
public Font font
{
get { return m_CustomFont != null ? m_CustomFont : m_Font; }
set { m_CustomFont = value; }
set { if (PropertyUtility.SetClass(ref m_CustomFont, value)) SetComponentDirty(); }
}
/// <summary>
/// the background color of chart.
@@ -103,7 +108,7 @@ namespace XCharts
public Color32 backgroundColor
{
get { return m_CustomBackgroundColor != Color.clear ? m_CustomBackgroundColor : m_BackgroundColor; }
set { m_CustomBackgroundColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the main title text color.
@@ -112,7 +117,7 @@ namespace XCharts
public Color32 titleTextColor
{
get { return m_CustomTitleTextColor != Color.clear ? m_CustomTitleTextColor : m_TitleTextColor; }
set { m_CustomTitleTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTitleTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the subtitie text color.
@@ -121,7 +126,7 @@ namespace XCharts
public Color32 titleSubTextColor
{
get { return m_CustomTitleSubTextColor != Color.clear ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
set { m_CustomTitleSubTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTitleSubTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the legend text color.
@@ -130,7 +135,7 @@ namespace XCharts
public Color32 legendTextColor
{
get { return m_CustomLegendTextColor != Color.clear ? m_CustomLegendTextColor : m_LegendTextColor; }
set { m_CustomLegendTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomLegendTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the legend unable text color.
@@ -139,7 +144,7 @@ namespace XCharts
public Color32 legendUnableColor
{
get { return m_CustomLegendUnableColor != Color.clear ? m_CustomLegendUnableColor : m_LegendUnableColor; }
set { m_CustomLegendUnableColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomLegendUnableColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the axis text color.
@@ -148,7 +153,7 @@ namespace XCharts
public Color32 axisTextColor
{
get { return m_CustomAxisTextColor != Color.clear ? m_CustomAxisTextColor : m_AxisTextColor; }
set { m_CustomAxisTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of axis line.
@@ -157,7 +162,7 @@ namespace XCharts
public Color32 axisLineColor
{
get { return m_CustomAxisLineColor != Color.clear ? m_CustomAxisLineColor : m_AxisLineColor; }
set { m_CustomAxisLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of axis split line.
@@ -166,7 +171,7 @@ namespace XCharts
public Color32 axisSplitLineColor
{
get { return m_CustomAxisSplitLineColor != Color.clear ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
set { m_CustomAxisSplitLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomAxisSplitLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the tooltip background color.
@@ -175,7 +180,7 @@ namespace XCharts
public Color32 tooltipBackgroundColor
{
get { return m_CustomTooltipBackgroundColor != Color.clear ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
set { m_CustomTooltipBackgroundColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipBackgroundColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of tooltip shadow crosshair indicator.
@@ -184,7 +189,7 @@ namespace XCharts
public Color32 tooltipFlagAreaColor
{
get { return m_CustomTooltipFlagAreaColor != Color.clear ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
set { m_CustomTooltipFlagAreaColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipFlagAreaColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of tooltip text.
@@ -193,7 +198,7 @@ namespace XCharts
public Color32 tooltipTextColor
{
get { return m_CustomTooltipTextColor != Color.clear ? m_CustomTooltipTextColor : m_TooltipTextColor; }
set { m_CustomTooltipTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the background color of tooltip cross indicator's axis label.
@@ -202,7 +207,7 @@ namespace XCharts
public Color32 tooltipLabelColor
{
get { return m_CustomTooltipLabelColor != Color.clear ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
set { m_CustomTooltipLabelColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLabelColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color tooltip indicator line.
@@ -211,7 +216,7 @@ namespace XCharts
public Color32 tooltipLineColor
{
get { return m_CustomTooltipLineColor != Color.clear ? m_CustomTooltipLineColor : m_TooltipLineColor; }
set { m_CustomTooltipLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of datazoom text.
@@ -220,7 +225,7 @@ namespace XCharts
public Color32 dataZoomTextColor
{
get { return m_CustomDataZoomTextColor != Color.clear ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
set { m_CustomDataZoomTextColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomTextColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of datazoom line.
@@ -229,7 +234,7 @@ namespace XCharts
public Color32 dataZoomLineColor
{
get { return m_CustomDataZoomLineColor != Color.clear ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
set { m_CustomDataZoomLineColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomLineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of datazoom selected area.
@@ -238,7 +243,7 @@ namespace XCharts
public Color32 dataZoomSelectedColor
{
get { return m_CustomDataZoomSelectedColor != Color.clear ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
set { m_CustomDataZoomSelectedColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomSelectedColor, value)) SetVerticesDirty(); }
}
/// <summary>
@@ -247,7 +252,7 @@ namespace XCharts
public Color32 visualMapBackgroundColor
{
get { return m_CustomVisualMapBackgroundColor != Color.clear ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
set { m_CustomVisualMapBackgroundColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
@@ -256,14 +261,14 @@ namespace XCharts
public Color32 visualMapBorderColor
{
get { return m_CustomVisualMapBorderColor != Color.clear ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
set { m_CustomVisualMapBorderColor = value; }
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBorderColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series.
/// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。
/// </summary>
public List<Color32> colorPalette { set { m_CustomColorPalette = value; } }
public List<Color32> colorPalette { set { m_CustomColorPalette = value; SetVerticesDirty(); } }
/// <summary>
/// Gets the color of the specified index from the palette.
@@ -288,6 +293,28 @@ namespace XCharts
else return Color.clear;
}
public void CheckWarning(StringBuilder sb)
{
if (m_Font == null && m_CustomFont == null)
{
sb.AppendFormat("warning:theme->font is null");
}
if (m_ColorPalette.Length == 0 && m_CustomColorPalette.Count == 0)
{
sb.AppendFormat("warning:theme->colorPalette is empty");
}
for (int i = 0; i < m_ColorPalette.Length; i++)
{
if (m_ColorPalette[i] != Color.clear && m_ColorPalette[i].a == 0)
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
}
for (int i = 0; i < m_CustomColorPalette.Count; i++)
{
if (m_CustomColorPalette[i] != Color.clear && m_CustomColorPalette[i].a == 0)
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
}
}
Dictionary<int, string> _colorDic = new Dictionary<int, string>();
/// <summary>
/// Gets the hexadecimal color string of the specified index from the palette.
@@ -310,6 +337,22 @@ namespace XCharts
}
}
public void Copy(Theme theme)
{
switch (theme)
{
case Theme.Dark:
Copy(ThemeInfo.Dark);
break;
case Theme.Default:
Copy(ThemeInfo.Default);
break;
case Theme.Light:
Copy(ThemeInfo.Light);
break;
}
}
/// <summary>
/// copy all configurations from theme.
/// 复制主题的所有配置。
@@ -391,7 +434,7 @@ namespace XCharts
m_LegendUnableColor = GetColor("#cccccc"),
m_TitleTextColor = GetColor("#514D4D"),
m_TitleSubTextColor = GetColor("#514D4D"),
m_LegendTextColor = GetColor("#eee"),
m_LegendTextColor = GetColor("#514D4D"),
m_AxisTextColor = GetColor("#514D4D"),
m_AxisLineColor = GetColor("#514D4D"),
m_AxisSplitLineColor = GetColor("#51515120"),
@@ -577,64 +620,6 @@ namespace XCharts
return (Color32)color;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is ThemeInfo)
{
return Equals((ThemeInfo)obj);
}
else
{
return false;
}
}
public bool Equals(ThemeInfo other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Font == other.m_Font &&
ChartHelper.IsValueEqualsColor(m_LegendUnableColor, other.m_LegendUnableColor) &&
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.m_BackgroundColor) &&
ChartHelper.IsValueEqualsColor(m_TitleTextColor, other.m_TitleTextColor) &&
ChartHelper.IsValueEqualsColor(m_TitleSubTextColor, other.m_TitleSubTextColor) &&
ChartHelper.IsValueEqualsColor(m_AxisTextColor, other.m_AxisTextColor) &&
ChartHelper.IsValueEqualsColor(m_AxisLineColor, other.m_AxisLineColor) &&
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipBackgroundColor, other.m_TooltipBackgroundColor) &&
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipTextColor, other.m_TooltipTextColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipFlagAreaColor, other.m_TooltipFlagAreaColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomLineColor, other.m_DataZoomLineColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomSelectedColor, other.m_DataZoomSelectedColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomTextColor, other.m_DataZoomTextColor) &&
m_ColorPalette.Length == other.m_ColorPalette.Length;
}
public static bool operator ==(ThemeInfo left, ThemeInfo right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(ThemeInfo left, ThemeInfo right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();

View File

@@ -15,55 +15,103 @@ namespace XCharts
/// 标题组件,包含主标题和副标题。
/// </summary>
[Serializable]
public class Title : MainComponent, IPropertyChanged, IEquatable<Title>
public class Title : MainComponent, IPropertyChanged
{
[SerializeField] private bool m_Show = true;
[SerializeField] private string m_Text;
[SerializeField] private int m_TextFontSize;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(16);
[SerializeField] private string m_SubText;
[SerializeField] private int m_SubTextFontSize;
[SerializeField] private float m_ItemGap;
[SerializeField] private Location m_Location;
[SerializeField] private TextStyle m_SubTextStyle = new TextStyle(14);
[SerializeField] private float m_ItemGap = 8;
[SerializeField] private Location m_Location = Location.defaultTop;
/// <summary>
/// [default:true]
/// Set this to false to prevent the title from showing.
/// 是否显示标题组件。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show { get { return m_Show; } set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
/// <summary>
/// The main title text, supporting for \n for newlines.
/// 主标题文本,支持使用 \n 换行。
/// </summary>
public string text { get { return m_Text; } set { m_Text = value; } }
public string text { get { return m_Text; } set { if (PropertyUtility.SetClass(ref m_Text, value)) SetComponentDirty(); } }
/// <summary>
/// [default:16]
/// main title font size.
/// 主标题文字的字体大小。
/// </summary>
public int textFontSize { get { return m_TextFontSize; } set { m_TextFontSize = value; } }
[Obsolete("use textStyle instead.", true)]
public int textFontSize { get { return m_TextStyle.fontSize; } set { m_TextStyle.fontSize = value; } }
/// <summary>
/// 主标题文本样式。
/// </summary>
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// Subtitle text, supporting for \n for newlines.
/// 副标题文本,支持使用 \n 换行。
/// </summary>
public string subText { get { return m_SubText; } set { m_SubText = value; } }
public string subText
{
get { return m_SubText; }
set { if (PropertyUtility.SetClass(ref m_SubText, value)) SetComponentDirty(); }
}
/// <summary>
/// 副标题文本样式。
/// </summary>
public TextStyle subTextStyle
{
get { return m_SubTextStyle; }
set { if (PropertyUtility.SetClass(ref m_SubTextStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// [default:14]
/// subtitle font size.
/// 副标题文字的字体大小。
/// </summary>
public int subTextFontSize { get { return m_SubTextFontSize; } set { m_SubTextFontSize = value; } }
[Obsolete("use subTextStyle instead.", true)]
public int subTextFontSize
{
get { return m_SubTextStyle.fontSize; }
set { m_SubTextStyle.fontSize = value; }
}
/// <summary>
/// [default:14]
/// [default:8]
/// The gap between the main title and subtitle.
/// 主副标题之间的间距。
/// </summary>
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
public float itemGap
{
get { return m_ItemGap; }
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
}
/// <summary>
/// The location of title component.
/// 标题显示位置。
/// </summary>
public Location location { get { return m_Location; } set { m_Location = value; } }
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
}
public override bool vertsDirty { get { return false; } }
public override bool componentDirty
{
get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty || subTextStyle.componentDirty; }
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
location.ClearComponentDirty();
textStyle.ClearComponentDirty();
subTextStyle.ClearComponentDirty();
}
public static Title defaultTitle
{
@@ -73,79 +121,15 @@ namespace XCharts
{
m_Show = true,
m_Text = "Chart Title",
m_TextFontSize = 16,
m_TextStyle = new TextStyle(16),
m_SubText = "",
m_SubTextFontSize = 14,
m_SubTextStyle = new TextStyle(14),
m_ItemGap = 8,
m_Location = Location.defaultTop
};
return title;
}
}
public void Copy(Title title)
{
m_Show = title.show;
m_Text = title.text;
m_TextFontSize = title.textFontSize;
m_SubText = title.subText;
m_SubTextFontSize = title.subTextFontSize;
m_ItemGap = title.itemGap;
m_Location.Copy(title.location);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Title)
{
return Equals((Title)obj);
}
else
{
return false;
}
}
public bool Equals(Title other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Show == other.show &&
m_Text.Equals(other.text) &&
m_TextFontSize == other.textFontSize &&
m_SubText.Equals(other.subText) &&
m_SubTextFontSize == other.subTextFontSize &&
m_ItemGap == other.itemGap &&
m_Location.Equals(other.location);
}
public static bool operator ==(Title left, Title right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Title left, Title right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public void OnChanged()
{

View File

@@ -1,4 +1,6 @@
/******************************************/
using System.Linq;
using System.Collections.ObjectModel;
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
@@ -8,6 +10,8 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using UnityEngine.EventSystems;
namespace XCharts
{
@@ -49,33 +53,74 @@ namespace XCharts
[SerializeField] private bool m_Show;
[SerializeField] private Type m_Type;
[SerializeField] private string m_Formatter;
[SerializeField] private string m_ItemFormatter;
[SerializeField] private string m_TitleFormatter;
[SerializeField] private float m_FixedWidth = 0;
[SerializeField] private float m_FixedHeight = 0;
[SerializeField] private float m_MinWidth = 0;
[SerializeField] private float m_MinHeight = 0;
[SerializeField] private int m_FontSize = 18;
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
[SerializeField] private bool m_ForceENotation = false;
[SerializeField] private float m_PaddingLeftRight = 5f;
[SerializeField] private float m_PaddingTopBottom = 5f;
[SerializeField] private string m_IgnoreDataDefaultContent = "-";
[SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18, FontStyle.Normal);
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f);
private GameObject m_GameObject;
private GameObject m_Content;
private Text m_ContentText;
private Image m_ContentImage;
private RectTransform m_ContentRect;
private RectTransform m_ContentTextRect;
private List<int> lastDataIndex { get; set; }
/// <summary>
/// Whether to show the tooltip component.
/// 是否显示提示框组件。
/// </summary>
/// <returns></returns>
public bool show { get { return m_Show; } set { m_Show = value; SetActive(value); } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetAllDirty(); SetActive(value); } }
}
/// <summary>
/// Indicator type.
/// 提示框指示器类型。
/// </summary>
public Type type { get { return m_Type; } set { m_Type = value; } }
public Type type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
}
/// <summary>
/// 提示框内容字符串模版格式器。支持用 \n 或 "<br/>" 换行。
/// 提示框内容字符串模版格式器。支持用 \n 或 "<br/>" 换行。当formatter不为空时优先使用formatter否则使用itemFormatter。
/// 模板变量有 {a}, {b}{c}{d}{e},分别表示系列名,数据名,数据值等。{a0},{b1},c{1}等可指定serie。
/// 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
/// <list type="bullet">
/// <item><description>折线区域图、柱状条形图、K线图 : {a}(系列名称),{b}(类目值),{c}(数值), {d}(无)。</description></item>
/// <item><description>散点图(气泡)图 : {a}(系列名称),{b}(数据名称),{c}(数值数组), {d}(无)。</description></item>
/// <item><description>地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)。</description></item>
/// <item><description>饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)。</description></item>
/// </list>
/// 示例:"{a}:{c}","{a1}:{c1:f1}"
/// </summary>
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
/// <summary>
/// 提示框标题内容的字符串模版格式器。支持用 \n 或 "<br/>" 换行。仅当itemFormatter生效时才有效。
/// 模板变量有 {a}, {b}{c}{d}{e},分别表示系列名,数据名,数据值等。{a0},{b1},c{1}等可指定serie。
/// 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
/// <list type="bullet">
/// <item><description>折线区域图、柱状条形图、K线图 : {a}(系列名称),{b}(类目值),{c}(数值), {d}(无)。</description></item>
/// <item><description>散点图(气泡)图 : {a}(系列名称),{b}(数据名称),{c}(数值数组), {d}(无)。</description></item>
/// <item><description>地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)。</description></item>
/// <item><description>饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)。</description></item>
/// </list>
/// 示例:"{a}:{c}","{a1}:{c1:f1}"
/// </summary>
public string titleFormatter { get { return m_TitleFormatter; } set { m_TitleFormatter = value; } }
/// <summary>
/// 提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 或 "<br/>" 换行。当formatter不为空时优先使用formatter否则使用itemFormatter。
/// 模板变量有 {a}, {b}{c}{d}{e},分别表示系列名,数据名,数据值等。
/// 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
/// <list type="bullet">
@@ -84,11 +129,10 @@ namespace XCharts
/// <item><description>地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)。</description></item>
/// <item><description>饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)。</description></item>
/// </list>
/// 示例:"{a}:{c}","{a}:{c:f1}"
/// </summary>
/// <example>
/// 示例:“{a}:{c}”
/// </example>
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } }
/// <summary>
/// 固定宽度。比 minWidth 优先。
/// </summary>
@@ -105,61 +149,105 @@ namespace XCharts
/// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。
/// </summary>
public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } }
/// <summary>
/// font size.
/// 文字的字体大小。
/// </summary>
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
/// <summary>
/// font style.
/// 文字的字体风格。
/// </summary>
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
[Obsolete("Use Tooltip.textStyle.fontSize instead.", true)]
public int fontSize { get; set; }
[Obsolete("Use Tooltip.textStyle.fontStyle instead.", true)]
public FontStyle fontStyle { get; set; }
/// <summary>
/// 是否强制使用科学计数法格式化显示数值。默认为false当小数精度大于3时才采用科学计数法。
/// </summary>
public bool forceENotation { get { return m_ForceENotation; } set { m_ForceENotation = value; } }
/// <summary>
/// the text padding of left and right. defaut:5.
/// 左右边距。
/// </summary>
public float paddingLeftRight { get { return m_PaddingLeftRight; } set { m_PaddingLeftRight = value; } }
/// <summary>
/// the text padding of top and bottom. defaut:5.
/// 上下边距。
/// </summary>
public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } }
/// <summary>
/// 被忽略数据的默认显示字符信息。
/// </summary>
public string ignoreDataDefaultContent { get { return m_IgnoreDataDefaultContent; } set { m_IgnoreDataDefaultContent = value; } }
/// <summary>
/// The image of icon.
/// 图标的图片。
/// </summary>
public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } }
/// <summary>
/// 提示框内容文本样式。
/// </summary>
public TextStyle textStyle
{
get { return m_TextStyle; }
set { if (value != null) { m_TextStyle = value; SetComponentDirty(); } }
}
/// <summary>
/// 指示线样式。
/// </summary>
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (value != null) m_LineStyle = value; SetComponentDirty(); }
}
/// <summary>
/// 组件是否需要刷新
/// </summary>
public override bool componentDirty
{
get { return m_ComponentDirty || lineStyle.componentDirty || textStyle.componentDirty; }
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
lineStyle.ClearComponentDirty();
textStyle.ClearComponentDirty();
}
/// <summary>
/// The data index currently indicated by Tooltip.
/// 当前提示框所指示的数据项索引。
/// </summary>
public List<int> dataIndex { get; set; }
public List<int> runtimeDataIndex { get; internal set; }
/// <summary>
/// the value for x indicator label.
/// 指示器X轴上要显示的值。
/// </summary>
public float[] xValues { get; set; }
public float[] runtimeXValues { get; internal set; }
/// <summary>
/// the value for y indicator label.
/// 指示器Y轴上要显示的值。
/// </summary>
public float[] yValues { get; set; }
public float[] runtimeYValues { get; internal set; }
/// <summary>
/// the current pointer position.
/// 当前鼠标位置。
/// </summary>
public Vector2 pointerPos { get; set; }
public Vector2 runtimePointerPos { get; internal set; }
/// <summary>
/// the width of tooltip.
/// 提示框宽。
/// </summary>
public float width { get { return m_ContentRect.sizeDelta.x; } }
public float runtimeWidth { get { return m_ContentRect.sizeDelta.x; } }
/// <summary>
/// the height of tooltip.
/// 提示框高。
/// </summary>
public float height { get { return m_ContentRect.sizeDelta.y; } }
public float runtimeHeight { get { return m_ContentRect.sizeDelta.y; } }
/// <summary>
/// Whether the tooltip has been initialized.
/// 提示框是否已初始化。
/// </summary>
public bool inited { get { return m_GameObject != null; } }
public bool runtimeInited { get { return m_GameObject != null; } }
/// <summary>
/// the gameObject of tooltip.
/// 提示框的gameObject。
/// </summary>
public GameObject gameObject { get { return m_GameObject; } }
public GameObject runtimeGameObject { get { return m_GameObject; } }
public static Tooltip defaultTooltip
{
@@ -168,9 +256,9 @@ namespace XCharts
var tooltip = new Tooltip
{
m_Show = true,
xValues = new float[2] { -1, -1 },
yValues = new float[2] { -1, -1 },
dataIndex = new List<int>() { -1, -1 },
runtimeXValues = new float[2] { -1, -1 },
runtimeYValues = new float[2] { -1, -1 },
runtimeDataIndex = new List<int>() { -1, -1 },
lastDataIndex = new List<int>() { -1, -1 }
};
return tooltip;
@@ -195,7 +283,13 @@ namespace XCharts
{
m_Content = content;
m_ContentRect = m_Content.GetComponent<RectTransform>();
m_ContentImage = m_Content.GetComponent<Image>();
m_ContentText = m_Content.GetComponentInChildren<Text>();
if (m_ContentText != null)
{
m_ContentTextRect = m_ContentText.gameObject.GetComponentInChildren<RectTransform>();
}
SetBackground(backgroundImage);
}
/// <summary>
@@ -214,7 +308,21 @@ namespace XCharts
/// <param name="color"></param>
public void SetContentBackgroundColor(Color color)
{
m_Content.GetComponent<Image>().color = color;
if (m_ContentImage != null)
m_ContentImage.color = color;
}
/// <summary>
/// 设置提示框文本背景图片
/// </summary>
/// <param name="sprite"></param>
public void SetBackground(Sprite sprite)
{
if (m_ContentImage != null)
{
m_ContentImage.type = Image.Type.Sliced;
m_ContentImage.sprite = sprite;
}
}
/// <summary>
@@ -241,22 +349,26 @@ namespace XCharts
float wid, hig;
if (m_FixedWidth > 0) wid = m_FixedWidth;
else if (m_MinWidth > 0 && m_ContentText.preferredWidth < m_MinWidth) wid = m_MinWidth;
else wid = m_ContentText.preferredWidth + 8;
else wid = m_ContentText.preferredWidth + m_PaddingLeftRight * 2;
if (m_FixedHeight > 0) hig = m_FixedHeight;
else if (m_MinHeight > 0 && m_ContentText.preferredHeight < m_MinHeight) hig = m_MinHeight;
else hig = m_ContentText.preferredHeight + 8;
m_ContentRect.sizeDelta = new Vector2(wid, hig);
else hig = m_ContentText.preferredHeight + m_PaddingTopBottom * 2;
if (m_ContentRect != null) m_ContentRect.sizeDelta = new Vector2(wid, hig);
if (m_ContentTextRect != null)
{
m_ContentTextRect.anchoredPosition = new Vector3(m_PaddingLeftRight, -m_PaddingTopBottom);
}
}
}
/// <summary>
/// 清除提示框指示数据
/// </summary>
public void ClearValue()
internal void ClearValue()
{
dataIndex[0] = dataIndex[1] = -1;
xValues[0] = xValues[1] = -1;
yValues[0] = yValues[1] = -1;
for (int i = 0; i < runtimeDataIndex.Count; i++) runtimeDataIndex[i] = -1;
for (int i = 0; i < runtimeXValues.Length; i++) runtimeXValues[i] = -1;
for (int i = 0; i < runtimeYValues.Length; i++) runtimeYValues[i] = -1;
}
/// <summary>
@@ -308,17 +420,17 @@ namespace XCharts
/// <returns></returns>
public bool IsDataIndexChanged()
{
return dataIndex[0] != lastDataIndex[0] ||
dataIndex[1] != lastDataIndex[1];
return runtimeDataIndex[0] != lastDataIndex[0] ||
runtimeDataIndex[1] != lastDataIndex[1];
}
/// <summary>
/// 当前索引缓存
/// </summary>
public void UpdateLastDataIndex()
internal void UpdateLastDataIndex()
{
lastDataIndex[0] = dataIndex[0];
lastDataIndex[1] = dataIndex[1];
lastDataIndex[0] = runtimeDataIndex[0];
lastDataIndex[1] = runtimeDataIndex[1];
}
/// <summary>
@@ -327,7 +439,7 @@ namespace XCharts
/// <returns></returns>
public bool IsSelected()
{
return dataIndex[0] >= 0 || dataIndex[1] >= 0;
return runtimeDataIndex[0] >= 0 || runtimeDataIndex[1] >= 0;
}
/// <summary>
@@ -337,65 +449,7 @@ namespace XCharts
/// <returns></returns>
public bool IsSelected(int index)
{
return dataIndex[0] == index || dataIndex[1] == index;
}
public string GetFormatterContent(int dataIndex, Series series, string category, DataZoom dataZoom = null)
{
if (string.IsNullOrEmpty(m_Formatter))
{
return "";
}
else
{
string content = m_Formatter;
for (int i = 0; i < series.Count; i++)
{
var serie = series.GetSerie(i);
if (serie.show)
{
var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar;
var serieData = serie.GetSerieData(dataIndex, dataZoom);
if (i == 0)
{
content = content.Replace("{a}", serie.name);
content = content.Replace("{b}", needCategory ? category : serieData.name);
content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation));
//if (serie.type == SerieType.Pie)
{
var percent = serieData.GetData(1) / serie.yTotal * 100;
content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1));
}
}
content = content.Replace("{a" + i + "}", serie.name);
content = content.Replace("{b" + i + "}", needCategory ? category : serieData.name);
content = content.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation));
//if (serie.type == SerieType.Pie)
{
var percent = serieData.GetData(1) / serie.yTotal * 100;
content = content.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1));
}
}
}
content = content.Replace("\\n", "\n");
content = content.Replace("<br/>", "\n");
return content;
}
}
public string GetFormatterContent(string serieName, string dataName, float dataValue)
{
if (string.IsNullOrEmpty(m_Formatter))
return ChartCached.FloatToStr(dataValue, 0, m_ForceENotation);
else
{
var content = m_Formatter.Replace("{a}", serieName);
content = content.Replace("{b}", dataName);
content = content.Replace("{c}", ChartCached.FloatToStr(dataValue, 0, m_ForceENotation));
content = content.Replace("\\n", "\n");
content = content.Replace("<br/>", "\n");
return content;
}
return runtimeDataIndex[0] == index || runtimeDataIndex[1] == index;
}
}
}

View File

@@ -73,27 +73,51 @@ namespace XCharts
/// <summary>
/// 是否开启组件功能。
/// </summary>
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
public bool enable
{
get { return m_Enable; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否显示组件。如果设置为 false不会显示但是数据映射的功能还存在。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
}
/// <summary>
/// 组件类型。
/// </summary>
public Type type { get { return m_Type; } set { m_Type = value; } }
public Type type
{
get { return m_Type; }
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// 选择模式。
/// </summary>
public SelectedMode selectedMode { get { return m_SelectedMode; } set { m_SelectedMode = value; } }
public SelectedMode selectedMode
{
get { return m_SelectedMode; }
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
}
/// <summary>
/// 允许的最小值。'min' 必须用户指定。[visualMap.min, visualMap.max] 形成了视觉映射的『定义域』。
/// </summary>
public float min { get { return m_Min; } set { m_Min = value; } }
public float min
{
get { return m_Min; }
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
}
/// <summary>
/// 允许的最大值。'max' 必须用户指定。[visualMap.min, visualMax.max] 形成了视觉映射的『定义域』。
/// </summary>
public float max { get { return m_Max; } set { m_Max = value < min ? min + 1 : value; } }
public float max
{
get { return m_Max; }
set { m_Max = value < min ? min + 1 : value; SetVerticesDirty(); }
}
/// <summary>
/// 指定手柄对应数值的位置。range 应在 min max 范围内。
/// </summary>
@@ -110,68 +134,129 @@ namespace XCharts
/// 对于连续型数据自动平均切分成几段默认为0时自动匹配inRange颜色列表大小。
/// </summary>
/// <value></value>
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否显示拖拽用的手柄(手柄能拖拽调整选中范围)。
/// </summary>
public bool calculable { get { return m_Calculable; } set { m_Calculable = value; } }
public bool calculable
{
get { return m_Calculable; }
set { if (PropertyUtility.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
}
/// <summary>
/// 拖拽时,是否实时更新。
/// </summary>
public bool realtime { get { return m_Realtime; } set { m_Realtime = value; } }
public bool realtime
{
get { return m_Realtime; }
set { if (PropertyUtility.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
}
/// <summary>
/// 图形的宽度,即颜色条的宽度。
/// </summary>
public float itemWidth { get { return m_ItemWidth; } set { m_ItemWidth = value; } }
public float itemWidth
{
get { return m_ItemWidth; }
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 图形的高度,即颜色条的高度。
/// </summary>
public float itemHeight { get { return m_ItemHeight; } set { m_ItemHeight = value; } }
public float itemHeight
{
get { return m_ItemHeight; }
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框线宽单位px。
/// </summary>
public float borderWidth { get { return m_BorderWidth; } set { m_BorderWidth = value; } }
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 指定用数据的『哪个维度』,映射到视觉元素上。『数据』即 series.data。从1开始默认为0取 data 中最后一个维度。
/// </summary>
public int dimension { get { return m_Dimension; } set { m_Dimension = value; } }
public int dimension
{
get { return m_Dimension; }
set { if (PropertyUtility.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
}
/// <summary>
/// 打开 hoverLink 功能时,鼠标悬浮到 visualMap 组件上时,鼠标位置对应的数值 在 图表中对应的图形元素,会高亮。
/// 反之,鼠标悬浮到图表中的图形元素上时,在 visualMap 组件的相应位置会有三角提示其所对应的数值。
/// </summary>
/// <value></value>
public bool hoverLink { get { return m_HoverLink; } set { m_HoverLink = value; } }
public bool hoverLink
{
get { return m_HoverLink; }
set { if (PropertyUtility.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
}
/// <summary>
/// Specify whether the layout of component is horizontal or vertical.
/// 布局方式是横还是竖。
/// </summary>
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
public Orient orient
{
get { return m_Orient; }
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
}
/// <summary>
/// The location of component.
/// 组件显示的位置。
/// </summary>
public Location location { get { return m_Location; } set { m_Location = value; } }
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetVerticesDirty(); }
}
/// <summary>
/// 定义 在选中范围中 的视觉颜色。
/// </summary>
public List<Color> inRange { get { return m_InRange; } set { if (value != null) m_InRange = value; } }
public List<Color> inRange
{
get { return m_InRange; }
set { if (value != null) { m_InRange = value; SetVerticesDirty(); } }
}
/// <summary>
/// 定义 在选中范围外 的视觉颜色。
/// </summary>
public List<Color> outOfRange { get { return m_OutOfRange; } set { if (value != null) m_OutOfRange = value; } }
public List<Color> outOfRange
{
get { return m_OutOfRange; }
set { if (value != null) { m_OutOfRange = value; SetVerticesDirty(); } }
}
public override bool vertsDirty { get { return m_VertsDirty || location.anyDirty; } }
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
location.ClearVerticesDirty();
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
location.ClearComponentDirty();
}
/// <summary>
/// 鼠标悬停选中的index
/// </summary>
/// <value></value>
public int rtSelectedIndex { get; set; }
public float rtSelectedValue { get; set; }
public int runtimeSelectedIndex { get; internal set; }
public float runtimeSelectedValue { get; internal set; }
/// <summary>
/// the current pointer position.
/// 当前鼠标位置。
/// </summary>
public Vector2 pointerPos { get; set; }
public bool isVertical { get { return orient == Orient.Vertical; } }
public Vector2 runtimePointerPos { get; internal set; }
public bool runtimeIsVertical { get { return orient == Orient.Vertical; } }
public float rangeMin
{
get
@@ -198,7 +283,7 @@ namespace XCharts
}
}
public int rtSplitNumber
public int runtimeSplitNumber
{
get
{
@@ -207,18 +292,18 @@ namespace XCharts
}
}
public float rangeMinHeight { get { return (rangeMin - min) / (max - min) * itemHeight; } }
public float rangeMaxHeight { get { return (rangeMax - min) / (max - min) * itemHeight; } }
public float runtimeRangeMinHeight { get { return (rangeMin - min) / (max - min) * itemHeight; } }
public float runtimeRangeMaxHeight { get { return (rangeMax - min) / (max - min) * itemHeight; } }
private List<Color> m_RtInRange = new List<Color>();
public List<Color> rtInRange
public List<Color> runtimeInRange
{
get
{
if (splitNumber == 0 || m_InRange.Count >= splitNumber || m_InRange.Count < 1) return m_InRange;
else
{
if (m_RtInRange.Count != rtSplitNumber)
if (m_RtInRange.Count != runtimeSplitNumber)
{
m_RtInRange.Clear();
var total = max - min;
@@ -256,7 +341,7 @@ namespace XCharts
public Color GetColor(float value)
{
int splitNumber = rtInRange.Count;
int splitNumber = runtimeInRange.Count;
if (splitNumber <= 0) return Color.clear;
value = Mathf.Clamp(value, min, max);
@@ -264,13 +349,13 @@ namespace XCharts
var index = GetIndex(value);
var nowMin = min + index * diff;
var rate = (value - nowMin) / diff;
if (index == splitNumber - 1) return rtInRange[index];
else return Color.Lerp(rtInRange[index], rtInRange[index + 1], rate);
if (index == splitNumber - 1) return runtimeInRange[index];
else return Color.Lerp(runtimeInRange[index], runtimeInRange[index + 1], rate);
}
public int GetIndex(float value)
{
int splitNumber = rtInRange.Count;
int splitNumber = runtimeInRange.Count;
if (splitNumber <= 0) return -1;
value = Mathf.Clamp(value, min, max);
@@ -289,19 +374,19 @@ namespace XCharts
public bool IsInSelectedValue(float value)
{
if (rtSelectedIndex < 0) return true;
if (runtimeSelectedIndex < 0) return true;
else
{
return rtSelectedIndex == GetIndex(value);
return runtimeSelectedIndex == GetIndex(value);
}
}
public float GetValue(Vector3 pos, float chartWidth, float chartHeight)
{
var centerPos = location.GetPosition(chartWidth, chartHeight);
var pos1 = centerPos + (isVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
var pos2 = centerPos + (isVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
if (isVertical)
var pos1 = centerPos + (runtimeIsVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
var pos2 = centerPos + (runtimeIsVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
if (runtimeIsVertical)
{
if (pos.y < pos1.y) return min;
else if (pos.y > pos2.y) return max;
@@ -337,12 +422,12 @@ namespace XCharts
{
var pos1 = centerPos + Vector3.down * itemHeight / 2;
return local.x >= centerPos.x - itemWidth / 2 && local.x <= centerPos.x + itemWidth / 2 &&
local.y >= pos1.y + rangeMinHeight && local.y <= pos1.y + rangeMaxHeight;
local.y >= pos1.y + runtimeRangeMinHeight && local.y <= pos1.y + runtimeRangeMaxHeight;
}
else
{
var pos1 = centerPos + Vector3.left * itemHeight / 2;
return local.x >= pos1.x + rangeMinHeight && local.x <= pos1.x + rangeMaxHeight &&
return local.x >= pos1.x + runtimeRangeMinHeight && local.x <= pos1.x + runtimeRangeMaxHeight &&
local.y >= centerPos.y - itemWidth / 2 && local.y <= centerPos.y + itemWidth / 2;
}
}
@@ -354,7 +439,7 @@ namespace XCharts
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.down * itemHeight / 2;
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + rangeMinHeight - radius);
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMinHeight - radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
@@ -363,7 +448,7 @@ namespace XCharts
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.left * itemHeight / 2;
var cpos = new Vector3(pos1.x + rangeMinHeight, pos1.y + itemWidth / 2 + radius);
var cpos = new Vector3(pos1.x + runtimeRangeMinHeight, pos1.y + itemWidth / 2 + radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
}
@@ -376,7 +461,7 @@ namespace XCharts
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.down * itemHeight / 2;
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + rangeMaxHeight + radius);
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMaxHeight + radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
@@ -385,7 +470,7 @@ namespace XCharts
{
var radius = triangleLen / 2;
var pos1 = centerPos + Vector3.left * itemHeight / 2;
var cpos = new Vector3(pos1.x + rangeMaxHeight + radius, pos1.y + itemWidth / 2 + radius);
var cpos = new Vector3(pos1.x + runtimeRangeMaxHeight + radius, pos1.y + itemWidth / 2 + radius);
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
}

View File

@@ -22,7 +22,7 @@ namespace XCharts
/// </para>
/// </summary>
[Serializable]
public class Grid : MainComponent, IEquatable<Grid>
public class Grid : MainComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Left;
@@ -35,32 +35,56 @@ namespace XCharts
/// Whether to show the grid in rectangular coordinate.
/// 是否显示直角坐标系网格。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Distance between grid component and the left side of the container.
/// grid 组件离容器左侧的距离。
/// </summary>
public float left { get { return m_Left; } set { m_Left = value; } }
public float left
{
get { return m_Left; }
set { if (PropertyUtility.SetStruct(ref m_Left, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the right side of the container.
/// grid 组件离容器右侧的距离。
/// </summary>
public float right { get { return m_Right; } set { m_Right = value; } }
public float right
{
get { return m_Right; }
set { if (PropertyUtility.SetStruct(ref m_Right, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the top side of the container.
/// grid 组件离容器上侧的距离。
/// </summary>
public float top { get { return m_Top; } set { m_Top = value; } }
public float top
{
get { return m_Top; }
set { if (PropertyUtility.SetStruct(ref m_Top, value)) SetAllDirty(); }
}
/// <summary>
/// Distance between grid component and the bottom side of the container.
/// grid 组件离容器下侧的距离。
/// </summary>
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
public float bottom
{
get { return m_Bottom; }
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
}
/// <summary>
/// Background color of grid, which is transparent by default.
/// 网格背景色,默认透明。
/// </summary>
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
public static Grid defaultGrid
{
@@ -77,67 +101,5 @@ namespace XCharts
return coordinate;
}
}
public void Copy(Grid other)
{
m_Show = other.show;
m_Left = other.left;
m_Right = other.right;
m_Top = other.top;
m_Bottom = other.bottom;
m_BackgroundColor = other.backgroundColor;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
else if (obj is Grid)
{
return Equals((Grid)obj);
}
else
{
return false;
}
}
public bool Equals(Grid other)
{
if (ReferenceEquals(null, other))
{
return false;
}
return m_Show == other.show &&
m_Left == other.left &&
m_Right == other.right &&
m_Top == other.top &&
m_Bottom == other.bottom &&
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.backgroundColor);
}
public static bool operator ==(Grid left, Grid right)
{
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
{
return true;
}
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
{
return false;
}
return Equals(left, right);
}
public static bool operator !=(Grid left, Grid right)
{
return !(left == right);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

View File

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

View File

@@ -52,41 +52,73 @@ namespace XCharts
/// Set this to false to prevent the areafrom showing.
/// 是否显示区域填充。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// the origin of area.
/// 区域填充的起始位置。
/// </summary>
public AreaOrigin origin { get { return m_Origin; } set { m_Origin = value; } }
public AreaOrigin origin
{
get { return m_Origin; }
set { if (PropertyUtility.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of area,default use serie color.
/// 区域填充的颜色如果toColor不是默认值则表示渐变色的起点颜色。
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; } }
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color, start color to toColor.
/// 渐变色的终点颜色。
/// </summary>
public Color toColor { get { return m_ToColor; } set { m_ToColor = value; } }
public Color toColor
{
get { return m_ToColor; }
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
/// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
/// </summary>
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
public float opacity
{
get { return m_Opacity; }
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
}
/// <summary>
/// 鼠标悬浮时是否高亮之前的区域
/// </summary>
public bool tooltipHighlight { get { return m_TooltipHighlight; } set { m_TooltipHighlight = value; } }
public bool tooltipHighlight
{
get { return m_TooltipHighlight; }
set { if (PropertyUtility.SetStruct(ref m_TooltipHighlight, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of area,default use serie color.
/// 高亮时区域填充的颜色如果highlightToColor不是默认值则表示渐变色的起点颜色。
/// </summary>
public Color highlightColor { get { return m_HighlightColor; } set { m_HighlightColor = value; } }
public Color highlightColor
{
get { return m_HighlightColor; }
set { if (PropertyUtility.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color, start highlightColor to highlightToColor.
/// 高亮时渐变色的终点颜色。
/// </summary>
public Color highlightToColor { get { return m_HighlightToColor; } set { m_HighlightToColor = value; } }
public Color highlightToColor
{
get { return m_HighlightToColor; }
set { if (PropertyUtility.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
}
public static AreaStyle defaultAreaStyle
{

View File

@@ -7,6 +7,7 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
@@ -27,57 +28,112 @@ namespace XCharts
[SerializeField] private int m_FontSize;
[SerializeField] private FontStyle m_FontStyle;
[SerializeField] private bool m_ForceENotation = false;
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
/// <summary>
/// Set this to false to prevent the axis label from appearing.
/// 是否显示刻度标签。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// The display interval of the axis label.
/// 坐标轴刻度标签的显示间隔在类目轴中有效。0表示显示所有标签1表示隔一个隔显示一个标签以此类推。
/// </summary>
public int interval { get { return m_Interval; } set { m_Interval = value; } }
public int interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetComponentDirty(); }
}
/// <summary>
/// Set this to true so the axis labels face the inside direction.
/// 刻度标签是否朝内,默认朝外。
/// </summary>
public bool inside { get { return m_Inside; } set { m_Inside = value; } }
public bool inside
{
get { return m_Inside; }
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
}
/// <summary>
/// Rotation degree of axis label, which is especially useful when there is no enough space for category axis.
/// 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠。
/// </summary>
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
public float rotate
{
get { return m_Rotate; }
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
}
/// <summary>
/// The margin between the axis label and the axis line.
/// 刻度标签与轴线之间的距离。
/// </summary>
public float margin { get { return m_Margin; } set { m_Margin = value; } }
public float margin
{
get { return m_Margin; }
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of axis label text.
/// 刻度标签文字的颜色默认取Theme的axisTextColor。
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; } }
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
}
/// <summary>
/// font size.
/// 文字的字体大小。
/// </summary>
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
}
/// <summary>
/// font style.
/// 文字字体的风格。
/// </summary>
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// 图例内容字符串模版格式器。支持用 \n 换行。
/// 模板变量为图例名称 {value}{value:f1} 表示取1为小数
/// 模板变量为图例名称 {value}支持{value:f0}{value:f1}{value:f2}
/// </summary>
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
}
/// <summary>
/// 是否强制使用科学计数法格式化显示数值。默认为false当小数精度大于3时才采用科学计数法。
/// </summary>
public bool forceENotation { get { return m_ForceENotation; } set { m_ForceENotation = value; } }
public bool forceENotation
{
get { return m_ForceENotation; }
set { if (PropertyUtility.SetStruct(ref m_ForceENotation, value)) SetComponentDirty(); }
}
/// <summary>
/// 文本限制。
/// </summary>
public TextLimit textLimit
{
get { return m_TextLimit; }
set { if (value != null) { m_TextLimit = value; SetComponentDirty(); } }
}
public override bool componentDirty { get { return m_ComponentDirty || m_TextLimit.componentDirty; } }
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
textLimit.ClearComponentDirty();
}
public static AxisLabel defaultAxisLabel
{
@@ -96,65 +152,45 @@ namespace XCharts
};
}
}
public void Copy(AxisLabel other)
{
m_Show = other.show;
m_Interval = other.interval;
m_Inside = other.inside;
m_Rotate = other.rotate;
m_Margin = other.margin;
m_Color = other.color;
m_FontSize = other.fontSize;
m_FontStyle = other.fontStyle;
m_Formatter = other.formatter;
}
public override bool Equals(object obj)
public void SetRelatedText(Text txt, float labelWidth)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
var other = (AxisLabel)obj;
return m_Show == other.show &&
m_Interval.Equals(other.interval) &&
m_Inside == other.inside &&
m_Rotate == other.rotate &&
m_Margin == other.margin &&
m_Color == other.color &&
m_FontSize == other.fontSize &&
m_FontStyle == other.fontStyle &&
m_ForceENotation == other.forceENotation &&
m_Formatter == other.formatter;
}
public override int GetHashCode()
{
return base.GetHashCode();
m_TextLimit.SetRelatedText(txt, labelWidth);
}
public string GetFormatterContent(string category)
{
if (string.IsNullOrEmpty(category)) return category;
if (string.IsNullOrEmpty(m_Formatter))
return category;
{
return m_TextLimit.GetLimitContent(category);
}
else
{
var content = m_Formatter.Replace("{value}", category);
content = content.Replace("\\n", "\n");
content = content.Replace("<br/>", "\n");
return content;
return m_TextLimit.GetLimitContent(content);
}
}
public string GetFormatterContent(float value, float minValue, float maxValue)
public string GetFormatterContent(float value, float minValue, float maxValue, bool isLog = false)
{
if (string.IsNullOrEmpty(m_Formatter))
{
if (isLog)
{
if (value - (int)value == 0)
return ChartCached.IntToStr((int)value);
else
return ChartCached.FloatToStr(value);
}
if (minValue >= -1 && minValue <= 1 && maxValue >= -1 && maxValue <= 1)
{
int minAcc = ChartHelper.GetFloatAccuracy(minValue);
int maxAcc = ChartHelper.GetFloatAccuracy(maxValue);
int acc = Mathf.Max(minAcc, maxAcc);
int curAcc = ChartHelper.GetFloatAccuracy(value);
int acc = Mathf.Max(Mathf.Max(minAcc, maxAcc), curAcc);
return ChartCached.FloatToStr(value, acc, m_ForceENotation);
}
else if (value - (int)value == 0)
@@ -162,9 +198,11 @@ namespace XCharts
else
return ChartCached.FloatToStr(value, 1);
}
else
else if (m_Formatter.Contains("{value"))
{
var content = m_Formatter;
if (content.Contains("{value:f0}"))
content = m_Formatter.Replace("{value:f0}", ChartCached.IntToStr((int)value));
if (content.Contains("{value:f2}"))
content = m_Formatter.Replace("{value:f2}", ChartCached.FloatToStr(value, 2));
else if (content.Contains("{value:f1}"))
@@ -172,7 +210,6 @@ namespace XCharts
else if (content.Contains("{value}"))
{
if (value - (int)value == 0)
content = m_Formatter.Replace("{value}", ChartCached.IntToStr((int)value));
else
content = m_Formatter.Replace("{value}", ChartCached.FloatToStr(value, 1));
@@ -182,6 +219,10 @@ namespace XCharts
content = content.Replace("<br/>", "\n");
return content;
}
else
{
return value.ToString(m_Formatter);
}
}
}
}

View File

@@ -13,7 +13,7 @@ namespace XCharts
/// Settings related to axis line.
/// 坐标轴的分隔线。
/// </summary>
[System.Serializable]
[System.Serializable]
public class AxisLine : SubComponent
{
[SerializeField] private bool m_Show;
@@ -29,42 +29,74 @@ namespace XCharts
/// Set this to false to prevent the axis line from showing.
/// 是否显示坐标轴轴线。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// When mutiple axes exists, this option can be used to specify which axis can be "onZero" to.
/// X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
/// </summary>
public bool onZero { get { return m_OnZero; } set { m_OnZero = value; } }
public bool onZero
{
get { return m_OnZero; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// line style line width.
/// 坐标轴线线宽。
/// </summary>
public float width { get { return m_Width; } set { m_Width = value; } }
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show the arrow symbol of axis.
/// 是否显示箭头。
/// </summary>
public bool symbol { get { return m_Symbol; } set { m_Symbol = value; } }
public bool symbol
{
get { return m_Symbol; }
set { if (PropertyUtility.SetStruct(ref m_Symbol, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of arrow symbol.
/// 箭头宽。
/// </summary>
public float symbolWidth { get { return m_SymbolWidth; } set { m_SymbolWidth = value; } }
public float symbolWidth
{
get { return m_SymbolWidth; }
set { if (PropertyUtility.SetStruct(ref m_SymbolWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// the height of arrow symbol.
/// 箭头高。
/// </summary>
public float symbolHeight { get { return m_SymbolHeight; } set { m_SymbolHeight = value; } }
public float symbolHeight
{
get { return m_SymbolHeight; }
set { if (PropertyUtility.SetStruct(ref m_SymbolHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// the offset of arrow symbol.
/// 箭头偏移。
/// </summary>
public float symbolOffset { get { return m_SymbolOffset; } set { m_SymbolOffset = value; } }
public float symbolOffset
{
get { return m_SymbolOffset; }
set { if (PropertyUtility.SetStruct(ref m_SymbolOffset, value)) SetVerticesDirty(); }
}
/// <summary>
/// the dent of arrow symbol.
/// 箭头的凹陷程度。
/// </summary>
public float symbolDent { get { return m_SymbolDent; } set { m_SymbolDent = value; } }
public float symbolDent
{
get { return m_SymbolDent; }
set { if (PropertyUtility.SetStruct(ref m_SymbolDent, value)) SetVerticesDirty(); }
}
public static AxisLine defaultAxisLine
{
@@ -78,7 +110,7 @@ namespace XCharts
m_Symbol = false,
m_SymbolWidth = 10,
m_SymbolHeight = 15,
m_SymbolOffset = 0,
m_SymbolOffset = -5f,
m_SymbolDent = 3,
};
return axisLine;

View File

@@ -40,42 +40,74 @@ namespace XCharts
/// Whether to show axis name.
/// 是否显示坐标名称。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// the name of axis.
/// 坐标轴名称。
/// </summary>
public string name { get { return m_Name; } set { m_Name = value; } }
public string name
{
get { return m_Name; }
set { if (PropertyUtility.SetClass(ref m_Name, value)) SetComponentDirty(); }
}
/// <summary>
/// Location of axis name.
/// 坐标轴名称显示位置。
/// </summary>
public Location location { get { return m_Location; } set { m_Location = value; } }
public Location location
{
get { return m_Location; }
set { if (PropertyUtility.SetStruct(ref m_Location, value)) SetComponentDirty(); }
}
/// <summary>
/// the offset of axis name and axis line.
/// 坐标轴名称与轴线之间的偏移。
/// </summary>
public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } }
public Vector2 offset
{
get { return m_Offset; }
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
}
/// <summary>
/// Rotation of axis name.
/// 坐标轴名字旋转,角度值。
/// </summary>
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
public float rotate
{
get { return m_Rotate; }
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
}
/// <summary>
/// Color of axis name.
/// 坐标轴名称的文字颜色。
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; } }
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
}
/// <summary>
/// axis name font size.
/// 坐标轴名称的文字大小。
/// </summary>
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
public int fontSize
{
get { return m_FontSize; }
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
}
/// <summary>
/// axis name font style.
/// 坐标轴名称的文字风格。
/// </summary>
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
public FontStyle fontStyle
{
get { return m_FontStyle; }
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
}
public static AxisName defaultAxisName
{
@@ -93,39 +125,5 @@ namespace XCharts
};
}
}
public void Copy(AxisName other)
{
m_Show = other.show;
m_Name = other.name;
m_Location = other.location;
m_Offset = other.offset;
m_Rotate = other.rotate;
m_Color = other.color;
m_FontSize = other.fontSize;
m_FontStyle = other.fontStyle;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
var other = (AxisName)obj;
return m_Show == other.show &&
m_Name.Equals(other.name) &&
m_Location == other.location &&
m_Rotate == other.rotate &&
m_Color == other.color &&
m_Offset == other.offset &&
m_FontSize == other.fontSize &&
m_FontStyle == other.fontStyle;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

View File

@@ -25,14 +25,22 @@ namespace XCharts
/// Set this to true to show the splitArea.
/// 是否显示分隔区域。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Color of split area. SplitArea color could also be set in color array,
/// which the split lines would take as their colors in turns.
/// Dark and light colors in turns are used by default.
/// 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
/// </summary>
public List<Color> color { get { return m_Color; } set { m_Color = value; } }
public List<Color> color
{
get { return m_Color; }
set { if (value != null) { m_Color = value; SetVerticesDirty(); } }
}
public static AxisSplitArea defaultSplitArea
{

View File

@@ -0,0 +1,85 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Split line of axis in grid area.
/// 坐标轴在 grid 区域中的分隔线。
/// </summary>
[Serializable]
public class AxisSplitLine : SubComponent
{
[SerializeField] private bool m_Show;
[SerializeField] private int m_Interval;
[SerializeField] private LineStyle m_LineStyle = new LineStyle(0.7f);
/// <summary>
/// Set this to true to show the split line.
/// 是否显示分隔线。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
public int interval
{
get { return m_Interval; }
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
}
/// <summary>
/// 线条样式
/// </summary>
public LineStyle lineStyle
{
get { return m_LineStyle; }
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
}
public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
m_LineStyle.ClearVerticesDirty();
}
public static AxisSplitLine defaultSplitLine
{
get
{
return new AxisSplitLine()
{
m_Show = false,
};
}
}
internal Color GetColor(ThemeInfo theme)
{
if (lineStyle.color != Color.clear)
{
var color = lineStyle.color;
color.a *= lineStyle.opacity;
return color;
}
else
{
var color = (Color)theme.axisSplitLineColor;
color.a *= lineStyle.opacity;
return color;
}
}
internal bool NeedShow(int index)
{
return show && (interval == 0 || index % (interval + 1) == 0);
}
}
}

View File

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

View File

@@ -21,27 +21,53 @@ namespace XCharts
[SerializeField] private bool m_AlignWithLabel;
[SerializeField] private bool m_Inside;
[SerializeField] private float m_Length;
[SerializeField] private float m_Width;
/// <summary>
/// Set this to false to prevent the axis tick from showing.
/// 是否显示坐标轴刻度。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
/// 类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
/// </summary>
public bool alignWithLabel { get { return m_AlignWithLabel; } set { m_AlignWithLabel = value; } }
public bool alignWithLabel
{
get { return m_AlignWithLabel; }
set { if (PropertyUtility.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
}
/// <summary>
/// Set this to true so the axis labels face the inside direction.
/// 坐标轴刻度是否朝内,默认朝外。
/// </summary>
public bool inside { get { return m_Inside; } set { m_Inside = value; } }
public bool inside
{
get { return m_Inside; }
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
}
/// <summary>
/// The length of the axis tick.
/// 坐标轴刻度的长度。
/// </summary>
public float length { get { return m_Length; } set { m_Length = value; } }
public float length
{
get { return m_Length; }
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
}
/// <summary>
/// The width of the axis tick.Keep the same width with axis line when default 0.
/// 坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
public static AxisTick defaultTick
{
@@ -52,6 +78,7 @@ namespace XCharts
m_Show = true,
m_AlignWithLabel = false,
m_Inside = false,
m_Width = 0f,
m_Length = 5f
};
return tick;

View File

@@ -22,14 +22,43 @@ namespace XCharts
/// <summary>
/// 是否启用高亮样式。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { m_Show = value; }
}
/// <summary>
/// 图形文本标签。
/// </summary>
public SerieLabel label { get { return m_Label; } }
public SerieLabel label
{
get { return m_Label; }
set { if (PropertyUtility.SetClass(ref m_Label, value, true)) SetAllDirty(); }
}
/// <summary>
/// 图形样式。
/// </summary>
public ItemStyle itemStyle { get { return m_ItemStyle; } }
public ItemStyle itemStyle
{
get { return m_ItemStyle; }
set { if (PropertyUtility.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
}
public override bool vertsDirty { get { return m_VertsDirty || label.vertsDirty || itemStyle.vertsDirty; } }
public override bool componentDirty { get { return m_ComponentDirty || label.componentDirty; } }
internal override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
label.ClearVerticesDirty();
itemStyle.ClearVerticesDirty();
}
internal override void ClearComponentDirty()
{
base.ClearComponentDirty();
label.ClearComponentDirty();
}
}
}

View File

@@ -0,0 +1,304 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Settings related to gauge axis line.
/// 仪表盘轴线相关设置。
/// </summary>
[System.Serializable]
public class GaugeAxis : SubComponent
{
[System.Serializable]
public class AxisLine
{
[System.Serializable]
public class StageColor
{
[SerializeField] private float m_Percent;
[SerializeField] private Color m_Color;
/// <summary>
/// 结束位置百分比。
/// </summary>
public float percent { get { return m_Percent; } set { m_Percent = value; } }
/// <summary>
/// 颜色。
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; } }
public StageColor(float percent, Color color)
{
m_Percent = percent;
m_Color = color;
}
}
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Width = 15f;
[SerializeField] private float m_Opacity = 1f;
[SerializeField] private Color m_BarColor;
[SerializeField] private Color m_BarBackgroundColor = new Color32(200, 200, 200, 255);
[SerializeField]
private List<StageColor> m_StageColor = new List<StageColor>()
{
new StageColor(0.2f,new Color32(145,199,174,255)),
new StageColor(0.8f,new Color32(99,134,158,255)),
new StageColor(1.0f,new Color32(194,53,49,255)),
};
/// <summary>
/// Set this to false to prevent the axis line from showing.
/// 是否显示坐标轴轴线。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
/// <summary>
/// line style line width.
/// 坐标轴线线宽。
/// </summary>
public float width { get { return m_Width; } set { m_Width = value; } }
/// <summary>
/// The opacity of axis line.
/// 透明度。
/// </summary>
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
/// <summary>
/// 进度条颜色。
/// </summary>
public Color barColor { get { return m_BarColor; } set { m_BarColor = value; } }
/// <summary>
/// 进度条背景颜色。
/// </summary>
public Color barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
/// <summary>
/// 阶段颜色。
/// </summary>
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
}
/// <summary>
/// 分割线
/// </summary>
[System.Serializable]
public class SplitLine
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Length = 15;
[SerializeField]
private LineStyle m_LineStyle = new LineStyle()
{
width = 1.5f,
type = LineStyle.Type.Solid,
color = new Color32(238, 238, 238, 255)
};
/// <summary>
/// 是否显示分割线。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
/// <summary>
/// 分割线长度。
/// </summary>
public float length { get { return m_Length; } set { m_Length = value; } }
/// <summary>
/// 分割线样式。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
}
/// <summary>
/// 刻度
/// </summary>
[System.Serializable]
public class AxisTick
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Length = 5;
[SerializeField] private float m_SplitNumber = 5;
[SerializeField]
private LineStyle m_LineStyle = new LineStyle()
{
width = 1f,
type = LineStyle.Type.Solid,
color = new Color32(238, 238, 238, 255)
};
/// <summary>
/// 是否显示刻度。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
/// <summary>
/// 刻度长度。当为0-1的浮点数时表示半径的百分比。
/// </summary>
public float length { get { return m_Length; } set { m_Length = value; } }
/// <summary>
/// 分割线之间的分割段数。
/// </summary>
public float splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
/// <summary>
/// 刻度线样式。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
}
[SerializeField] private bool m_Show = true;
[SerializeField] private AxisLine m_AxisLine = new AxisLine();
[SerializeField] private SplitLine m_SplitLine = new SplitLine();
[SerializeField] private AxisTick m_AxisTick = new AxisTick();
[SerializeField] private SerieLabel m_AxisLabel = new SerieLabel();
[SerializeField] private List<string> m_AxisLabelText = new List<string>();
public bool show { get { return m_Show; } set { m_Show = value; } }
/// <summary>
/// 仪表盘轴线。
/// </summary>
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
/// <summary>
/// 分割线。
/// </summary>
public SplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
/// <summary>
/// 刻度。
/// </summary>
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
/// <summary>
/// 文本标签。
/// </summary>
public SerieLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
/// <summary>
/// 自定义Label的内容。
/// </summary>
public List<string> axisLabelText { get { return m_AxisLabelText; } set { m_AxisLabelText = value; } }
public List<float> runtimeStageAngle = new List<float>();
public List<Vector3> runtimeLabelPosition = new List<Vector3>();
private List<LabelObject> m_RuntimeLabelList = new List<LabelObject>();
internal Color GetAxisLineColor(ThemeInfo theme, int index)
{
var color = axisLine.barColor != Color.clear ? axisLine.barColor : (Color)theme.GetColor(index);
color.a *= axisLine.opacity;
return color;
}
internal Color GetAxisLineBackgroundColor(ThemeInfo theme, int index)
{
var color = axisLine.barBackgroundColor != Color.clear ? axisLine.barBackgroundColor : Color.grey;
color.a *= axisLine.opacity;
return color;
}
internal Color GetSplitLineColor(ThemeInfo theme, int serieIndex, float angle)
{
Color color;
if (splitLine.lineStyle.color != Color.clear)
{
color = splitLine.lineStyle.color;
color.a *= splitLine.lineStyle.opacity;
return color;
}
for (int i = 0; i < runtimeStageAngle.Count; i++)
{
if (angle < runtimeStageAngle[i])
{
color = axisLine.stageColor[i].color;
color.a *= splitLine.lineStyle.opacity;
return color;
}
}
color = theme.GetColor(serieIndex);
color.a *= splitLine.lineStyle.opacity;
return color;
}
internal Color GetAxisTickColor(ThemeInfo theme, int serieIndex, float angle)
{
Color color;
if (axisTick.lineStyle.color != Color.clear)
{
color = axisTick.lineStyle.color;
color.a *= axisTick.lineStyle.opacity;
return color;
}
for (int i = 0; i < runtimeStageAngle.Count; i++)
{
if (angle < runtimeStageAngle[i])
{
color = axisLine.stageColor[i].color;
color.a *= axisTick.lineStyle.opacity;
return color;
}
}
color = theme.GetColor(serieIndex);
color.a *= axisTick.lineStyle.opacity;
return color;
}
internal Color GetPointerColor(ThemeInfo theme, int serieIndex, float angle, ItemStyle itemStyle)
{
Color color;
if (itemStyle.color != Color.clear)
{
color = itemStyle.color;
color.a *= itemStyle.opacity;
return color;
}
for (int i = 0; i < runtimeStageAngle.Count; i++)
{
if (angle < runtimeStageAngle[i])
{
color = axisLine.stageColor[i].color;
color.a *= itemStyle.opacity;
return color;
}
}
color = theme.GetColor(serieIndex);
color.a *= itemStyle.opacity;
return color;
}
public void ClearLabelObject()
{
m_RuntimeLabelList.Clear();
}
public void AddLabelObject(LabelObject label)
{
m_RuntimeLabelList.Add(label);
}
public LabelObject GetLabelObject(int index)
{
if (index >= 0 && index < m_RuntimeLabelList.Count)
{
return m_RuntimeLabelList[index];
}
return null;
}
public void SetLabelObjectPosition(int index, Vector3 pos)
{
if (index >= 0 && index < m_RuntimeLabelList.Count)
{
m_RuntimeLabelList[index].SetPosition(pos);
}
}
public void SetLabelObjectText(int index, string text)
{
if (index >= 0 && index < m_RuntimeLabelList.Count)
{
m_RuntimeLabelList[index].SetText(text);
}
}
public void SetLabelObjectActive(bool flag)
{
foreach (var label in m_RuntimeLabelList)
{
label.SetActive(flag);
}
}
}
}

View File

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

View File

@@ -0,0 +1,52 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Settings related to gauge pointer.
/// 仪表盘指针相关设置。
/// </summary>
[System.Serializable]
public class GaugePointer : SubComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private float m_Length = 0.8f;
[SerializeField] private float m_Width = 15;
/// <summary>
/// 是否显示指针。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// 指针长度。可以是绝对值也可以是相对于半径的百分比0-1的浮点数
/// </summary>
/// <value></value>
public float length
{
get { return m_Length; }
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
}
/// <summary>
/// 指针宽度。
/// </summary>
/// <value></value>
public float width
{
get { return m_Width; }
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
}
}

View File

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

View File

@@ -0,0 +1,105 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
/// <summary>
/// 系列数据项的图标
/// </summary>
[System.Serializable]
public class IconStyle : SubComponent
{
public enum Layer
{
UnderLabel,
AboveLabel
}
[SerializeField] private bool m_Show;
[SerializeField] private Layer m_Layer;
[SerializeField] private Sprite m_Sprite;
[SerializeField] private Color m_Color = Color.white;
[SerializeField] private float m_Width = 40;
[SerializeField] private float m_Height = 40;
[SerializeField] private Vector3 m_Offset;
/// <summary>
/// Whether the data icon is show.
/// 是否显示图标。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; UpdateIcon(); } }
/// <summary>
/// 显示在上层还是在下层。
/// </summary>
public Layer layer { get { return m_Layer; } set { m_Layer = value; } }
/// <summary>
/// The image of icon.
/// 图标的图片。
/// </summary>
public Sprite sprite { get { return m_Sprite; } set { m_Sprite = value; } }
/// <summary>
/// 图标颜色。
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; } }
/// <summary>
/// 图标宽。
/// </summary>
public float width { get { return m_Width; } set { m_Width = value; } }
/// <summary>
/// 图标高。
/// </summary>
public float height { get { return m_Height; } set { m_Height = value; } }
/// <summary>
/// 图标偏移。
/// </summary>
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
public Image image { get; private set; }
public RectTransform rect { get; private set; }
public void SetImage(Image image)
{
this.image = image;
if (image)
{
rect = image.GetComponent<RectTransform>();
if (m_Layer == Layer.UnderLabel)
rect.SetSiblingIndex(0);
else
rect.SetSiblingIndex(image.transform.childCount - 1);
UpdateIcon();
}
}
public void SetActive(bool flag)
{
if (image)
{
ChartHelper.SetActive(image.gameObject, flag);
}
}
public void UpdateIcon()
{
if (image == null) return;
if (show)
{
ChartHelper.SetActive(image.gameObject, true);
image.sprite = m_Sprite;
image.color = m_Color;
rect.sizeDelta = new Vector2(m_Width, m_Height);
image.transform.localPosition = m_Offset;
}
else
{
ChartHelper.SetActive(image.gameObject, false);
}
}
}
}

View File

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

View File

@@ -5,7 +5,8 @@
/* */
/******************************************/
using System;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
@@ -36,34 +37,142 @@ namespace XCharts
}
[SerializeField] private bool m_Show = false;
[SerializeField] private Color m_Color;
[SerializeField] private Color m_ToColor;
[SerializeField] private Color m_BackgroundColor;
[SerializeField] private float m_BackgroundWidth;
[SerializeField] private Color m_CenterColor;
[SerializeField] private float m_CenterGap;
[SerializeField] private Type m_BorderType = Type.Solid;
[SerializeField] private float m_BorderWidth = 0;
[SerializeField] private Color m_BorderColor;
[SerializeField] [Range(0, 1)] private float m_Opacity = 1;
[SerializeField] private string m_TooltipFormatter;
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
/// <summary>
/// 是否启用。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项颜色。
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; } }
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// Gradient color, start color to toColor.
/// 渐变色的终点颜色。
/// </summary>
public Color toColor
{
get { return m_ToColor; }
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项背景颜色。
/// </summary>
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 中心区域颜色。
/// </summary>
public Color centerColor
{
get { return m_CenterColor; }
set { if (PropertyUtility.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 中心区域间隙。
/// </summary>
public float centerGap
{
get { return m_CenterGap; }
set { if (PropertyUtility.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项背景颜色。
/// </summary>
public float backgroundWidth
{
get { return m_BackgroundWidth; }
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框的类型。
/// </summary>
public Type borderType { get { return m_BorderType; } set { m_BorderType = value; } }
public Type borderType
{
get { return m_BorderType; }
set { if (PropertyUtility.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框的颜色。
/// </summary>
public Color borderColor { get { return m_BorderColor; } set { m_BorderColor = value; } }
public Color borderColor
{
get { return m_BorderColor; }
set { if (PropertyUtility.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框宽。
/// </summary>
public float borderWidth { get { return m_BorderWidth; } set { m_BorderWidth = value; } }
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
/// </summary>
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
public float opacity
{
get { return m_Opacity; }
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
}
/// <summary>
/// 提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`
/// </summary>
public string tooltipFormatter
{
get { return m_TooltipFormatter; }
set { if (PropertyUtility.SetClass(ref m_TooltipFormatter, value)) SetVerticesDirty(); }
}
/// <summary>
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left, upper right, bottom right and bottom left)).
/// 圆角半径。用数组分别指定4个圆角半径顺时针左上右上右下左下
/// </summary>
public float[] cornerRadius
{
get { return m_CornerRadius; }
set { if (PropertyUtility.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 实际边框宽。边框不显示时为0。
/// </summary>
public float runtimeBorderWidth { get { return NeedShowBorder() ? borderWidth : 0; } }
/// <summary>
/// 是否需要显示边框。
/// </summary>
public bool NeedShowBorder()
{
return borderWidth != 0 && borderColor != Color.clear;
}
public Color GetColor()
{
var color = m_Color;
color.a *= m_Opacity;
return color;
}
}
}

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