mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 11:40:13 +00:00
Compare commits
132 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e48c23225 | ||
|
|
5cf93b6111 | ||
|
|
a3aa610d57 | ||
|
|
ce69581a3a | ||
|
|
523067ad58 | ||
|
|
e67bab471c | ||
|
|
10fe66fcb8 | ||
|
|
1639dcd4ee | ||
|
|
b8bb3abac7 | ||
|
|
75a58c6975 | ||
|
|
eb9da8210e | ||
|
|
04c69ea9e0 | ||
|
|
02a5b45e10 | ||
|
|
5835a372f5 | ||
|
|
590a13688d | ||
|
|
45dede8aee | ||
|
|
e77c9fd327 | ||
|
|
d694c5d9f1 | ||
|
|
30b6b061e6 | ||
|
|
a65ad893eb | ||
|
|
77fd92d2b0 | ||
|
|
8c759fd94d | ||
|
|
536cccbfaf | ||
|
|
64568ce2cc | ||
|
|
22ca68e04a | ||
|
|
63fd4c81b4 | ||
|
|
c77d13f5db | ||
|
|
63fb591b46 | ||
|
|
f93355e6c4 | ||
|
|
53e988e8d2 | ||
|
|
a2e1cd9840 | ||
|
|
9b0165b291 | ||
|
|
91a7c88ea1 | ||
|
|
384c6a842e | ||
|
|
6590b70db6 | ||
|
|
930fb59755 | ||
|
|
8851e54266 | ||
|
|
e597ab7d3f | ||
|
|
e1ed738ec9 | ||
|
|
5811ebfda1 | ||
|
|
c897d78a79 | ||
|
|
9a300dc531 | ||
|
|
68cccdec32 | ||
|
|
bc6e5675e9 | ||
|
|
c08367fdac | ||
|
|
36200c7386 | ||
|
|
2c5577f534 | ||
|
|
b9a11845ef | ||
|
|
bacec6dec2 | ||
|
|
af0cc9988b | ||
|
|
b0aad6405c | ||
|
|
738173fe7c | ||
|
|
b4a127511c | ||
|
|
e8eb8a5468 | ||
|
|
3db8eba92c | ||
|
|
463305a63e | ||
|
|
51f3558b55 | ||
|
|
b56099ad2e | ||
|
|
f3ec7dc196 | ||
|
|
382c976f02 | ||
|
|
5d85fdb7f9 | ||
|
|
314362321d | ||
|
|
a0fd70372f | ||
|
|
47c8f76252 | ||
|
|
7191f8a5ad | ||
|
|
18d02be719 | ||
|
|
40a1a0cbf6 | ||
|
|
2f61dfd9bd | ||
|
|
a2394a506c | ||
|
|
eabf202755 | ||
|
|
738bee9ed5 | ||
|
|
16377cabfa | ||
|
|
c8165c896e | ||
|
|
54103be0f8 | ||
|
|
7432f75f2f | ||
|
|
55c374c07f | ||
|
|
f476c2c907 | ||
|
|
897d596174 | ||
|
|
2859496156 | ||
|
|
2c420ac336 | ||
|
|
2e2a16bbf4 | ||
|
|
d3484d6283 | ||
|
|
9990f54edd | ||
|
|
b234a53b73 | ||
|
|
8916cb5250 | ||
|
|
a178858b85 | ||
|
|
00ce32fffd | ||
|
|
898f1bd563 | ||
|
|
c0cd81bf6f | ||
|
|
41d01f0555 | ||
|
|
b333a87f04 | ||
|
|
00d139d553 | ||
|
|
f4f1bb4b54 | ||
|
|
e512d27784 | ||
|
|
6cdeb2516b | ||
|
|
6d64156db4 | ||
|
|
a66b8a576c | ||
|
|
839e1fe9d1 | ||
|
|
c64653cab8 | ||
|
|
3df6465764 | ||
|
|
b689a18a01 | ||
|
|
20886dd1d5 | ||
|
|
0e892fbb55 | ||
|
|
6290b9ae91 | ||
|
|
753b1d5b2b | ||
|
|
97a81b7816 | ||
|
|
1a0412a984 | ||
|
|
0dde0217f9 | ||
|
|
cc0187291e | ||
|
|
90f5c1ef8a | ||
|
|
b3e9e8833c | ||
|
|
772701a549 | ||
|
|
bef00f18e1 | ||
|
|
72cf428bd9 | ||
|
|
e64486079d | ||
|
|
9a295d674f | ||
|
|
af8127ef2c | ||
|
|
0d63c23493 | ||
|
|
4c2a5a76ce | ||
|
|
99d78549c2 | ||
|
|
ca1e6957a8 | ||
|
|
25941d2050 | ||
|
|
0d361555f3 | ||
|
|
d50db7b16c | ||
|
|
27c2c88e26 | ||
|
|
46ecdf430e | ||
|
|
0e22dcbcdb | ||
|
|
a0f20f696e | ||
|
|
541bc421b7 | ||
|
|
a1018801d4 | ||
|
|
2a3d8dc5b2 | ||
|
|
b6c206c299 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,6 +6,8 @@
|
||||
/Temp
|
||||
/Logs
|
||||
/UnityPackageManager
|
||||
/Packages
|
||||
/ProjectSettings/XRSettings.asset
|
||||
/Assets/Res
|
||||
/Assets/Res.meta
|
||||
/Assets/Package
|
||||
|
||||
@@ -1,6 +1,77 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
* (2020.06.25) 发布`v1.5.2`版本
|
||||
* (2020.06.25) 修复`BarChart`在数值为`0`时还会绘制一小部分柱条的问题
|
||||
* (2020.06.24) 修复`PieChart`在设置`clockwise`后绘制异常的问题#65
|
||||
* (2020.06.23) 优化`LineChart`在峰谷差异过大时的绘制效果#64
|
||||
* (2020.06.18) 修复`SerieLabel`在重新添加数据时可能不显示的问题
|
||||
* (2020.06.17) 增加`SerieData`可单独设置`SerieSymbol`#66
|
||||
* (2020.06.17) 修复`Check For Update`在`Unity 2018`部分版本报错的问题#63
|
||||
* (2020.06.16) 增加`Serie`的`avoidLabelOverlap`参数避免饼图标签堆叠的情况#56
|
||||
* (2020.06.15) 修复`SerieLabel`单独控制显示时可能错乱的问题
|
||||
* (2020.06.11) 修复`Check warning`不生效的问题
|
||||
* (2020.06.11) 修复`PieChart`和`RingChart`在数据占比很小时不显示的问题
|
||||
* (2020.06.11) 增加`Tooltip`的`titleFormatter`支持配置占位符`{i}`表示忽略不显示标题
|
||||
* (2020.06.07) 增加`Animation`的`customFadeInDelay`等自定义数据项延时和时长回调函数#58
|
||||
* (2020.06.07) 优化`PieChart`在数据全为`0`时的显示为等份的效果#59
|
||||
* (2020.06.04) 增加`SerieLabel`的`autoOffset`参数设置是否自动判断上下偏移
|
||||
* (2020.06.04) 增加`Tooltip`的`alwayShow`参数设置触发后一直显示
|
||||
* (2020.06.04) 优化`Tooltip`的`formatter`支持`{.1}`通配符
|
||||
* (2020.06.04) 优化`Legend`数量过多时自动换行显示#53
|
||||
* (2020.06.03) 发布`v1.5.1`版本
|
||||
* (2020.06.02) 增加`Radar`的`ceilRate`,设置最大最小值的取整倍率
|
||||
* (2020.06.02) 优化`Tooltip`的`formatter`,支持`{c1:1-1:f1}`格式配置
|
||||
* (2020.05.31) 优化`Background`组件的生效条件,需要有单独的父节点(升级前需要自己处理旧的背景节点)
|
||||
* (2020.05.30) 优化`PieChart`支持设置`ignoreValue`不显示指定数据
|
||||
* (2020.05.30) 修复`RadarChart`为`Circle`时不绘制`SplitArea`的问题
|
||||
* (2020.05.30) 优化`RadarChart`在设置`max`为`0`时可自动刷新最大值
|
||||
* (2020.05.29) 修复`PieChart`设置`space`时只有一个数据时绘制异常的问题
|
||||
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题
|
||||
* (2020.05.27) 优化`柱状图`的渐变色效果
|
||||
* (2020.05.24) 修复`Axis`同时设置`boundaryGap`和`alignWithLabel`时`Tick`绘制异常的问题
|
||||
* (2020.05.24) 优化版本更新检测
|
||||
* (2020.05.22) 发布`v1.5.0`版本
|
||||
* (2020.05.21) 增加`圆角柱图`支持渐变
|
||||
* (2020.05.21) 增加`Background`背景组件
|
||||
* (2020.05.19) 隐藏`Hierarchy`试图下自动生成的子节点
|
||||
* (2020.05.18) 增加`chartName`属性可指定图表的别称,可通过`XChartMgr.Instance.GetChart(chartName)`获取图表
|
||||
* (2020.05.16) 增加部分鼠标事件回调
|
||||
* (2020.05.15) 优化自带例子,`Demo`改名为`Example`
|
||||
* (2020.05.13) 增加`Serie`的`large`和`largeThreshold`参数配置折线图和柱状图的性能模式
|
||||
* (2020.05.13) 完善Demo,增加性能演示Demo
|
||||
* (2020.05.13) 优化性能,优化大数据绘制,重构代码
|
||||
* (2020.05.04) 增加`numericFormatter`参数可配置数值格式化显示,去掉`forceENotation`参数
|
||||
* (2020.04.28) 增加`自由锚点`支持,任意对齐方式
|
||||
* (2020.04.23) 优化`ScatterChart`的`Tooltip`显示效果
|
||||
* (2020.04.23) 增加`Tooltip`的`formatter`对`{.}`、`{c:0}`、`{c1:1}`的支持
|
||||
* (2020.04.19) 优化`LineChart`折线图的区域填充渐变效果
|
||||
* (2020.04.19) 增加`AxisLabel`的`onZero`参数可将`Label`显示在`0`刻度上
|
||||
* (2020.04.19) 增加`Serie`和`AxisLabel`的`showAsPositiveNumber`参数将负数数值显示为正数
|
||||
* (2020.04.18) 增加`Covert XY Axis`互换XY轴配置
|
||||
* (2020.04.17) 增加`Axis`可通过`inverse`参数设置坐标轴反转
|
||||
* (2020.04.16) 修复`Check warning`在`Unity2019.3`上的显示问题
|
||||
* (2020.04.16) 修复`PieChart`在设置`Space`参数后动画绘制异常的问题
|
||||
* (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`偏移显示异常的问题
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e27021e8c8377464a8b439cf785080ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75813849985304690b882bdd95364bae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b4ec86ec75e9428e878f99c14f7676f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ccf4c940af6c343e6abea9580e3915bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb56350d2a2b24960a7174a1d3f2ea56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f7e5ced8db104dcc8447f1e5ac903f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14e10f24be7ee4f609b36b904224382d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 250f744fcb07d4401994d964c4369d9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7774c94c82584c0ca35e6f79d1fc29c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c777ceb41c4c743d2ba0ea573287be9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c85e69c8e4374481be85fda06a45209
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e538728f2646249ae9c9206b8ceffe25
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,10 +11,21 @@
|
||||
* `BaseChart.legend`:图例组件`Legend`。
|
||||
* `BaseChart.tooltip`:提示框组件`Tooltip`。
|
||||
* `BaseChart.series`:系列列表`Series`。
|
||||
* `BaseChart.chartName`:图表的别称。
|
||||
* `BaseChart.chartWidth`:图表的宽。
|
||||
* `BaseChart.chartHeight`:图表的高。
|
||||
* `BaseChart.customDrawCallback`:自定义绘制回调函数。
|
||||
* `BaseChart.SetSize(float width, float height)`:设置图表的大小。
|
||||
* `BaseChart.forceOpenRaycastTarget`:强制开启鼠标事件检测。一般不用手动设置,内部会自动判断是否需要检测。
|
||||
* `BaseChart.onCustomDraw`:自定义绘制回调。
|
||||
* `BaseChart.onPointerClick`:鼠标点击回调。
|
||||
* `BaseChart.onPointerDown`:鼠标按下回调。
|
||||
* `BaseChart.onPointerUp`:鼠标弹起回调。
|
||||
* `BaseChart.onPointerEnter`:鼠标进入图表回调。
|
||||
* `BaseChart.onPointerExit`:鼠标退出图表回调。
|
||||
* `BaseChart.onBeginDrag`:鼠标开始拖拽回调。
|
||||
* `BaseChart.onDrag`:鼠标拖拽回调。
|
||||
* `BaseChart.onEndDrag`:鼠标结束拖拽回调。
|
||||
* `BaseChart.onScroll`:鼠标滚动回调。
|
||||
* `BaseChart.SetSize(float width, float height)`: 设置图表的宽高(在非stretch pivot下才有效,其他情况需要自己调整RectTransform)。
|
||||
* `BaseChart.ClearData()`:清除所有数据,系列列表会保留,只是移除列表中系列的数据。
|
||||
* `BaseChart.RemoveData()`:清除所有系列和图例数据,系列列表也会被清除。
|
||||
* `BaseChart.RemoveData(string serieName)`:清除指定系列名称的数据。
|
||||
@@ -49,6 +60,9 @@
|
||||
* `BaseChart.AnimationResume()`:继续动画。
|
||||
* `BaseChart.AnimationReset()`:重置动画。
|
||||
* `BaseChart.ClickLegendButton(int legendIndex, string legendName, bool show)`:点击图例按钮。
|
||||
* `BaseChart.IsInChart(Vector2 local)`:坐标是否在图表范围内。
|
||||
* `BaseChart.IsInChart(float x, float y)`:坐标是否在图表范围内。
|
||||
* `BaseChart.EnableBackground(bool flag)`:开启背景组件。背景组件在`chart`受上层布局控制时无法开启。
|
||||
|
||||
## `CoordinateChart`
|
||||
|
||||
@@ -70,6 +84,14 @@
|
||||
* `CoordinateChart.IsValue()`:是否是纯数值坐标。
|
||||
* `CoordinateChart.RefreshDataZoom()`:在下一帧刷新DataZoom组件。
|
||||
* `CoordinateChart.RefreshAxisMinMaxValue()`:立即刷新数值坐标轴的最大最小值(更新坐标轴标签并触发重绘)。
|
||||
* `CoordinateChart.IsInCooridate(Vector2 local)`:坐标是否在坐标轴内。
|
||||
* `CoordinateChart.IsInCooridate(Vector3 local)`:坐标是否在坐标轴内。
|
||||
* `CoordinateChart.IsInCooridate(float x, float y)`:坐标是否在坐标轴内。
|
||||
* `CoordinateChart.IsInCooridate(Vector2 local)`:坐标是否在坐标轴内。
|
||||
* `CoordinateChart.ClampInCoordinate(Vector3 pos)`:将坐标限制在坐标系内。
|
||||
* `CoordinateChart.CovertXYAxis(int index)`:转换X轴和Y轴的配置。
|
||||
* `CoordinateChart.UpdateCoordinate()`:更新坐标系原点和宽高。一般内部会自动更新,也可强制更新。
|
||||
* `CoordinateChart.SetMaxCache(int maxCache)`:设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。
|
||||
|
||||
## `LineChart`
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
主组件:
|
||||
|
||||
* [Axis 坐标轴](#XAxis)
|
||||
* [Background 背景图](#Background)
|
||||
* [DataZoom 区域缩放](#DataZoom)
|
||||
* [Grid 网格](#Grid)
|
||||
* [Legend 图例](#Legend)
|
||||
@@ -36,7 +37,7 @@
|
||||
* [AxisSplitArea 坐标轴分割区域](#AxisSplitArea)
|
||||
* [AxisTick 坐标轴刻度](#AxisTick)
|
||||
* [Emphasis 高亮样式](#Emphasis)
|
||||
* [ItemStyle 图形样式](#ItemStyle)
|
||||
* [ItemStyle 数据项样式](#ItemStyle)
|
||||
* [LineArrow 折线图箭头](#LineArrow)
|
||||
* [LineStyle 折线图样式](#LineStyle)
|
||||
* [Location 位置](#Location)
|
||||
@@ -147,6 +148,8 @@
|
||||
* `Between`:显示在顶点之间。
|
||||
* `radius`:雷达图的半径。
|
||||
* `center`:雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||
* `ceilRate`:最大最小值向上取整的倍率。默认为0时自动计算。
|
||||
* `splitNumber`:分割段数。默认为 `5`。
|
||||
* `splitLine`:分割线条 [AxisSplitLine](#AxisSplitLine)。
|
||||
* `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。
|
||||
* `indicator`:是否显示指示器。
|
||||
@@ -189,14 +192,23 @@
|
||||
* `Line`:线性指示器。
|
||||
* `Shadow`:阴影指示器。
|
||||
* `None`:无指示器。
|
||||
* `Corss`:十字准星指示器。坐标轴显示Label和交叉线。
|
||||
* `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`。
|
||||
* `Corss`:十字准星指示器。坐标轴显示`Label`和交叉线。
|
||||
* `formatter`:提示框内容字符串模版格式器。支持用 `\n` 换行。当`formatter`不为空时,优先使用`formatter`,否则使用`itemFormatter`。
|
||||
* 模板变量有`{.}`、`{a}`、`{b}`、`{c}`、`{d}`。
|
||||
* `{.}`为当前所指示或`index`为`0`的`serie`的对应颜色的圆点。
|
||||
* `{a}`为当前所指示或`index`为`0`的`serie`的系列名`name`。
|
||||
* `{b}`为当前所指示或`index`为`0`的`serie`的数据项`serieData`的`name`,或者类目值(如折线图的`X`轴)。
|
||||
* `{c}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)的数值。
|
||||
* `{d}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)百分比值,注意不带`%`号。
|
||||
* `{.1}`表示指定`index`为`1`的`serie`对应颜色的圆点。
|
||||
* `{a1}`、`{b1}`、`{c1}`中的`1`表示指定`index`为`1`的`serie`。
|
||||
* `{c1:2}`表示索引为`1`的`serie`的当前指示数据项的第`3`个数据(一个数据项有多个数据,index为`2`表示第`3`个数据)。
|
||||
* `{c1:2-2}`表示索引为`1`的`serie`的第`3`个数据项的第`3`个数据(也就是要指定第几个数据项时必须要指定第几个数据)。
|
||||
* `{d1:2:f2}`表示单独指定了数值的格式化字符串为`f2`(不指定时用`numericFormatter`)。
|
||||
* 示例:`"{a}:{c}"`、`"{a1}:{c1:f1}"`、`"{a1}:{c1:1f1}"`
|
||||
* `titleFormatter`:提示框标题内容的字符串模版格式器。支持用 `\n` 换行。仅当`itemFormatter`生效时才有效。可以单独设置占位符`{i}`表示忽略不显示标题内容。
|
||||
* `itemFormatter`:提示框单个`serie`或数据项内容的字符串模版格式器。支持用 `\n` 换行。当`formatter`不为空时,优先使用`formatter`,否则使用`itemFormatter`。
|
||||
* `numericFormatter`:标准数字格式字符串。用于将数值格式化显示为字符串。使用`Axx`的形式:`A`是格式说明符的单字符,支持`C`货币、`D`十进制、`E`指数、`F`顶点数、`G`常规、`N`数字、`P`百分比、`R`往返过程、`X`十六进制等九种。`xx`是精度说明,从`0`-`99`。
|
||||
* `fixedWidth`:固定宽度。当同时设置 `fixedWidth` 和 `minWidth` 时,`fixedWidth` 比 `minWidth` 优先级高。
|
||||
* `fixedHeight`:固定高度。当同时设置 `fixedHeight` 和 `minHeight` 时,`fixedHeight` 比 `minHeight` 优先级高。
|
||||
* `minWidth`:最小宽度。当同时设置 `fixedWidth` 和 `minWidth` 时,`fixedWidth` 比 `minWidth` 优先级高。
|
||||
@@ -204,8 +216,8 @@
|
||||
* `paddingLeftRight`:文字和边框的左右边距。
|
||||
* `paddingTopBottom`:文字和边框的上下边距。
|
||||
* `backgroundImage`:提示框的背景图。
|
||||
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||
* `ignoreDataDefaultContent`:被忽略数据的默认显示字符信息。
|
||||
* `alwayShow`:是否触发后一直显示。
|
||||
* `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。
|
||||
* `textStyle`:显示内容文本样式 [TextStyle](#TextStyle)。
|
||||
|
||||
@@ -247,7 +259,7 @@
|
||||
视觉映射组件。用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)。
|
||||
|
||||
* `enable`:开启或关闭视觉映射功能。
|
||||
* `show`:是否显示组件。如果设置为 false,不会显示,但是数据映射的功能还存在。
|
||||
* `show`:是否显示组件。如果设置为 `false`,不会显示,但是数据映射的功能还存在。
|
||||
* `type`:组件类型。支持以下类型:
|
||||
* `Continuous`:连续型。
|
||||
* ~~`Piecewise`:分段型。~~
|
||||
@@ -274,7 +286,7 @@
|
||||
|
||||
## `Grid`
|
||||
|
||||
网格组件。直角坐标系内绘图网格,单个 `grid` 内最多可以放置上下两个 `X` 轴,左右两个 `Y` 轴。可以在网格上绘制折线图,柱状图,散点图(气泡图)。目前最多只能存在一个 `grid` 组件。
|
||||
网格组件。直角坐标系内绘图网格,单个 `grid` 内最多可以放置上下两个 `X` 轴,左右两个 `Y` 轴。可以在网格上绘制折线图,柱状图,散点图。目前最多只能存在一个 `grid` 组件。
|
||||
|
||||
相关参数:
|
||||
|
||||
@@ -293,14 +305,14 @@
|
||||
* `splitLine`:坐标轴分割线样式。
|
||||
* `axisTick`:坐标轴刻度样式。
|
||||
* `axisLabel`:坐标轴刻度标签样式。
|
||||
* `axisLabelText`:坐标轴刻度标签自定义内容。当内容为空时,axisLabel根据刻度自动显示内容,否则取自该列表定义的内容。
|
||||
* `axisLabelText`:坐标轴刻度标签自定义内容。当内容为空时,`axisLabel`根据刻度自动显示内容,否则取自该列表定义的内容。
|
||||
|
||||
## `GaugePointer`
|
||||
|
||||
仪表盘指针。
|
||||
|
||||
* `width`:指针宽度。
|
||||
* `length`:指针长度。当为0-1的浮点数时表示相对仪表盘半径的百分比。
|
||||
* `length`:指针长度。当为`0-1`的浮点数时表示相对仪表盘半径的百分比。
|
||||
|
||||
## `XAxis`
|
||||
|
||||
@@ -321,10 +333,12 @@
|
||||
* `Custom`:自定义的最小值-最大值。
|
||||
* `min`:设定的坐标轴刻度最小值,当 `minMaxType` 为 `Custom` 时有效。
|
||||
* `max`:设定的坐标轴刻度最大值,当 `minMaxType` 为 `Custom` 时有效。
|
||||
* `ceilRate`:最大最小值向上取整的倍率。默认为0时自动计算。
|
||||
* `splitNumber`:坐标轴的分割段数。默认为 `5`。当 `splitNumber` 设为 `0` 时,表示绘制所有的类目数据。
|
||||
* `interval`:强制设置坐标轴分割间隔。无法在类目轴中使用。设置改值时 `splitNumber` 无效。
|
||||
* `interval`:强制设置坐标轴分割间隔。无法在类目轴中使用。设置该值时 `splitNumber` 无效。
|
||||
* `boundaryGap`:坐标轴两边是否留白。默认为 `true`。
|
||||
* `maxCache`:类目数据中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||
* `maxCache`:类目数据中可缓存的最大数据量。默认为`0`没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||
* `inverse`:是否反向坐标轴。只在数值轴`Value`中有效。
|
||||
* `data`:类目数据,在类目轴(`type: 'Category'`)中有效。
|
||||
* `axisLine`:坐标轴轴线相关配置 [AxisLine](#AxisLine)。
|
||||
* `axisName`:坐标轴名称相关配置 [AxisName](#AxisName)。
|
||||
@@ -340,6 +354,22 @@
|
||||
* `IsValue()`:是否为数值轴。
|
||||
* `AddData(string category, int maxDataNumber)`:添加一个类目到类目数据列表。
|
||||
|
||||
## `Background`
|
||||
|
||||
背景组件。
|
||||
由于框架的局限性,背景组件使用有以下两个限制:
|
||||
1:`chart`的父节点不能有布局控制类组件。
|
||||
2:`chart`的父节点只能有当前`chart`一个子节点。
|
||||
背景组件的开启需要通过接口来开启:`BaseChart.EnableBackground(bool flag)`。
|
||||
|
||||
相关参数:
|
||||
|
||||
* `show`:是否显示启用背景组件。但能否激活背景组件还要受其他条件限制。
|
||||
* `image`:背景图。
|
||||
* `imageType`:背景图填充类型。
|
||||
* `imageColor`背景图颜色。默认`white`。
|
||||
* `hideThemeBackgroundColor`:当背景组件启用时,是否隐藏主题中设置的背景色。
|
||||
|
||||
## `YAxis`
|
||||
|
||||
直角坐标系 `grid` 中的 `Y` 轴。单个 `grid` 组件最多只能放左右两个 `Y` 轴。两个 `Y` 轴存储在 `yAxises` 中。
|
||||
@@ -467,7 +497,10 @@
|
||||
* `sampleAverage`:设定的采样平均值。当 `sampleType` 为 `Peak` 时,用于和过滤数据的平均值做对比是取最大值还是最小值。默认为`0`时会实时计算所有数据的平均值。
|
||||
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
||||
* `ignoreValue`:忽略数据的默认值。当 `ignore` 为 `true` 才有效。
|
||||
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
||||
* `showAsPositiveNumber`:将负数数值显示为正数。一般和`AxisLabel`的`showAsPositiveNumber`配合使用。仅在折线图和柱状图中有效。
|
||||
* `large`:是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。开启后配合 largeThreshold 在数据量大于指定阈值的时候对绘制进行优化。缺点:优化后不能自定义设置单个数据项的样式,不能显示Label,折线图不绘制Symbol。
|
||||
* `largeThreshold`:开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
|
||||
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||
* `lineType`:折线图样式类型。支持以下十种类型:
|
||||
@@ -511,6 +544,11 @@
|
||||
* `barZebraWidth`:斑马线的粗细。`barType` 为 `Zebra` 时有效。
|
||||
* `barZebraGap`:斑马线的间距。`barType` 为 `Zebra` 时有效。
|
||||
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
||||
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
||||
* `showAsPositiveNumber`:将负数数值显示为正数。一般和`AxisLabel`的`showAsPositiveNumber`配合使用。仅在折线图和柱状图中有效。
|
||||
* `large`:是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。开启后配合 largeThreshold 在数据量大于指定阈值的时候对绘制进行优化。缺点:优化后不能自定义设置单个数据项的样式,不能显示Label,折线图不绘制Symbol。
|
||||
* `largeThreshold`:开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
|
||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||
* `itemStyle`:柱条样式 [ItemStyle](#ItemStyle)。
|
||||
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||
@@ -531,9 +569,12 @@
|
||||
* `Radius`:扇区圆心角展现数据的百分比,半径展现数据的大小。
|
||||
* `Area`:所有扇区圆心角相同,仅通过半径展现数据大小。
|
||||
* `space`:扇区间隙。
|
||||
* `center`:中心点坐标。当值为0-1的浮点数时表示百分比。
|
||||
* `center`:中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
||||
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
||||
* `roundCap`:是否启用圆弧效果。
|
||||
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制,对应的`Label`和`Legend`也不会显示。
|
||||
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
||||
* `avoidLabelOverlap`:在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。
|
||||
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||
@@ -546,9 +587,15 @@
|
||||
* `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`维数据。
|
||||
|
||||
@@ -573,6 +620,8 @@
|
||||
* `show`:系列是否显示在图表上。
|
||||
* `type`:`Scatter`。
|
||||
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
||||
* `ignoreValue`:忽略数据的默认值。默认值默认为`0`,当 `ignore` 为 `true` 才有效。
|
||||
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||
@@ -590,10 +639,10 @@
|
||||
* `ProgressBar`:进度条类型。
|
||||
* `center`:中心点坐标。当值为0-1的浮点数时表示百分比。
|
||||
* `radius`:仪表盘半径。
|
||||
* `min`:最小的数据值。映射到startAngle。
|
||||
* `max`:最大的数据值。映射到endAngle。
|
||||
* `startAngle`:仪表盘起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||
* `endAngle`:仪表盘结束角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||
* `min`:最小的数据值。映射到`startAngle`。
|
||||
* `max`:最大的数据值。映射到`endAngle`。
|
||||
* `startAngle`:仪表盘起始角度。和时钟一样,`12`点钟位置是`0`度,顺时针到`360`度。
|
||||
* `endAngle`:仪表盘结束角度。和时钟一样,`12`点钟位置是`0`度,顺时针到`360`度。
|
||||
* `splitNumber`:仪表盘刻度分割段数。
|
||||
* `roundCap`:是否启用圆弧效果。
|
||||
* `titleStyle`:仪表盘标题 [TitleStyle](#TitleStyle)。
|
||||
@@ -612,9 +661,9 @@
|
||||
* `show`:系列是否显示在图表上。
|
||||
* `type`:`Ring`。
|
||||
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||
* `center`:中心点坐标。当值为0-1的浮点数时表示百分比。
|
||||
* `center`:中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
||||
* `radius`:仪表盘半径。
|
||||
* `startAngle`:仪表盘起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||
* `startAngle`:仪表盘起始角度。和时钟一样,`12`点钟位置是`0`度,顺时针到`360`度。
|
||||
* `ringGap`:环形图的环间隙。
|
||||
* `roundCap`:是否启用圆弧效果。
|
||||
* `clockwise`:是否顺时针,默认为`true`。
|
||||
@@ -638,9 +687,10 @@
|
||||
|
||||
* `enable`:是否开启动画系统。
|
||||
* ~~`threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。~~
|
||||
* `fadeInDelay`:设定的渐入动画延时,单位毫秒。
|
||||
* `fadeInDuration`:设定的渐入动画时长,单位毫秒。
|
||||
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒。
|
||||
* `fadeInDelay`:设定的渐入动画延时,单位毫秒。如果要设置单个数据项的延时,可以用代码定制:`customFadeInDelay`。
|
||||
* `fadeInDuration`:设定的渐入动画时长,单位毫秒。如果要设置单个数据项的渐入时长,可以用代码定制:`customFadeInDuration`。
|
||||
* `fadeOutDelay`:设定的渐出动画延时,单位毫秒。如果要设置单个数据项的延时,可以用代码定制:`customFadeOutDelay`。
|
||||
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒。如果要设置单个数据项的渐出时长,可以用代码定制:`customFadeOutDuration`。
|
||||
* `dataChangeEnable`:是否开启数据变更动画。
|
||||
* `dataChangeDuration`:数据变更动画时长,单位毫秒。
|
||||
|
||||
@@ -655,27 +705,29 @@
|
||||
* `toColor`:区域填充的渐变色的终点颜色。
|
||||
* `highlightColor`:高亮时区域填充的颜色,默认取 `serie` 对应的颜色。如果 `highlightToColor` 不是默认值,则表示渐变色的起点颜色。
|
||||
* `highlightToColor`:高亮时区域填充的渐变色的终点颜色。
|
||||
* `opacity`:图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
* `opacity`:图形透明度。支持从 `0` 到 `1` 的数字,为 `0` 时不绘制该图形。
|
||||
* `tooltipHighlight`:鼠标悬浮时是否高亮之前的区域。
|
||||
|
||||
## `AxisLabel`
|
||||
|
||||
* `show`:是否显示刻度标签。
|
||||
* `interval`:坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
* `interval`:坐标轴刻度标签的显示间隔,在类目轴中有效。`0`表示显示所有标签,`1`表示隔一个隔显示一个标签,以此类推。
|
||||
* `inside`:刻度标签是否朝内,默认朝外。
|
||||
* `rotate`:刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠。
|
||||
* `margin`:刻度标签与轴线之间的距离。
|
||||
* `color`:刻度标签文字的颜色,默认取主题Theme的axisTextColor。
|
||||
* `color`:刻度标签文字的颜色,默认取主题`Theme`的`axisTextColor`。
|
||||
* `fontSize`:文字的字体大小。
|
||||
* `fontStyle`:文字字体的风格。
|
||||
* `formatter`:图例内容字符串模版格式器。支持用 \n 换行。模板变量为图例名称 {value},支持{value:f0},{value:f1},{value:f2}。
|
||||
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||
* `formatter`:图例内容字符串模版格式器。支持用 `\n` 换行。模板变量为图例名称 `{value}`,数值格式化通过`numericFormatter`。
|
||||
* `numericFormatter`:标准数字格式字符串。用于将数值格式化显示为字符串。使用`Axx`的形式:`A`是格式说明符的单字符,支持`C`货币、`D`十进制、`E`指数、`F`顶点数、`G`常规、`N`数字、`P`百分比、`R`往返过程、`X`十六进制等九种。`xx`是精度说明,从`0`-`99`。
|
||||
* `showAsPositiveNumber`:将负数数值显示为正数。一般和`Serie`的`showAsPositiveNumber`配合使用。
|
||||
* `onZero`:刻度标签显示在`0`刻度上。
|
||||
* `textLimit`:文本自适应 [TextLimit](#TextLimit)。只在类目轴中有效。
|
||||
|
||||
## `AxisLine`
|
||||
|
||||
* `show`:是否显示坐标轴轴线。
|
||||
* `onZero`:X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
||||
* `onZero`: `X` 轴或者 `Y` 轴的轴线是否在另一个轴的 `0` 刻度上,只有在另一个轴为数值轴且包含 `0` 刻度时有效。
|
||||
* `width`:坐标轴线线宽。
|
||||
* `symbol`:是否显示箭头。
|
||||
* `symbolWidth`:箭头宽。
|
||||
@@ -700,7 +752,7 @@
|
||||
## `AxisSplitLine`
|
||||
|
||||
* `show`:是否显示坐标分割线。
|
||||
* `interval`:分割线的显示间隔。0表示显示所有分割线,1表示隔一个隔显示一个分割线,以此类推。
|
||||
* `interval`:分割线的显示间隔。`0` 表示显示所有分割线,`1` 表示隔一个隔显示一个分割线,以此类推。
|
||||
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
|
||||
|
||||
## `AxisSplitArea`
|
||||
@@ -711,9 +763,10 @@
|
||||
## `AxisTick`
|
||||
|
||||
* `show`:是否显示坐标轴刻度。
|
||||
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
||||
* `alignWithLabel`:类目轴中在 `boundaryGap` 为 `true` 的时候有效,可以保证刻度线和标签对齐。
|
||||
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
||||
* `length`:坐标轴刻度的长度。
|
||||
* `width`:坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
|
||||
|
||||
## `Emphasis`
|
||||
|
||||
@@ -733,6 +786,9 @@
|
||||
* `borderColor`:边框的颜色。
|
||||
* `borderWidth`:边框宽。
|
||||
* `opacity`:透明度。
|
||||
* `tooltipFormatter`:提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`。
|
||||
* `numericFormatter`:标准数字格式字符串。用于将数值格式化显示为字符串。使用`Axx`的形式:`A`是格式说明符的单字符,支持`C`货币、`D`十进制、`E`指数、`F`顶点数、`G`常规、`N`数字、`P`百分比、`R`往返过程、`X`十六进制等九种。`xx`是精度说明,从`0`-`99`。此字段优先于`SerieLabel`和`Tooltip`的`numericFormatter`。
|
||||
* `cornerRadius`:圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。支持用0-1的浮点数设置百分比。
|
||||
|
||||
## `LineArrow`
|
||||
|
||||
@@ -757,7 +813,7 @@
|
||||
* `DashDotDot`:双点划线。
|
||||
* `color`:线条颜色。默认和 `serie` 一致。
|
||||
* `width`:线条宽。
|
||||
* `opacity`:线条的透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
* `opacity`:线条的透明度。支持从 `0` 到 `1` 的数字,为 `0` 时不绘制该图形。
|
||||
|
||||
## `Location`
|
||||
|
||||
@@ -781,12 +837,16 @@
|
||||
* `name`:数据项名称。
|
||||
* `selected`:该数据项是否被选中。
|
||||
* `radius`:自定义半径。可用在饼图中自定义某个数据项的半径。
|
||||
* `showIcon`:是否显示图标。
|
||||
* `iconImage`:图标的图片。
|
||||
* `iconColor`:图标颜色。
|
||||
* `iconWidth`:图标宽。
|
||||
* `iconHeight`:图标高。
|
||||
* `iconOffset`:图标偏移。
|
||||
* `iconStyle`:数据项图标样式。
|
||||
* `enableLabel`:是否启用单个数据项的标签设置。
|
||||
* `label`:单个数据项的标签设置。
|
||||
* `enableItemStyle`:是否启用单个数据项的样式。
|
||||
* `itemStyle`:单个数据项的样式设置。
|
||||
* `enableEmphasis`:是否启用单个数据项的高亮样式。
|
||||
* `emphasis`:单个数据项的高亮样式设置。
|
||||
* `enableSymbol`:是否启用单个数据项的标记设置。
|
||||
* `symbol`:单个数据项的标记设置。
|
||||
* `data`:可指定任意维数的数值列表。对于折线图和柱状图,`data`其实是`size`为`2`的数组,`data[0]`是x的编号,`data[1]`是`y`的数值,默认显示`data[1]`。其他图表看需求而定是长度大于`2`的数组。可通过`Serie`的`showDataDimension`指定数据长度。
|
||||
|
||||
## `SerieLabel`
|
||||
|
||||
@@ -797,8 +857,10 @@
|
||||
* `Center`:在中心位置(折线图,柱状图,饼图)。
|
||||
* `Top`:顶部(柱状图)。
|
||||
* `Bottom`:底部(柱状图)。
|
||||
* `formatter`:标签内容字符串模版格式器。支持用 `\n` 换行。模板变量有:`{a}`:系列名;`{b}`:数据名;`{c}`:数据值;`{d}`:百分比。示例:`{b}:{c:f1}`。
|
||||
* `formatter`:标签内容字符串模版格式器。支持用 `\n` 换行。模板变量有:`{a}`:系列名;`{b}`:数据名;`{c}`:数据值;`{d}`:百分比。示例:`{b}:{c}`。
|
||||
* `numericFormatter`:标准数字格式字符串。用于将数值格式化显示为字符串。使用`Axx`的形式:`A`是格式说明符的单字符,支持`C`货币、`D`十进制、`E`指数、`F`顶点数、`G`常规、`N`数字、`P`百分比、`R`往返过程、`X`十六进制等九种。`xx`是精度说明,从`0`-`99`。
|
||||
* `offset`:距离图形元素的偏移。
|
||||
* `autoOffset`:是否开启自动偏移。当开启时,Y的偏移会自动判断曲线的开口来决定向上还是向下偏移。
|
||||
* `color`:自定义文字颜色,默认和系列的颜色一致。
|
||||
* `backgroundColor`:标签的背景色,默认无颜色。
|
||||
* `backgroundWidth`:标签的背景宽度。一般不用指定,不指定时则自动是文字的宽度。
|
||||
@@ -820,14 +882,14 @@
|
||||
* `border`:是否显示边框。
|
||||
* `borderWidth`:边框宽度。
|
||||
* `borderColor`:边框颜色。
|
||||
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||
|
||||
## `SerieSymbol`
|
||||
|
||||
* `show`:是否显示标记。
|
||||
* `type`:标记类型。支持以下六种类型:
|
||||
* `EmptyCircle`:空心圆。
|
||||
* `Circle`:实心圆。
|
||||
* `Rect`:正方形。
|
||||
* `Rect`:正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
|
||||
* `Triangle`:三角形。
|
||||
* `Diamond`:菱形。
|
||||
* `None`:不显示标记。
|
||||
@@ -846,7 +908,7 @@
|
||||
* `color`:标记图形的颜色,默认和系列一致。
|
||||
* `opacity`:图形标记的透明度。
|
||||
* `startIndex`:开始显示图形标记的索引。
|
||||
* `interval`:显示图形标记的间隔。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
* `interval`:显示图形标记的间隔。`0`表示显示所有标签,`1`表示隔一个隔显示一个标签,以此类推。
|
||||
* `forceShowLast`:是否强制显示最后一个图形标记。默认为 `false`。
|
||||
|
||||
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
|
||||
|
||||
@@ -20,14 +20,18 @@
|
||||
[QA 14:如何在数据项顶上显示文本?](#如何在数据项顶上显示文本)
|
||||
[QA 15:如何给数据项自定义图标?](#如何给数据项自定义图标)
|
||||
[QA 16:锯齿太严重,如何让图表更顺滑?](#锯齿太严重,如何让图表更顺滑)
|
||||
[QA 17:为什么鼠标移上图表Tooltip不显示?](#为什么鼠标移上图表`Tooltip`不显示)
|
||||
[QA 18:如何取消Tooltip的竖线?](#如何取消`Tooltip`的竖线)
|
||||
[QA 19:如何让Y轴(数值轴)显示多位小数?](#如何让Y轴(数值轴)显示多位小数)
|
||||
[QA 20:如何用代码动态更新数据?](#如何用代码动态更新数据)
|
||||
[QA 21:如何显示图例?](#如何显示图例)
|
||||
[QA 22:如何做成预设?](#如何做成预设)
|
||||
[QA 23:如何在图表上画点画线等自定义内容?](#如何在图表上画点画线等自定义内容)
|
||||
[QA 24:如何实现心电图类似的数据移动效果?](#如何实现心电图类似的数据移动效果)
|
||||
[QA 17:为什么鼠标移上图表 Tooltip 不显示?](#为什么鼠标移上图表`Tooltip`不显示)
|
||||
[QA 18:如何取消 Tooltip 的竖线?](#如何取消`Tooltip`的竖线)
|
||||
[QA 19:如何自定义 Tooltip 的显示内容?](#如何自定义`Tooltip`的显示内容)
|
||||
[QA 20:如何让Y轴(数值轴)显示多位小数?](#如何让Y轴(数值轴)显示多位小数)
|
||||
[QA 21:如何用代码动态更新数据?](#如何用代码动态更新数据)
|
||||
[QA 22:如何显示图例?为什么有时候图例无法显示?](#如何显示图例?为什么有时候图例无法显示)
|
||||
[QA 23:如何做成预设?](#如何做成预设)
|
||||
[QA 24:如何在图表上画点画线等自定义内容?](#如何在图表上画点画线等自定义内容)
|
||||
[QA 25:如何实现心电图类似的数据移动效果?](#如何实现心电图类似的数据移动效果)
|
||||
[QA 26:如何使用背景组件?有什么条件限制?](#如何使用背景组件?有什么条件限制)
|
||||
[QA 27:Mesh can not have more than 65000 vertices?](#Mesh_cannot_have_more_than_65000_vertices)
|
||||
[QA 28:为什么serie里设置的参数运行后又被重置了?](#为什么serie里设置的参数运行后又被重置了)
|
||||
|
||||
## 如何调整坐标轴与背景的边距
|
||||
|
||||
@@ -43,7 +47,7 @@
|
||||
|
||||
## 如何格式化文字,如我想给坐标轴标签加上单位
|
||||
|
||||
答:通过`formatter`参数,在`Legend`、`Axis`的`AxisLabel`、`Tooltop`、`Serie`的`Label`都提供改参数的配置。
|
||||
答:通过`formatter`和`numericFormatter`参数,在`Legend`、`Axis`的`AxisLabel`、`Tooltop`、`Serie`的`Label`都提供该参数的配置。
|
||||
|
||||
## 如何让柱形图的柱子堆叠显示
|
||||
|
||||
@@ -59,15 +63,15 @@
|
||||
|
||||
## 如何调整柱形图单个柱子的颜色
|
||||
|
||||
答:目前暂不支持调整单子柱子的颜色,但可以通过两个`serie`同柱不堆叠来实现,通过设置数据项为`0`来达到类似效果。
|
||||
答:可通过调整单个`Data`下的`ItemStyle`调整,也可以通过两个`serie`同柱不堆叠来实现,通过设置数据项为`0`来达到类似效果。
|
||||
|
||||
## 如何调整图表的对齐方式
|
||||
|
||||
答:默认为左下角对齐,暂不支持调整。可以通过包一层parent来辅助控制。
|
||||
答:默认为左下角对齐,暂不支持调整。可以通过包一层parent来辅助控制。(最新版本`1.5.0`及以上已支持任意锚点,可和做UI一样任意调整对其方式)。
|
||||
|
||||
## 可以显示超过1000以上的大数据吗
|
||||
|
||||
答:可以。但`UGUI`对单个`Graphic`限制`65000`个顶点,所以太多的数据不一定能显示完全。可通过设置采样距离`sampleDist`开启采样简化过密曲线。也可以通过设置一些参数来减少图表的顶点数有助于显示更多数据。如缩小图表的尺寸,关闭或减少坐标轴的客户端绘制,关闭`Serie`的`symbol`和`label`显示等。折线图的普通线图`Normal`比平滑线图`Smooth`占用顶点数更少。
|
||||
答:可以。但`UGUI`对单个`Graphic`限制`65000`个顶点,所以太多的数据不一定能显示完全。可通过设置采样距离`sampleDist`开启采样简化过密曲线。也可以通过设置一些参数来减少图表的顶点数有助于显示更多数据。如缩小图表的尺寸,关闭或减少坐标轴的客户端绘制,关闭`Serie`的`symbol`和`label`显示等。折线图的普通线图`Normal`比平滑线图`Smooth`占用顶点数更少。`1.5.0`以上版本可以设置`large`和`largeThreshold`参数来开启性能模式。
|
||||
|
||||
## 折线图可以画虚线、点线、点划线吗
|
||||
|
||||
@@ -91,7 +95,7 @@
|
||||
|
||||
## 锯齿太严重,如何让图表更顺滑
|
||||
|
||||
答:开启抗锯齿设置。调整UI渲染模式为Camera模式,开启MSAA,设置4倍或更高抗锯齿。锯齿只能减少难以避免,像素越高锯齿越不明显。
|
||||
答:开启抗锯齿设置(在`Unity`里设置)。调整UI渲染模式为`Camera`模式,开启`MSAA`,设置`4`倍或更高抗锯齿。锯齿只能减少难以避免,像素越高锯齿越不明显。
|
||||
|
||||
## 为什么鼠标移上图表`Tooltip`不显示
|
||||
|
||||
@@ -99,19 +103,23 @@
|
||||
|
||||
## 如何取消`Tooltip`的竖线
|
||||
|
||||
答:设置`Tooltip`的`type`为`None`。
|
||||
答:设置`Tooltip`的`type`为`None`。或者调整`lineStyle`的参数。
|
||||
|
||||
## 如何自定义`Tooltip`的显示内容
|
||||
|
||||
答:自定义总的内容可以通过`Tooltip`的`formatter`。如果只是想调整所有的`serie`的显示格式可以用`itemFormatter`和`titleFormatter`结合。如果想每个`serie`的显示格式不一样,可以定制`serie`的`itemStyle`里的`tooltipFormatter`。具体的用法请查阅[XCharts配置项手册](XCharts配置项手册.md)。
|
||||
|
||||
## 如何让Y轴(数值轴)显示多位小数
|
||||
|
||||
答:设置`Axis`下的`AxisLabel`中的`formatter`为`{value:f1}`或`{value:f2}`
|
||||
答:设置`Axis`下的`AxisLabel`中的`formatter`为`{value:f1}`或`{value:f2}`。`1.5.0`及以上版本通过`numericFormatter`设置。
|
||||
|
||||
## 如何用代码动态更新数据
|
||||
|
||||
答:请查阅`Demo`下的代码,`Demo10_LineSimple.cs`就是一个简单添加数据构建折线图的例子,其他`Demo`也都是通过代码控制不同的组件实现不同的功能。
|
||||
答:请查阅`Example`下的代码,`Example13_LineSimple.cs`就是一个简单添加数据构建折线图的例子,其他`Demo`也都是通过代码控制不同的组件实现不同的功能,相关API请查看文档:[XChartsAPI接口](XChartsAPI.md) 。
|
||||
|
||||
## 如何显示图例
|
||||
## 如何显示图例?为什么有时候图例无法显示
|
||||
|
||||
答:首先,你的`serie`里的`name`需有值不为空。然后开启`Legend`显示,里面的`data`可以默认为空,表示显示所有的图例。如果你只想显示部分`serie`的图例,在`data`中填入要显示的图例即可。
|
||||
答:首先,你的`serie`里的`name`需有值不为空。然后开启`Legend`显示,里面的`data`可以默认为空,表示显示所有的图例。如果你只想显示部分`serie`的图例,在`data`中填入要显示的图例的`name`即可。如果`data`中的值都不是系列的`name`,那图例就不会显示。
|
||||
|
||||
## 如何做成预设
|
||||
|
||||
@@ -119,11 +127,27 @@
|
||||
|
||||
## 如何在图表上画点画线等自定义内容
|
||||
|
||||
答:xcharts有自定义绘制回调`customDrawCallback`,具体可参考`Demo12_CustomDrawing.cs`
|
||||
答:`XCharts`有自定义绘制回调`onCustomDraw`,具体可参考`Example12_CustomDrawing.cs`
|
||||
|
||||
## 如何实现心电图类似的数据移动效果
|
||||
|
||||
答:axis和serie都设置相同的maxCache。maxCache可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
|
||||
答:参考`Example`目录下的`Example_Dynamic.cs`。主要通过设置`maxCache`参数实现。`axis`和`serie`都设置相同的`maxCache`。`maxCache`可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
|
||||
|
||||
## 如何使用背景组件?有什么条件限制
|
||||
|
||||
答:设置`background`组件的`show`为`true`,但不一定就能激活背景组件。由于框架的局限性,背景组件有两个前提条件:一是图表的父节点不能用布局控制,因为背景组件和图表的节点关系是并行的,用了布局控制背景组件的位置就无法控制。二是图表的父节点只能有图表自己一个子节点,这是方便管理背景组件节点的需要,要不然并行关系的原因,容易错乱对不上。另外,调整图表的层级关系时最好先隐藏背景组件,这是会自动删除关联的背景组件节点。
|
||||
|
||||
## 区域折线图在用半透明颜色时有时候会一条叠加的线
|
||||
|
||||
答:这是区域折线图绘制的bug。可以用浅的不透的颜色替代半透明颜色。
|
||||
|
||||
## Mesh_cannot_have_more_than_65000_vertices
|
||||
|
||||
答:这是`UGUI`对单个`Graphic`的顶点数限制。`XCharts`是将图形绘制在单个`Graphic`上,所以也会有这个限制。解决的办法可以参考:[QA 10:可以显示超过1000以上的大数据吗?](#可以显示超过1000以上的大数据吗)
|
||||
|
||||
## 为什么serie里设置的参数运行后又被重置了
|
||||
|
||||
答:检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。
|
||||
|
||||
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
|
||||
[XChartsAPI接口](XChartsAPI.md)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
/******************************************/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Text;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -22,25 +24,33 @@ namespace XCharts
|
||||
protected SerializedProperty m_ChartHeight;
|
||||
protected SerializedProperty m_Theme;
|
||||
protected SerializedProperty m_ThemeInfo;
|
||||
protected SerializedProperty m_Background;
|
||||
protected SerializedProperty m_Title;
|
||||
protected SerializedProperty m_Legend;
|
||||
protected SerializedProperty m_Tooltip;
|
||||
protected SerializedProperty m_Series;
|
||||
protected SerializedProperty m_Settings;
|
||||
protected SerializedProperty m_Large;
|
||||
protected SerializedProperty m_ChartName;
|
||||
protected SerializedProperty m_DebugMode;
|
||||
|
||||
protected float m_DefaultLabelWidth;
|
||||
protected float m_DefaultFieldWidth;
|
||||
private int m_SeriesSize;
|
||||
private Vector2 scrollPos;
|
||||
private bool m_CheckWarning = false;
|
||||
private StringBuilder sb = new StringBuilder();
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_Target = (BaseChart)target;
|
||||
m_Script = serializedObject.FindProperty("m_Script");
|
||||
m_ChartName = serializedObject.FindProperty("m_ChartName");
|
||||
m_ChartWidth = serializedObject.FindProperty("m_ChartWidth");
|
||||
m_ChartHeight = serializedObject.FindProperty("m_ChartHeight");
|
||||
m_Theme = serializedObject.FindProperty("m_Theme");
|
||||
m_ThemeInfo = serializedObject.FindProperty("m_ThemeInfo");
|
||||
m_Background = serializedObject.FindProperty("m_Background");
|
||||
m_Title = serializedObject.FindProperty("m_Title");
|
||||
m_Legend = serializedObject.FindProperty("m_Legend");
|
||||
m_Tooltip = serializedObject.FindProperty("m_Tooltip");
|
||||
@@ -48,6 +58,7 @@ namespace XCharts
|
||||
|
||||
m_Large = serializedObject.FindProperty("m_Large");
|
||||
m_Settings = serializedObject.FindProperty("m_Settings");
|
||||
m_DebugMode = serializedObject.FindProperty("m_DebugMode");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@@ -65,15 +76,26 @@ namespace XCharts
|
||||
OnMiddleInspectorGUI();
|
||||
OnEndInspectorGUI();
|
||||
|
||||
CheckWarning();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
protected virtual void OnStartInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_Script);
|
||||
EditorGUILayout.PropertyField(m_ChartWidth);
|
||||
EditorGUILayout.PropertyField(m_ChartHeight);
|
||||
|
||||
EditorGUILayout.PropertyField(m_ChartName);
|
||||
EditorGUILayout.PropertyField(m_ThemeInfo, true);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(m_Background, true);
|
||||
|
||||
var m_Show = m_Background.FindPropertyRelative("m_Show");
|
||||
if (m_Show.boolValue && !m_Target.CanShowBackgroundComponent())
|
||||
{
|
||||
var msg = "The background component cannot be activated because chart is controlled by LayoutGroup,"
|
||||
+ " or its parent have more than one child.";
|
||||
EditorGUILayout.HelpBox(msg, MessageType.Error);
|
||||
}
|
||||
EditorGUILayout.PropertyField(m_Title, true);
|
||||
EditorGUILayout.PropertyField(m_Legend, true);
|
||||
EditorGUILayout.PropertyField(m_Tooltip, true);
|
||||
@@ -87,6 +109,54 @@ namespace XCharts
|
||||
|
||||
protected virtual void OnEndInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.PropertyField(m_DebugMode);
|
||||
}
|
||||
|
||||
private void CheckWarning()
|
||||
{
|
||||
if (GUILayout.Button("Check XCharts Update "))
|
||||
{
|
||||
CheckVersionEditor.ShowWindow();
|
||||
}
|
||||
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();
|
||||
sb.Length = 0;
|
||||
sb.AppendFormat("version:{0}", XChartsMgr.Instance.nowVersion);
|
||||
if (!string.IsNullOrEmpty(m_Target.warningInfo))
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.Append(m_Target.warningInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine();
|
||||
sb.Append("Perfect! No warning!");
|
||||
}
|
||||
EditorGUILayout.HelpBox(sb.ToString(), MessageType.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button("Check warning"))
|
||||
{
|
||||
m_CheckWarning = true;
|
||||
m_Target.CheckWarning();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ namespace XCharts
|
||||
private Vector2 scrollPos;
|
||||
private static CheckVersionEditor window;
|
||||
|
||||
[MenuItem("Component/XCharts/Check For Update")]
|
||||
private static void ShowWindow()
|
||||
[MenuItem("XCharts/Check For Update")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
window = GetWindow<CheckVersionEditor>();
|
||||
window.titleContent = new GUIContent("XCharts Check For Update");
|
||||
@@ -25,6 +25,11 @@ namespace XCharts
|
||||
XChartsMgr.Instance.CheckVersion();
|
||||
}
|
||||
|
||||
void OnInspectorUpdate()
|
||||
{
|
||||
Repaint();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
var mgr = XChartsMgr.Instance;
|
||||
@@ -32,46 +37,70 @@ namespace XCharts
|
||||
GUILayout.Label("当前版本:" + mgr.nowVersion);
|
||||
if (mgr.needUpdate && !mgr.isCheck)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("最新版本:" + mgr.newVersion);
|
||||
GUILayout.Label("");
|
||||
if (mgr.isCheck) GUILayout.Label("检测中...");
|
||||
else GUILayout.Label("有更新!");
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
else if (mgr.isNetworkError) GUILayout.Label("检测失败:" + mgr.networkError);
|
||||
else
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
GUILayout.Label("有更新!");
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Label("");
|
||||
if (!string.IsNullOrEmpty(mgr.desc))
|
||||
{
|
||||
GUILayout.Label(mgr.desc);
|
||||
GUILayout.Label("");
|
||||
}
|
||||
|
||||
scrollPos = GUILayout.BeginScrollView(scrollPos);
|
||||
GUILayout.TextArea(mgr.changeLog);
|
||||
GUILayout.EndScrollView();
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
}
|
||||
if (GUILayout.Button("点Star支持"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
|
||||
}
|
||||
if (GUILayout.Button("问题反馈"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mgr.changeLog))
|
||||
{
|
||||
scrollPos = GUILayout.BeginScrollView(scrollPos);
|
||||
GUILayout.TextArea(mgr.changeLog);
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
}
|
||||
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 (GUILayout.Button("去Github主页"))
|
||||
{
|
||||
Application.OpenURL(mgr.homepage);
|
||||
}
|
||||
}
|
||||
GUILayout.Label("");
|
||||
if (!string.IsNullOrEmpty(mgr.desc))
|
||||
{
|
||||
GUILayout.Label(mgr.desc);
|
||||
}
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
}
|
||||
if (GUILayout.Button("点Star支持"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
|
||||
}
|
||||
if (GUILayout.Button("问题反馈"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
|
||||
}
|
||||
if (mgr.isNetworkError && GUILayout.Button("重新检测"))
|
||||
{
|
||||
XChartsMgr.Instance.CheckVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
/******************************************/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -38,8 +39,14 @@ namespace XCharts
|
||||
protected override void OnStartInspectorGUI()
|
||||
{
|
||||
base.OnStartInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_DataZoom);
|
||||
EditorGUILayout.PropertyField(m_VisualMap);
|
||||
if (m_Target is LineChart || m_Target is BarChart)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_DataZoom);
|
||||
}
|
||||
if (m_Target is HeatmapChart)
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_VisualMap);
|
||||
}
|
||||
EditorGUILayout.PropertyField(m_Grid);
|
||||
for (int i = 0; i < m_XAxises.arraySize; i++)
|
||||
{
|
||||
@@ -52,5 +59,19 @@ namespace XCharts
|
||||
EditorGUILayout.PropertyField(axis);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
CovertXYAxis();
|
||||
}
|
||||
|
||||
private void CovertXYAxis()
|
||||
{
|
||||
if (GUILayout.Button("Covert XY Axis"))
|
||||
{
|
||||
(m_Target as CoordinateChart).CovertXYAxis(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,9 @@ namespace XCharts
|
||||
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_Threshold = prop.FindPropertyRelative("m_Threshold");
|
||||
SerializedProperty m_ActualDuration = prop.FindPropertyRelative("m_ActualDuration");
|
||||
SerializedProperty m_FadeOutDelay = prop.FindPropertyRelative("m_FadeOutDelay");
|
||||
// SerializedProperty m_CurrDetailProgress = prop.FindPropertyRelative("m_CurrDetailProgress");
|
||||
// SerializedProperty m_DestDetailProgress = prop.FindPropertyRelative("m_DestDetailProgress");
|
||||
|
||||
@@ -40,15 +41,18 @@ namespace XCharts
|
||||
++EditorGUI.indentLevel;
|
||||
//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.PropertyField(drawRect, m_Threshold);
|
||||
// if (m_Threshold.intValue < 0) m_Threshold.intValue = 0;
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FadeInDelay);
|
||||
if (m_FadeInDelay.floatValue < 0) m_FadeInDelay.floatValue = 0;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FadeInDuration);
|
||||
if (m_FadeInDuration.floatValue < 0) m_FadeInDuration.floatValue = 0;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FadeOutDelay);
|
||||
if (m_FadeOutDelay.floatValue < 0) m_FadeOutDelay.floatValue = 0;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FadeOutDuration);
|
||||
if (m_FadeOutDuration.floatValue < 0) m_FadeOutDuration.floatValue = 0;
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace XCharts
|
||||
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");
|
||||
SerializedProperty m_Inverse = prop.FindPropertyRelative("m_Inverse");
|
||||
|
||||
int index = InitToggle(prop);
|
||||
bool toggle = m_AxisModuleToggle[index];
|
||||
@@ -87,8 +89,11 @@ namespace XCharts
|
||||
EditorGUI.indentLevel--;
|
||||
break;
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_CeilRate);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Inverse);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Interval);
|
||||
@@ -168,7 +173,7 @@ namespace XCharts
|
||||
}
|
||||
else if (type == Axis.AxisType.Value)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
||||
if (m_MinMaxType.enumValueIndex == (int)Axis.AxisMinMaxType.Custom)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,9 @@ namespace XCharts
|
||||
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
||||
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||
SerializedProperty m_NumericFormatter = prop.FindPropertyRelative("m_NumericFormatter");
|
||||
SerializedProperty m_ShowAsPositiveNumber = prop.FindPropertyRelative("m_ShowAsPositiveNumber");
|
||||
SerializedProperty m_OnZero = prop.FindPropertyRelative("m_OnZero");
|
||||
SerializedProperty m_TextLimit = prop.FindPropertyRelative("m_TextLimit");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLabelToggle, prop, "Axis Label", show, false);
|
||||
@@ -37,6 +39,8 @@ namespace XCharts
|
||||
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_OnZero);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Inside);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Interval);
|
||||
@@ -53,7 +57,9 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Formatter);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||
EditorGUI.PropertyField(drawRect, m_NumericFormatter);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_TextLimit);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_TextLimit);
|
||||
@@ -66,7 +72,7 @@ namespace XCharts
|
||||
float height = 0;
|
||||
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
||||
{
|
||||
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 12 * EditorGUIUtility.singleLineHeight + 11 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextLimit"));
|
||||
}
|
||||
return height;
|
||||
|
||||
@@ -66,7 +66,8 @@ namespace XCharts
|
||||
float height = 0;
|
||||
if (ChartEditorHelper.IsToggle(m_AxisNameToggle, prop))
|
||||
{
|
||||
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
67
Assets/XCharts/Editor/PropertyDrawers/BackgroundDrawer.cs
Normal file
67
Assets/XCharts/Editor/PropertyDrawers/BackgroundDrawer.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Background), true)]
|
||||
public class BackgroundDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_BackgroundModuleToggle = false;
|
||||
|
||||
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_Image = prop.FindPropertyRelative("m_Image");
|
||||
SerializedProperty m_ImageType = prop.FindPropertyRelative("m_ImageType");
|
||||
// SerializedProperty m_Left = prop.FindPropertyRelative("m_Left");
|
||||
// SerializedProperty m_Right = prop.FindPropertyRelative("m_Right");
|
||||
// SerializedProperty m_Top = prop.FindPropertyRelative("m_Top");
|
||||
// SerializedProperty m_Bottom = prop.FindPropertyRelative("m_Bottom");
|
||||
SerializedProperty m_ImageColor = prop.FindPropertyRelative("m_ImageColor");
|
||||
SerializedProperty m_HideThemeBackgroundColor = prop.FindPropertyRelative("m_HideThemeBackgroundColor");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_BackgroundModuleToggle, "Background", m_Show);
|
||||
EditorGUI.LabelField(drawRect, "Background", EditorStyles.boldLabel);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_BackgroundModuleToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.PropertyField(drawRect, m_Image);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ImageType);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Left);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Right);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Top);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, m_Bottom);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ImageColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_HideThemeBackgroundColor);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
if (m_BackgroundModuleToggle)
|
||||
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
else
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfc9b72c568f74d1dbf37310311aac8e
|
||||
guid: 24e3f8609cdf9494cb350a110566176f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -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,6 +24,7 @@ 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");
|
||||
@@ -30,6 +33,9 @@ namespace XCharts
|
||||
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_NumericFormatter = prop.FindPropertyRelative("m_NumericFormatter");
|
||||
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))
|
||||
@@ -37,6 +43,8 @@ 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);
|
||||
@@ -53,6 +61,16 @@ 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;
|
||||
EditorGUI.PropertyField(drawRect, m_NumericFormatter);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +80,12 @@ namespace XCharts
|
||||
float height = 0;
|
||||
if (ChartEditorHelper.IsToggle(m_ItemStyleToggle, prop))
|
||||
{
|
||||
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 14 * EditorGUIUtility.singleLineHeight + 13 * EditorGUIUtility.standardVerticalSpacing;
|
||||
var m_CornerRadius = prop.FindPropertyRelative("m_CornerRadius");
|
||||
if (ChartEditorHelper.IsToggle(m_CornerRadiusToggle, m_CornerRadius))
|
||||
{
|
||||
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -25,69 +25,78 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, align, new GUIContent("Location"));
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
++EditorGUI.indentLevel;
|
||||
switch ((Location.Align)align.enumValueIndex)
|
||||
{
|
||||
case Location.Align.TopCenter:
|
||||
EditorGUI.PropertyField(drawRect, top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.TopLeft:
|
||||
EditorGUI.PropertyField(drawRect, top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.TopRight:
|
||||
EditorGUI.PropertyField(drawRect, top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.BottomCenter:
|
||||
EditorGUI.PropertyField(drawRect, bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.BottomLeft:
|
||||
EditorGUI.PropertyField(drawRect, bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.BottomRight:
|
||||
EditorGUI.PropertyField(drawRect, bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.Center:
|
||||
break;
|
||||
case Location.Align.CenterLeft:
|
||||
EditorGUI.PropertyField(drawRect, left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case Location.Align.CenterRight:
|
||||
EditorGUI.PropertyField(drawRect, right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, top);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, bottom);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, left);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, right);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// switch ((Location.Align)align.enumValueIndex)
|
||||
// {
|
||||
// case Location.Align.TopCenter:
|
||||
// EditorGUI.PropertyField(drawRect, top);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// case Location.Align.TopLeft:
|
||||
// EditorGUI.PropertyField(drawRect, top);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, left);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// case Location.Align.TopRight:
|
||||
// EditorGUI.PropertyField(drawRect, top);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, right);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// case Location.Align.BottomCenter:
|
||||
// EditorGUI.PropertyField(drawRect, bottom);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// case Location.Align.BottomLeft:
|
||||
// EditorGUI.PropertyField(drawRect, bottom);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, left);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// case Location.Align.BottomRight:
|
||||
// EditorGUI.PropertyField(drawRect, bottom);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// EditorGUI.PropertyField(drawRect, right);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// case Location.Align.Center:
|
||||
// break;
|
||||
// case Location.Align.CenterLeft:
|
||||
// EditorGUI.PropertyField(drawRect, left);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// case Location.Align.CenterRight:
|
||||
// EditorGUI.PropertyField(drawRect, right);
|
||||
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
// break;
|
||||
// }
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
SerializedProperty align = prop.FindPropertyRelative("m_Align");
|
||||
switch ((Location.Align)align.enumValueIndex)
|
||||
{
|
||||
case Location.Align.Center:
|
||||
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
case Location.Align.TopCenter:
|
||||
case Location.Align.BottomCenter:
|
||||
case Location.Align.CenterLeft:
|
||||
case Location.Align.CenterRight:
|
||||
return 2 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||
default:
|
||||
return 3 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
// SerializedProperty align = prop.FindPropertyRelative("m_Align");
|
||||
// switch ((Location.Align)align.enumValueIndex)
|
||||
// {
|
||||
// case Location.Align.Center:
|
||||
// return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
// case Location.Align.TopCenter:
|
||||
// case Location.Align.BottomCenter:
|
||||
// case Location.Align.CenterLeft:
|
||||
// case Location.Align.CenterRight:
|
||||
// return 2 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||
// default:
|
||||
// return 3 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ namespace XCharts
|
||||
SerializedProperty m_SplitArea;
|
||||
SerializedProperty m_Indicator;
|
||||
SerializedProperty m_IndicatorGap;
|
||||
SerializedProperty m_CeilRate;
|
||||
SerializedProperty m_IndicatorList;
|
||||
|
||||
private Dictionary<string, bool> m_RadarModuleToggle = new Dictionary<string, bool>();
|
||||
@@ -43,6 +44,7 @@ namespace XCharts
|
||||
m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
||||
m_Indicator = prop.FindPropertyRelative("m_Indicator");
|
||||
m_IndicatorGap = prop.FindPropertyRelative("m_IndicatorGap");
|
||||
m_CeilRate = prop.FindPropertyRelative("m_CeilRate");
|
||||
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
|
||||
}
|
||||
|
||||
@@ -72,10 +74,7 @@ namespace XCharts
|
||||
var tempWidth = (pos.width - startX + 35) / 2;
|
||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
||||
var centerYRect = new Rect(centerXRect.x + tempWidth - 20, drawRect.y, tempWidth, drawRect.height);
|
||||
while (m_Center.arraySize < 2)
|
||||
{
|
||||
m_Center.InsertArrayElementAtIndex(m_Center.arraySize);
|
||||
}
|
||||
while (m_Center.arraySize < 2) m_Center.arraySize++;
|
||||
EditorGUI.PropertyField(centerXRect, m_Center.GetArrayElementAtIndex(0), GUIContent.none);
|
||||
EditorGUI.PropertyField(centerYRect, m_Center.GetArrayElementAtIndex(1), GUIContent.none);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
@@ -84,6 +83,8 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_CeilRate);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_SplitLine);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
|
||||
@@ -109,7 +110,7 @@ namespace XCharts
|
||||
int propNum = 1;
|
||||
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
|
||||
{
|
||||
propNum += 7;
|
||||
propNum += 8;
|
||||
if (m_IndicatorJsonAreaToggle) propNum += 4;
|
||||
float height = propNum * EditorGUIUtility.singleLineHeight + (propNum - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitLine"));
|
||||
|
||||
@@ -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");
|
||||
@@ -73,6 +74,10 @@ namespace XCharts
|
||||
SerializedProperty m_Clip = prop.FindPropertyRelative("m_Clip");
|
||||
SerializedProperty m_Ignore = prop.FindPropertyRelative("m_Ignore");
|
||||
SerializedProperty m_IgnoreValue = prop.FindPropertyRelative("m_IgnoreValue");
|
||||
SerializedProperty m_ShowAsPositiveNumber = prop.FindPropertyRelative("m_ShowAsPositiveNumber");
|
||||
SerializedProperty m_Large = prop.FindPropertyRelative("m_Large");
|
||||
SerializedProperty m_LargeThreshold = prop.FindPropertyRelative("m_LargeThreshold");
|
||||
SerializedProperty m_AvoidLabelOverlap = prop.FindPropertyRelative("m_AvoidLabelOverlap");
|
||||
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
||||
|
||||
int index = InitToggle(prop);
|
||||
@@ -80,8 +85,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;
|
||||
}
|
||||
@@ -128,6 +135,12 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Large);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LargeThreshold);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
@@ -171,12 +184,18 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
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_Ignore);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ShowAsPositiveNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Large);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LargeThreshold);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
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);
|
||||
@@ -191,6 +210,14 @@ namespace XCharts
|
||||
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
|
||||
EditorGUI.PropertyField(drawRect, m_RoundCap);
|
||||
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_AvoidLabelOverlap);
|
||||
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);
|
||||
@@ -217,14 +244,22 @@ namespace XCharts
|
||||
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:
|
||||
@@ -232,12 +267,18 @@ namespace XCharts
|
||||
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);
|
||||
@@ -292,15 +333,22 @@ namespace XCharts
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
float nameWid = 42;
|
||||
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("Other")))
|
||||
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;
|
||||
}
|
||||
@@ -318,10 +366,8 @@ namespace XCharts
|
||||
bool showSelected = (serieType == SerieType.Pie);
|
||||
if (listSize != m_Datas.arraySize)
|
||||
{
|
||||
while (listSize > m_Datas.arraySize)
|
||||
m_Datas.InsertArrayElementAtIndex(m_Datas.arraySize);
|
||||
while (listSize < m_Datas.arraySize)
|
||||
m_Datas.DeleteArrayElementAtIndex(m_Datas.arraySize - 1);
|
||||
while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
|
||||
while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
|
||||
}
|
||||
if (listSize > 30)
|
||||
{
|
||||
@@ -344,6 +390,7 @@ namespace XCharts
|
||||
DrawDataElement(ref drawRect, dimension, m_Datas, showName, showIcon, showSelected, i, pos.width);
|
||||
}
|
||||
}
|
||||
drawRect.y += EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
@@ -367,7 +414,11 @@ namespace XCharts
|
||||
if (fieldCount <= 1)
|
||||
{
|
||||
while (2 > data.arraySize)
|
||||
data.InsertArrayElementAtIndex(data.arraySize);
|
||||
{
|
||||
var value = data.arraySize == 0 ? index : 0;
|
||||
data.arraySize++;
|
||||
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
|
||||
}
|
||||
SerializedProperty element = data.GetArrayElementAtIndex(1);
|
||||
if (showSelected)
|
||||
{
|
||||
@@ -386,16 +437,26 @@ namespace XCharts
|
||||
}
|
||||
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++)
|
||||
{
|
||||
while (i >= data.arraySize - 1)
|
||||
var dataCount = i < 1 ? 2 : i + 1;
|
||||
while (dataCount > data.arraySize)
|
||||
{
|
||||
data.InsertArrayElementAtIndex(data.arraySize);
|
||||
var value = data.arraySize == 0 ? index : 0;
|
||||
data.arraySize++;
|
||||
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
|
||||
}
|
||||
drawRect.x = startX + i * xWid;
|
||||
drawRect.width = dataWid + 40;
|
||||
@@ -405,7 +466,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);
|
||||
}
|
||||
|
||||
@@ -421,12 +482,26 @@ namespace XCharts
|
||||
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");
|
||||
var m_EnableSymbol = serieData.FindPropertyRelative("m_EnableSymbol");
|
||||
var m_Symbol = serieData.FindPropertyRelative("m_Symbol");
|
||||
EditorGUI.PropertyField(drawRect, m_Icon);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Icon);
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
ChartEditorHelper.MakeBool(drawRect, m_EnableSymbol, 1, "(enable)");
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
EditorGUI.PropertyField(drawRect, m_Label);
|
||||
ChartEditorHelper.MakeBool(ref drawRect, m_EnableLabel, 1, "(enable)");
|
||||
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.indentLevel -= 2;
|
||||
}
|
||||
}
|
||||
@@ -435,7 +510,7 @@ 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;
|
||||
}
|
||||
@@ -446,7 +521,7 @@ namespace XCharts
|
||||
switch (serieType)
|
||||
{
|
||||
case SerieType.Line:
|
||||
height += 16 * EditorGUIUtility.singleLineHeight + 15 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 19 * EditorGUIUtility.singleLineHeight + 18 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||
@@ -457,15 +532,15 @@ namespace XCharts
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||
break;
|
||||
case SerieType.Bar:
|
||||
height += 17 * EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 21 * EditorGUIUtility.singleLineHeight + 20 * EditorGUIUtility.standardVerticalSpacing;
|
||||
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.Pie:
|
||||
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 12 * EditorGUIUtility.singleLineHeight + 11 * 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"));
|
||||
@@ -479,10 +554,12 @@ namespace XCharts
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||
break;
|
||||
case SerieType.Radar:
|
||||
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
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;
|
||||
@@ -490,12 +567,13 @@ namespace XCharts
|
||||
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 += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
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"));
|
||||
@@ -526,14 +604,17 @@ namespace XCharts
|
||||
{
|
||||
height += (num) * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
if (prop.FindPropertyRelative("m_ShowDataIcon").boolValue)
|
||||
{
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
var item = m_Data.GetArrayElementAtIndex(i);
|
||||
//height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_IconStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Symbol"));
|
||||
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Label"));
|
||||
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_ItemStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(item.FindPropertyRelative("m_Emphasis"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace XCharts
|
||||
SerializedProperty m_Border = prop.FindPropertyRelative("m_Border");
|
||||
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
||||
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
|
||||
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||
SerializedProperty m_NumericFormatter = prop.FindPropertyRelative("m_NumericFormatter");
|
||||
SerializedProperty m_AutoOffset = prop.FindPropertyRelative("m_AutoOffset");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieLabelToggle, prop, null, show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
@@ -53,21 +54,17 @@ 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_AutoOffset);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
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_NumericFormatter);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Color);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
|
||||
@@ -104,8 +101,6 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_LineLength2);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
@@ -116,6 +111,7 @@ namespace XCharts
|
||||
if (ChartEditorHelper.IsToggle(m_SerieLabelToggle, prop))
|
||||
{
|
||||
height += 24 * EditorGUIUtility.singleLineHeight + 23 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace XCharts
|
||||
{
|
||||
Rect drawRect = pos;
|
||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
||||
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty m_SizeType = prop.FindPropertyRelative("m_SizeType");
|
||||
SerializedProperty m_Size = prop.FindPropertyRelative("m_Size");
|
||||
@@ -27,19 +28,19 @@ 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);
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieSymbolToggle, prop, null, m_Show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (ChartEditorHelper.IsToggle(m_SerieSymbolToggle, prop))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
|
||||
EditorGUI.PropertyField(drawRect, m_Type);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Gap);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_SizeType);
|
||||
@@ -64,10 +65,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,16 +81,18 @@ namespace XCharts
|
||||
{
|
||||
SerializedProperty m_SizeType = prop.FindPropertyRelative("m_SizeType");
|
||||
SerieSymbolSizeType sizeType = (SerieSymbolSizeType)m_SizeType.enumValueIndex;
|
||||
var hig = 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||
switch (sizeType)
|
||||
{
|
||||
case SerieSymbolSizeType.Custom:
|
||||
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case SerieSymbolSizeType.FromData:
|
||||
return 11 * EditorGUIUtility.singleLineHeight + 11 * EditorGUIUtility.standardVerticalSpacing;
|
||||
hig += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
case SerieSymbolSizeType.Callback:
|
||||
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||
break;
|
||||
}
|
||||
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||
return hig;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
@@ -318,10 +320,10 @@ namespace XCharts
|
||||
{
|
||||
while (i > m_CustomColorPalette.arraySize - 1)
|
||||
{
|
||||
m_CustomColorPalette.InsertArrayElementAtIndex(m_CustomColorPalette.arraySize);
|
||||
m_CustomColorPalette.arraySize++;
|
||||
}
|
||||
var customElement = m_CustomColorPalette.GetArrayElementAtIndex(i);
|
||||
color = customElement.colorValue != Color.clear ?
|
||||
color = !ChartHelper.IsClearColor(customElement.colorValue) ?
|
||||
customElement :
|
||||
m_ColorPalette.GetArrayElementAtIndex(i);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace XCharts
|
||||
SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight");
|
||||
SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth");
|
||||
SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight");
|
||||
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||
SerializedProperty m_NumericFormatter = prop.FindPropertyRelative("m_NumericFormatter");
|
||||
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
|
||||
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
|
||||
SerializedProperty m_BackgroundImage = prop.FindPropertyRelative("m_BackgroundImage");
|
||||
@@ -49,6 +49,8 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_ItemFormatter);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_NumericFormatter);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FixedWidth);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_FixedHeight);
|
||||
@@ -63,8 +65,6 @@ namespace XCharts
|
||||
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);
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace XCharts
|
||||
|
||||
protected override void OnEndInspectorGUI()
|
||||
{
|
||||
base.OnEndInspectorGUI();
|
||||
EditorGUILayout.PropertyField(m_Radars, true);
|
||||
base.OnEndInspectorGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Assets/XCharts/Editor/RingChartEditor.cs
Normal file
28
Assets/XCharts/Editor/RingChartEditor.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI RingChart.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(RingChart), false)]
|
||||
public class RingChartEditor : BaseChartEditor
|
||||
{
|
||||
protected SerializedProperty m_Radar;
|
||||
protected SerializedProperty m_Radars;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
m_Target = (RingChart)target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6faaaf3d4a8444b4b2736825e237fcf
|
||||
guid: f61a72b23edc44f48884d4989b04c509
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -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)
|
||||
{
|
||||
@@ -21,19 +32,39 @@ public class ChartEditorHelper
|
||||
|
||||
public static void MakeTwoField(ref Rect drawRect, float rectWidth, SerializedProperty arrayProp, string name)
|
||||
{
|
||||
while (arrayProp.arraySize < 2)
|
||||
{
|
||||
arrayProp.InsertArrayElementAtIndex(arrayProp.arraySize);
|
||||
}
|
||||
while (arrayProp.arraySize < 2) arrayProp.arraySize++;
|
||||
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.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 +73,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,27 +123,28 @@ 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);
|
||||
MakeBool(ref drawRect, prop);
|
||||
MakeBool(drawRect, prop);
|
||||
drawRect.width = defaultWidth;
|
||||
drawRect.x = defaultX;
|
||||
return moduleToggle;
|
||||
}
|
||||
|
||||
public static void MakeBool(ref Rect drawRect, SerializedProperty boolProp, int index = 0, string name = null)
|
||||
public static void MakeBool(Rect drawRect, SerializedProperty boolProp, int index = 0, string name = null)
|
||||
{
|
||||
float defaultWidth = drawRect.width;
|
||||
float defaultX = drawRect.x;
|
||||
drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2 + index * 30;
|
||||
drawRect.width = 20 + EditorGUI.indentLevel * 20;
|
||||
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);
|
||||
drawRect.x += 13;
|
||||
drawRect.width = 200;
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
drawRect.x += BOOL_WIDTH;
|
||||
drawRect.width = 200;
|
||||
EditorGUI.LabelField(drawRect, name);
|
||||
}
|
||||
}
|
||||
@@ -117,23 +164,28 @@ public class ChartEditorHelper
|
||||
|
||||
float defaultWidth = drawRect.width;
|
||||
float defaultX = drawRect.x;
|
||||
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
||||
#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 = 100;
|
||||
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);
|
||||
}
|
||||
@@ -142,20 +194,37 @@ 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.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.arraySize++;
|
||||
while (listSize < listProp.arraySize) listProp.arraySize--;
|
||||
}
|
||||
}
|
||||
if (listSize > 30)
|
||||
{
|
||||
@@ -181,8 +250,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--;
|
||||
|
||||
@@ -66,50 +66,62 @@ namespace XCharts
|
||||
chart.transform.SetParent(parent);
|
||||
chart.transform.localScale = Vector3.one;
|
||||
chart.transform.localPosition = Vector3.zero;
|
||||
var rect = chart.GetComponent<RectTransform>();
|
||||
rect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
rect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
rect.pivot = new Vector2(0.5f, 0.5f);
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/LineChart", priority = 44)]
|
||||
[MenuItem("GameObject/XCharts/LineChart", priority = 44)]
|
||||
public static void AddLineChart()
|
||||
{
|
||||
AddChart<LineChart>("LineChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/BarChart", priority = 45)]
|
||||
[MenuItem("GameObject/XCharts/BarChart", priority = 45)]
|
||||
public static void AddBarChart()
|
||||
{
|
||||
AddChart<BarChart>("BarChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/PieChart", priority = 46)]
|
||||
[MenuItem("GameObject/XCharts/PieChart", priority = 46)]
|
||||
public static void AddPieChart()
|
||||
{
|
||||
AddChart<PieChart>("PieChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/RadarChart", priority = 47)]
|
||||
[MenuItem("GameObject/XCharts/RadarChart", priority = 47)]
|
||||
public static void AddRadarChart()
|
||||
{
|
||||
AddChart<RadarChart>("RadarChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/ScatterChart", priority = 48)]
|
||||
[MenuItem("GameObject/XCharts/ScatterChart", priority = 48)]
|
||||
public static void AddScatterChart()
|
||||
{
|
||||
AddChart<ScatterChart>("ScatterChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/HeatmapChart", priority = 49)]
|
||||
[MenuItem("GameObject/XCharts/HeatmapChart", priority = 49)]
|
||||
public static void AddHeatmapChart()
|
||||
{
|
||||
AddChart<HeatmapChart>("HeatmapChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/GaugeChart", priority = 50)]
|
||||
[MenuItem("GameObject/XCharts/GaugeChart", priority = 50)]
|
||||
public static void AddGaugeChart()
|
||||
{
|
||||
AddChart<GaugeChart>("GaugeChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/RingChart", priority = 51)]
|
||||
[MenuItem("GameObject/XCharts/RingChart", priority = 51)]
|
||||
public static void AddRingChart()
|
||||
{
|
||||
|
||||
62
Assets/XCharts/Editor/XChartMgrEditor.cs
Normal file
62
Assets/XCharts/Editor/XChartMgrEditor.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor class used to edit UI XChartsMgr.
|
||||
/// </summary>
|
||||
|
||||
[CustomEditor(typeof(XChartsMgr), false)]
|
||||
public class XChartsMgrEditor : Editor
|
||||
{
|
||||
protected XChartsMgr m_Target;
|
||||
protected SerializedProperty m_Script;
|
||||
protected SerializedProperty m_NowVersion;
|
||||
protected SerializedProperty m_NewVersion;
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_Target = (XChartsMgr)target;
|
||||
m_Script = serializedObject.FindProperty("m_Script");
|
||||
m_NowVersion = serializedObject.FindProperty("m_NowVersion");
|
||||
m_NewVersion = serializedObject.FindProperty("m_NewVersion");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (m_Target == null && target == null)
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
return;
|
||||
}
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_NowVersion);
|
||||
EditorGUILayout.PropertyField(m_NewVersion);
|
||||
if (GUILayout.Button("检测更新"))
|
||||
{
|
||||
CheckVersionEditor.ShowWindow();
|
||||
}
|
||||
if (GUILayout.Button("去Github主页"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts");
|
||||
}
|
||||
if (GUILayout.Button("点Star支持"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/stargazers");
|
||||
}
|
||||
if (GUILayout.Button("问题反馈"))
|
||||
{
|
||||
Application.OpenURL("https://github.com/monitor1394/unity-ugui-XCharts/issues");
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 060e74df53e174634b42ea5f3c852e94
|
||||
guid: 69cbbe551cf1f45c984e6b4febc9f697
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6b0fb015bc6524d8bab146b6f2ba3a
|
||||
guid: 0cfb5d7eeb260491b9d2545237eab7ce
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -9,10 +9,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Demo00_CheatSheet : MonoBehaviour
|
||||
public class Example00_CheatSheet : MonoBehaviour
|
||||
{
|
||||
private LineChart chart;
|
||||
private float speed = 100f;
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce2fe7c8c98c644b9a8585050ea1d963
|
||||
guid: 677b2673e728a4e308f26a5a9b236277
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo01_UpdateData : MonoBehaviour
|
||||
public class Example01_UpdateData : MonoBehaviour
|
||||
{
|
||||
private float updateTime = 0;
|
||||
BaseChart chart;
|
||||
11
Assets/XCharts/Examples/Runtime/Example01_UpdateData.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example01_UpdateData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d369a0cba6716422cb15efa26bef0918
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/XCharts/Examples/Runtime/Example02_ChartEvent.cs
Normal file
64
Assets/XCharts/Examples/Runtime/Example02_ChartEvent.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example02_ChartEvent : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<LineChart>();
|
||||
}
|
||||
chart.onPointerEnter = OnPointerEnter;
|
||||
chart.onPointerExit = OnPointerExit;
|
||||
chart.onPointerDown = OnPointerDown;
|
||||
chart.onPointerUp = OnPointerUp;
|
||||
chart.onPointerClick = OnPointerClick;
|
||||
chart.onScroll = OnScroll;
|
||||
}
|
||||
|
||||
void OnPointerEnter(BaseGraph chart, PointerEventData eventData)
|
||||
{
|
||||
//Debug.LogError("enter:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerExit(BaseGraph chart, PointerEventData eventData)
|
||||
{
|
||||
//Debug.LogError("exit:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerDown(BaseGraph chart, PointerEventData eventData)
|
||||
{
|
||||
//Debug.LogError("down:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerUp(BaseGraph chart, PointerEventData eventData)
|
||||
{
|
||||
//Debug.LogError("up:" + chart);
|
||||
}
|
||||
|
||||
void OnPointerClick(BaseGraph chart, PointerEventData eventData)
|
||||
{
|
||||
//Debug.LogError("click:" + chart);
|
||||
}
|
||||
|
||||
void OnScroll(BaseGraph chart, PointerEventData eventData)
|
||||
{
|
||||
//Debug.LogError("scroll:" + chart);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Examples/Runtime/Example02_ChartEvent.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example02_ChartEvent.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c549dc496cd86467e8286252906562cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/XCharts/Examples/Runtime/Example03_ChartAnimation.cs
Normal file
43
Assets/XCharts/Examples/Runtime/Example03_ChartAnimation.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example03_ChartAnimation : MonoBehaviour
|
||||
{
|
||||
BaseChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<BarChart>();
|
||||
}
|
||||
var serie = chart.series.GetSerie(0);
|
||||
serie.animation.enable = true;
|
||||
//自定义每个数据项的渐入延时
|
||||
serie.animation.customFadeInDelay = CustomFadeInDelay;
|
||||
//自定义每个数据项的渐入时长
|
||||
serie.animation.customFadeInDuration = CustomFadeInDuration;
|
||||
}
|
||||
|
||||
float CustomFadeInDelay(int dataIndex)
|
||||
{
|
||||
return dataIndex * 1000;
|
||||
}
|
||||
|
||||
float CustomFadeInDuration(int dataIndex)
|
||||
{
|
||||
return dataIndex * 1000 + 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6258ca3b055714eac92804f501011b53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,10 +8,10 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Demo10_LineChart : MonoBehaviour
|
||||
public class Example10_LineChart : MonoBehaviour
|
||||
{
|
||||
private LineChart chart;
|
||||
private Serie serie;
|
||||
11
Assets/XCharts/Examples/Runtime/Example10_LineChart.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example10_LineChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6155c7e0df4504ebfaf0c671ae200197
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo11_AddSinCurve : MonoBehaviour
|
||||
public class Example11_AddSinCurve : MonoBehaviour
|
||||
{
|
||||
private float time;
|
||||
public int angle;
|
||||
@@ -46,7 +46,7 @@ namespace XCharts
|
||||
chart.RemoveData();
|
||||
|
||||
var serie = chart.AddSerie(SerieType.Line);
|
||||
serie.symbol.type = SerieSymbolType.None;
|
||||
serie.symbol.show = false;
|
||||
serie.lineType = LineType.Normal;
|
||||
for (angle = 0; angle < 1080; angle++)
|
||||
{
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b380753d3cb4149c4a3a65a1816e0cc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,11 +9,11 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo12_CustomDrawing : MonoBehaviour
|
||||
public class Example12_CustomDrawing : MonoBehaviour
|
||||
{
|
||||
LineChart chart;
|
||||
void Awake()
|
||||
@@ -21,7 +21,7 @@ namespace XCharts
|
||||
chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null) return;
|
||||
|
||||
chart.customDrawCallback = delegate (VertexHelper vh)
|
||||
chart.onCustomDraw = delegate (VertexHelper vh)
|
||||
{
|
||||
var dataPoints = chart.series.list[0].dataPoints;
|
||||
if (dataPoints.Count > 0)
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da550ad36be5f442e96ad021cc10ca68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo13_LineSimple : MonoBehaviour
|
||||
public class Example13_LineSimple : MonoBehaviour
|
||||
{
|
||||
void Awake()
|
||||
{
|
||||
11
Assets/XCharts/Examples/Runtime/Example13_LineSimple.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example13_LineSimple.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6d0f65efd8e14ebdafa172e0ccbd562
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,10 +8,10 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Demo20_BarChart : MonoBehaviour
|
||||
public class Example20_BarChart : MonoBehaviour
|
||||
{
|
||||
private BarChart chart;
|
||||
private Serie serie, serie2;
|
||||
11
Assets/XCharts/Examples/Runtime/Example20_BarChart.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example20_BarChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03916f7ca858b446883197ae17e50f16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,10 +8,10 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Demo30_PieChart : MonoBehaviour
|
||||
public class Example30_PieChart : MonoBehaviour
|
||||
{
|
||||
private PieChart chart;
|
||||
private Serie serie, serie1;
|
||||
11
Assets/XCharts/Examples/Runtime/Example30_PieChart.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example30_PieChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b8649d38981b4b5bbdf16e8f303fa1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
80
Assets/XCharts/Examples/Runtime/Example31_PieUpdateName.cs
Normal file
80
Assets/XCharts/Examples/Runtime/Example31_PieUpdateName.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example31_PieUpdateName : MonoBehaviour
|
||||
{
|
||||
PieChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<PieChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<PieChart>();
|
||||
}
|
||||
var serieIndex = 0;
|
||||
var serie = chart.series.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
serie.label.show = true;
|
||||
serie.label.position = SerieLabel.Position.Outside;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
ClearAndAddData();
|
||||
//UpdateDataName();
|
||||
//UpdateDataName();
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDataName()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.series.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var value = Random.Range(10, 100);
|
||||
chart.UpdateData(serieIndex, i, value);
|
||||
chart.UpdateDataName(serieIndex, i, "value=" + value);
|
||||
}
|
||||
}
|
||||
|
||||
void ResetSameName()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.series.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
chart.UpdateDataName(serieIndex, i, "piename");
|
||||
}
|
||||
}
|
||||
|
||||
void ClearAndAddData()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.series.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
int count = serie.dataCount;
|
||||
serie.ClearData();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
chart.AddData(0, Random.Range(0, 100), "pie" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41195ee7a652f4ef79c22c365d314621
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,10 +9,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class Demo40_Radar : MonoBehaviour
|
||||
public class Example40_Radar : MonoBehaviour
|
||||
{
|
||||
private RadarChart chart;
|
||||
private Serie serie, serie1;
|
||||
11
Assets/XCharts/Examples/Runtime/Example40_Radar.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example40_Radar.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95a60d7e7a0fc41ecaec5f48823b70bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
80
Assets/XCharts/Examples/Runtime/Example41_RadarUpdate.cs
Normal file
80
Assets/XCharts/Examples/Runtime/Example41_RadarUpdate.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Example41_RadarUpdate : MonoBehaviour
|
||||
{
|
||||
RadarChart chart;
|
||||
int count = 0;
|
||||
float max = 0;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<RadarChart>();
|
||||
if (chart == null)
|
||||
{
|
||||
chart = gameObject.AddComponent<RadarChart>();
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
UpdateData();
|
||||
count++;
|
||||
}
|
||||
UpdateMax();
|
||||
}
|
||||
|
||||
void UpdateData()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.series.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
if (serie.radarType == RadarType.Multiple)
|
||||
{
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var serieData = serie.GetSerieData(i);
|
||||
for (int j = 0; j < serieData.data.Count; j++)
|
||||
{
|
||||
var value = Random.Range(10, 100);
|
||||
chart.UpdateData(serieIndex, i, j, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < serie.dataCount; i++)
|
||||
{
|
||||
var value = Random.Range(10, 100);
|
||||
chart.UpdateData(serieIndex, i, value);
|
||||
}
|
||||
}
|
||||
chart.title.subText = "max:" + serie.runtimeDataMax;
|
||||
}
|
||||
|
||||
void UpdateMax()
|
||||
{
|
||||
var serieIndex = 0;
|
||||
var serie = chart.series.GetSerie(serieIndex);
|
||||
if (serie == null) return;
|
||||
if (serie.runtimeDataMax != max)
|
||||
{
|
||||
chart.title.subText = "max:" + serie.runtimeDataMax;
|
||||
max = serie.runtimeDataMax;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a2ad6907bd5045ec920b4f0e359535e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,11 +8,11 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo50_Scatter : MonoBehaviour
|
||||
public class Example50_Scatter : MonoBehaviour
|
||||
{
|
||||
private ScatterChart chart;
|
||||
|
||||
11
Assets/XCharts/Examples/Runtime/Example50_Scatter.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example50_Scatter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6c9b864ab644b45ae93df3878ab1dd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,11 +8,11 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo60_Heatmap : MonoBehaviour
|
||||
public class Example60_Heatmap : MonoBehaviour
|
||||
{
|
||||
private HeatmapChart chart;
|
||||
|
||||
11
Assets/XCharts/Examples/Runtime/Example60_Heatmap.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example60_Heatmap.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e702e0ac05be84dbe9622180d4f6ef71
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo70_Gauge : MonoBehaviour
|
||||
public class Example70_Gauge : MonoBehaviour
|
||||
{
|
||||
private GaugeChart chart;
|
||||
private float updateTime;
|
||||
@@ -47,7 +47,7 @@ namespace XCharts
|
||||
serie.label.offset = new Vector3(0, -20);
|
||||
|
||||
serie.gaugeAxis.show = true;
|
||||
serie.gaugeAxis.axisLine.width = 15;
|
||||
serie.gaugeAxis.axisLine.width = 15;
|
||||
|
||||
serie.gaugePointer.show = true;
|
||||
serie.gaugePointer.width = 15;
|
||||
11
Assets/XCharts/Examples/Runtime/Example70_Gauge.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example70_Gauge.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3a7b70d5b66640dca4aaecf13d3769f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,12 +8,12 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(CoordinateChart))]
|
||||
public class Demo_Dynamic : MonoBehaviour
|
||||
public class Example_Dynamic : MonoBehaviour
|
||||
{
|
||||
public int maxCacheDataNumber = 100;
|
||||
public float initDataTime = 2;
|
||||
@@ -31,7 +31,7 @@ namespace XCharts
|
||||
chart = gameObject.GetComponentInChildren<CoordinateChart>();
|
||||
chart.RemoveData();
|
||||
var serie = chart.AddSerie(SerieType.Line);
|
||||
serie.symbol.type = SerieSymbolType.None;
|
||||
serie.symbol.show = false;
|
||||
serie.maxCache = maxCacheDataNumber;
|
||||
chart.xAxises[0].maxCache = maxCacheDataNumber;
|
||||
timeNow = DateTime.Now;
|
||||
11
Assets/XCharts/Examples/Runtime/Example_Dynamic.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example_Dynamic.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 310037ac5daa645058285cf176cc9eab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(CoordinateChart))]
|
||||
public class Demo_LargeData : MonoBehaviour
|
||||
public class Example_LargeData : MonoBehaviour
|
||||
{
|
||||
public int maxCacheDataNumber = 3000;
|
||||
public float initDataTime = 5;
|
||||
@@ -28,8 +28,7 @@ namespace XCharts
|
||||
timeNow = System.DateTime.Now;
|
||||
chart.ClearAxisData();
|
||||
chart.series.ClearData();
|
||||
chart.series.list[0].maxCache = maxCacheDataNumber;
|
||||
chart.xAxises[0].maxCache = maxCacheDataNumber;
|
||||
chart.SetMaxCache(maxCacheDataNumber);
|
||||
chart.title.text = maxCacheDataNumber + "数据";
|
||||
}
|
||||
|
||||
11
Assets/XCharts/Examples/Runtime/Example_LargeData.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example_LargeData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 188d38c155a804c7d9d31730d3b12885
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(PieChart))]
|
||||
public class Demo_PieChart : MonoBehaviour
|
||||
public class Example_PieChart : MonoBehaviour
|
||||
{
|
||||
private PieChart chart;
|
||||
private float time;
|
||||
11
Assets/XCharts/Examples/Runtime/Example_PieChart.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example_PieChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a36ce96ed11a24212aafad603286a3ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,13 +8,12 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
namespace XCharts.Examples
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[ExecuteInEditMode]
|
||||
public class Demo_Test : MonoBehaviour
|
||||
public class Example_Test : MonoBehaviour
|
||||
{
|
||||
private float updateTime = 0;
|
||||
BaseChart chart;
|
||||
void Awake()
|
||||
{
|
||||
@@ -36,20 +35,21 @@ namespace XCharts
|
||||
|
||||
void OnTestBtn()
|
||||
{
|
||||
chart.ClearData();
|
||||
//chart.ClearData();
|
||||
chart.SetSize(800,400);
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
chart.ClearData();
|
||||
int count = Random.Range(5, 20);
|
||||
int count = Random.Range(5, 100);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
(chart as CoordinateChart).AddXAxisData("x" + i);
|
||||
if (Random.Range(1, 3) == 2)
|
||||
chart.AddData(0, Random.Range(10, 200));
|
||||
chart.AddData(0, Random.Range(-110, 200));
|
||||
else
|
||||
chart.AddData(0, Random.Range(10, 100));
|
||||
chart.AddData(0, Random.Range(-100, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Examples/Runtime/Example_Test.cs.meta
Normal file
11
Assets/XCharts/Examples/Runtime/Example_Test.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bac63bf58d06d47be8e1759189fbd9ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "XCharts.Demo.Runtime",
|
||||
"name": "XCharts.Examples.Runtime",
|
||||
"references": [
|
||||
"XCharts.Runtime"
|
||||
],
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80ba6ed17de4740039736cf78bca3a17
|
||||
guid: 9ca8daef375784f86b76407e76c9045a
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
@@ -1,47 +1,49 @@
|
||||
# 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端和手机端上的数据筛选、视图缩放、细节展示等交互操作。
|
||||
* 支持万级大数据绘制。
|
||||
## Environment
|
||||
|
||||
## 使用
|
||||
* Unity2017.4.27f1
|
||||
* .Net 3.5
|
||||
* macOS 10.15.4
|
||||
|
||||
* 本项目在`Unity 2018.3.14f1`和`.Net 3.5`下开发,在 `Unity 5`、`Unity 2017`、`Unity 2019`上测试正常。理论上可运行于任何支持`UGUI`的`Unity`版本。
|
||||
* 通过下载源码或`unitypackage`包导入到你的项目中。如果你是`2018.3`及以上版本,强烈建议通过`Package Manager`的`Git`来导入包:
|
||||
## Usage
|
||||
|
||||
1. 打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入:
|
||||
|
||||
* This project was developed under `Unity 2017.4.27f1` and `.net 3.5`, tested normally on `Unity 5`, `Unity 2018` and `Unity 2019`. It can theoretically run on any version that supports `UGUI`.
|
||||
* Download the source code or `unitypackage` to import into your project. If `Unity` version are `2018.3` or above, it is recommended to import packages through `Package Manager`:
|
||||
1. Open the `manifest.json` file under `Packages` directory and add under `dependencies`:
|
||||
``` json
|
||||
"com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#package",
|
||||
```
|
||||
2. Going back to `Unity`, it may take 3 to 5 minutes to download.
|
||||
3. If you want to delete `XCharts`, just delete the content added in step 1.
|
||||
4. If you want to update `XCharts`, open `manifest.json` file , delete the content about `com.monitor1394.xcharts` under `lock`, it will download anagain. Also can check For update in `components-> XCharts -> Check For Update`.
|
||||
|
||||
2. 回到`Unity`,可能会花3到5分钟进行下载和编译,成功后就可以开始使用`XCharts`了。
|
||||
3. 如果要删除`XCharts`,删除掉1步骤所加的内容即可。
|
||||
4. 如果要更新`XCharts`,删除`manifest.json`文件的`lock`下的`com.monitor1394.xcharts`相关内容即会从新下载编译。在 `Component -> XCharts -> Check For Update`可以检测是否有新版本可更新。
|
||||
* Add a chart in Editor quickly:
|
||||
1. In `Hierarchy`, right-click menu `XChart->LineChart`.
|
||||
2. In unity menu bar, `Component->XCharts->LineChart`.
|
||||
3. In `Inspector`,`Add Component->LineChart`.
|
||||
4. Then a simple line chart is done.
|
||||
5. In `Inspector` you can adjust the parameters of components, and in `Game` will feedback the adjustment effect in realtime 。the detail of parameters go to see: [XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts配置项手册.md).
|
||||
|
||||
* 在Editor上快速创建一个图表:
|
||||
* See more examples of code dynamic control: [教程:5分钟上手XCharts](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/教程:5分钟上手XCharts.md) .
|
||||
|
||||
1. 在`Canvas`下通过`Create Empty`创建一个空`gameObject`,命名为 `line_chart`。
|
||||
2. 通过菜单栏 `Component->XCharts->LineChart` 或者 `Inspector` 视图的 `Add Component` 添加 `LineChart` 脚本。一个简单的折线图就出来了。
|
||||
3. `Inspector` 视图下可以调整各个组件的参数,`Game` 视图会实时反馈调整的效果。各个组件的详细参数说明可查阅[XCharts配置项手册](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts配置项手册.md)。
|
||||
|
||||
* 更多的代码动态控制的例子请参考[教程:5分钟上手XCharts](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/教程:5分钟上手XCharts.md) 。
|
||||
|
||||
## 文档
|
||||
## Documents
|
||||
|
||||
* [XCharts主页](https://github.com/monitor1394/unity-ugui-XCharts)
|
||||
* 常见问题看这里☞ [XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md)
|
||||
|
||||
@@ -14,10 +14,28 @@ namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// The base class of all charts.
|
||||
/// 所有Chart的基类,不可直接使用。
|
||||
/// 所有Chart的基类。
|
||||
/// </summary>
|
||||
public partial class BaseChart
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of chart.
|
||||
/// </summary>
|
||||
public string chartName
|
||||
{
|
||||
get { return m_ChartName; }
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value) && XChartsMgr.Instance.ContainsChart(value))
|
||||
{
|
||||
Debug.LogError("chartName repeated:" + value);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ChartName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The theme info.
|
||||
/// </summary>
|
||||
@@ -48,6 +66,16 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Settings settings { get { return m_Settings; } }
|
||||
/// <summary>
|
||||
/// The x of chart.
|
||||
/// 图表的X
|
||||
/// </summary>
|
||||
public float chartX { get { return m_ChartX; } }
|
||||
/// <summary>
|
||||
/// The y of chart.
|
||||
/// 图表的Y
|
||||
/// </summary>
|
||||
public float chartY { get { return m_ChartY; } }
|
||||
/// <summary>
|
||||
/// The width of chart.
|
||||
/// 图表的宽
|
||||
/// </summary>
|
||||
@@ -58,29 +86,24 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public float chartHeight { get { return m_ChartHeight; } }
|
||||
/// <summary>
|
||||
/// The postion of pointer.
|
||||
/// 鼠标位置
|
||||
/// The position of chart.
|
||||
/// 图表的左下角起始坐标。
|
||||
/// </summary>
|
||||
public Vector2 pointerPos { get; protected set; }
|
||||
public Vector3 chartPosition { get { return m_ChartPosition; } }
|
||||
public Rect chartRect { get { return m_ChartRect; } }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义绘制回调。
|
||||
/// </summary>
|
||||
public Action<VertexHelper> customDrawCallback { set { m_CustomDrawCallback = value; } }
|
||||
/// <summary>
|
||||
/// Set the size of chart.
|
||||
/// 设置图表的大小。
|
||||
/// </summary>
|
||||
/// <param name="width">width</param>
|
||||
/// <param name="height">height</param>
|
||||
public virtual void SetSize(float width, float height)
|
||||
{
|
||||
m_ChartWidth = width;
|
||||
m_ChartHeight = height;
|
||||
m_CheckWidth = width;
|
||||
m_CheckHeight = height;
|
||||
public Action<VertexHelper> onCustomDraw { set { m_OnCustomDrawCallback = value; } }
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(m_ChartWidth, m_ChartHeight);
|
||||
OnSizeChanged();
|
||||
/// <summary>
|
||||
/// Redraw chart in next frame.
|
||||
/// 在下一帧刷新图表。
|
||||
/// </summary>
|
||||
public void RefreshChart()
|
||||
{
|
||||
m_RefreshChart = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,6 +133,7 @@ namespace XCharts
|
||||
m_Tooltip.ClearValue();
|
||||
m_CheckAnimation = false;
|
||||
m_ReinitLabel = true;
|
||||
m_SerieLabelRoot = null;
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
@@ -122,6 +146,7 @@ namespace XCharts
|
||||
{
|
||||
m_Series.Remove(serieName);
|
||||
m_Legend.RemoveData(serieName);
|
||||
m_SerieLabelRoot = null;
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
@@ -152,8 +177,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieName, data, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieName);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -171,8 +197,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieIndex, data, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieIndex);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -190,8 +217,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieName, multidimensionalData, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieName);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -209,8 +237,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddData(serieIndex, multidimensionalData, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieIndex);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -229,8 +258,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddXYData(serieName, xValue, yValue, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieName);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -249,8 +279,9 @@ namespace XCharts
|
||||
var serieData = m_Series.AddXYData(serieIndex, xValue, yValue, dataName);
|
||||
if (serieData != null)
|
||||
{
|
||||
var serie = m_Series.GetSerie(serieIndex);
|
||||
AddSerieLabel(serie, serieData);
|
||||
RefreshChart();
|
||||
RefreshLabel();
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -473,27 +504,13 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Redraw chart in next frame.
|
||||
/// 在下一帧刷新图表。
|
||||
/// </summary>
|
||||
public void RefreshChart()
|
||||
{
|
||||
m_RefreshChart = true;
|
||||
}
|
||||
|
||||
[Obsolete("Use BaseChart.RefreshLabel() instead.", true)]
|
||||
public void ReinitChartLabel()
|
||||
{
|
||||
RefreshLabel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新文本标签Label,重新初始化,当有改动Label参数时手动调用改接口
|
||||
/// </summary>
|
||||
public void RefreshLabel()
|
||||
{
|
||||
m_ReinitLabel = true;
|
||||
m_SerieLabelRoot = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -537,15 +554,7 @@ namespace XCharts
|
||||
m_Series.AnimationEnable(flag);
|
||||
}
|
||||
|
||||
[Obsolete("Use BaseChart.AnimationFadeIn() instead.", true)]
|
||||
public void AnimationStart()
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("Use BaseChart.AnimationFadeOut() instead.", true)]
|
||||
public void MissAnimationStart()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fadeIn animation.
|
||||
@@ -616,26 +625,70 @@ namespace XCharts
|
||||
/// <returns></returns>
|
||||
public bool IsInChart(Vector2 local)
|
||||
{
|
||||
if (local.x < 0 || local.x > chartWidth ||
|
||||
local.y < 0 || local.y > chartHeight)
|
||||
return IsInChart(local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInChart(float x, float y)
|
||||
{
|
||||
if (x < m_ChartX || x > m_ChartX + m_ChartWidth ||
|
||||
y < m_ChartY || y > m_ChartY + m_ChartHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Vector3 ClampInChart(Vector3 pos)
|
||||
public void ClampInChart(ref Vector3 pos)
|
||||
{
|
||||
if (IsInChart(pos)) return pos;
|
||||
else
|
||||
if (!IsInChart(pos.x, pos.y))
|
||||
{
|
||||
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;
|
||||
if (pos.x < m_ChartX) pos.x = m_ChartX;
|
||||
if (pos.x > m_ChartX + m_ChartWidth) pos.x = m_ChartX + m_ChartWidth;
|
||||
if (pos.y < m_ChartY) pos.y = m_ChartY;
|
||||
if (pos.y > m_ChartY + m_ChartHeight) pos.y = m_ChartY + m_ChartHeight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否可以开启背景组件。背景组件在chart受上层布局控制时无法开启。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CanShowBackgroundComponent()
|
||||
{
|
||||
return !m_IsControlledByLayout && m_Background.runtimeActive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启背景组件。背景组件在chart受上层布局控制时不适用。
|
||||
/// </summary>
|
||||
/// <param name="flag"></param>
|
||||
public void EnableBackground(bool flag)
|
||||
{
|
||||
if (flag && !CanShowBackgroundComponent())
|
||||
{
|
||||
var msg = "The background component cannot be activated because chart is controlled by LayoutGroup,"
|
||||
+ " or its parent have more than one child.";
|
||||
Debug.LogError(msg);
|
||||
return;
|
||||
}
|
||||
m_Background.show = flag;
|
||||
}
|
||||
|
||||
public Vector3 GetTitlePosition()
|
||||
{
|
||||
return chartPosition + m_Title.location.GetPosition(chartWidth, chartHeight);
|
||||
}
|
||||
|
||||
[Obsolete("Use BaseChart.RefreshLabel() instead.", true)]
|
||||
public void ReinitChartLabel() { }
|
||||
|
||||
[Obsolete("Use BaseChart.AnimationFadeIn() instead.", true)]
|
||||
public void AnimationStart() { }
|
||||
|
||||
[Obsolete("Use BaseChart.AnimationFadeOut() instead.", true)]
|
||||
public void MissAnimationStart() { }
|
||||
|
||||
[Obsolete("Use onCustomDraw instead.", false)]
|
||||
public Action<VertexHelper> customDrawCallback { set { m_OnCustomDrawCallback = value; } }
|
||||
}
|
||||
}
|
||||
|
||||
133
Assets/XCharts/Runtime/API/BaseGraph_API.cs
Normal file
133
Assets/XCharts/Runtime/API/BaseGraph_API.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// The base class of all graphs or components.
|
||||
/// 所有图形的基类。
|
||||
/// </summary>
|
||||
public partial class BaseGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// The x of graph.
|
||||
/// 图形的X
|
||||
/// </summary>
|
||||
public float graphX { get { return m_GraphX; } }
|
||||
/// <summary>
|
||||
/// The y of graph.
|
||||
/// 图形的Y
|
||||
/// </summary>
|
||||
public float graphY { get { return m_GraphY; } }
|
||||
/// <summary>
|
||||
/// The width of graph.
|
||||
/// 图形的宽
|
||||
/// </summary>
|
||||
public float graphWidth { get { return m_GraphWidth; } }
|
||||
/// <summary>
|
||||
/// The height of graph.
|
||||
/// 图形的高
|
||||
/// </summary>
|
||||
public float graphHeight { get { return m_GraphHeight; } }
|
||||
/// <summary>
|
||||
/// The position of graph.
|
||||
/// 图形的左下角起始坐标。
|
||||
/// </summary>
|
||||
public Vector3 graphPosition { get { return m_GraphPosition; } }
|
||||
public Rect graphRect { get { return m_GraphRect; } }
|
||||
/// <summary>
|
||||
/// The postion of pointer.
|
||||
/// 鼠标位置
|
||||
/// </summary>
|
||||
public Vector2 pointerPos { get; protected set; }
|
||||
/// <summary>
|
||||
/// 警告信息。
|
||||
/// </summary>
|
||||
public string warningInfo { get; protected set; }
|
||||
public bool isControlledByLayout { get { return m_IsControlledByLayout; } }
|
||||
/// <summary>
|
||||
/// 强制开启鼠标事件检测。
|
||||
/// </summary>
|
||||
public bool forceOpenRaycastTarget { get { return m_ForceOpenRaycastTarget; } set { m_ForceOpenRaycastTarget = value; } }
|
||||
/// <summary>
|
||||
/// 鼠标点击回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onPointerClick { set { m_OnPointerClick = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标按下回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onPointerDown { set { m_OnPointerDown = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标弹起回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onPointerUp { set { m_OnPointerUp = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标进入回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onPointerEnter { set { m_OnPointerEnter = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标退出回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onPointerExit { set { m_OnPointerExit = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标开始拖拽回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onBeginDrag { set { m_OnBeginDrag = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标拖拽回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onDrag { set { m_OnDrag = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标结束拖拽回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onEndDrag { set { m_OnEndDrag = value; m_ForceOpenRaycastTarget = true; } }
|
||||
/// <summary>
|
||||
/// 鼠标滚动回调。
|
||||
/// </summary>
|
||||
public Action<BaseGraph, PointerEventData> onScroll { set { m_OnScroll = value; m_ForceOpenRaycastTarget = true; } }
|
||||
|
||||
/// <summary>
|
||||
/// 设置图形的宽高(在非stretch pivot下才有效,其他情况需要自己调整RectTransform)
|
||||
/// </summary>
|
||||
/// <param name="width"></param>
|
||||
/// <param name="height"></param>
|
||||
public virtual void SetSize(float width, float height)
|
||||
{
|
||||
if (LayerHelper.IsFixedWidthHeight(rectTransform))
|
||||
{
|
||||
rectTransform.sizeDelta = new Vector2(width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Can't set size on stretch pivot,you need to modify rectTransform by yourself.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Redraw graph in next frame.
|
||||
/// 在下一帧刷新图形。
|
||||
/// </summary>
|
||||
public void RefreshGraph()
|
||||
{
|
||||
m_RefreshChart = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测警告信息。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string CheckWarning()
|
||||
{
|
||||
warningInfo = CheckHelper.CheckChart(this);
|
||||
return warningInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/API/BaseGraph_API.cs.meta
Normal file
11
Assets/XCharts/Runtime/API/BaseGraph_API.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e17adfd3dc62d435cb79fa8c330fe186
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -22,29 +22,23 @@ namespace XCharts
|
||||
/// The lower left position x of coordinate system.
|
||||
/// 坐标系的左下角坐标X。
|
||||
/// </summary>
|
||||
public float coordinateX { get { return m_Grid.left; } }
|
||||
public float coordinateX { get { return m_CoordinateX; } }
|
||||
/// <summary>
|
||||
/// The lower left position y of coordinate system.
|
||||
/// 坐标系的左下角坐标Y。
|
||||
/// </summary>
|
||||
public float coordinateY { get { return m_Grid.bottom; } }
|
||||
|
||||
[Obsolete("Use CoordinateChart.coordinateWidth instead.", true)]
|
||||
public float coordinateWid { get { return coordinateWidth; } }
|
||||
|
||||
[Obsolete("Use CoordinateChart.coordinateHeight instead.", true)]
|
||||
public float coordinateHig { get { return coordinateHeight; } }
|
||||
public float coordinateY { get { return m_CoordinateY; } }
|
||||
|
||||
/// <summary>
|
||||
/// the width of coordinate system。
|
||||
/// 坐标系的宽。
|
||||
/// </summary>
|
||||
public float coordinateWidth { get { return chartWidth - m_Grid.left - m_Grid.right; } }
|
||||
public float coordinateWidth { get { return m_CoordinateWidth; } }
|
||||
/// <summary>
|
||||
/// the height of coordinate system。
|
||||
/// 坐标系的高。
|
||||
/// </summary>
|
||||
public float coordinateHeight { get { return chartHeight - m_Grid.top - m_Grid.bottom; } }
|
||||
public float coordinateHeight { get { return m_CoordinateHeight; } }
|
||||
/// <summary>
|
||||
/// grid component.
|
||||
/// 网格组件。
|
||||
@@ -146,7 +140,6 @@ namespace XCharts
|
||||
/// reutrn true when all the show axis is `Value` type.
|
||||
/// 纯数值坐标轴(数值轴或对数轴)。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsValue()
|
||||
{
|
||||
foreach (var axis in m_XAxises)
|
||||
@@ -160,6 +153,9 @@ namespace XCharts
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 纯类目轴。
|
||||
/// </summary>
|
||||
public bool IsCategory()
|
||||
{
|
||||
foreach (var axis in m_XAxises)
|
||||
@@ -173,10 +169,23 @@ namespace XCharts
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 坐标是否在坐标轴内。
|
||||
/// </summary>
|
||||
public bool IsInCooridate(Vector2 local)
|
||||
{
|
||||
if (local.x < coordinateX - 1 || local.x > coordinateX + coordinateWidth + 1 ||
|
||||
local.y < coordinateY - 1 || local.y > coordinateY + coordinateHeight + 1)
|
||||
return IsInCooridate(local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInCooridate(Vector3 local)
|
||||
{
|
||||
return IsInCooridate(local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInCooridate(float x, float y)
|
||||
{
|
||||
if (x < m_CoordinateX - 1 || x > m_CoordinateX + m_CoordinateWidth + 1 ||
|
||||
y < m_CoordinateY - 1 || y > m_CoordinateY + m_CoordinateHeight + 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -204,14 +213,60 @@ namespace XCharts
|
||||
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;
|
||||
// var pos = new Vector3(pos.x, pos.y);
|
||||
if (pos.x < m_CoordinateX) pos.x = m_CoordinateX;
|
||||
if (pos.x > m_CoordinateX + m_CoordinateWidth) pos.x = m_CoordinateX + m_CoordinateWidth;
|
||||
if (pos.y < m_CoordinateY) pos.y = m_CoordinateY;
|
||||
if (pos.y > m_CoordinateY + m_CoordinateHeight) pos.y = m_CoordinateY + m_CoordinateHeight;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转换X轴和Y轴的配置
|
||||
/// </summary>
|
||||
/// <param name="index">坐标轴索引,0或1</param>
|
||||
public void CovertXYAxis(int index)
|
||||
{
|
||||
if (index >= 0 && index <= 1)
|
||||
{
|
||||
var xAxis = m_XAxises[index];
|
||||
var yAxis = m_YAxises[index];
|
||||
var tempX = m_XAxises[index].Clone();
|
||||
xAxis.Copy(m_YAxises[index]);
|
||||
yAxis.Copy(tempX);
|
||||
xAxis.runtimeZeroXOffset = 0;
|
||||
xAxis.runtimeZeroYOffset = 0;
|
||||
yAxis.runtimeZeroXOffset = 0;
|
||||
yAxis.runtimeZeroYOffset = 0;
|
||||
xAxis.runtimeMinValue = 0;
|
||||
xAxis.runtimeMaxValue = 0;
|
||||
yAxis.runtimeMinValue = 0;
|
||||
yAxis.runtimeMaxValue = 0;
|
||||
RefreshChart();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新坐标系原点和宽高
|
||||
/// </summary>
|
||||
public void UpdateCoordinate()
|
||||
{
|
||||
m_CoordinateX = m_ChartX + m_Grid.left;
|
||||
m_CoordinateY = m_ChartY + m_Grid.bottom;
|
||||
m_CoordinateWidth = m_ChartWidth - m_Grid.left - m_Grid.right;
|
||||
m_CoordinateHeight = m_ChartHeight - m_Grid.top - m_Grid.bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。
|
||||
/// </summary>
|
||||
public void SetMaxCache(int maxCache)
|
||||
{
|
||||
foreach (var serie in m_Series.list) serie.maxCache = maxCache;
|
||||
foreach (var axis in m_XAxises) axis.maxCache = maxCache;
|
||||
foreach (var axis in m_YAxises) axis.maxCache = maxCache;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ namespace XCharts
|
||||
[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 bool m_Inverse = false;
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
||||
@@ -84,7 +86,7 @@ namespace XCharts
|
||||
[SerializeField] protected AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||
|
||||
[NonSerialized] private float m_ValueRange;
|
||||
[NonSerialized] private float m_MinMaxValueRange;
|
||||
[NonSerialized] private bool m_NeedUpdateFilterData;
|
||||
|
||||
/// <summary>
|
||||
@@ -187,6 +189,23 @@ namespace XCharts
|
||||
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>
|
||||
/// Whether the axis are reversed or not. Invalid in `Category` axis.
|
||||
/// 是否反向坐标轴。在类目轴中无效。
|
||||
/// </summary>
|
||||
public bool inverse
|
||||
{
|
||||
get { return m_Inverse; }
|
||||
set { if (m_Type == AxisType.Value && PropertyUtility.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Category data, available in type: 'Category' axis.
|
||||
/// 类目数据,在类目轴(type: 'category')中有效。
|
||||
/// </summary>
|
||||
@@ -319,7 +338,8 @@ namespace XCharts
|
||||
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); } }
|
||||
|
||||
internal bool runtimeLastCheckInverse { get; set; }
|
||||
internal float runtimeMinMaxRange { get { return m_MinMaxValueRange; } set { m_MinMaxValueRange = value; } }
|
||||
private int filterStart;
|
||||
private int filterEnd;
|
||||
private int filterMinShow;
|
||||
@@ -339,6 +359,55 @@ namespace XCharts
|
||||
private bool m_RuntimeMinValueFirstChanged = true;
|
||||
private bool m_RuntimeMaxValueFirstChanged = true;
|
||||
|
||||
public Axis Clone()
|
||||
{
|
||||
var axis = new Axis();
|
||||
axis.show = show;
|
||||
axis.type = type;
|
||||
axis.minMaxType = minMaxType;
|
||||
axis.min = min;
|
||||
axis.max = max;
|
||||
axis.splitNumber = splitNumber;
|
||||
axis.interval = interval;
|
||||
axis.boundaryGap = boundaryGap;
|
||||
axis.maxCache = maxCache;
|
||||
axis.logBase = logBase;
|
||||
axis.logBaseE = logBaseE;
|
||||
axis.ceilRate = ceilRate;
|
||||
axis.axisLine = axisLine.Clone();
|
||||
axis.axisName = axisName.Clone();
|
||||
axis.axisTick = axisTick.Clone();
|
||||
axis.axisLabel = axisLabel.Clone();
|
||||
axis.splitLine = splitLine.Clone();
|
||||
axis.splitArea = splitArea.Clone();
|
||||
axis.data = new List<string>();
|
||||
ChartHelper.CopyList(axis.data, data);
|
||||
return axis;
|
||||
}
|
||||
|
||||
public void Copy(Axis axis)
|
||||
{
|
||||
show = axis.show;
|
||||
type = axis.type;
|
||||
minMaxType = axis.minMaxType;
|
||||
min = axis.min;
|
||||
max = axis.max;
|
||||
splitNumber = axis.splitNumber;
|
||||
interval = axis.interval;
|
||||
boundaryGap = axis.boundaryGap;
|
||||
maxCache = axis.maxCache;
|
||||
logBase = axis.logBase;
|
||||
logBaseE = axis.logBaseE;
|
||||
ceilRate = axis.ceilRate;
|
||||
axisLine.Copy(axis.axisLine);
|
||||
axisName.Copy(axis.axisName);
|
||||
axisTick.Copy(axis.axisTick);
|
||||
axisLabel.Copy(axis.axisLabel);
|
||||
splitLine.Copy(axis.splitLine);
|
||||
splitArea.Copy(axis.splitArea);
|
||||
ChartHelper.CopyList(data, axis.data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空类目数据
|
||||
/// </summary>
|
||||
@@ -393,13 +462,26 @@ namespace XCharts
|
||||
SetAllDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的类目数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public string GetData(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
return m_Data[index];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得在dataZoom范围内指定索引的类目数据
|
||||
/// </summary>
|
||||
/// <param name="index">类目数据索引</param>
|
||||
/// <param name="dataZoom">区域缩放</param>
|
||||
/// <returns></returns>
|
||||
internal string GetData(int index, DataZoom dataZoom)
|
||||
public string GetData(int index, DataZoom dataZoom)
|
||||
{
|
||||
var showData = GetDataList(dataZoom);
|
||||
if (index >= 0 && index < showData.Count)
|
||||
@@ -471,55 +553,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割段数
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
internal int GetSplitNumber(float coordinateWid, DataZoom dataZoom)
|
||||
{
|
||||
if (type == AxisType.Value)
|
||||
{
|
||||
if (m_Interval > 0)
|
||||
{
|
||||
if (coordinateWid <= 0) return 0;
|
||||
int num = Mathf.CeilToInt(m_ValueRange / m_Interval) + 1;
|
||||
int maxNum = Mathf.CeilToInt(coordinateWid / 15);
|
||||
if (num > maxNum)
|
||||
{
|
||||
m_Interval = m_ValueRange / (maxNum - 1);
|
||||
num = Mathf.CeilToInt(m_ValueRange / m_Interval) + 1;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
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)
|
||||
return m_SplitNumber;
|
||||
else
|
||||
return dataCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割段的宽度
|
||||
/// </summary>
|
||||
/// <param name="coordinateWidth"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
internal float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
|
||||
{
|
||||
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
||||
int segment = (m_BoundaryGap ? split : split - 1);
|
||||
segment = segment <= 0 ? 1 : segment;
|
||||
return coordinateWidth / segment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得类目数据个数
|
||||
/// </summary>
|
||||
@@ -530,122 +563,6 @@ namespace XCharts
|
||||
return GetDataList(dataZoom).Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得一个类目数据在坐标系中代表的宽度
|
||||
/// </summary>
|
||||
/// <param name="coordinateWidth"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
internal float GetDataWidth(float coordinateWidth, int dataCount, DataZoom dataZoom)
|
||||
{
|
||||
if (dataCount < 1) dataCount = 1;
|
||||
var categoryCount = GetDataNumber(dataZoom);
|
||||
int segment = (m_BoundaryGap ? categoryCount : categoryCount - 1);
|
||||
segment = segment <= 0 ? dataCount : segment;
|
||||
return coordinateWidth / segment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得标签显示的名称
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
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)
|
||||
{
|
||||
if (index == split - 1) value = maxValue;
|
||||
else value = minValue + index * m_Interval;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (minValue + (maxValue - minValue) * index / (split - 1));
|
||||
}
|
||||
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 "";
|
||||
|
||||
if (index == split - 1 && !m_BoundaryGap)
|
||||
{
|
||||
return m_AxisLabel.GetFormatterContent(showData[dataCount - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
float rate = dataCount / split;
|
||||
if (rate < 1) rate = 1;
|
||||
int offset = m_BoundaryGap ? (int)(rate / 2) : 0;
|
||||
int newIndex = (int)(index * rate >= dataCount - 1 ?
|
||||
dataCount - 1 : offset + index * rate);
|
||||
return m_AxisLabel.GetFormatterContent(showData[newIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割线条数
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
internal int GetScaleNumber(float coordinateWidth, DataZoom dataZoom)
|
||||
{
|
||||
if (type == AxisType.Value || type == AxisType.Log)
|
||||
{
|
||||
int splitNum = GetSplitNumber(coordinateWidth, dataZoom);
|
||||
return m_BoundaryGap ? splitNum + 1 : splitNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
var showData = GetDataList(dataZoom);
|
||||
int dataCount = showData.Count;
|
||||
if (m_SplitNumber <= 0) return m_BoundaryGap ? dataCount + 1 : dataCount;
|
||||
if (dataCount > 2 * splitNumber || dataCount <= 0)
|
||||
return m_BoundaryGap ? m_SplitNumber + 1 : m_SplitNumber;
|
||||
else
|
||||
return m_BoundaryGap ? dataCount + 1 : dataCount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得分割段宽度
|
||||
/// </summary>
|
||||
/// <param name="coordinateWidth"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
internal float GetScaleWidth(float coordinateWidth, int index, DataZoom dataZoom)
|
||||
{
|
||||
int num = GetScaleNumber(coordinateWidth, dataZoom) - 1;
|
||||
if (num <= 0) num = 1;
|
||||
if (type == AxisType.Value && m_Interval > 0)
|
||||
{
|
||||
if (index == num - 1) return coordinateWidth - (num - 1) * m_Interval * coordinateWidth / m_ValueRange;
|
||||
else return m_Interval * coordinateWidth / m_ValueRange;
|
||||
}
|
||||
else
|
||||
{
|
||||
return coordinateWidth / num;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新刻度标签文字
|
||||
/// </summary>
|
||||
@@ -658,7 +575,8 @@ namespace XCharts
|
||||
{
|
||||
if (axisLabelTextList[i] != null)
|
||||
{
|
||||
axisLabelTextList[i].text = GetLabelName(coordinateWidth, i, minValue, maxValue, dataZoom, forcePercent);
|
||||
var text = AxisHelper.GetLabelName(this, coordinateWidth, i, minValue, maxValue, dataZoom, forcePercent);
|
||||
axisLabelTextList[i].text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -668,7 +586,7 @@ namespace XCharts
|
||||
m_TooltipLabel = label;
|
||||
m_TooltipLabelRect = label.GetComponent<RectTransform>();
|
||||
m_TooltipLabelText = label.GetComponentInChildren<Text>();
|
||||
m_TooltipLabel.SetActive(true);
|
||||
ChartHelper.SetActive(m_TooltipLabel, true);
|
||||
}
|
||||
|
||||
internal void SetTooltipLabelColor(Color bgColor, Color textColor)
|
||||
@@ -681,7 +599,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
|
||||
{
|
||||
m_TooltipLabel.SetActive(flag);
|
||||
ChartHelper.SetActive(m_TooltipLabel, flag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,71 +621,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
internal bool NeedShowSplit()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调整最大最小值
|
||||
/// </summary>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
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)
|
||||
{
|
||||
minValue = min;
|
||||
maxValue = max;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (minMaxType)
|
||||
{
|
||||
case Axis.AxisMinMaxType.Default:
|
||||
if (minValue == 0 && maxValue == 0)
|
||||
{
|
||||
}
|
||||
else if (minValue > 0 && maxValue > 0)
|
||||
{
|
||||
minValue = 0;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue) : maxValue;
|
||||
}
|
||||
else if (minValue < 0 && maxValue < 0)
|
||||
{
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue) : minValue;
|
||||
maxValue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue) : minValue;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue) : maxValue;
|
||||
}
|
||||
break;
|
||||
case Axis.AxisMinMaxType.MinMax:
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue) : minValue;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue) : maxValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ValueRange = maxValue - minValue;
|
||||
}
|
||||
|
||||
internal void UpdateMinValue(float value, bool check)
|
||||
{
|
||||
if (value != m_RuntimeMaxValue)
|
||||
|
||||
140
Assets/XCharts/Runtime/Component/Main/Background.cs
Normal file
140
Assets/XCharts/Runtime/Component/Main/Background.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System.Net.Mime;
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 背景组件。
|
||||
/// 由于框架的局限性,背景组件使用有以下两个限制:
|
||||
/// 1:chart的父节点不能有布局控制类组件。
|
||||
/// 2:chart的父节点只能有当前chart一个子节点。
|
||||
/// 背景组件的开启需要通过接口来开启:BaseChart.EnableBackground(bool flag)
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Background : MainComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Sprite m_Image;
|
||||
[SerializeField] private Image.Type m_ImageType;
|
||||
[SerializeField] private float m_Left;
|
||||
[SerializeField] private float m_Right;
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
[SerializeField] private Color m_ImageColor = Color.white;
|
||||
[SerializeField] private bool m_HideThemeBackgroundColor = true;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用背景组件。但能否激活背景组件还要受其他条件限制。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
internal set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 背景图。
|
||||
/// </summary>
|
||||
public Sprite image
|
||||
{
|
||||
get { return m_Image; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Image, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 背景图填充类型。
|
||||
/// </summary>
|
||||
public Image.Type imageType
|
||||
{
|
||||
get { return m_ImageType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Distance between background component and the left side of the container.
|
||||
/// background 组件离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Left, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between background component and the right side of the container.
|
||||
/// background 组件离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Right, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between background component and the top side of the container.
|
||||
/// background 组件离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Top, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between background component and the bottom side of the container.
|
||||
/// background 组件离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 背景图颜色。
|
||||
/// </summary>
|
||||
public Color imageColor
|
||||
{
|
||||
get { return m_ImageColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当background组件开启时,是否隐藏主题中设置的背景色。
|
||||
/// </summary>
|
||||
public bool hideThemeBackgroundColor
|
||||
{
|
||||
get { return m_HideThemeBackgroundColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否已激活
|
||||
/// </summary>
|
||||
public bool runtimeActive{get;internal set;}
|
||||
|
||||
public static Background defaultBackground
|
||||
{
|
||||
get
|
||||
{
|
||||
var background = new Background
|
||||
{
|
||||
m_Show = false,
|
||||
m_Image = null,
|
||||
m_ImageType = Image.Type.Sliced,
|
||||
m_Left = 0,
|
||||
m_Right = 0,
|
||||
m_Top = 0,
|
||||
m_Bottom = 0,
|
||||
m_ImageColor = Color.white,
|
||||
m_HideThemeBackgroundColor = true,
|
||||
};
|
||||
return background;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/XCharts/Runtime/Component/Main/Background.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Main/Background.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20bad62e2503e49dcacbecdc99542025
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -321,9 +321,9 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
Rect rect = Rect.MinMaxRect(startX, m_Bottom, startX + width, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(startX, startY + m_Bottom, startX + width, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -334,11 +334,11 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInSelectedZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInSelectedZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
var end = startX + width * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(start, m_Bottom, end, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(start, startY + m_Bottom, end, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -349,10 +349,10 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInStartZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInStartZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
Rect rect = Rect.MinMaxRect(start - 10, m_Bottom, start + 10, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(start - 10, startY + m_Bottom, start + 10, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -363,10 +363,10 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInEndZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInEndZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
var end = startX + width * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(end - 10, m_Bottom, end + 10, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(end - 10, startY + m_Bottom, end + 10, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,38 +188,22 @@ namespace XCharts
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
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>
|
||||
/// 运行时图例的总宽度
|
||||
/// </summary>
|
||||
public float runtimeWidth { get; internal set; }
|
||||
/// <summary>
|
||||
/// 运行时图例的总高度
|
||||
/// </summary>
|
||||
public float runtimeHeight { get; internal set; }
|
||||
/// <summary>
|
||||
/// 多列时每列的宽度
|
||||
/// </summary>
|
||||
public Dictionary<int, float> runtimeEachWidth { get; internal set; }
|
||||
/// <summary>
|
||||
/// 单列高度
|
||||
/// </summary>
|
||||
public float runtimeEachHeight { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// 一个在顶部居中显示的默认图例。
|
||||
@@ -237,6 +221,7 @@ namespace XCharts
|
||||
m_ItemWidth = 24.0f,
|
||||
m_ItemHeight = 12.0f,
|
||||
m_ItemGap = 10f,
|
||||
runtimeEachWidth = new Dictionary<int, float>()
|
||||
};
|
||||
legend.location.top = 30;
|
||||
legend.textStyle.offset = new Vector2(2, 0);
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Indicator = true;
|
||||
[SerializeField] private PositionType m_PositionType = PositionType.Vertice;
|
||||
[SerializeField] private float m_IndicatorGap = 10;
|
||||
[SerializeField] protected int m_CeilRate = 0;
|
||||
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
||||
/// <summary>
|
||||
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
||||
@@ -164,6 +165,14 @@ namespace XCharts
|
||||
set { if (PropertyUtility.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 最大最小值向上取整的倍率。默认为0时自动计算。
|
||||
/// </summary>
|
||||
public int ceilRate
|
||||
{
|
||||
get { return m_CeilRate; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// /// 显示位置类型。
|
||||
/// </summary>
|
||||
public PositionType positionType
|
||||
@@ -181,7 +190,7 @@ namespace XCharts
|
||||
/// the center position of radar in container.
|
||||
/// 雷达图在容器中的具体中心点。
|
||||
/// </summary>
|
||||
public Vector2 runtimeCenterPos { get; internal set; }
|
||||
public Vector3 runtimeCenterPos { get; internal set; }
|
||||
/// <summary>
|
||||
/// the true radius of radar.
|
||||
/// 雷达图的运行时实际半径。
|
||||
@@ -205,11 +214,11 @@ namespace XCharts
|
||||
m_SplitNumber = 5,
|
||||
m_Indicator = true,
|
||||
m_IndicatorList = new List<Indicator>(5){
|
||||
new Indicator(){name="indicator1",max = 100},
|
||||
new Indicator(){name="indicator2",max = 100},
|
||||
new Indicator(){name="indicator3",max = 100},
|
||||
new Indicator(){name="indicator4",max = 100},
|
||||
new Indicator(){name="indicator5",max = 100},
|
||||
new Indicator(){name="indicator1",max = 0},
|
||||
new Indicator(){name="indicator2",max = 0},
|
||||
new Indicator(){name="indicator3",max = 0},
|
||||
new Indicator(){name="indicator4",max = 0},
|
||||
new Indicator(){name="indicator5",max = 0},
|
||||
}
|
||||
};
|
||||
radar.center[0] = 0.5f;
|
||||
@@ -282,12 +291,12 @@ namespace XCharts
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal void UpdateRadarCenter(float chartWidth, float chartHeight)
|
||||
internal void UpdateRadarCenter(Vector3 chartPosition, 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];
|
||||
runtimeCenterPos = new Vector2(centerX, centerY);
|
||||
runtimeCenterPos = chartPosition + new Vector3(centerX, centerY);
|
||||
if (radius <= 0)
|
||||
{
|
||||
runtimeRadius = 0;
|
||||
|
||||
@@ -165,6 +165,20 @@ namespace XCharts
|
||||
ProgressBar
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 雷达图类型
|
||||
/// </summary>
|
||||
public enum RadarType
|
||||
{
|
||||
/// <summary>
|
||||
/// 多圈雷达图。此时可一个雷达里绘制多个圈,一个serieData就可组成一个圈(多维数据)。
|
||||
/// </summary>
|
||||
Multiple,
|
||||
/// <summary>
|
||||
/// 单圈雷达图。此时一个雷达只能绘制一个圈,多个serieData组成一个圈,数据取自`data[1]`。
|
||||
/// </summary>
|
||||
Single
|
||||
}
|
||||
/// <summary>
|
||||
/// 采样类型
|
||||
/// </summary>
|
||||
@@ -253,9 +267,14 @@ namespace XCharts
|
||||
[SerializeField] [Range(1, 10)] private int m_ShowDataDimension;
|
||||
[SerializeField] private bool m_ShowDataName;
|
||||
[SerializeField] private bool m_ShowDataIcon;
|
||||
[SerializeField] private bool m_Clip = true;
|
||||
[SerializeField] private bool m_Clip = false;
|
||||
[SerializeField] private bool m_Ignore = false;
|
||||
[SerializeField] private float m_IgnoreValue = 0;
|
||||
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||
[SerializeField] private bool m_Large = true;
|
||||
[SerializeField] private int m_LargeThreshold = 200;
|
||||
[SerializeField] private bool m_AvoidLabelOverlap = false;
|
||||
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
|
||||
|
||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||
|
||||
@@ -627,6 +646,14 @@ namespace XCharts
|
||||
set { if (PropertyUtility.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 雷达图类型。
|
||||
/// </summary>
|
||||
public RadarType radarType
|
||||
{
|
||||
get { return m_RadarType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 仪表盘轴线。
|
||||
/// </summary>
|
||||
public GaugeAxis gaugeAxis
|
||||
@@ -720,6 +747,55 @@ namespace XCharts
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Show negative number as positive number.
|
||||
/// 将负数数值显示为正数。一般和`AxisLabel`的`showAsPositiveNumber`配合使用。仅在折线图和柱状图中有效。
|
||||
/// </summary>
|
||||
public bool showAsPositiveNumber
|
||||
{
|
||||
get { return m_ShowAsPositiveNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。
|
||||
/// 开启后配合 largeThreshold 在数据量大于指定阈值的时候对绘制进行优化。
|
||||
/// 缺点:优化后不能自定义设置单个数据项的样式,不能显示Label。
|
||||
/// </summary>
|
||||
public bool large
|
||||
{
|
||||
get { return m_Large; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtility.SetStruct(ref m_Large, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
|
||||
/// </summary>
|
||||
public int largeThreshold
|
||||
{
|
||||
get { return m_LargeThreshold; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtility.SetStruct(ref m_LargeThreshold, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。
|
||||
/// </summary>
|
||||
public bool avoidLabelOverlap
|
||||
{
|
||||
get { return m_AvoidLabelOverlap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_AvoidLabelOverlap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
public List<SerieData> data { get { return m_Data; } }
|
||||
@@ -804,9 +880,13 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public float runtimeOutsideRadius { get; internal set; }
|
||||
/// <summary>
|
||||
/// 饼图的数据项最大值
|
||||
/// 运行时的最大数据值
|
||||
/// </summary>
|
||||
public float runtimePieDataMax { get; internal set; }
|
||||
public float runtimeDataMax { get; internal set; }
|
||||
/// <summary>
|
||||
/// 运行时的最小数据值
|
||||
/// </summary>
|
||||
public float runtimeDataMin { get; internal set; }
|
||||
/// <summary>
|
||||
/// 饼图的数据项之和
|
||||
/// </summary>
|
||||
@@ -836,7 +916,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = new List<Vector3>(size);
|
||||
var list = ListPool<Vector3>.Get();
|
||||
m_UpSmoothPoints[dataIndex] = list;
|
||||
return list;
|
||||
}
|
||||
@@ -850,7 +930,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = new List<Vector3>(size);
|
||||
var list = ListPool<Vector3>.Get();
|
||||
m_DownSmoothPoints[dataIndex] = list;
|
||||
return list;
|
||||
}
|
||||
@@ -983,6 +1063,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
while (m_Data.Count > 0)
|
||||
{
|
||||
RemoveData(0);
|
||||
}
|
||||
m_Data.Clear();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
@@ -1000,6 +1084,22 @@ namespace XCharts
|
||||
SetNameDirty();
|
||||
}
|
||||
SetVerticesDirty();
|
||||
var serieData = m_Data[index];
|
||||
SerieDataPool.Release(serieData);
|
||||
if (serieData.labelObject != null)
|
||||
{
|
||||
SerieLabelPool.Release(serieData.labelObject.gameObject);
|
||||
}
|
||||
if (m_UpSmoothPoints.ContainsKey(serieData.index))
|
||||
{
|
||||
ListPool<Vector3>.Release(m_UpSmoothPoints[serieData.index]);
|
||||
m_UpSmoothPoints.Remove(serieData.index);
|
||||
}
|
||||
if (m_DownSmoothPoints.ContainsKey(serieData.index))
|
||||
{
|
||||
ListPool<Vector3>.Release(m_DownSmoothPoints[serieData.index]);
|
||||
m_DownSmoothPoints.Remove(serieData.index);
|
||||
}
|
||||
m_Data.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
@@ -1011,20 +1111,12 @@ namespace XCharts
|
||||
/// <param name="dataName"></param>
|
||||
public SerieData AddYData(float value, string dataName = null)
|
||||
{
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
CheckMaxCache();
|
||||
int xValue = m_Data.Count;
|
||||
var serieData = new SerieData()
|
||||
{
|
||||
data = new List<float>() { xValue, value },
|
||||
name = dataName
|
||||
};
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.data.Add(xValue);
|
||||
serieData.data.Add(value);
|
||||
serieData.name = dataName;
|
||||
serieData.index = xValue;
|
||||
m_Data.Add(serieData);
|
||||
m_ShowDataDimension = 1;
|
||||
@@ -1054,19 +1146,11 @@ namespace XCharts
|
||||
/// <param name="maxDataNumber"></param>
|
||||
public SerieData AddXYData(float xValue, float yValue, string dataName = null)
|
||||
{
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
var serieData = new SerieData()
|
||||
{
|
||||
data = new List<float>() { xValue, yValue },
|
||||
name = dataName
|
||||
};
|
||||
CheckMaxCache();
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.data.Add(xValue);
|
||||
serieData.data.Add(yValue);
|
||||
serieData.name = dataName;
|
||||
serieData.index = m_Data.Count;
|
||||
m_Data.Add(serieData);
|
||||
m_ShowDataDimension = 2;
|
||||
@@ -1095,16 +1179,9 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_MaxCache > 0)
|
||||
{
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
m_Data.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
CheckMaxCache();
|
||||
m_ShowDataDimension = valueList.Count;
|
||||
var serieData = new SerieData();
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.name = dataName;
|
||||
serieData.index = m_Data.Count;
|
||||
for (int i = 0; i < valueList.Count; i++)
|
||||
@@ -1118,6 +1195,42 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckMaxCache()
|
||||
{
|
||||
if (m_MaxCache <= 0) return;
|
||||
while (m_Data.Count > m_MaxCache)
|
||||
{
|
||||
m_NeedUpdateFilterData = true;
|
||||
RemoveData(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定index指定维数的数据
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="dimension"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public float GetData(int index, int dimension, DataZoom dataZoom = null)
|
||||
{
|
||||
if (index < 0 || dimension < 0) return 0;
|
||||
var serieData = GetSerieData(index, dataZoom);
|
||||
if (serieData != null && dimension < serieData.data.Count)
|
||||
{
|
||||
var value = serieData.GetData(dimension);
|
||||
if (showAsPositiveNumber)
|
||||
{
|
||||
value = Mathf.Abs(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得维度Y索引对应的数据
|
||||
/// </summary>
|
||||
@@ -1130,7 +1243,12 @@ namespace XCharts
|
||||
var serieData = GetDataList(dataZoom);
|
||||
if (index < serieData.Count)
|
||||
{
|
||||
return serieData[index].data[1];
|
||||
var value = serieData[index].data[1];
|
||||
if (showAsPositiveNumber)
|
||||
{
|
||||
value = Mathf.Abs(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1141,7 +1259,12 @@ namespace XCharts
|
||||
var serieData = GetDataList(dataZoom);
|
||||
if (index < serieData.Count)
|
||||
{
|
||||
return serieData[index].GetCurrData(1, animation.GetUpdateAnimationDuration());
|
||||
var value = serieData[index].GetCurrData(1, animation.GetUpdateAnimationDuration());
|
||||
if (showAsPositiveNumber)
|
||||
{
|
||||
value = Mathf.Abs(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1162,6 +1285,10 @@ namespace XCharts
|
||||
if (index < serieData.Count)
|
||||
{
|
||||
yData = serieData[index].data[1];
|
||||
if (showAsPositiveNumber)
|
||||
{
|
||||
yData = Mathf.Abs(yData);
|
||||
}
|
||||
dataName = serieData[index].name;
|
||||
}
|
||||
}
|
||||
@@ -1182,24 +1309,6 @@ namespace XCharts
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的数据项的Label
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public SerieLabel GetSerieLabel(int index, DataZoom dataZoom = null)
|
||||
{
|
||||
var data = GetDataList(dataZoom);
|
||||
if (index >= 0 && index <= data.Count - 1)
|
||||
{
|
||||
var serieData = data[index];
|
||||
if (serieData.enableLabel) return serieData.label;
|
||||
else return label;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的维度X和维度Y的数据
|
||||
/// </summary>
|
||||
@@ -1218,9 +1327,25 @@ namespace XCharts
|
||||
var serieData = showData[index];
|
||||
xValue = serieData.data[0];
|
||||
yVlaue = serieData.data[1];
|
||||
if (showAsPositiveNumber)
|
||||
{
|
||||
xValue = Mathf.Abs(xValue);
|
||||
yVlaue = Mathf.Abs(yVlaue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float GetDataTotal(int dimension)
|
||||
{
|
||||
float total = 0;
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
if (sdata.show)
|
||||
total += sdata.GetData(dimension);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得系列的数据列表
|
||||
/// </summary>
|
||||
@@ -1239,31 +1364,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定维数的最大最小值
|
||||
/// </summary>
|
||||
/// <param name="dimension"></param>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public void GetMinMaxData(int dimension, out float minValue, out float maxValue, DataZoom dataZoom = null)
|
||||
{
|
||||
var dataList = GetDataList(dataZoom);
|
||||
float max = float.MinValue;
|
||||
float min = float.MaxValue;
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
var serieData = dataList[i];
|
||||
if (serieData.data.Count > dimension)
|
||||
{
|
||||
var value = serieData.data[dimension];
|
||||
if (value > max) max = value;
|
||||
if (value < min) min = value;
|
||||
}
|
||||
}
|
||||
maxValue = max;
|
||||
minValue = min;
|
||||
}
|
||||
|
||||
private List<SerieData> emptyFilter = new List<SerieData>();
|
||||
/// <summary>
|
||||
/// 根据dataZoom更新数据列表缓存
|
||||
@@ -1379,9 +1479,9 @@ namespace XCharts
|
||||
var serieData = m_Data[index];
|
||||
serieData.name = name;
|
||||
SetNameDirty();
|
||||
if (serieData.labelText != null)
|
||||
if (serieData.labelObject != null)
|
||||
{
|
||||
serieData.labelText.text = name == null ? "" : name;
|
||||
serieData.labelObject.SetText(name == null ? "" : name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1413,73 +1513,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
internal Color GetAreaColor(ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
var color = areaStyle.color != Color.clear ? areaStyle.color : (Color)theme.GetColor(index);
|
||||
if (highlight)
|
||||
{
|
||||
if (areaStyle.highlightColor != Color.clear) color = areaStyle.highlightColor;
|
||||
else color *= color;
|
||||
}
|
||||
color.a *= areaStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color GetAreaToColor(ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
if (areaStyle.toColor != Color.clear)
|
||||
{
|
||||
var color = areaStyle.toColor;
|
||||
if (highlight)
|
||||
{
|
||||
if (areaStyle.highlightToColor != Color.clear) color = areaStyle.highlightToColor;
|
||||
else color *= color;
|
||||
}
|
||||
color.a *= areaStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetAreaColor(theme, index, highlight);
|
||||
}
|
||||
}
|
||||
|
||||
internal Color GetLineColor(ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
if (lineStyle.color != Color.clear)
|
||||
{
|
||||
var color = lineStyle.color;
|
||||
if (highlight) color *= color;
|
||||
color.a *= lineStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = (Color)theme.GetColor(index);
|
||||
if (highlight) color *= color;
|
||||
color.a *= lineStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
internal Color GetSymbolColor(ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
if (symbol.color != Color.clear)
|
||||
{
|
||||
var color = symbol.color;
|
||||
if (highlight) color *= color;
|
||||
color.a *= symbol.opacity;
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = (Color)theme.GetColor(index);
|
||||
if (highlight) color *= color;
|
||||
color.a *= symbol.opacity;
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
internal float GetBarWidth(float categoryWidth)
|
||||
{
|
||||
if (m_BarWidth > 1) return m_BarWidth;
|
||||
@@ -1556,12 +1589,25 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsIngoreValue(float value)
|
||||
public bool IsIgnoreIndex(int index, int dimension)
|
||||
{
|
||||
if (m_Ignore)
|
||||
{
|
||||
var serieData = GetSerieData(index);
|
||||
if (serieData != null)
|
||||
{
|
||||
return IsIgnoreValue(serieData.GetData(dimension));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsIgnoreValue(float value)
|
||||
{
|
||||
return m_Ignore && Mathf.Approximately(value, m_IgnoreValue);
|
||||
}
|
||||
|
||||
public bool IsIngorePoint(int index)
|
||||
public bool IsIgnorePoint(int index)
|
||||
{
|
||||
if (index >= 0 && index < dataPoints.Count)
|
||||
{
|
||||
@@ -1571,19 +1617,14 @@ namespace XCharts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新运行时中心点和半径
|
||||
/// 是否为性能模式。只有折线图和柱状图才有性能模式。性能模式下不绘制Symbol,不刷新Label,不单独设置数据项配置。
|
||||
/// </summary>
|
||||
/// <param name="chartWidth"></param>
|
||||
/// <param name="chartHeight"></param>
|
||||
internal void UpdateCenter(float chartWidth, float chartHeight)
|
||||
public bool IsPerformanceMode()
|
||||
{
|
||||
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];
|
||||
runtimeCenterPos = new Vector2(centerX, centerY);
|
||||
var minWidth = Mathf.Min(chartWidth, chartHeight);
|
||||
runtimeInsideRadius = radius[0] <= 1 ? minWidth * radius[0] : radius[0];
|
||||
runtimeOutsideRadius = radius[1] <= 1 ? minWidth * radius[1] : radius[1];
|
||||
if (m_Type == SerieType.Line || m_Type == SerieType.Bar)
|
||||
return m_Large && m_Data.Count > m_LargeThreshold;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user