mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-06-17 08:13:43 +00:00
Compare commits
114 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc065edb0f | ||
|
|
2db035a9e1 | ||
|
|
78c76878d3 | ||
|
|
f130c8378a | ||
|
|
43c323153c | ||
|
|
64636b1f0f | ||
|
|
c42a46b1a9 | ||
|
|
11f639ba8d | ||
|
|
7c0534098a | ||
|
|
9118fdb660 | ||
|
|
1cf107f47b | ||
|
|
16f7781e49 | ||
|
|
ca5839576a | ||
|
|
3ef5f9653a | ||
|
|
d6df474182 | ||
|
|
5cf7b5d571 | ||
|
|
8c1cc28776 | ||
|
|
d4426776b7 | ||
|
|
2468393f14 | ||
|
|
70a303cb12 | ||
|
|
e5f136c954 | ||
|
|
dd72e773e7 | ||
|
|
8459bccb1e | ||
|
|
c73e1d6e3f | ||
|
|
695c2fe311 | ||
|
|
29598de9b7 | ||
|
|
d60ae1a5cf | ||
|
|
5443e4931a | ||
|
|
3cee08c434 | ||
|
|
5246d59173 | ||
|
|
5b923f9990 | ||
|
|
c458d4c27c | ||
|
|
49ed5ac153 | ||
|
|
616d63a4de | ||
|
|
8043b116a2 | ||
|
|
8b7955f498 | ||
|
|
ce11222784 | ||
|
|
87059b2e7f | ||
|
|
4e7bcceda3 | ||
|
|
c4f95d3c4f | ||
|
|
892b84829d | ||
|
|
519063e5e0 | ||
|
|
9dea742254 | ||
|
|
5b9652e48d | ||
|
|
02915db85b | ||
|
|
db36d68788 | ||
|
|
0dbc2e1c5c | ||
|
|
4c27359cc0 | ||
|
|
44ebca4a39 | ||
|
|
c7272f1817 | ||
|
|
4898b0060f | ||
|
|
3147eb156e | ||
|
|
6f8017f0bf | ||
|
|
7e6d7d72d7 | ||
|
|
3df991e5c0 | ||
|
|
5d885e190b | ||
|
|
be0bdd0248 | ||
|
|
78cf3dafa7 | ||
|
|
03aaa61e91 | ||
|
|
44ed434e13 | ||
|
|
067a70e385 | ||
|
|
ac61213db3 | ||
|
|
59d8b7fb52 | ||
|
|
1a52a8e098 | ||
|
|
9e51e16e9c | ||
|
|
b29fc0ed02 | ||
|
|
74b304a72d | ||
|
|
ab057cb623 | ||
|
|
3a478c2abc | ||
|
|
d8a8b5e50e | ||
|
|
8b5ddc725d | ||
|
|
55807ac941 | ||
|
|
110f4ee5f8 | ||
|
|
5aaa53c503 | ||
|
|
dc3168747c | ||
|
|
38d9232136 | ||
|
|
b661c8e3d1 | ||
|
|
1a949ecb50 | ||
|
|
27dca7c67b | ||
|
|
a19a917941 | ||
|
|
fb08b62839 | ||
|
|
bd75f43b2a | ||
|
|
668aa4ef0f | ||
|
|
837658ddcc | ||
|
|
6503ac2e24 | ||
|
|
eae0afe659 | ||
|
|
ddb526fb42 | ||
|
|
db50c8ffbe | ||
|
|
7198734083 | ||
|
|
6cfcf84b5d | ||
|
|
70bcebe9ea | ||
|
|
d45e2695a5 | ||
|
|
aef05a53ef | ||
|
|
70c9dafda3 | ||
|
|
6491660432 | ||
|
|
31b0a385de | ||
|
|
301a507c9b | ||
|
|
322a1bd9d6 | ||
|
|
fde0b3e242 | ||
|
|
6b1fb386f1 | ||
|
|
759b3f22f9 | ||
|
|
ec9277c0d8 | ||
|
|
a4d91b3c4e | ||
|
|
00996b92d0 | ||
|
|
8ba251d5be | ||
|
|
773cfe6c7d | ||
|
|
e01c55c3ca | ||
|
|
e58fb2b31f | ||
|
|
d4e7fdbb9c | ||
|
|
9e6632897b | ||
|
|
13222ddbc6 | ||
|
|
e13049774a | ||
|
|
39278499a4 | ||
|
|
912e0b55eb |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -11,10 +11,10 @@
|
|||||||
/Assets/Package
|
/Assets/Package
|
||||||
/Assets/Package.meta
|
/Assets/Package.meta
|
||||||
|
|
||||||
/Assets/XCharts/Demo/demo_test.unity
|
/Assets/XChartsDemo/demo_test.unity
|
||||||
/Assets/XCharts/Demo/demo_test.unity.meta
|
/Assets/XChartsDemo/demo_test.unity.meta
|
||||||
/Assets/XCharts/Demo/empty.unity
|
/Assets/XChartsDemo/empty.unity
|
||||||
/Assets/XCharts/Demo/empty.unity.meta
|
/Assets/XChartsDemo/empty.unity.meta
|
||||||
|
|
||||||
*.sln
|
*.sln
|
||||||
*.csproj
|
*.csproj
|
||||||
|
|||||||
@@ -1,6 +1,77 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (2020.03.14) 发布`v1.3.1`版本
|
||||||
|
* (2020.03.14) 修复`LineChart`开启`ingore`时部分数据可能绘制异常的问题
|
||||||
|
* (2020.03.13) 修复`LineChart`的`label`偏移显示异常的问题
|
||||||
|
* (2020.03.11) 发布`v1.3.0`版本
|
||||||
|
* (2020.03.11) 优化`LineChart`的`label`偏移显示
|
||||||
|
* (2020.03.11) 优化清空并重新添加数据后的自动刷新问题
|
||||||
|
* (2020.03.10) 增加`LineChart`的普通折线图可通过`ignore`参数设置忽略数据的支持
|
||||||
|
* (2020.03.09) 增加`BarChart`可通过`ItemStyle`配置边框的支持
|
||||||
|
* (2020.03.08) 增加`RingChart`环形图
|
||||||
|
* (2020.03.05) 调整`Serie`的`arcShaped`参数重命名为`roundCap`
|
||||||
|
* (2020.03.05) 增加运行时和非运行时参数变更自动刷新图表
|
||||||
|
* (2020.02.26) 重构`Legend`图例,改变样式,增加自定义图标等设置
|
||||||
|
* (2020.02.23) 增加`BaseChart.AnimationFadeOut()`渐出动画,重构动画系统
|
||||||
|
* (2020.02.13) 增加`BaseChart.RefreshTooltip()`接口立即重新初始化`Tooltip`组件
|
||||||
|
* (2020.02.13) 增加`Tooltip`的`textStyle`参数配置内容文本样式,去掉`fontSize`和`fontStyle`参数
|
||||||
|
* (2020.02.13) 增加`TextStyle`的`lineSpacing`参数配置行间距
|
||||||
|
* (2020.02.11) 增加`Radar`的`splitLine`参数配置分割线,去掉`lineStyle`参数
|
||||||
|
* (2020.02.11) 增加`Tooltip`的`backgroundImage`参数配置背景图
|
||||||
|
* (2020.02.11) 增加`Tooltip`的`paddingLeftRight`和`paddingTopBottom`参数配置文字和边框的间距
|
||||||
|
* (2020.02.11) 增加`Tooltip`的`lineStyle`参数配置指示线样式
|
||||||
|
* (2020.02.11) 增加`Axis`的`splitLine`参数控制分割线,去掉`showSplitLine`和`splitLineType`参数(更新时需要重新设置分割线相关设置)
|
||||||
|
* (2020.02.10) 增加`Serie`的`clip`参数控制是否超出坐标系外裁剪(只适用于折线图、柱状图、散点图)
|
||||||
|
* (2020.02.08) 增加`SerieSymbol`的`gap`参数控制图形标记的外留白距离
|
||||||
|
* (2020.01.26) 增加`TextLimit`组件可以设置`AxisLabel`的文本自适应
|
||||||
|
* (2020.01.20) 优化`Tooltip`设置`itemFormatter`时显示系列颜色
|
||||||
|
* (2020.01.20) 增加`Radar`雷达图在`inspector`配置`areaStyle`的支持
|
||||||
|
* (2020.01.15) 发布`v1.2.0`版本
|
||||||
|
* (2020.01.15) 增加`AxisLabel`格式化为整数的支持(`{value:f0}`)
|
||||||
|
* (2020.01.15) 增加折线图对数轴`Log`的支持
|
||||||
|
* (2020.01.09) 修复当设置`DataZoom`的`minShowNum`时可能异常的问题
|
||||||
|
* (2020.01.08) 修复当设置`AxisLine`的`onZero`时刻度显示异常的问题
|
||||||
|
* (2020.01.08) 增加`Mask`遮罩遮挡支持
|
||||||
|
* (2019.12.21) 增加`Tooltip`的单个数据项和标题的字符串模版格式器
|
||||||
|
* (2019.12.21) 增加`DataZoom`的最小显示数据个数`minShowNum`
|
||||||
|
* (2019.12.20) 增加`Demo40_Radar.cs`雷达图代码操作`Demo`
|
||||||
|
* (2019.12.20) 添加`RadarChart`相关API接口
|
||||||
|
* (2019.12.17) 发布`v1.1.0`版本
|
||||||
|
* (2019.12.16) 修复`Overlay`模式下不显示`Tooltip`的问题
|
||||||
|
* (2019.12.15) 增加`Title`的`TextStyle`支持
|
||||||
|
* (2019.12.11) 修复`Legend`都隐藏时`Value轴`还显示数值的问题
|
||||||
|
* (2019.12.11) 修复`Series->Data->Size`重置为0后设置无效的问题
|
||||||
|
* (2019.12.06) 修复数据过小时`AxisLabel`直接科学计数法显示的问题
|
||||||
|
* (2019.12.04) 优化和完善数据更新`UpdateData`接口
|
||||||
|
* (2019.12.03) 增加圆环饼图的圆角支持,参数:`serie.arcShaped`
|
||||||
|
* (2019.12.03) 增加数据更新动画,参数:`serie.animation.dataChangeEnable`
|
||||||
|
* (2019.11.30) 增加`GaugeChart`仪表盘
|
||||||
|
* (2019.11.22) 修复`BarChart`清空数据重新赋值后`SerieLabel`显示异常的问题
|
||||||
|
* (2019.11.16) 修复`SerieLabel`设置`color`等参数不生效的问题
|
||||||
|
* (2019.11.12) 发布`v1.0.5`版本
|
||||||
|
* (2019.11.12) 修复`2018.3`以下版本打开项目报错的问题
|
||||||
|
* (2019.11.12) 增加`IconStyle`子组件,优化`SerieData`的图标配置
|
||||||
|
* (2019.11.11) 修复`Serie`的图标显示在上层遮挡`Label`的问题
|
||||||
|
* (2019.11.11) 修复饼图当数据过小时视觉引导线会穿透的的问题
|
||||||
|
* (2019.11.09) 修复饼图添加数据时`Label`异常的问题
|
||||||
|
* (2019.11.09) 优化结构,分离为`XCharts`和`XChartsDemo`两部分
|
||||||
|
* (2019.11.05) 发布`v1.0.4`版本
|
||||||
|
* (2019.11.05) 增加`Radar`雷达组件文本样式参数配置支持
|
||||||
|
* (2019.11.04) 修复`Unity2018.3`以下版本代码不兼容的问题
|
||||||
|
* (2019.11.04) 优化`SerieLabel`过多时引起的性能问题
|
||||||
|
* (2019.11.03) 发布`v1.0.3`版本
|
||||||
|
* (2019.11.03) 增加`Editor`快捷添加图表:`Hierarchy`试图下右键`XCharts->LineChart`
|
||||||
|
* (2019.11.02) 优化非配置参数变量命名和访问权限,简化`API`
|
||||||
|
* (2019.10.31) 发布`v1.0.2`版本
|
||||||
|
* (2019.10.31) 修复`prefab`预设制作报错的问题
|
||||||
|
* (2019.10.31) 增加访问主题组件API:`BaseChart.themeInfo`
|
||||||
|
* (2019.10.26) 发布`v1.0.1`版本
|
||||||
|
* (2019.10.26) 修复版本检查功能在非运行时异常的问题
|
||||||
|
* (2019.10.26) 增加科学计数法显示数值的支持(查阅`forceENotation`参数)
|
||||||
|
* (2019.10.26) 增加`Axis`类目轴数据为空时的默认显示支持
|
||||||
|
* (2019.10.26) 增加`Axis`数值轴的最大最小值可设置为小数的支持,优化极小数图表的表现效果
|
||||||
|
* (2019.10.25) 发布`v1.0.0`版本
|
||||||
* (2019.10.23) 增加版本检测功能:`Component -> XCharts -> Check For Update`
|
* (2019.10.23) 增加版本检测功能:`Component -> XCharts -> Check For Update`
|
||||||
* (2019.10.22) 增加`Package Manager`安装的支持
|
* (2019.10.22) 增加`Package Manager`安装的支持
|
||||||
* (2019.10.20) 增加`Demo`首页`BarChart`的代码动态控制效果
|
* (2019.10.20) 增加`Demo`首页`BarChart`的代码动态控制效果
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5e6b0fb015bc6524d8bab146b6f2ba3a
|
guid: 5e6b0fb015bc6524d8bab146b6f2ba3a
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
timeCreated: 1553641866
|
|
||||||
licenseType: Free
|
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "XCharts.Editor.Demo",
|
|
||||||
"references": [
|
|
||||||
"XCharts.Demo.Runtime",
|
|
||||||
"XCharts.Runtime"
|
|
||||||
],
|
|
||||||
"optionalUnityReferences": [],
|
|
||||||
"includePlatforms": [
|
|
||||||
"Editor"
|
|
||||||
],
|
|
||||||
"excludePlatforms": [],
|
|
||||||
"allowUnsafeCode": false,
|
|
||||||
"overrideReferences": false,
|
|
||||||
"precompiledReferences": [],
|
|
||||||
"autoReferenced": true,
|
|
||||||
"defineConstraints": []
|
|
||||||
}
|
|
||||||
52
Assets/XCharts/Demo/Runtime/Demo01_UpdateData.cs
Normal file
52
Assets/XCharts/Demo/Runtime/Demo01_UpdateData.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class Demo01_UpdateData : MonoBehaviour
|
||||||
|
{
|
||||||
|
private float updateTime = 0;
|
||||||
|
BaseChart chart;
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
chart = gameObject.GetComponent<BaseChart>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
updateTime += Time.deltaTime;
|
||||||
|
if (chart && updateTime > 2)
|
||||||
|
{
|
||||||
|
updateTime = 0;
|
||||||
|
var serie = chart.series.GetSerie(0);
|
||||||
|
//serie.animation.dataChangeEnable = true;
|
||||||
|
var dataCount = serie.dataCount;
|
||||||
|
if (chart is RadarChart)
|
||||||
|
{
|
||||||
|
var dimension = serie.GetSerieData(0).data.Count - 1;
|
||||||
|
chart.UpdateData(0, 0, Random.Range(0, dimension + 1), Random.Range(0, 100));
|
||||||
|
}
|
||||||
|
else if (chart is HeatmapChart)
|
||||||
|
{
|
||||||
|
var dimension = serie.GetSerieData(0).data.Count - 1;
|
||||||
|
for (int i = 0; i < dataCount; i++)
|
||||||
|
{
|
||||||
|
chart.UpdateData(0, i, dimension, Random.Range(0, 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chart.UpdateData(0, Random.Range(0, dataCount), Random.Range(10, 90));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5420ab107823641e49c2df9e3556ea30
|
guid: e6faaaf3d4a8444b4b2736825e237fcf
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -38,10 +38,12 @@ namespace XCharts
|
|||||||
|
|
||||||
chart.RemoveData();
|
chart.RemoveData();
|
||||||
chart.AddSerie(SerieType.Line);
|
chart.AddSerie(SerieType.Line);
|
||||||
|
chart.AddSerie(SerieType.Line);
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
chart.AddXAxisData("x" + i);
|
chart.AddXAxisData("x" + i);
|
||||||
chart.AddData(0, Random.Range(10, 20));
|
chart.AddData(0, Random.Range(10, 20));
|
||||||
|
chart.AddData(1, Random.Range(10, 20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ namespace XCharts
|
|||||||
|
|
||||||
chart.RemoveData();
|
chart.RemoveData();
|
||||||
serie = chart.AddSerie(SerieType.Pie, "访问来源");
|
serie = chart.AddSerie(SerieType.Pie, "访问来源");
|
||||||
serie.pieRadius[0] = 0;
|
serie.radius[0] = 0;
|
||||||
serie.pieRadius[1] = 110;
|
serie.radius[1] = 110;
|
||||||
serie.pieCenter[0] = 0.5f;
|
serie.center[0] = 0.5f;
|
||||||
serie.pieCenter[1] = 0.4f;
|
serie.center[1] = 0.4f;
|
||||||
chart.AddData(0, 335, "直接访问");
|
chart.AddData(0, 335, "直接访问");
|
||||||
chart.AddData(0, 310, "邮件营销");
|
chart.AddData(0, 310, "邮件营销");
|
||||||
chart.AddData(0, 243, "联盟广告");
|
chart.AddData(0, 243, "联盟广告");
|
||||||
@@ -105,10 +105,10 @@ namespace XCharts
|
|||||||
IEnumerator Doughnut()
|
IEnumerator Doughnut()
|
||||||
{
|
{
|
||||||
chart.title.subText = "圆环图";
|
chart.title.subText = "圆环图";
|
||||||
serie.pieRadius[0] = 2f;
|
serie.radius[0] = 2f;
|
||||||
while (serie.pieRadius[0] < serie.pieRadius[1] * 0.7f)
|
while (serie.radius[0] < serie.radius[1] * 0.7f)
|
||||||
{
|
{
|
||||||
serie.pieRadius[0] += m_RadiusSpeed * Time.deltaTime;
|
serie.radius[0] += m_RadiusSpeed * Time.deltaTime;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
@@ -134,14 +134,14 @@ namespace XCharts
|
|||||||
chart.AddData(1, 335, "直达");
|
chart.AddData(1, 335, "直达");
|
||||||
chart.AddData(1, 679, "营销广告");
|
chart.AddData(1, 679, "营销广告");
|
||||||
chart.AddData(1, 1548, "搜索引擎");
|
chart.AddData(1, 1548, "搜索引擎");
|
||||||
serie1.pieRadius[0] = 0;
|
serie1.radius[0] = 0;
|
||||||
serie1.pieRadius[1] = 2f;
|
serie1.radius[1] = 2f;
|
||||||
serie1.pieCenter[0] = 0.5f;
|
serie1.center[0] = 0.5f;
|
||||||
serie1.pieCenter[1] = 0.4f;
|
serie1.center[1] = 0.4f;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
while (serie1.pieRadius[1] < serie.pieRadius[0] * 0.75f)
|
while (serie1.radius[1] < serie.radius[0] * 0.75f)
|
||||||
{
|
{
|
||||||
serie1.pieRadius[1] += m_RadiusSpeed * Time.deltaTime;
|
serie1.radius[1] += m_RadiusSpeed * Time.deltaTime;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ namespace XCharts
|
|||||||
chart.legend.show = false;
|
chart.legend.show = false;
|
||||||
serie1.ClearData();
|
serie1.ClearData();
|
||||||
serie.ClearData();
|
serie.ClearData();
|
||||||
serie1.pieRadius = serie.pieRadius = new float[2] { 0, 80 };
|
serie1.radius = serie.radius = new float[2] { 0, 80 };
|
||||||
serie1.label.position = SerieLabel.Position.Outside;
|
serie1.label.position = SerieLabel.Position.Outside;
|
||||||
serie1.label.lineType = SerieLabel.LineType.Curves;
|
serie1.label.lineType = SerieLabel.LineType.Curves;
|
||||||
serie1.label.color = Color.clear;
|
serie1.label.color = Color.clear;
|
||||||
@@ -179,24 +179,24 @@ namespace XCharts
|
|||||||
chart.AddData(i, 40, "rose8");
|
chart.AddData(i, 40, "rose8");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (serie.pieCenter[0] > 0.25f || serie1.pieCenter[0] < 0.7f)
|
while (serie.center[0] > 0.25f || serie1.center[0] < 0.7f)
|
||||||
{
|
{
|
||||||
if (serie.pieCenter[0] > 0.25f) serie.pieCenter[0] -= m_CenterSpeed * Time.deltaTime;
|
if (serie.center[0] > 0.25f) serie.center[0] -= m_CenterSpeed * Time.deltaTime;
|
||||||
if (serie1.pieCenter[0] < 0.7f) serie1.pieCenter[0] += m_CenterSpeed * Time.deltaTime;
|
if (serie1.center[0] < 0.7f) serie1.center[0] += m_CenterSpeed * Time.deltaTime;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
yield return new WaitForSeconds(1);
|
yield return new WaitForSeconds(1);
|
||||||
while (serie.pieRadius[0] > 3f)
|
while (serie.radius[0] > 3f)
|
||||||
{
|
{
|
||||||
serie.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
|
serie.radius[0] -= m_RadiusSpeed * Time.deltaTime;
|
||||||
serie1.pieRadius[0] -= m_RadiusSpeed * Time.deltaTime;
|
serie1.radius[0] -= m_RadiusSpeed * Time.deltaTime;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
serie.pieRadius[0] = 0;
|
serie.radius[0] = 0;
|
||||||
serie1.pieRadius[0] = 0;
|
serie1.radius[0] = 0;
|
||||||
serie.pieRoseType = RoseType.Area;
|
serie.pieRoseType = RoseType.Area;
|
||||||
serie1.pieRoseType = RoseType.Radius;
|
serie1.pieRoseType = RoseType.Radius;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
|
|||||||
124
Assets/XCharts/Demo/Runtime/Demo40_Radar.cs
Normal file
124
Assets/XCharts/Demo/Runtime/Demo40_Radar.cs
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
public class Demo40_Radar : MonoBehaviour
|
||||||
|
{
|
||||||
|
private RadarChart chart;
|
||||||
|
private Serie serie, serie1;
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
LoopDemo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
LoopDemo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoopDemo()
|
||||||
|
{
|
||||||
|
StopAllCoroutines();
|
||||||
|
StartCoroutine(RadarDemo());
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator RadarDemo()
|
||||||
|
{
|
||||||
|
StartCoroutine(RadarAdd());
|
||||||
|
yield return new WaitForSeconds(2);
|
||||||
|
StartCoroutine(RadarUpdate());
|
||||||
|
yield return new WaitForSeconds(2);
|
||||||
|
StartCoroutine(RadarAddMultiple());
|
||||||
|
yield return new WaitForSeconds(2);
|
||||||
|
LoopDemo();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator RadarAdd()
|
||||||
|
{
|
||||||
|
chart = gameObject.GetComponent<RadarChart>();
|
||||||
|
if (chart == null) chart = gameObject.AddComponent<RadarChart>();
|
||||||
|
chart.RemoveRadar();
|
||||||
|
chart.RemoveData();
|
||||||
|
|
||||||
|
chart.title.text = "RadarChart - 雷达图";
|
||||||
|
chart.title.subText = "";
|
||||||
|
|
||||||
|
chart.legend.show = true;
|
||||||
|
chart.legend.location.align = Location.Align.TopLeft;
|
||||||
|
chart.legend.location.top = 60;
|
||||||
|
chart.legend.location.left = 2;
|
||||||
|
chart.legend.itemWidth = 70;
|
||||||
|
chart.legend.itemHeight = 20;
|
||||||
|
chart.legend.orient = Orient.Vertical;
|
||||||
|
|
||||||
|
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.5f, 0.4f), 0.4f);
|
||||||
|
chart.AddIndicator(0, "indicator1", 0, 100);
|
||||||
|
chart.AddIndicator(0, "indicator2", 0, 100);
|
||||||
|
chart.AddIndicator(0, "indicator3", 0, 100);
|
||||||
|
chart.AddIndicator(0, "indicator4", 0, 100);
|
||||||
|
chart.AddIndicator(0, "indicator5", 0, 100);
|
||||||
|
|
||||||
|
serie = chart.AddSerie(SerieType.Radar, "test");
|
||||||
|
serie.radarIndex = 0;
|
||||||
|
chart.AddData(0, new List<float> { 10, 20, 60, 40, 20 }, "data1");
|
||||||
|
chart.AddData(0, new List<float> { 40, 60, 90, 80, 70 }, "data2");
|
||||||
|
yield return new WaitForSeconds(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator RadarUpdate()
|
||||||
|
{
|
||||||
|
chart.UpdateIndicator(0, 0, "new1", 0, 100);
|
||||||
|
chart.UpdateData(0, 0, new List<float> { 15, 30, 50, 60, 50 });
|
||||||
|
chart.UpdateDataName(0, 0, "new1");
|
||||||
|
yield return new WaitForSeconds(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator RadarAddMultiple()
|
||||||
|
{
|
||||||
|
chart.RemoveRadar();
|
||||||
|
chart.RemoveData();
|
||||||
|
|
||||||
|
chart.title.text = "RadarChart - 多雷达图";
|
||||||
|
chart.title.subText = "";
|
||||||
|
|
||||||
|
chart.legend.show = true;
|
||||||
|
chart.legend.location.align = Location.Align.TopLeft;
|
||||||
|
chart.legend.location.top = 60;
|
||||||
|
chart.legend.location.left = 2;
|
||||||
|
chart.legend.itemWidth = 70;
|
||||||
|
chart.legend.itemHeight = 20;
|
||||||
|
chart.legend.orient = Orient.Vertical;
|
||||||
|
|
||||||
|
chart.AddRadar(Radar.Shape.Polygon, new Vector2(0.25f, 0.4f), 0.25f);
|
||||||
|
for (int i = 1; i <= 5; i++)
|
||||||
|
{
|
||||||
|
chart.AddIndicator(0, "radar1" + i, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
chart.AddRadar(Radar.Shape.Circle, new Vector2(0.75f, 0.4f), 0.25f);
|
||||||
|
for (int i = 1; i <= 5; i++)
|
||||||
|
{
|
||||||
|
chart.AddIndicator(1, "radar2" + i, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
serie = chart.AddSerie(SerieType.Radar, "test1");
|
||||||
|
serie.radarIndex = 0;
|
||||||
|
chart.AddData(0, new List<float> { 10, 20, 60, 40, 20 }, "data1");
|
||||||
|
|
||||||
|
serie1 = chart.AddSerie(SerieType.Radar, "test2");
|
||||||
|
serie1.radarIndex = 1;
|
||||||
|
chart.AddData(1, new List<float> { 10, 20, 60, 40, 20 }, "data2");
|
||||||
|
yield return new WaitForSeconds(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 73e326ed8a76f90408bfa9feb1797433
|
guid: cb56350d2a2b24960a7174a1d3f2ea56
|
||||||
timeCreated: 1555379601
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
70
Assets/XCharts/Demo/Runtime/Demo70_Gauge.cs
Normal file
70
Assets/XCharts/Demo/Runtime/Demo70_Gauge.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class Demo70_Gauge : MonoBehaviour
|
||||||
|
{
|
||||||
|
private GaugeChart chart;
|
||||||
|
private float updateTime;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
chart = gameObject.GetComponent<GaugeChart>();
|
||||||
|
if (chart == null)
|
||||||
|
{
|
||||||
|
chart = gameObject.AddComponent<GaugeChart>();
|
||||||
|
}
|
||||||
|
chart.title.text = "GaugeChart";
|
||||||
|
chart.RemoveData();
|
||||||
|
|
||||||
|
var serie = chart.AddSerie(SerieType.Gauge, "速度");
|
||||||
|
serie.min = 0;
|
||||||
|
serie.max = 220;
|
||||||
|
serie.startAngle = -125;
|
||||||
|
serie.endAngle = 125;
|
||||||
|
serie.center[0] = 0.5f;
|
||||||
|
serie.center[1] = 0.5f;
|
||||||
|
serie.radius[0] = 80;
|
||||||
|
serie.splitNumber = 5;
|
||||||
|
serie.animation.dataChangeEnable = true;
|
||||||
|
serie.roundCap = true;
|
||||||
|
|
||||||
|
serie.titleStyle.show = true;
|
||||||
|
serie.titleStyle.textStyle.offset = new Vector2(0, 20);
|
||||||
|
|
||||||
|
serie.label.show = true;
|
||||||
|
serie.label.offset = new Vector3(0, -20);
|
||||||
|
|
||||||
|
serie.gaugeAxis.show = true;
|
||||||
|
serie.gaugeAxis.axisLine.width = 15;
|
||||||
|
|
||||||
|
serie.gaugePointer.show = true;
|
||||||
|
serie.gaugePointer.width = 15;
|
||||||
|
|
||||||
|
var value = UnityEngine.Random.Range(serie.min, serie.max);
|
||||||
|
chart.AddData(0, value, "km/h");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
updateTime += Time.deltaTime;
|
||||||
|
if (updateTime > 2)
|
||||||
|
{
|
||||||
|
updateTime = 0;
|
||||||
|
var value = UnityEngine.Random.Range(0, 220);
|
||||||
|
chart.UpdateData(0, 0, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Demo/Runtime/Demo70_Gauge.cs.meta
Normal file
11
Assets/XCharts/Demo/Runtime/Demo70_Gauge.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 250f744fcb07d4401994d964c4369d9d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -14,27 +14,42 @@ namespace XCharts
|
|||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
public class Demo_Test : MonoBehaviour
|
public class Demo_Test : MonoBehaviour
|
||||||
{
|
{
|
||||||
LineChart chart;
|
private float updateTime = 0;
|
||||||
|
BaseChart chart;
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
chart = gameObject.GetComponent<LineChart>();
|
chart = gameObject.GetComponent<BaseChart>();
|
||||||
if (chart == null)
|
var btnTrans = transform.parent.Find("Button");
|
||||||
|
if (btnTrans)
|
||||||
{
|
{
|
||||||
chart = gameObject.AddComponent<LineChart>();
|
btnTrans.gameObject.GetComponent<Button>().onClick.AddListener(OnTestBtn);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var buttom = transform.parent.gameObject.GetComponentInChildren<Button>();
|
void Update()
|
||||||
buttom.onClick.AddListener(AddData);
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.Space))
|
||||||
|
{
|
||||||
|
AddData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTestBtn()
|
||||||
|
{
|
||||||
|
chart.ClearData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddData()
|
void AddData()
|
||||||
{
|
{
|
||||||
chart.series.list[0].ClearData();
|
chart.ClearData();
|
||||||
chart.series.list[1].ClearData();
|
int count = Random.Range(5, 20);
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
chart.AddData(0, Random.Range(20, 100));
|
(chart as CoordinateChart).AddXAxisData("x" + i);
|
||||||
chart.AddData(1, Random.Range(1, 10));
|
if (Random.Range(1, 3) == 2)
|
||||||
|
chart.AddData(0, Random.Range(10, 200));
|
||||||
|
else
|
||||||
|
chart.AddData(0, Random.Range(10, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,8 +6,7 @@
|
|||||||
|
|
||||||
## `BaseChart`
|
## `BaseChart`
|
||||||
|
|
||||||
---
|
* `BaseChart.themeInfo`:主题组件`ThemeInfo`。
|
||||||
|
|
||||||
* `BaseChart.title`:标题组件`Title`。
|
* `BaseChart.title`:标题组件`Title`。
|
||||||
* `BaseChart.legend`:图例组件`Legend`。
|
* `BaseChart.legend`:图例组件`Legend`。
|
||||||
* `BaseChart.tooltip`:提示框组件`Tooltip`。
|
* `BaseChart.tooltip`:提示框组件`Tooltip`。
|
||||||
@@ -28,6 +27,10 @@
|
|||||||
* `BaseChart.AddData(int serieIndex, float xValue, float yValue, string dataName = null)`:添加`(x,y)`数据到指定系列中。
|
* `BaseChart.AddData(int serieIndex, float xValue, float yValue, string dataName = null)`:添加`(x,y)`数据到指定系列中。
|
||||||
* `BaseChart.UpdateData(string serieName,int dataIndex, float value)`:更新指定系列中的指定索引数据。
|
* `BaseChart.UpdateData(string serieName,int dataIndex, float value)`:更新指定系列中的指定索引数据。
|
||||||
* `BaseChart.UpdateData(int serieIndex,int dataIndex, float value)`:更新指定系列中的指定索引数据。
|
* `BaseChart.UpdateData(int serieIndex,int dataIndex, float value)`:更新指定系列中的指定索引数据。
|
||||||
|
* `BaseChart.UpdateData(string serieName, int dataIndex, List<float> multidimensionalData)`:更新指定系列指定索引的数据项的多维数据。
|
||||||
|
* `BaseChart.UpdateData(int serieIndex, int dataIndex, List<float> multidimensionalData)`:更新指定系列指定索引的数据项的多维数据。
|
||||||
|
* `BaseChart.UpdateData(string serieName, int dataIndex, int dimension, float value)`:更新指定系列指定索引指定维数的数据。维数从0开始。
|
||||||
|
* `BaseChart.UpdateData(int serieIndex, int dataIndex, int dimension, float value)`:更新指定系列指定索引指定维数的数据。维数从0开始。
|
||||||
* `BaseChart.UpdateDataName(string serieName,int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
|
* `BaseChart.UpdateDataName(string serieName,int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
|
||||||
* `BaseChart.UpdateDataName(int serieIndex, int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
|
* `BaseChart.UpdateDataName(int serieIndex, int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
|
||||||
* `BaseChart.SetActive(string serieName, bool active)`:设置指定系列是否显示。
|
* `BaseChart.SetActive(string serieName, bool active)`:设置指定系列是否显示。
|
||||||
@@ -37,17 +40,18 @@
|
|||||||
* `BaseChart.IsActiveByLegend(string legendName)`:获得指定图例名字的系列是否显示。
|
* `BaseChart.IsActiveByLegend(string legendName)`:获得指定图例名字的系列是否显示。
|
||||||
* `BaseChart.RefreshChart()`:在下一帧刷新图表。
|
* `BaseChart.RefreshChart()`:在下一帧刷新图表。
|
||||||
* `BaseChart.RefreshLabel()`:在下一帧刷新文本标签。
|
* `BaseChart.RefreshLabel()`:在下一帧刷新文本标签。
|
||||||
|
* `BaseChart.RefreshTooltip()`:立即刷新`Tooltip`组件。
|
||||||
* `BaseChart.UpdateTheme(Theme theme)`:切换图表主题。
|
* `BaseChart.UpdateTheme(Theme theme)`:切换图表主题。
|
||||||
* `BaseChart.AnimationEnable(bool flag)`:启用或关闭起始动画。
|
* `BaseChart.AnimationEnable(bool flag)`:启用或关闭动画。
|
||||||
* `BaseChart.AnimationStart()`:开始初始动画。
|
* `BaseChart.AnimationFadeIn()`:渐入动画。
|
||||||
* `BaseChart.AnimationStop()`:停止初始化动画。
|
* `BaseChart.AnimationFadeOut()`:渐出动画。
|
||||||
* `BaseChart.AnimationReset()`:重置初始动画,重新播放。
|
* `BaseChart.AnimationPause()`:暂停动画。
|
||||||
|
* `BaseChart.AnimationResume()`:继续动画。
|
||||||
|
* `BaseChart.AnimationReset()`:重置动画。
|
||||||
* `BaseChart.ClickLegendButton(int legendIndex, string legendName, bool show)`:点击图例按钮。
|
* `BaseChart.ClickLegendButton(int legendIndex, string legendName, bool show)`:点击图例按钮。
|
||||||
|
|
||||||
## `CoordinateChart`
|
## `CoordinateChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `CoordinateChart.grid`:网格组件 `Grid`。
|
* `CoordinateChart.grid`:网格组件 `Grid`。
|
||||||
* `CoordinateChart.xAxises`:左右两个 `X` 轴组件 `XAxis`。
|
* `CoordinateChart.xAxises`:左右两个 `X` 轴组件 `XAxis`。
|
||||||
* `CoordinateChart.yAxises`:左右两个 `Y` 轴组件 `YAxis`。
|
* `CoordinateChart.yAxises`:左右两个 `Y` 轴组件 `YAxis`。
|
||||||
@@ -69,45 +73,48 @@
|
|||||||
|
|
||||||
## `LineChart`
|
## `LineChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* 继承 `BaseChart`。
|
* 继承 `BaseChart`。
|
||||||
* 继承自 `CoordinateChart`。
|
* 继承自 `CoordinateChart`。
|
||||||
|
|
||||||
## `BarChart`
|
## `BarChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* 继承自 `BaseChart`。
|
* 继承自 `BaseChart`。
|
||||||
* 继承自 `CoordinateChart`。
|
* 继承自 `CoordinateChart`。
|
||||||
|
|
||||||
## `PieChart`
|
## `PieChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* 继承自 `BaseChart`。
|
* 继承自 `BaseChart`。
|
||||||
|
|
||||||
## `RadarChart`
|
## `RadarChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* 继承自 `BaseChart`。
|
* 继承自 `BaseChart`。
|
||||||
* `radars`:雷达组件列表 `Radar`。
|
* `RadarChart.radars`:雷达坐标系组件列表 `Radar`。
|
||||||
|
* `RadarChart.RemoveRadar()`:移除所有雷达坐标系组件。
|
||||||
|
* `RadarChart.AddRadar(Radar radar)`:添加雷达坐标系组件。
|
||||||
|
* `RadarChart.AddRadar(Radar.Shape shape, Vector2 center, float radius, int splitNumber = 5,float lineWidth = 0.6f, bool showIndicator = true, bool showSplitArea = true)`:添加雷达坐标系组件。
|
||||||
|
* `RadarChart.AddIndicator(int radarIndex, string name, float min, float max)`:添加指示器。
|
||||||
|
* `RadarChart.UpdateIndicator(int radarIndex, int indicatorIndex, string name, float min, float max)`:更新指示器。
|
||||||
|
* `RadarChart.GetRadar(int radarIndex)`:获得指定索引的雷达坐标系组件。
|
||||||
|
* `RadarChart.GetIndicator(int radarIndex, int indicatorIndex)`:获得指定雷达坐标系组件指定索引的指示器。
|
||||||
|
|
||||||
## `ScatterChart`
|
## `ScatterChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* 继承自 `BaseChart`。
|
* 继承自 `BaseChart`。
|
||||||
* 继承自 `CoordinateChart`。
|
* 继承自 `CoordinateChart`。
|
||||||
|
|
||||||
## `HeatmapChart`
|
## `HeatmapChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* 继承自 `BaseChart`。
|
* 继承自 `BaseChart`。
|
||||||
* 继承自 `CoordinateChart`。
|
* 继承自 `CoordinateChart`。
|
||||||
|
|
||||||
|
## `RingChart`
|
||||||
|
|
||||||
|
* 继承自 `BaseChart`。
|
||||||
|
* `RingChart.UpdateMax(int serieIndex, int dataIndex, float value)`:更新指定系列执行数据项的最大值。
|
||||||
|
* `RingChart.UpdateMax(int serieIndex, float value)`:更新指定系列的所有数据项的最大值。
|
||||||
|
* `RingChart.UpdateMax(float value)`:更新第一个系列第一个数据项的最大值。
|
||||||
|
|
||||||
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
|
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
|
||||||
[XCharts配置项手册](XCharts配置项手册.md)
|
[XCharts配置项手册](XCharts配置项手册.md)
|
||||||
[XCharts问答](XCharts问答.md)
|
[XCharts问答](XCharts问答.md)
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,16 @@
|
|||||||
* [DataZoom 区域缩放](#DataZoom)
|
* [DataZoom 区域缩放](#DataZoom)
|
||||||
* [Grid 网格](#Grid)
|
* [Grid 网格](#Grid)
|
||||||
* [Legend 图例](#Legend)
|
* [Legend 图例](#Legend)
|
||||||
|
* [Radar 雷达](#Radar)
|
||||||
* [Series 系列](#Series)
|
* [Series 系列](#Series)
|
||||||
|
* [Serie-Line 折线图](#Serie-Line)
|
||||||
|
* [Serie-Bar 柱形图](#Serie-Bar)
|
||||||
|
* [Serie-Pie 饼图](#Serie-Pie)
|
||||||
|
* [Serie-Radar 雷达图](#Serie-Radar)
|
||||||
|
* [Serie-Scatter 散点图](#Serie-Scatter)
|
||||||
|
* [Serie-Heatmap 热力图](#Serie-Heatmap)
|
||||||
|
* [Serie-Gauge 仪表盘](#Serie-Gauge)
|
||||||
|
* [Serie-Ring 环形图](#Serie-Ring)
|
||||||
* [Settings 设置](#Settings)
|
* [Settings 设置](#Settings)
|
||||||
* [Theme 主题](#Theme)
|
* [Theme 主题](#Theme)
|
||||||
* [Tooltip 提示框](#Tooltip)
|
* [Tooltip 提示框](#Tooltip)
|
||||||
@@ -23,6 +32,7 @@
|
|||||||
* [AxisLabel 坐标轴刻度标签](#AxisLabel)
|
* [AxisLabel 坐标轴刻度标签](#AxisLabel)
|
||||||
* [AxisLine 坐标轴轴线](#AxisLine)
|
* [AxisLine 坐标轴轴线](#AxisLine)
|
||||||
* [AxisName 坐标轴名称](#AxisName)
|
* [AxisName 坐标轴名称](#AxisName)
|
||||||
|
* [AxisSplitLine 坐标轴分割线条](#AxisSplitLine)
|
||||||
* [AxisSplitArea 坐标轴分割区域](#AxisSplitArea)
|
* [AxisSplitArea 坐标轴分割区域](#AxisSplitArea)
|
||||||
* [AxisTick 坐标轴刻度](#AxisTick)
|
* [AxisTick 坐标轴刻度](#AxisTick)
|
||||||
* [Emphasis 高亮样式](#Emphasis)
|
* [Emphasis 高亮样式](#Emphasis)
|
||||||
@@ -34,10 +44,11 @@
|
|||||||
* [SerieData 数据项](#SerieData)
|
* [SerieData 数据项](#SerieData)
|
||||||
* [SerieLabel 图形上的文本标签](#SerieLabel)
|
* [SerieLabel 图形上的文本标签](#SerieLabel)
|
||||||
* [SerieSymbol 图形标记](#SerieSymbol)
|
* [SerieSymbol 图形标记](#SerieSymbol)
|
||||||
|
* [TextLimit 文本自适应](#TextLimit)
|
||||||
|
* [TextStyle 文本样式](#TextStyle)
|
||||||
|
|
||||||
## `Theme`
|
## `Theme`
|
||||||
|
|
||||||
---
|
|
||||||
主题组件。主题用来配置图表的全局配色等其他参数。
|
主题组件。主题用来配置图表的全局配色等其他参数。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -70,22 +81,31 @@
|
|||||||
|
|
||||||
## `Title`
|
## `Title`
|
||||||
|
|
||||||
---
|
|
||||||
标题组件,包含主标题和副标题。
|
标题组件,包含主标题和副标题。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
|
|
||||||
* `show`:是否显示标题组件。
|
* `show`:是否显示标题组件。
|
||||||
* `text`:主标题文本,支持使用 `\n` 换行。
|
* `text`:主标题文本,支持使用 `\n` 换行。
|
||||||
* `textFontSize`:主标题文字的字体大小。
|
* `textStyle`:主标题文本样式 [TextStyle](#TextStyle)。
|
||||||
* `subText`:副标题文本,支持使用 `\n` 换行。
|
* `subText`:副标题文本,支持使用 `\n` 换行。
|
||||||
* `subTextFontSize`:副标题文字的字体大小。
|
* `subTextStyle`:副标题文本样式 [TextStyle](#TextStyle)。
|
||||||
* `itemGap`:主副标题之间的间距。
|
* `itemGap`:主副标题之间的间距。
|
||||||
* `location`:标题显示位置 [Location](#Location)。
|
* `location`:标题显示位置 [Location](#Location)。
|
||||||
|
|
||||||
|
## `TitleStyle`
|
||||||
|
|
||||||
|
标题样式。
|
||||||
|
|
||||||
|
* `show`:是否显示标题组件。
|
||||||
|
* `rotate`:旋转。
|
||||||
|
* `offset`:偏移。
|
||||||
|
* `color`:颜色。
|
||||||
|
* `fontSize`:字体大小。
|
||||||
|
* `fontStyle`:字体风格。
|
||||||
|
|
||||||
## `Legend`
|
## `Legend`
|
||||||
|
|
||||||
---
|
|
||||||
图例组件。图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
图例组件。图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -99,12 +119,14 @@
|
|||||||
* `Horizonal`:水平。
|
* `Horizonal`:水平。
|
||||||
* `Vertical`:垂直。
|
* `Vertical`:垂直。
|
||||||
* `location`:图例的显示位置 [Location](#Location)。
|
* `location`:图例的显示位置 [Location](#Location)。
|
||||||
* `itemWidth`:每个图例项的宽度。
|
* `itemWidth`:图例标记的图形宽度。
|
||||||
* `itemHeight`:每个图例项的高度。
|
* `itemHeight`:图例标记的图形高度。
|
||||||
* `itemGap`:图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
|
* `itemGap`:图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
|
||||||
* `itemFontSize`:图例项的字体大小。
|
* `itemAutoColor`:图例标记的图形是否自动匹配颜色。
|
||||||
* `formatter`:图例内容字符串模版格式器。支持用 `\n` 换行。模板变量为图例名称 `{name}`
|
* `formatter`:图例内容字符串模版格式器。支持用 `\n` 换行。模板变量为图例名称 `{name}`
|
||||||
* `data`:图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 `name`(如果是饼图,也可以是饼图单个数据的 `name`)。如果 `data` 没有被指定,会自动从当前系列中获取。指定 `data` 时里面的数据项和 `serie` 匹配时才会生效。
|
* `data`:图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 `name`(如果是饼图,也可以是饼图单个数据的 `name`)。如果 `data` 没有被指定,会自动从当前系列中获取。指定 `data` 时里面的数据项和 `serie` 匹配时才会生效。
|
||||||
|
* `icons`:自定义的图例标记图形。
|
||||||
|
* `textStyle`:图例的内容文本样式 [TextStyle](#TextStyle)。
|
||||||
|
|
||||||
相关接口:
|
相关接口:
|
||||||
|
|
||||||
@@ -115,9 +137,48 @@
|
|||||||
* `GetData(int index)`:获得指定索引的图例。
|
* `GetData(int index)`:获得指定索引的图例。
|
||||||
* `GetIndex(string legendName)`:获得指定图例的索引。
|
* `GetIndex(string legendName)`:获得指定图例的索引。
|
||||||
|
|
||||||
## `Tooltip`
|
## `Radar`
|
||||||
|
|
||||||
---
|
* `shape`:雷达图绘制类型。
|
||||||
|
* `Polygon`:多边形。
|
||||||
|
* `Circle`:圆形。
|
||||||
|
* `positionType`:显示位置类型。
|
||||||
|
* `Vertice`:显示在顶点处。
|
||||||
|
* `Between`:显示在顶点之间。
|
||||||
|
* `radius`:雷达图的半径。
|
||||||
|
* `center`:雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||||
|
* `splitLine`:分割线条 [AxisSplitLine](#AxisSplitLine)。
|
||||||
|
* `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。
|
||||||
|
* `indicator`:是否显示指示器。
|
||||||
|
* `indicatorGap`:指示器和雷达的间距。
|
||||||
|
* `indicatorList`指示器列表 [Radar.Indicator](#Radar.Indicator)。
|
||||||
|
|
||||||
|
## `Radar.Indicator`
|
||||||
|
|
||||||
|
* `name`:指示器名称。
|
||||||
|
* `max`:指示器的最大值,默认为 0 无限制。
|
||||||
|
* `min`:指示器的最小值,默认为 0 无限制。
|
||||||
|
* `textStyle`:文本样式 [TextStyle](#TextStyle)。
|
||||||
|
|
||||||
|
## `TextLimit`
|
||||||
|
|
||||||
|
* `enable`:是否启用文本自适应。默认为`true`。
|
||||||
|
* `maxWidth`:设定最大宽度。默认为`0`表示自动获取,否则表示自定义。当文本的宽度大于该值进行裁剪。
|
||||||
|
* `gap`:两边留白像素距离。默认为`10`。
|
||||||
|
* `suffix`: 长度超出被裁剪后附加的后缀。默认为`...`。
|
||||||
|
|
||||||
|
## `TextStyle`
|
||||||
|
|
||||||
|
* `rotate`:旋转。
|
||||||
|
* `offset`:偏移。
|
||||||
|
* `color`:颜色。
|
||||||
|
* `backgroundColor`:背景颜色。
|
||||||
|
* `font`:字体。
|
||||||
|
* `fontSize`:字体大小。
|
||||||
|
* `fontStyle`:字体风格。
|
||||||
|
* `lineSpacing`:行间距。
|
||||||
|
|
||||||
|
## `Tooltip`
|
||||||
|
|
||||||
提示框组件。
|
提示框组件。
|
||||||
|
|
||||||
@@ -129,20 +190,27 @@
|
|||||||
* `Shadow`:阴影指示器。
|
* `Shadow`:阴影指示器。
|
||||||
* `None`:无指示器。
|
* `None`:无指示器。
|
||||||
* `Corss`:十字准星指示器。坐标轴显示Label和交叉线。
|
* `Corss`:十字准星指示器。坐标轴显示Label和交叉线。
|
||||||
* `formatter`:提示框内容字符串模版格式器。支持用 `\n` 或 `<br/>` 换行。其中变量 `{a}`, `{b}`, `{c}`, `{d}` 在不同图表类型下代表数据含义为:
|
* `formatter`:提示框内容字符串模版格式器。支持用 `\n` 或 `<br/>` 换行。当`formatter`不为空时,优先使用`formatter`,否则使用`itemFormatter`。示例:`{a}:{c}`,`{a1}:{c1:f1}`。其中变量 `{a}`, `{b}`, `{c}`, `{d}` 在不同图表类型下代表数据含义为:
|
||||||
* 折线(区域)图、柱状(条形)图、K线图 : `{a}`(系列名称),`{b}`(类目值),`{c}`(数值), `{d}`(无)。
|
* 折线(区域)图、柱状(条形)图、K线图 : `{a}`(系列名称),`{b}`(类目值),`{c}`(数值), `{d}`(无)。
|
||||||
* 散点图(气泡)图 : `{a}`(系列名称),`{b}`(数据名称),`{c}`(数值数组), `{d}`(无)。
|
* 散点图(气泡)图 : `{a}`(系列名称),`{b}`(数据名称),`{c}`(数值数组), `{d}`(无)。
|
||||||
* 地图 : `{a}`(系列名称),`{b}`(区域名称),`{c}`(合并数值), `{d}`(无)。
|
* 地图 : `{a}`(系列名称),`{b}`(区域名称),`{c}`(合并数值), `{d}`(无)。
|
||||||
* 饼图、仪表盘、漏斗图: `{a}`(系列名称),`{b}`(数据项名称),`{c}`(数值), `{d}`(百分比)。
|
* 饼图、仪表盘、漏斗图: `{a}`(系列名称),`{b}`(数据项名称),`{c}`(数值), `{d}`(百分比)。
|
||||||
|
* `titleFormatter`:提示框标题内容的字符串模版格式器。支持用 `\n` 或 `<br/>` 换行。仅当`itemFormatter`生效时才有效。
|
||||||
|
* `itemFormatter`:提示框单个`serie`或数据项内容的字符串模版格式器。支持用 `\n` 或 `<br/>` 换行。当`formatter`不为空时,优先使用`formatter`,否则使用`itemFormatter`。
|
||||||
* `fixedWidth`:固定宽度。当同时设置 `fixedWidth` 和 `minWidth` 时,`fixedWidth` 比 `minWidth` 优先级高。
|
* `fixedWidth`:固定宽度。当同时设置 `fixedWidth` 和 `minWidth` 时,`fixedWidth` 比 `minWidth` 优先级高。
|
||||||
* `fixedHeight`:固定高度。当同时设置 `fixedHeight` 和 `minHeight` 时,`fixedHeight` 比 `minHeight` 优先级高。
|
* `fixedHeight`:固定高度。当同时设置 `fixedHeight` 和 `minHeight` 时,`fixedHeight` 比 `minHeight` 优先级高。
|
||||||
* `minWidth`:最小宽度。当同时设置 `fixedWidth` 和 `minWidth` 时,`fixedWidth` 比 `minWidth` 优先级高。
|
* `minWidth`:最小宽度。当同时设置 `fixedWidth` 和 `minWidth` 时,`fixedWidth` 比 `minWidth` 优先级高。
|
||||||
* `minHeight`:最小高度。当同时设置 f`ixedHeight` 和 `minHeight` 时,`fixedHeight` 比 `minHeight` 优先级高。
|
* `minHeight`:最小高度。当同时设置 f`ixedHeight` 和 `minHeight` 时,`fixedHeight` 比 `minHeight` 优先级高。
|
||||||
|
* `paddingLeftRight`:文字和边框的左右边距。
|
||||||
|
* `paddingTopBottom`:文字和边框的上下边距。
|
||||||
|
* `backgroundImage`:提示框的背景图。
|
||||||
|
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
* `ignoreDataDefaultContent`:被忽略数据的默认显示字符信息。
|
||||||
|
* `lineStyle`:指示器线条样式 [LineStyle](#LineStyle)。
|
||||||
|
* `textStyle`:显示内容文本样式 [TextStyle](#TextStyle)。
|
||||||
|
|
||||||
## `DataZoom`
|
## `DataZoom`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
区域缩放组件。用于区域缩放,从而能自由关注细节的数据信息,或者概览数据整体,或者去除离群点的影响。
|
区域缩放组件。用于区域缩放,从而能自由关注细节的数据信息,或者概览数据整体,或者去除离群点的影响。
|
||||||
目前只支持控制 `X` 轴。
|
目前只支持控制 `X` 轴。
|
||||||
|
|
||||||
@@ -172,11 +240,10 @@
|
|||||||
* `scrollSensitivity`:缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
* `scrollSensitivity`:缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
||||||
* `fontSize`:字体大小。
|
* `fontSize`:字体大小。
|
||||||
* `fontStyle`:字体样式。
|
* `fontStyle`:字体样式。
|
||||||
|
* `minShowNum`:最小显示数据个数。当DataZoom放大到最大时,最小显示的数据个数。
|
||||||
|
|
||||||
## `VisualMap`
|
## `VisualMap`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
视觉映射组件。用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)。
|
视觉映射组件。用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)。
|
||||||
|
|
||||||
* `enable`:开启或关闭视觉映射功能。
|
* `enable`:开启或关闭视觉映射功能。
|
||||||
@@ -207,8 +274,6 @@
|
|||||||
|
|
||||||
## `Grid`
|
## `Grid`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
网格组件。直角坐标系内绘图网格,单个 `grid` 内最多可以放置上下两个 `X` 轴,左右两个 `Y` 轴。可以在网格上绘制折线图,柱状图,散点图(气泡图)。目前最多只能存在一个 `grid` 组件。
|
网格组件。直角坐标系内绘图网格,单个 `grid` 内最多可以放置上下两个 `X` 轴,左右两个 `Y` 轴。可以在网格上绘制折线图,柱状图,散点图(气泡图)。目前最多只能存在一个 `grid` 组件。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -220,18 +285,36 @@
|
|||||||
* `bottom`:组件离容器底部的距离。
|
* `bottom`:组件离容器底部的距离。
|
||||||
* `backgroundColor`:背景颜色。
|
* `backgroundColor`:背景颜色。
|
||||||
|
|
||||||
## `XAxis`
|
## `GaugeAxis`
|
||||||
|
|
||||||
---
|
仪表盘坐标轴。
|
||||||
|
|
||||||
|
* `axisLine`:坐标轴轴线样式。
|
||||||
|
* `splitLine`:坐标轴分割线样式。
|
||||||
|
* `axisTick`:坐标轴刻度样式。
|
||||||
|
* `axisLabel`:坐标轴刻度标签样式。
|
||||||
|
* `axisLabelText`:坐标轴刻度标签自定义内容。当内容为空时,axisLabel根据刻度自动显示内容,否则取自该列表定义的内容。
|
||||||
|
|
||||||
|
## `GaugePointer`
|
||||||
|
|
||||||
|
仪表盘指针。
|
||||||
|
|
||||||
|
* `width`:指针宽度。
|
||||||
|
* `length`:指针长度。当为0-1的浮点数时表示相对仪表盘半径的百分比。
|
||||||
|
|
||||||
|
## `XAxis`
|
||||||
|
|
||||||
直角坐标系 `grid` 中的 `X` 轴。单个 `grid` 组件最多只能放上下两个 `X` 轴。两个 `X` 轴存储在 `xAxises` 中。
|
直角坐标系 `grid` 中的 `X` 轴。单个 `grid` 组件最多只能放上下两个 `X` 轴。两个 `X` 轴存储在 `xAxises` 中。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
|
|
||||||
* `show`:是否显示 `X` 轴。默认 `xAxises[0]` 为 `true`,`xAxises[1]` 为 `false`。
|
* `show`:是否显示 `X` 轴。默认 `xAxises[0]` 为 `true`,`xAxises[1]` 为 `false`。
|
||||||
* `type`:坐标轴类型。默认为 `Category`。有以下两种类型:
|
* `type`:坐标轴类型。默认为 `Category`。支持以下类型:
|
||||||
* `Value`:数值轴,用于连续数据。
|
* `Value`:数值轴,用于连续数据。
|
||||||
* `Category`:类目轴,适用于离散的类目数据,为该类型时必须通过 `data` 设置类目数据。
|
* `Category`:类目轴,适用于离散的类目数据,为该类型时必须通过 `data` 设置类目数据。
|
||||||
|
* `Log`:对数轴,适用于对数数据。
|
||||||
|
* `logBaseE`:对数轴是否以自然数 `e` 为底数,为 `true` 时 `logBase` 失效,只在对数轴(`type:'Log'`)中有效。
|
||||||
|
* `logBase`:对数轴的底数,只在对数轴(`type:'Log'`)中有效。
|
||||||
* `minMaxType`:坐标轴刻度最大最小值显示类型。默认为 `Default`。有以下三种类型:
|
* `minMaxType`:坐标轴刻度最大最小值显示类型。默认为 `Default`。有以下三种类型:
|
||||||
* `Default`:0-最大值。
|
* `Default`:0-最大值。
|
||||||
* `MinMax`:最小值-最大值。
|
* `MinMax`:最小值-最大值。
|
||||||
@@ -240,13 +323,6 @@
|
|||||||
* `max`:设定的坐标轴刻度最大值,当 `minMaxType` 为 `Custom` 时有效。
|
* `max`:设定的坐标轴刻度最大值,当 `minMaxType` 为 `Custom` 时有效。
|
||||||
* `splitNumber`:坐标轴的分割段数。默认为 `5`。当 `splitNumber` 设为 `0` 时,表示绘制所有的类目数据。
|
* `splitNumber`:坐标轴的分割段数。默认为 `5`。当 `splitNumber` 设为 `0` 时,表示绘制所有的类目数据。
|
||||||
* `interval`:强制设置坐标轴分割间隔。无法在类目轴中使用。设置改值时 `splitNumber` 无效。
|
* `interval`:强制设置坐标轴分割间隔。无法在类目轴中使用。设置改值时 `splitNumber` 无效。
|
||||||
* `splitLineType`:分割线类型。默认为 `Dashed`。有以下五种类型:
|
|
||||||
* `None`:不显示分割线。
|
|
||||||
* `Solid`:实线。
|
|
||||||
* `Dashed`:虚线。
|
|
||||||
* `Dotted`:点线。
|
|
||||||
* `DashDot`:点划线。
|
|
||||||
* `DashDotDot`:双点划线。
|
|
||||||
* `boundaryGap`:坐标轴两边是否留白。默认为 `true`。
|
* `boundaryGap`:坐标轴两边是否留白。默认为 `true`。
|
||||||
* `maxCache`:类目数据中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
* `maxCache`:类目数据中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||||
* `data`:类目数据,在类目轴(`type: 'Category'`)中有效。
|
* `data`:类目数据,在类目轴(`type: 'Category'`)中有效。
|
||||||
@@ -254,7 +330,8 @@
|
|||||||
* `axisName`:坐标轴名称相关配置 [AxisName](#AxisName)。
|
* `axisName`:坐标轴名称相关配置 [AxisName](#AxisName)。
|
||||||
* `axisTick`:坐标轴刻度相关配置 [AxisTick](#AxisTick)。
|
* `axisTick`:坐标轴刻度相关配置 [AxisTick](#AxisTick)。
|
||||||
* `axisLabel`:坐标轴刻度标签 [AxisLabel](#AxisLabel)。
|
* `axisLabel`:坐标轴刻度标签 [AxisLabel](#AxisLabel)。
|
||||||
* `splitArea`:坐标轴轴线坐标轴分割区域 [SplitArea](#SplitArea)。
|
* `splitLine`:坐标轴轴线坐标轴分割线 [AxisSplitLine](#SplitLine)。
|
||||||
|
* `splitArea`:坐标轴轴线坐标轴分割区域 [AxisSplitArea](#AxisSplitArea)。
|
||||||
|
|
||||||
相关接口:
|
相关接口:
|
||||||
|
|
||||||
@@ -265,8 +342,6 @@
|
|||||||
|
|
||||||
## `YAxis`
|
## `YAxis`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
直角坐标系 `grid` 中的 `Y` 轴。单个 `grid` 组件最多只能放左右两个 `Y` 轴。两个 `Y` 轴存储在 `yAxises` 中。
|
直角坐标系 `grid` 中的 `Y` 轴。单个 `grid` 组件最多只能放左右两个 `Y` 轴。两个 `Y` 轴存储在 `yAxises` 中。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -307,8 +382,6 @@
|
|||||||
|
|
||||||
## `Series`
|
## `Series`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
系列列表。每个系列通过 type 决定自己的图表类型。
|
系列列表。每个系列通过 type 决定自己的图表类型。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -365,18 +438,195 @@
|
|||||||
* `pieSpace`:饼图项间的空隙留白。
|
* `pieSpace`:饼图项间的空隙留白。
|
||||||
* `pieCenter`:饼图的中心点。
|
* `pieCenter`:饼图的中心点。
|
||||||
* `pieRadius`:饼图的半径。`radius[0]` 表示内径,`radius[1]` 表示外径。
|
* `pieRadius`:饼图的半径。`radius[0]` 表示内径,`radius[1]` 表示外径。
|
||||||
|
* `roundCap`:启用圆弧效果。
|
||||||
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
* `lineArrow`:折线图的箭头 [LineArrow](#LineArrow)。
|
* `lineArrow`:折线图的箭头 [LineArrow](#LineArrow)。
|
||||||
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
相关接口:
|
## `Serie-Line`
|
||||||
|
|
||||||
|
折线图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Line`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `stack`:数据堆叠。同个类目轴上系列配置相同的 `stack` 值后,后一个系列的值会在前一个系列的值上相加。
|
||||||
|
* `axisIndex`:使用的坐标轴轴的 `index`,在单个图表实例中存在多个坐标轴轴的时候有用。
|
||||||
|
* `minShow`:系列显示数据的最小索引。
|
||||||
|
* `maxShow`:系列显示数据的最大索引。
|
||||||
|
* `maxCache`:系列中可缓存的最大数据量。默认为`0`没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||||
|
* `sampleDist`采样的最小水平像素距离,默认为`0`时不采样。当两个数据点间的水平像素距离小于该值时,开启采样,保证两点间的水平像素距离不小于该值。
|
||||||
|
* `sampleType`:采样类型。当`sampleDist`大于`0`时有效。支持以下五种采样类型:
|
||||||
|
* `Peak`:取峰值。当过滤点的平均值大于等于`sampleAverage`时,取最大值;反之取最小值。
|
||||||
|
* `Average`:取过滤点的平均值。
|
||||||
|
* `Max`:取过滤点的最大值。
|
||||||
|
* `Min`:取过滤点的最小值。
|
||||||
|
* `Sum`:取过滤点之和。
|
||||||
|
* `sampleAverage`:设定的采样平均值。当 `sampleType` 为 `Peak` 时,用于和过滤数据的平均值做对比是取最大值还是最小值。默认为`0`时会实时计算所有数据的平均值。
|
||||||
|
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||||
|
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制。
|
||||||
|
* `ignoreValue`:忽略数据的默认值。当 `ignore` 为 `true` 才有效。
|
||||||
|
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||||
|
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||||
|
* `lineType`:折线图样式类型。支持以下十种类型:
|
||||||
|
* `Normal`:普通折线图。
|
||||||
|
* `Smooth`:平滑曲线。
|
||||||
|
* `SmoothDash`:平滑虚线。
|
||||||
|
* `StepStart`:阶梯线图:当前点。
|
||||||
|
* `StepMiddle`:阶梯线图:当前点和下一个点的中间。
|
||||||
|
* `StepEnd`:阶梯线图:下一个拐点。
|
||||||
|
* `Dash`:虚线。
|
||||||
|
* `Dot`:点线。
|
||||||
|
* `DashDot`:点划线。
|
||||||
|
* `DashDotDot`:双点划线。
|
||||||
|
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
|
||||||
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `lineArrow`:折线图的箭头 [LineArrow](#LineArrow)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
|
## `Serie-Bar`
|
||||||
|
|
||||||
|
折线图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Bar`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `stack`:数据堆叠。同个类目轴上系列配置相同的 `stack` 值后,后一个系列的值会在前一个系列的值上相加。
|
||||||
|
* `axisIndex`:使用的坐标轴轴的 `index`,在单个图表实例中存在多个坐标轴轴的时候有用。
|
||||||
|
* `minShow`:系列显示数据的最小索引。
|
||||||
|
* `maxShow`:系列显示数据的最大索引。
|
||||||
|
* `maxCache`:系列中可缓存的最大数据量。默认为`0`没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||||
|
* `barType`:柱状图类型。以下几种类型:
|
||||||
|
* `Normal`:普通柱状图。
|
||||||
|
* `Zebra`:斑马柱状图。
|
||||||
|
* `Capsule`:胶囊柱状图。
|
||||||
|
* `barPercentStack`:是否百分比堆叠柱状图,相同 `stack` 的 `serie` 只要有一个 `barPercentStack` 为 `true`,则就显示成百分比堆叠柱状图。
|
||||||
|
* `barWidth`:柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。
|
||||||
|
* `barGap`:不同系列的柱间距离。为百分比(如 `'0.3f'`,表示柱子宽度的 `30%`)。如果想要两个系列的柱子重叠,可以设置 `barGap` 为 `'-1f'`。这在用柱子做背景的时候有用。在同一坐标系上,此属性会被多个 `'bar'` 系列共享。此属性应设置于此坐标系中最后一个 `'bar'` 系列上才会生效,并且是对此坐标系中所有 `'bar'` 系列生效。
|
||||||
|
* `barCategoryGap`:同一系列的柱间距离,默认为类目间距的20%,可设固定值。在同一坐标系上,此属性会被多个 `'bar'` 系列共享。此属性应设置于此坐标系中最后一个 `'bar'` 系列上才会生效,并且是对此坐标系中所有 `'bar'` 系列生效。
|
||||||
|
* `barZebraWidth`:斑马线的粗细。`barType` 为 `Zebra` 时有效。
|
||||||
|
* `barZebraGap`:斑马线的间距。`barType` 为 `Zebra` 时有效。
|
||||||
|
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||||
|
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||||
|
* `itemStyle`:柱条样式 [ItemStyle](#ItemStyle)。
|
||||||
|
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||||
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
|
## `Serie-Pie`
|
||||||
|
|
||||||
|
饼图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Pie`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `pieRoseType`:南丁格尔玫瑰图类型,支持以下类型:
|
||||||
|
* `None`:不展示成南丁格尔玫瑰图。
|
||||||
|
* `Radius`:扇区圆心角展现数据的百分比,半径展现数据的大小。
|
||||||
|
* `Area`:所有扇区圆心角相同,仅通过半径展现数据大小。
|
||||||
|
* `space`:扇区间隙。
|
||||||
|
* `center`:中心点坐标。当值为0-1的浮点数时表示百分比。
|
||||||
|
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
||||||
|
* `roundCap`:是否启用圆弧效果。
|
||||||
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
|
## `Serie-Radar`
|
||||||
|
|
||||||
|
雷达图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Radar`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `radarIndex`:雷达图所使用的 `radar` 组件的 `index`。
|
||||||
|
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||||
|
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
|
## `Serie-Scatter`
|
||||||
|
|
||||||
|
散点图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Scatter`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||||
|
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||||
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
|
## `Serie-Heatmap`
|
||||||
|
|
||||||
|
热力图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Scatter`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
|
## `Serie-Gauge`
|
||||||
|
|
||||||
|
仪表盘系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Gauge`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `gaugeType`:仪表盘类型,支持以下类型:
|
||||||
|
* `Pointer`:指针类型。
|
||||||
|
* `ProgressBar`:进度条类型。
|
||||||
|
* `center`:中心点坐标。当值为0-1的浮点数时表示百分比。
|
||||||
|
* `radius`:仪表盘半径。
|
||||||
|
* `min`:最小的数据值。映射到startAngle。
|
||||||
|
* `max`:最大的数据值。映射到endAngle。
|
||||||
|
* `startAngle`:仪表盘起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||||
|
* `endAngle`:仪表盘结束角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||||
|
* `splitNumber`:仪表盘刻度分割段数。
|
||||||
|
* `roundCap`:是否启用圆弧效果。
|
||||||
|
* `titleStyle`:仪表盘标题 [TitleStyle](#TitleStyle)。
|
||||||
|
* `gaugeAxis`: 仪表盘坐标轴 [GaugeAxis](#GaugeAxis)。
|
||||||
|
* `gaugePointer`:仪表盘指针 [GaugePointer](#GaugePointer)。
|
||||||
|
* `itemStyle`:仪表盘指针样式 [ItemStyle](#ItemStyle)。
|
||||||
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。仪表盘的数据一般只有一个,值通过`label`样式显示,`name`通过`titleStyle`样式显示。
|
||||||
|
|
||||||
|
## `Serie-Ring`
|
||||||
|
|
||||||
|
环形图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Ring`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `center`:中心点坐标。当值为0-1的浮点数时表示百分比。
|
||||||
|
* `radius`:仪表盘半径。
|
||||||
|
* `startAngle`:仪表盘起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||||
|
* `ringGap`:环形图的环间隙。
|
||||||
|
* `roundCap`:是否启用圆弧效果。
|
||||||
|
* `clockwise`:是否顺时针,默认为`true`。
|
||||||
|
* `titleStyle`:环形图中心标题 [TitleStyle](#TitleStyle)。
|
||||||
|
* `itemStyle`:环形图的圆环样式,包括设置背景颜色和边框等 [ItemStyle](#ItemStyle)。
|
||||||
|
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
|
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。环形图的数据只有二维,`data[0]`表示当前值,`data[1]`表示最大值。
|
||||||
|
|
||||||
## `Settings`
|
## `Settings`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
|
全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
|
||||||
|
|
||||||
* `lineSmoothStyle`:曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
|
* `lineSmoothStyle`:曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
|
||||||
@@ -384,21 +634,18 @@
|
|||||||
* `lineSegmentDistance`: 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
* `lineSegmentDistance`: 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
||||||
* `cicleSmoothness`:圆形(包括扇形、环形等)的平滑度。数越小圆越平滑,但顶点数也会随之增加。
|
* `cicleSmoothness`:圆形(包括扇形、环形等)的平滑度。数越小圆越平滑,但顶点数也会随之增加。
|
||||||
|
|
||||||
## `Animation`
|
## `SerieAnimation`
|
||||||
|
|
||||||
---
|
* `enable`:是否开启动画系统。
|
||||||
|
* ~~`threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。~~
|
||||||
* `enable`:是否开起始画效果。
|
* `fadeInDelay`:设定的渐入动画延时,单位毫秒。
|
||||||
* `easing`:动画的缓动效果。支持以下动画效果:
|
* `fadeInDuration`:设定的渐入动画时长,单位毫秒。
|
||||||
* `Linear`:线性效果。
|
* `fadeOutDuration`:设定的渐出动画时长,单位毫秒。
|
||||||
* `duration`:设定的动画时长,单位毫秒。
|
* `dataChangeEnable`:是否开启数据变更动画。
|
||||||
* `threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。
|
* `dataChangeDuration`:数据变更动画时长,单位毫秒。
|
||||||
* `delay`:动画延时,单位毫秒。
|
|
||||||
|
|
||||||
## `AreaStyle`
|
## `AreaStyle`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示区域填充。
|
* `show`:是否显示区域填充。
|
||||||
* `origin`:区域填充的起始位置 `AreaOrigin`。有以下三种填充方式:
|
* `origin`:区域填充的起始位置 `AreaOrigin`。有以下三种填充方式:
|
||||||
* `Auto`:填充坐标轴轴线到数据间的区域。
|
* `Auto`:填充坐标轴轴线到数据间的区域。
|
||||||
@@ -413,8 +660,6 @@
|
|||||||
|
|
||||||
## `AxisLabel`
|
## `AxisLabel`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示刻度标签。
|
* `show`:是否显示刻度标签。
|
||||||
* `interval`:坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
* `interval`:坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||||
* `inside`:刻度标签是否朝内,默认朝外。
|
* `inside`:刻度标签是否朝内,默认朝外。
|
||||||
@@ -423,12 +668,12 @@
|
|||||||
* `color`:刻度标签文字的颜色,默认取主题Theme的axisTextColor。
|
* `color`:刻度标签文字的颜色,默认取主题Theme的axisTextColor。
|
||||||
* `fontSize`:文字的字体大小。
|
* `fontSize`:文字的字体大小。
|
||||||
* `fontStyle`:文字字体的风格。
|
* `fontStyle`:文字字体的风格。
|
||||||
* `formatter`:图例内容字符串模版格式器。支持用 \n 换行。模板变量为图例名称 {value},{value:f1} 表示取1为小数
|
* `formatter`:图例内容字符串模版格式器。支持用 \n 换行。模板变量为图例名称 {value},支持{value:f0},{value:f1},{value:f2}。
|
||||||
|
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
* `textLimit`:文本自适应 [TextLimit](#TextLimit)。只在类目轴中有效。
|
||||||
|
|
||||||
## `AxisLine`
|
## `AxisLine`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示坐标轴轴线。
|
* `show`:是否显示坐标轴轴线。
|
||||||
* `onZero`:X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
* `onZero`:X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
||||||
* `width`:坐标轴线线宽。
|
* `width`:坐标轴线线宽。
|
||||||
@@ -440,8 +685,6 @@
|
|||||||
|
|
||||||
## `AxisName`
|
## `AxisName`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示坐标名称。
|
* `show`:是否显示坐标名称。
|
||||||
* `name`:坐标轴名称。
|
* `name`:坐标轴名称。
|
||||||
* `location`:坐标轴名称的位置。支持以下类型:
|
* `location`:坐标轴名称的位置。支持以下类型:
|
||||||
@@ -454,17 +697,19 @@
|
|||||||
* `fontSize`:坐标轴名称的文字大小。
|
* `fontSize`:坐标轴名称的文字大小。
|
||||||
* `fontStyle`:坐标轴名称的文字风格。
|
* `fontStyle`:坐标轴名称的文字风格。
|
||||||
|
|
||||||
## `AxisSplitArea`
|
## `AxisSplitLine`
|
||||||
|
|
||||||
---
|
* `show`:是否显示坐标分割线。
|
||||||
|
* `interval`:分割线的显示间隔。0表示显示所有分割线,1表示隔一个隔显示一个分割线,以此类推。
|
||||||
|
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
|
||||||
|
|
||||||
|
## `AxisSplitArea`
|
||||||
|
|
||||||
* `show`:是否显示坐标分割区域。
|
* `show`:是否显示坐标分割区域。
|
||||||
* `color`:分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
* `color`:分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
||||||
|
|
||||||
## `AxisTick`
|
## `AxisTick`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示坐标轴刻度。
|
* `show`:是否显示坐标轴刻度。
|
||||||
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
||||||
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
||||||
@@ -472,27 +717,25 @@
|
|||||||
|
|
||||||
## `Emphasis`
|
## `Emphasis`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否启用高亮样式。
|
* `show`:是否启用高亮样式。
|
||||||
* `label`:图形文本标签样式 [SerieLabel](#SerieLabel)。
|
* `label`:图形文本标签样式 [SerieLabel](#SerieLabel)。
|
||||||
* `itemStyle`:图形样式 [ItemStyle](#ItemStyle)。
|
* `itemStyle`:图形样式 [ItemStyle](#ItemStyle)。
|
||||||
|
|
||||||
## `ItemStyle`
|
## `ItemStyle`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否启用。
|
* `show`:是否启用。
|
||||||
* `color`:颜色。
|
* `color`:颜色。
|
||||||
|
* `backgroundColor`:背景颜色。
|
||||||
|
* `backgroundWidth`:背景的宽。
|
||||||
|
* `centerColor`:中心区域的颜色。如环形图的中心区域。
|
||||||
|
* `centerGap`:中心区域的间隙。如环形图的中心区域于最内环的间隙。
|
||||||
* `borderType`:边框的类型。
|
* `borderType`:边框的类型。
|
||||||
* `borderColor`:边框的颜色。
|
* `borderColor`:边框的颜色。
|
||||||
* `borderWidth`:边框宽。
|
* `borderWidth`:边框宽。
|
||||||
* `borderWidth`:opacity。
|
* `opacity`:透明度。
|
||||||
|
|
||||||
## `LineArrow`
|
## `LineArrow`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示箭头。
|
* `show`:是否显示箭头。
|
||||||
* `position`:箭头显示位置。支持以下两种位置:
|
* `position`:箭头显示位置。支持以下两种位置:
|
||||||
* `End`:末端显示。最后一个数据上显示箭头。
|
* `End`:末端显示。最后一个数据上显示箭头。
|
||||||
@@ -504,9 +747,7 @@
|
|||||||
|
|
||||||
## `LineStyle`
|
## `LineStyle`
|
||||||
|
|
||||||
---
|
* `show`:是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。
|
||||||
|
|
||||||
* `show`:是否显示线条。在折线图中无效。
|
|
||||||
* `type`:线条类型。支持以下五种类型:
|
* `type`:线条类型。支持以下五种类型:
|
||||||
* `None`:不显示分割线。
|
* `None`:不显示分割线。
|
||||||
* `Solid`:实线。
|
* `Solid`:实线。
|
||||||
@@ -520,8 +761,6 @@
|
|||||||
|
|
||||||
## `Location`
|
## `Location`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `align`:对齐方式。有以下对齐方式。
|
* `align`:对齐方式。有以下对齐方式。
|
||||||
* `TopLeft`:左上角对齐。
|
* `TopLeft`:左上角对齐。
|
||||||
* `TopRight`:右上角对齐。
|
* `TopRight`:右上角对齐。
|
||||||
@@ -539,8 +778,6 @@
|
|||||||
|
|
||||||
## `SerieData`
|
## `SerieData`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `name`:数据项名称。
|
* `name`:数据项名称。
|
||||||
* `selected`:该数据项是否被选中。
|
* `selected`:该数据项是否被选中。
|
||||||
* `radius`:自定义半径。可用在饼图中自定义某个数据项的半径。
|
* `radius`:自定义半径。可用在饼图中自定义某个数据项的半径。
|
||||||
@@ -553,8 +790,6 @@
|
|||||||
|
|
||||||
## `SerieLabel`
|
## `SerieLabel`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示文本标签。
|
* `show`:是否显示文本标签。
|
||||||
* `position`:标签的位置。折线图时强制默认为 `Center`,支持以下 `5` 种位置:
|
* `position`:标签的位置。折线图时强制默认为 `Center`,支持以下 `5` 种位置:
|
||||||
* `Outside`:饼图扇区外侧,通过视觉引导线连到相应的扇区。只在饼图种可用。
|
* `Outside`:饼图扇区外侧,通过视觉引导线连到相应的扇区。只在饼图种可用。
|
||||||
@@ -585,11 +820,10 @@
|
|||||||
* `border`:是否显示边框。
|
* `border`:是否显示边框。
|
||||||
* `borderWidth`:边框宽度。
|
* `borderWidth`:边框宽度。
|
||||||
* `borderColor`:边框颜色。
|
* `borderColor`:边框颜色。
|
||||||
|
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
|
||||||
## `SerieSymbol`
|
## `SerieSymbol`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `type`:标记类型。支持以下六种类型:
|
* `type`:标记类型。支持以下六种类型:
|
||||||
* `EmptyCircle`:空心圆。
|
* `EmptyCircle`:空心圆。
|
||||||
* `Circle`:实心圆。
|
* `Circle`:实心圆。
|
||||||
@@ -597,6 +831,7 @@
|
|||||||
* `Triangle`:三角形。
|
* `Triangle`:三角形。
|
||||||
* `Diamond`:菱形。
|
* `Diamond`:菱形。
|
||||||
* `None`:不显示标记。
|
* `None`:不显示标记。
|
||||||
|
* `gap`:图形标记的外留白距离。
|
||||||
* `sizeType`:标记图形的大小获取方式。支持以下三种类型:
|
* `sizeType`:标记图形的大小获取方式。支持以下三种类型:
|
||||||
* `Custom`:自定义大小。
|
* `Custom`:自定义大小。
|
||||||
* `FromData`:通过 `dataIndex` 从数据中获取,再乘以一个比例系数 `dataScale` 。
|
* `FromData`:通过 `dataIndex` 从数据中获取,再乘以一个比例系数 `dataScale` 。
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
[QA 21:如何显示图例?](#如何显示图例)
|
[QA 21:如何显示图例?](#如何显示图例)
|
||||||
[QA 22:如何做成预设?](#如何做成预设)
|
[QA 22:如何做成预设?](#如何做成预设)
|
||||||
[QA 23:如何在图表上画点画线等自定义内容?](#如何在图表上画点画线等自定义内容)
|
[QA 23:如何在图表上画点画线等自定义内容?](#如何在图表上画点画线等自定义内容)
|
||||||
|
[QA 24:如何实现心电图类似的数据移动效果?](#如何实现心电图类似的数据移动效果)
|
||||||
|
|
||||||
## 如何调整坐标轴与背景的边距
|
## 如何调整坐标轴与背景的边距
|
||||||
|
|
||||||
@@ -120,6 +121,10 @@
|
|||||||
|
|
||||||
答:xcharts有自定义绘制回调`customDrawCallback`,具体可参考`Demo12_CustomDrawing.cs`
|
答:xcharts有自定义绘制回调`customDrawCallback`,具体可参考`Demo12_CustomDrawing.cs`
|
||||||
|
|
||||||
|
## 如何实现心电图类似的数据移动效果
|
||||||
|
|
||||||
|
答:axis和serie都设置相同的maxCache。maxCache可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
|
||||||
|
|
||||||
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
|
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
|
||||||
[XChartsAPI接口](XChartsAPI.md)
|
[XChartsAPI接口](XChartsAPI.md)
|
||||||
[XCharts配置项手册](XCharts配置项手册.md)
|
[XCharts配置项手册](XCharts配置项手册.md)
|
||||||
|
|||||||
33
Assets/XCharts/Editor/GaugeChartEditor.cs
Normal file
33
Assets/XCharts/Editor/GaugeChartEditor.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Editor class used to edit UI GaugeChart.
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
[CustomEditor(typeof(GaugeChart), false)]
|
||||||
|
public class GaugeChartEditor : BaseChartEditor
|
||||||
|
{
|
||||||
|
protected SerializedProperty m_Radar;
|
||||||
|
protected SerializedProperty m_Radars;
|
||||||
|
|
||||||
|
protected override void OnEnable()
|
||||||
|
{
|
||||||
|
base.OnEnable();
|
||||||
|
m_Target = (GaugeChart)target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnEndInspectorGUI()
|
||||||
|
{
|
||||||
|
base.OnEndInspectorGUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Editor/GaugeChartEditor.cs.meta
Normal file
11
Assets/XCharts/Editor/GaugeChartEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bd96c5068df484d1c95748a85d8380a8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -22,35 +22,47 @@ namespace XCharts
|
|||||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
|
||||||
SerializedProperty m_Enable = prop.FindPropertyRelative("m_Enable");
|
SerializedProperty m_Enable = prop.FindPropertyRelative("m_Enable");
|
||||||
SerializedProperty m_Easting = prop.FindPropertyRelative("m_Easting");
|
//SerializedProperty m_Easting = prop.FindPropertyRelative("m_Easting");
|
||||||
SerializedProperty m_Duration = prop.FindPropertyRelative("m_Duration");
|
SerializedProperty m_FadeInDuration = prop.FindPropertyRelative("m_FadeInDuration");
|
||||||
SerializedProperty m_Delay = prop.FindPropertyRelative("m_Delay");
|
SerializedProperty m_FadeOutDuration = prop.FindPropertyRelative("m_FadeOutDuration");
|
||||||
|
SerializedProperty m_DataChangeEnable = prop.FindPropertyRelative("m_DataChangeEnable");
|
||||||
|
SerializedProperty m_DataChangeDuration = prop.FindPropertyRelative("m_DataChangeDuration");
|
||||||
|
SerializedProperty m_FadeInDelay = prop.FindPropertyRelative("m_FadeInDelay");
|
||||||
SerializedProperty m_Threshold = prop.FindPropertyRelative("m_Threshold");
|
SerializedProperty m_Threshold = prop.FindPropertyRelative("m_Threshold");
|
||||||
SerializedProperty m_ActualDuration = prop.FindPropertyRelative("m_ActualDuration");
|
SerializedProperty m_ActualDuration = prop.FindPropertyRelative("m_ActualDuration");
|
||||||
SerializedProperty m_CurrDetailProgress = prop.FindPropertyRelative("m_CurrDetailProgress");
|
// SerializedProperty m_CurrDetailProgress = prop.FindPropertyRelative("m_CurrDetailProgress");
|
||||||
SerializedProperty m_DestDetailProgress = prop.FindPropertyRelative("m_DestDetailProgress");
|
// SerializedProperty m_DestDetailProgress = prop.FindPropertyRelative("m_DestDetailProgress");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AnimationModuleToggle, prop, null, m_Enable, false);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AnimationModuleToggle, prop, null, m_Enable, false);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (ChartEditorHelper.IsToggle(m_AnimationModuleToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_AnimationModuleToggle, prop))
|
||||||
{
|
{
|
||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
EditorGUI.PropertyField(drawRect, m_Easting);
|
//EditorGUI.PropertyField(drawRect, m_Easting);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Duration);
|
|
||||||
if (m_Duration.intValue < 0) m_Duration.intValue = 0;
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Delay);
|
|
||||||
if (m_Delay.intValue < 0) m_Delay.intValue = 0;
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Threshold);
|
EditorGUI.PropertyField(drawRect, m_Threshold);
|
||||||
if (m_Threshold.intValue < 0) m_Threshold.intValue = 0;
|
if (m_Threshold.intValue < 0) m_Threshold.intValue = 0;
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.LabelField(drawRect, "CurrDetailProgress:" + m_CurrDetailProgress.floatValue);
|
EditorGUI.PropertyField(drawRect, m_FadeInDelay);
|
||||||
|
if (m_FadeInDelay.floatValue < 0) m_FadeInDelay.floatValue = 0;
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.LabelField(drawRect, "DestDetailProgress:" + m_DestDetailProgress.floatValue);
|
EditorGUI.PropertyField(drawRect, m_FadeInDuration);
|
||||||
|
if (m_FadeInDuration.floatValue < 0) m_FadeInDuration.floatValue = 0;
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.LabelField(drawRect, "Actual duration:" + m_ActualDuration.intValue + " ms");
|
EditorGUI.PropertyField(drawRect, m_FadeOutDuration);
|
||||||
|
if (m_FadeOutDuration.floatValue < 0) m_FadeOutDuration.floatValue = 0;
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_DataChangeEnable);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_DataChangeDuration);
|
||||||
|
if (m_DataChangeDuration.floatValue < 0) m_DataChangeDuration.floatValue = 0;
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
|
// EditorGUI.LabelField(drawRect, "CurrDetailProgress:" + m_CurrDetailProgress.floatValue);
|
||||||
|
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
// EditorGUI.LabelField(drawRect, "DestDetailProgress:" + m_DestDetailProgress.floatValue);
|
||||||
|
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.LabelField(drawRect, "Actual duration:" + m_ActualDuration.floatValue + " ms");
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,17 +33,18 @@ namespace XCharts
|
|||||||
|
|
||||||
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
||||||
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
||||||
|
SerializedProperty m_LogBaseE = prop.FindPropertyRelative("m_LogBaseE");
|
||||||
|
SerializedProperty m_LogBase = prop.FindPropertyRelative("m_LogBase");
|
||||||
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||||
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
|
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
|
||||||
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
|
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
|
||||||
SerializedProperty m_ShowSplitLine = prop.FindPropertyRelative("m_ShowSplitLine");
|
|
||||||
SerializedProperty m_SplitLineType = prop.FindPropertyRelative("m_SplitLineType");
|
|
||||||
SerializedProperty m_BoundaryGap = prop.FindPropertyRelative("m_BoundaryGap");
|
SerializedProperty m_BoundaryGap = prop.FindPropertyRelative("m_BoundaryGap");
|
||||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||||
SerializedProperty m_AxisLine = prop.FindPropertyRelative("m_AxisLine");
|
SerializedProperty m_AxisLine = prop.FindPropertyRelative("m_AxisLine");
|
||||||
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
||||||
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||||
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
||||||
|
SerializedProperty m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
|
||||||
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
||||||
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
||||||
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
||||||
@@ -59,6 +60,13 @@ namespace XCharts
|
|||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
EditorGUI.PropertyField(drawRect, m_Type);
|
EditorGUI.PropertyField(drawRect, m_Type);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (type == Axis.AxisType.Log)
|
||||||
|
{
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LogBaseE);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LogBase);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
if (type == Axis.AxisType.Value)
|
if (type == Axis.AxisType.Value)
|
||||||
{
|
{
|
||||||
EditorGUI.PropertyField(drawRect, m_MinMaxType);
|
EditorGUI.PropertyField(drawRect, m_MinMaxType);
|
||||||
@@ -80,27 +88,11 @@ namespace XCharts
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Interval);
|
EditorGUI.PropertyField(drawRect, m_Interval);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (m_ShowSplitLine.boolValue)
|
|
||||||
{
|
|
||||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
|
|
||||||
//drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
drawRect.x = EditorGUIUtility.labelWidth + 35;
|
|
||||||
drawRect.width = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 55;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_SplitLineType, GUIContent.none);
|
|
||||||
drawRect.x = pos.x;
|
|
||||||
drawRect.width = pos.width;
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
EditorGUI.PropertyField(drawRect, m_BoundaryGap);
|
EditorGUI.PropertyField(drawRect, m_BoundaryGap);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_AxisLine);
|
EditorGUI.PropertyField(drawRect, m_AxisLine);
|
||||||
@@ -115,6 +107,8 @@ namespace XCharts
|
|||||||
EditorGUI.PropertyField(drawRect, m_AxisLabel);
|
EditorGUI.PropertyField(drawRect, m_AxisLabel);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLabel);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLabel);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SplitLine);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
|
||||||
EditorGUI.PropertyField(drawRect, m_SplitArea);
|
EditorGUI.PropertyField(drawRect, m_SplitArea);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
|
||||||
@@ -149,8 +143,9 @@ namespace XCharts
|
|||||||
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
||||||
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
|
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
|
||||||
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
||||||
|
SerializedProperty m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
|
||||||
float height = 0;
|
float height = 0;
|
||||||
height += 11 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
|
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
|
||||||
if (type == Axis.AxisType.Category)
|
if (type == Axis.AxisType.Category)
|
||||||
{
|
{
|
||||||
@@ -180,11 +175,21 @@ namespace XCharts
|
|||||||
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (type == Axis.AxisType.Log)
|
||||||
|
{
|
||||||
|
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
||||||
|
if (m_MinMaxType.enumValueIndex == (int)Axis.AxisMinMaxType.Custom)
|
||||||
|
{
|
||||||
|
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
height += EditorGUI.GetPropertyHeight(m_AxisName);
|
height += EditorGUI.GetPropertyHeight(m_AxisName);
|
||||||
height += EditorGUI.GetPropertyHeight(m_AxisLine);
|
height += EditorGUI.GetPropertyHeight(m_AxisLine);
|
||||||
height += EditorGUI.GetPropertyHeight(m_AxisTick);
|
height += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||||
height += EditorGUI.GetPropertyHeight(m_AxisLabel);
|
height += EditorGUI.GetPropertyHeight(m_AxisLabel);
|
||||||
height += EditorGUI.GetPropertyHeight(m_SplitArea);
|
height += EditorGUI.GetPropertyHeight(m_SplitArea);
|
||||||
|
height += EditorGUI.GetPropertyHeight(m_SplitLine);
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +197,7 @@ namespace XCharts
|
|||||||
private int InitToggle(SerializedProperty prop)
|
private int InitToggle(SerializedProperty prop)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int.TryParse(prop.displayName.Split(' ')[1],out index);
|
int.TryParse(prop.displayName.Split(' ')[1], out index);
|
||||||
if (index >= m_DataFoldout.Count)
|
if (index >= m_DataFoldout.Count)
|
||||||
{
|
{
|
||||||
m_DataFoldout.Add(false);
|
m_DataFoldout.Add(false);
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ namespace XCharts
|
|||||||
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||||
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||||
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
||||||
|
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||||
|
SerializedProperty m_TextLimit = prop.FindPropertyRelative("m_TextLimit");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLabelToggle, prop, "Axis Label", show, false);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLabelToggle, prop, "Axis Label", show, false);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -51,6 +53,10 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Formatter);
|
EditorGUI.PropertyField(drawRect, m_Formatter);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TextLimit);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextLimit);
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +66,8 @@ namespace XCharts
|
|||||||
float height = 0;
|
float height = 0;
|
||||||
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
||||||
{
|
{
|
||||||
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextLimit"));
|
||||||
}
|
}
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|||||||
55
Assets/XCharts/Editor/PropertyDrawers/AxisSplitLineDrawer.cs
Normal file
55
Assets/XCharts/Editor/PropertyDrawers/AxisSplitLineDrawer.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(AxisSplitLine), true)]
|
||||||
|
public class AxisSplitLineDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_AxisSplitLineToggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
|
||||||
|
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisSplitLineToggle, prop, "Split Line", show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_AxisSplitLineToggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Interval);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
float height = 0;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_AxisSplitLineToggle, prop))
|
||||||
|
{
|
||||||
|
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: af473e9aba20f4f168b8f83a4db13f81
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -35,6 +35,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_RangeMode = prop.FindPropertyRelative("m_RangeMode");
|
SerializedProperty m_RangeMode = prop.FindPropertyRelative("m_RangeMode");
|
||||||
SerializedProperty m_Start = prop.FindPropertyRelative("m_Start");
|
SerializedProperty m_Start = prop.FindPropertyRelative("m_Start");
|
||||||
SerializedProperty m_End = prop.FindPropertyRelative("m_End");
|
SerializedProperty m_End = prop.FindPropertyRelative("m_End");
|
||||||
|
SerializedProperty m_MinShowNum = prop.FindPropertyRelative("m_MinShowNum");
|
||||||
SerializedProperty m_ScrollSensitivity = prop.FindPropertyRelative("m_ScrollSensitivity");
|
SerializedProperty m_ScrollSensitivity = prop.FindPropertyRelative("m_ScrollSensitivity");
|
||||||
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||||
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
||||||
@@ -79,8 +80,11 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_End);
|
EditorGUI.PropertyField(drawRect, m_End);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MinShowNum);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (m_Start.floatValue < 0) m_Start.floatValue = 0;
|
if (m_Start.floatValue < 0) m_Start.floatValue = 0;
|
||||||
if (m_End.floatValue > 100) m_End.floatValue = 100;
|
if (m_End.floatValue > 100) m_End.floatValue = 100;
|
||||||
|
if (m_MinShowNum.intValue < 0) m_MinShowNum.intValue = 0;
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,7 +95,7 @@ namespace XCharts
|
|||||||
int num = 1;
|
int num = 1;
|
||||||
if (m_DataZoomModuleToggle)
|
if (m_DataZoomModuleToggle)
|
||||||
{
|
{
|
||||||
num += 7;
|
num += 8;
|
||||||
if (prop.FindPropertyRelative("m_SupportSlider").boolValue) num += 6;
|
if (prop.FindPropertyRelative("m_SupportSlider").boolValue) num += 6;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
82
Assets/XCharts/Editor/PropertyDrawers/GaugeAxisDrawer.cs
Normal file
82
Assets/XCharts/Editor/PropertyDrawers/GaugeAxisDrawer.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(GaugeAxis), true)]
|
||||||
|
public class GaugeAxisDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private bool m_DataFoldout = false;
|
||||||
|
private int m_DataSize = 0;
|
||||||
|
private Dictionary<string, bool> m_AxisLineToggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_AxisLine = prop.FindPropertyRelative("m_AxisLine");
|
||||||
|
SerializedProperty m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
|
||||||
|
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||||
|
SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
|
||||||
|
SerializedProperty m_AxisLabelText = prop.FindPropertyRelative("m_AxisLabelText");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLineToggle, prop, "Gauge Axis", show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_AxisLineToggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_AxisLine);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLine);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SplitLine);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_AxisTick);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_AxisLabel);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLabel);
|
||||||
|
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||||
|
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Axis Label Text");
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
drawRect.width = pos.width;
|
||||||
|
if (m_DataFoldout)
|
||||||
|
{
|
||||||
|
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_AxisLabelText);
|
||||||
|
}
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
float height = 0;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_AxisLineToggle, prop))
|
||||||
|
{
|
||||||
|
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AxisLine"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitLine"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AxisTick"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AxisLabel"));
|
||||||
|
if (m_DataFoldout)
|
||||||
|
{
|
||||||
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_AxisLabelText");
|
||||||
|
int num = m_Data.arraySize + 1;
|
||||||
|
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dec6cfc5ef85147738a81d8de84b079a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
76
Assets/XCharts/Editor/PropertyDrawers/GaugeAxisLineDrawer.cs
Normal file
76
Assets/XCharts/Editor/PropertyDrawers/GaugeAxisLineDrawer.cs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(GaugeAxis.AxisLine), true)]
|
||||||
|
public class GaugeAxisLineDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private bool m_DataFoldout = false;
|
||||||
|
private int m_DataSize = 0;
|
||||||
|
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
|
||||||
|
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
|
||||||
|
SerializedProperty m_BarBackgroundColor = prop.FindPropertyRelative("m_BarBackgroundColor");
|
||||||
|
SerializedProperty m_BarColor = prop.FindPropertyRelative("m_BarColor");
|
||||||
|
SerializedProperty m_StageColor = prop.FindPropertyRelative("m_StageColor");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Axis Line", show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Width);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Opacity);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarColor);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarBackgroundColor);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Stage Color");
|
||||||
|
drawRect.width = pos.width;
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (m_DataFoldout)
|
||||||
|
{
|
||||||
|
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_StageColor);
|
||||||
|
}
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
float height = 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (m_DataFoldout)
|
||||||
|
{
|
||||||
|
var arraySize = prop.FindPropertyRelative("m_StageColor").arraySize + 1;
|
||||||
|
height += arraySize * EditorGUIUtility.singleLineHeight + (arraySize) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eb7a86643ea2349c8ac2475ab81cb2f9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(GaugeAxis.AxisLine.StageColor), true)]
|
||||||
|
public class GaugeAxisLineStageColorDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty m_Percent = prop.FindPropertyRelative("m_Percent");
|
||||||
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeTwoField(ref drawRect, drawRect.width, m_Percent, m_Color, "Stage");
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cc7cae70713a74fb496ef686296bc46b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(GaugeAxis.SplitLine), true)]
|
||||||
|
public class GaugeAxisSplitDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
|
||||||
|
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Split Line", show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Length);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
float height = 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d11eb7847e5c74746a570a7c9f6b339a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
57
Assets/XCharts/Editor/PropertyDrawers/GaugeAxisTickDrawer.cs
Normal file
57
Assets/XCharts/Editor/PropertyDrawers/GaugeAxisTickDrawer.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(GaugeAxis.AxisTick), true)]
|
||||||
|
public class GaugeAxisTickDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
|
||||||
|
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||||
|
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Axis Tick", show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Length);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
float height = 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f561506277b949c1b22116a3f3d3f4f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
51
Assets/XCharts/Editor/PropertyDrawers/GaugePointerDrawer.cs
Normal file
51
Assets/XCharts/Editor/PropertyDrawers/GaugePointerDrawer.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(GaugePointer), true)]
|
||||||
|
public class GaugePointerDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_Toggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
|
||||||
|
SerializedProperty m_Length = prop.FindPropertyRelative("m_Length");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_Toggle, prop, "Gauge Pointer", show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Width);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Length);
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
if (ChartEditorHelper.IsToggle(m_Toggle, prop))
|
||||||
|
{
|
||||||
|
return 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a3d180de37dd24cfc9bcbb46f650c902
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
67
Assets/XCharts/Editor/PropertyDrawers/IconStyleDrawer.cs
Normal file
67
Assets/XCharts/Editor/PropertyDrawers/IconStyleDrawer.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(IconStyle), true)]
|
||||||
|
public class IconStyleDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_IconStyleToggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_Layer = prop.FindPropertyRelative("m_Layer");
|
||||||
|
SerializedProperty m_Sprite = prop.FindPropertyRelative("m_Sprite");
|
||||||
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||||
|
SerializedProperty m_Width = prop.FindPropertyRelative("m_Width");
|
||||||
|
SerializedProperty m_Height = prop.FindPropertyRelative("m_Height");
|
||||||
|
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_IconStyleToggle, prop, null, m_Show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_IconStyleToggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Layer);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Sprite);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Color);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Width);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Height);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Offset);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
if (ChartEditorHelper.IsToggle(m_IconStyleToggle, prop))
|
||||||
|
{
|
||||||
|
var hight = 6 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
hight += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
|
||||||
|
hight += EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
return hight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9cae26ad61d224d8a97d41bdc52ec0b7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -22,6 +22,10 @@ namespace XCharts
|
|||||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||||
|
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
|
||||||
|
SerializedProperty m_BackgroundWidth = prop.FindPropertyRelative("m_BackgroundWidth");
|
||||||
|
SerializedProperty m_CenterColor = prop.FindPropertyRelative("m_CenterColor");
|
||||||
|
SerializedProperty m_CenterGap = prop.FindPropertyRelative("m_CenterGap");
|
||||||
SerializedProperty m_BorderType = prop.FindPropertyRelative("m_BorderType");
|
SerializedProperty m_BorderType = prop.FindPropertyRelative("m_BorderType");
|
||||||
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
||||||
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
|
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
|
||||||
@@ -33,6 +37,14 @@ namespace XCharts
|
|||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
EditorGUI.PropertyField(drawRect, m_Color);
|
EditorGUI.PropertyField(drawRect, m_Color);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BackgroundWidth);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_CenterColor);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_CenterGap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_BorderType);
|
EditorGUI.PropertyField(drawRect, m_BorderType);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_BorderWidth);
|
EditorGUI.PropertyField(drawRect, m_BorderWidth);
|
||||||
@@ -50,7 +62,7 @@ namespace XCharts
|
|||||||
float height = 0;
|
float height = 0;
|
||||||
if (ChartEditorHelper.IsToggle(m_ItemStyleToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_ItemStyleToggle, prop))
|
||||||
{
|
{
|
||||||
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ namespace XCharts
|
|||||||
public class LegendDrawer : PropertyDrawer
|
public class LegendDrawer : PropertyDrawer
|
||||||
{
|
{
|
||||||
private bool m_DataFoldout = false;
|
private bool m_DataFoldout = false;
|
||||||
|
private bool m_IconsFoldout = false;
|
||||||
private int m_DataSize = 0;
|
private int m_DataSize = 0;
|
||||||
|
private int m_IconsSize = 0;
|
||||||
private bool m_ShowJsonDataArea = false;
|
private bool m_ShowJsonDataArea = false;
|
||||||
private string m_JsonDataAreaText;
|
private string m_JsonDataAreaText;
|
||||||
private bool m_LegendModuleToggle = false;
|
private bool m_LegendModuleToggle = false;
|
||||||
@@ -30,9 +32,11 @@ namespace XCharts
|
|||||||
SerializedProperty itemWidth = prop.FindPropertyRelative("m_ItemWidth");
|
SerializedProperty itemWidth = prop.FindPropertyRelative("m_ItemWidth");
|
||||||
SerializedProperty itemHeight = prop.FindPropertyRelative("m_ItemHeight");
|
SerializedProperty itemHeight = prop.FindPropertyRelative("m_ItemHeight");
|
||||||
SerializedProperty itemGap = prop.FindPropertyRelative("m_ItemGap");
|
SerializedProperty itemGap = prop.FindPropertyRelative("m_ItemGap");
|
||||||
SerializedProperty itemFontSize = prop.FindPropertyRelative("m_ItemFontSize");
|
SerializedProperty m_ItemAutoColor = prop.FindPropertyRelative("m_ItemAutoColor");
|
||||||
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
||||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||||
|
SerializedProperty m_Icons = prop.FindPropertyRelative("m_Icons");
|
||||||
|
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_LegendModuleToggle, "Legend", show);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_LegendModuleToggle, "Legend", show);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -45,7 +49,7 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, itemGap);
|
EditorGUI.PropertyField(drawRect, itemGap);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, itemFontSize);
|
EditorGUI.PropertyField(drawRect, m_ItemAutoColor);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_SelectedMode);
|
EditorGUI.PropertyField(drawRect, m_SelectedMode);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -57,12 +61,20 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||||
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Data");
|
m_DataFoldout = EditorGUI.Foldout(drawRect, m_DataFoldout, "Data");
|
||||||
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop,pos.width);
|
ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop, pos.width);
|
||||||
drawRect.width = pos.width;
|
drawRect.width = pos.width;
|
||||||
if (m_DataFoldout)
|
if (m_DataFoldout)
|
||||||
{
|
{
|
||||||
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
|
ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
|
||||||
}
|
}
|
||||||
|
m_IconsFoldout = EditorGUI.Foldout(drawRect, m_IconsFoldout, "Icons");
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (m_IconsFoldout)
|
||||||
|
{
|
||||||
|
ChartEditorHelper.MakeList(ref drawRect, ref m_IconsSize, m_Icons);
|
||||||
|
}
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TextStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +85,7 @@ namespace XCharts
|
|||||||
if (m_LegendModuleToggle)
|
if (m_LegendModuleToggle)
|
||||||
{
|
{
|
||||||
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
||||||
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUI.GetPropertyHeight(location);
|
height += EditorGUI.GetPropertyHeight(location);
|
||||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (m_DataFoldout)
|
if (m_DataFoldout)
|
||||||
@@ -83,6 +95,14 @@ namespace XCharts
|
|||||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
|
if (m_IconsFoldout)
|
||||||
|
{
|
||||||
|
SerializedProperty m_Icons = prop.FindPropertyRelative("m_Icons");
|
||||||
|
int num = m_Icons.arraySize + 1;
|
||||||
|
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
|
||||||
}
|
}
|
||||||
if (m_ShowJsonDataArea)
|
if (m_ShowJsonDataArea)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,12 +15,14 @@ namespace XCharts
|
|||||||
public class RadarDrawer : PropertyDrawer
|
public class RadarDrawer : PropertyDrawer
|
||||||
{
|
{
|
||||||
SerializedProperty m_Shape;
|
SerializedProperty m_Shape;
|
||||||
|
SerializedProperty m_PositionType;
|
||||||
SerializedProperty m_Radius;
|
SerializedProperty m_Radius;
|
||||||
SerializedProperty m_SplitNumber;
|
SerializedProperty m_SplitNumber;
|
||||||
SerializedProperty m_Center;
|
SerializedProperty m_Center;
|
||||||
SerializedProperty m_LineStyle;
|
SerializedProperty m_SplitLine;
|
||||||
SerializedProperty m_SplitArea;
|
SerializedProperty m_SplitArea;
|
||||||
SerializedProperty m_Indicator;
|
SerializedProperty m_Indicator;
|
||||||
|
SerializedProperty m_IndicatorGap;
|
||||||
SerializedProperty m_IndicatorList;
|
SerializedProperty m_IndicatorList;
|
||||||
|
|
||||||
private Dictionary<string, bool> m_RadarModuleToggle = new Dictionary<string, bool>();
|
private Dictionary<string, bool> m_RadarModuleToggle = new Dictionary<string, bool>();
|
||||||
@@ -33,12 +35,14 @@ namespace XCharts
|
|||||||
private void InitProperty(SerializedProperty prop)
|
private void InitProperty(SerializedProperty prop)
|
||||||
{
|
{
|
||||||
m_Shape = prop.FindPropertyRelative("m_Shape");
|
m_Shape = prop.FindPropertyRelative("m_Shape");
|
||||||
|
m_PositionType = prop.FindPropertyRelative("m_PositionType");
|
||||||
m_Radius = prop.FindPropertyRelative("m_Radius");
|
m_Radius = prop.FindPropertyRelative("m_Radius");
|
||||||
m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||||
m_Center = prop.FindPropertyRelative("m_Center");
|
m_Center = prop.FindPropertyRelative("m_Center");
|
||||||
m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
|
||||||
m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
||||||
m_Indicator = prop.FindPropertyRelative("m_Indicator");
|
m_Indicator = prop.FindPropertyRelative("m_Indicator");
|
||||||
|
m_IndicatorGap = prop.FindPropertyRelative("m_IndicatorGap");
|
||||||
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
|
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,9 +54,9 @@ namespace XCharts
|
|||||||
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
|
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
|
||||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
int index = ChartEditorHelper.GetIndexFromPath(prop);
|
int index = ChartEditorHelper.GetIndexFromPath(prop);
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Radar " + index, null, false);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Radar " + index, null, true);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
|
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
|
||||||
{
|
{
|
||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
|
|
||||||
@@ -60,6 +64,8 @@ namespace XCharts
|
|||||||
EditorGUIUtility.fieldWidth = defaultFieldWidth;
|
EditorGUIUtility.fieldWidth = defaultFieldWidth;
|
||||||
EditorGUI.PropertyField(drawRect, m_Shape);
|
EditorGUI.PropertyField(drawRect, m_Shape);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_PositionType);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
EditorGUI.LabelField(drawRect, "Center");
|
EditorGUI.LabelField(drawRect, "Center");
|
||||||
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
||||||
@@ -79,8 +85,8 @@ namespace XCharts
|
|||||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
EditorGUI.PropertyField(drawRect, m_SplitLine);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
|
||||||
EditorGUI.PropertyField(drawRect, m_SplitArea);
|
EditorGUI.PropertyField(drawRect, m_SplitArea);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -90,6 +96,8 @@ namespace XCharts
|
|||||||
drawRect.x = pos.x;
|
drawRect.x = pos.x;
|
||||||
if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop))
|
||||||
{
|
{
|
||||||
|
EditorGUI.PropertyField(drawRect, m_IndicatorGap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
ChartEditorHelper.MakeList(ref drawRect, ref m_IndicatorSize, m_IndicatorList);
|
ChartEditorHelper.MakeList(ref drawRect, ref m_IndicatorSize, m_IndicatorList);
|
||||||
}
|
}
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
@@ -99,18 +107,18 @@ namespace XCharts
|
|||||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
{
|
{
|
||||||
int propNum = 1;
|
int propNum = 1;
|
||||||
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
|
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
|
||||||
{
|
{
|
||||||
propNum += 6;
|
propNum += 7;
|
||||||
if (m_IndicatorJsonAreaToggle) propNum += 4;
|
if (m_IndicatorJsonAreaToggle) propNum += 4;
|
||||||
float height = propNum * EditorGUIUtility.singleLineHeight + (propNum - 1) * EditorGUIUtility.standardVerticalSpacing;
|
float height = propNum * EditorGUIUtility.singleLineHeight + (propNum - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitLine"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitArea"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SplitArea"));
|
||||||
|
|
||||||
if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_IndicatorToggle, prop))
|
||||||
{
|
{
|
||||||
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
|
m_IndicatorList = prop.FindPropertyRelative("m_IndicatorList");
|
||||||
height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
for (int i = 0; i < m_IndicatorList.arraySize; i++)
|
for (int i = 0; i < m_IndicatorList.arraySize; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_Name = prop.FindPropertyRelative("m_Name");
|
SerializedProperty m_Name = prop.FindPropertyRelative("m_Name");
|
||||||
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
||||||
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
||||||
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
|
||||||
Rect drawRect = pos;
|
Rect drawRect = pos;
|
||||||
float defaultLabelWidth = EditorGUIUtility.labelWidth;
|
float defaultLabelWidth = EditorGUIUtility.labelWidth;
|
||||||
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
|
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
|
||||||
@@ -30,7 +30,7 @@ namespace XCharts
|
|||||||
int index = ChartEditorHelper.GetIndexFromPath(prop);
|
int index = ChartEditorHelper.GetIndexFromPath(prop);
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Indicator " + index, m_Name, false);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Indicator " + index, m_Name, false);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
|
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
|
||||||
{
|
{
|
||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
|
|
||||||
@@ -40,8 +40,8 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Max);
|
EditorGUI.PropertyField(drawRect, m_Max);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Color);
|
EditorGUI.PropertyField(drawRect, m_TextStyle);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
|
||||||
|
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
@@ -49,9 +49,11 @@ namespace XCharts
|
|||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
{
|
{
|
||||||
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle,prop))
|
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
|
||||||
{
|
{
|
||||||
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
var height = 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
|
||||||
|
return height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,6 +58,21 @@ namespace XCharts
|
|||||||
SerializedProperty m_DataDimension = prop.FindPropertyRelative("m_ShowDataDimension");
|
SerializedProperty m_DataDimension = prop.FindPropertyRelative("m_ShowDataDimension");
|
||||||
SerializedProperty m_ShowDataName = prop.FindPropertyRelative("m_ShowDataName");
|
SerializedProperty m_ShowDataName = prop.FindPropertyRelative("m_ShowDataName");
|
||||||
SerializedProperty m_ShowDataIcon = prop.FindPropertyRelative("m_ShowDataIcon");
|
SerializedProperty m_ShowDataIcon = prop.FindPropertyRelative("m_ShowDataIcon");
|
||||||
|
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
||||||
|
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
||||||
|
SerializedProperty m_StartAngle = prop.FindPropertyRelative("m_StartAngle");
|
||||||
|
SerializedProperty m_EndAngle = prop.FindPropertyRelative("m_EndAngle");
|
||||||
|
SerializedProperty m_RingGap = prop.FindPropertyRelative("m_RingGap");
|
||||||
|
SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||||
|
SerializedProperty m_Clockwise = prop.FindPropertyRelative("m_Clockwise");
|
||||||
|
SerializedProperty m_RoundCap = prop.FindPropertyRelative("m_RoundCap");
|
||||||
|
SerializedProperty m_GaugeType = prop.FindPropertyRelative("m_GaugeType");
|
||||||
|
SerializedProperty m_GaugeAxis = prop.FindPropertyRelative("m_GaugeAxis");
|
||||||
|
SerializedProperty m_GaugePointer = prop.FindPropertyRelative("m_GaugePointer");
|
||||||
|
SerializedProperty m_TitleStyle = prop.FindPropertyRelative("m_TitleStyle");
|
||||||
|
SerializedProperty m_Clip = prop.FindPropertyRelative("m_Clip");
|
||||||
|
SerializedProperty m_Ignore = prop.FindPropertyRelative("m_Ignore");
|
||||||
|
SerializedProperty m_IgnoreValue = prop.FindPropertyRelative("m_IgnoreValue");
|
||||||
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
||||||
|
|
||||||
int index = InitToggle(prop);
|
int index = InitToggle(prop);
|
||||||
@@ -82,87 +97,191 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, name);
|
EditorGUI.PropertyField(drawRect, name);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, stack);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
if (serieType == SerieType.Radar)
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, m_RadarIndex);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, m_AxisIndex);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
EditorGUI.PropertyField(drawRect, m_MinShow);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_MaxShow);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_MaxCache);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
|
||||||
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
|
||||||
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0;
|
|
||||||
if (serieType == SerieType.Line)
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, m_LineType);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_SampleDist);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_SampleType);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_SampleAverage);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
if (serieType == SerieType.Line
|
|
||||||
|| serieType == SerieType.Scatter
|
|
||||||
|| serieType == SerieType.EffectScatter
|
|
||||||
|| serieType == SerieType.Radar)
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
|
||||||
}
|
|
||||||
if (serieType == SerieType.Bar)
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, m_BarType);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_BarPercentStack);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_BarWidth);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_BarGap);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_BarZebraWidth);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_BarZebraGap);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
}
|
|
||||||
if (serieType == SerieType.Pie)
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, m_RoseType);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Space);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
|
|
||||||
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
|
switch (serieType)
|
||||||
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
|
||||||
if (serieType == SerieType.Line)
|
|
||||||
{
|
{
|
||||||
EditorGUI.PropertyField(drawRect, m_LineArrow);
|
case SerieType.Line:
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_LineArrow);
|
EditorGUI.PropertyField(drawRect, stack);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_AxisIndex);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MinShow);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MaxShow);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MaxCache);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
||||||
|
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
||||||
|
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineType);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SampleDist);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SampleType);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SampleAverage);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Clip);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Ignore);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_IgnoreValue);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineArrow);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_LineArrow);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_AreaStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Emphasis);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
||||||
|
break;
|
||||||
|
case SerieType.Bar:
|
||||||
|
EditorGUI.PropertyField(drawRect, stack);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_AxisIndex);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MinShow);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MaxShow);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MaxCache);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
||||||
|
if (m_MinShow.intValue < 0) m_MinShow.intValue = 0;
|
||||||
|
if (m_MaxCache.intValue < 0) m_MaxCache.intValue = 0;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarType);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarPercentStack);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarWidth);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarGap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarZebraWidth);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BarZebraGap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Clip);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||||
|
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.Pie:
|
||||||
|
EditorGUI.PropertyField(drawRect, m_RoseType);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Space);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
|
||||||
|
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
|
||||||
|
EditorGUI.PropertyField(drawRect, m_RoundCap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Emphasis);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
||||||
|
break;
|
||||||
|
case SerieType.Ring:
|
||||||
|
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
|
||||||
|
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
|
||||||
|
EditorGUI.PropertyField(drawRect, m_StartAngle);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_RingGap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_RoundCap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Clockwise);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TitleStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TitleStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Emphasis);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
||||||
|
break;
|
||||||
|
case SerieType.Radar:
|
||||||
|
EditorGUI.PropertyField(drawRect, m_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_AreaStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
|
||||||
|
break;
|
||||||
|
case SerieType.Scatter:
|
||||||
|
case SerieType.EffectScatter:
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Clip);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_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_ItemStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Emphasis);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
||||||
|
break;
|
||||||
|
case SerieType.Gauge:
|
||||||
|
EditorGUI.PropertyField(drawRect, m_GaugeType);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Center, "Center");
|
||||||
|
//ChartEditorHelper.MakeTwoField(ref drawRect, pos.width, m_Radius, "Radius");
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Radius.GetArrayElementAtIndex(0), new GUIContent("Radius"));
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Min);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Max);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_StartAngle);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_EndAngle);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (m_SplitNumber.intValue > 36)
|
||||||
|
{
|
||||||
|
m_SplitNumber.intValue = 36;
|
||||||
|
}
|
||||||
|
EditorGUI.PropertyField(drawRect, m_RoundCap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TitleStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TitleStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_GaugeAxis);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_GaugeAxis);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_GaugePointer);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_GaugePointer);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Emphasis);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_ItemStyle);
|
|
||||||
EditorGUI.PropertyField(drawRect, m_AreaStyle);
|
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AreaStyle);
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Label);
|
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Emphasis);
|
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Emphasis);
|
|
||||||
EditorGUI.PropertyField(drawRect, m_Animation);
|
EditorGUI.PropertyField(drawRect, m_Animation);
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Animation);
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Animation);
|
||||||
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
drawRect.width = EditorGUIUtility.labelWidth + 10;
|
||||||
@@ -173,7 +292,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
|
|
||||||
float nameWid = 40;
|
float nameWid = 42;
|
||||||
EditorGUI.PropertyField(new Rect(drawRect.x, drawRect.y, pos.width - 2 * nameWid - 2, pos.height), m_DataDimension);
|
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, drawRect.y, nameWid, pos.height);
|
||||||
if (GUI.Button(nameRect, new GUIContent("Name")))
|
if (GUI.Button(nameRect, new GUIContent("Name")))
|
||||||
@@ -181,7 +300,7 @@ namespace XCharts
|
|||||||
m_ShowDataName.boolValue = !m_ShowDataName.boolValue;
|
m_ShowDataName.boolValue = !m_ShowDataName.boolValue;
|
||||||
}
|
}
|
||||||
var iconRect = new Rect(pos.width - nameWid + 14, drawRect.y, nameWid, pos.height);
|
var iconRect = new Rect(pos.width - nameWid + 14, drawRect.y, nameWid, pos.height);
|
||||||
if (GUI.Button(iconRect, new GUIContent("Icon")))
|
if (GUI.Button(iconRect, new GUIContent("Other")))
|
||||||
{
|
{
|
||||||
m_ShowDataIcon.boolValue = !m_ShowDataIcon.boolValue;
|
m_ShowDataIcon.boolValue = !m_ShowDataIcon.boolValue;
|
||||||
}
|
}
|
||||||
@@ -232,7 +351,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawDataElement(ref Rect drawRect, int dimension, SerializedProperty m_Datas, bool showName,
|
private void DrawDataElement(ref Rect drawRect, int dimension, SerializedProperty m_Datas, bool showName,
|
||||||
bool showIconDetail, bool showSelected, int index, float currentWidth)
|
bool showDetail, bool showSelected, int index, float currentWidth)
|
||||||
{
|
{
|
||||||
var lastX = drawRect.x;
|
var lastX = drawRect.x;
|
||||||
var lastWid = drawRect.width;
|
var lastWid = drawRect.width;
|
||||||
@@ -253,7 +372,7 @@ namespace XCharts
|
|||||||
if (showSelected)
|
if (showSelected)
|
||||||
{
|
{
|
||||||
drawRect.width = drawRect.width - 18;
|
drawRect.width = drawRect.width - 18;
|
||||||
EditorGUI.PropertyField(drawRect, element);
|
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index));
|
||||||
drawRect.x = currentWidth - 45;
|
drawRect.x = currentWidth - 45;
|
||||||
EditorGUI.PropertyField(drawRect, selected, GUIContent.none);
|
EditorGUI.PropertyField(drawRect, selected, GUIContent.none);
|
||||||
drawRect.x = lastX;
|
drawRect.x = lastX;
|
||||||
@@ -261,7 +380,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EditorGUI.PropertyField(drawRect, element);
|
EditorGUI.PropertyField(drawRect, element, new GUIContent("Element " + index));
|
||||||
}
|
}
|
||||||
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUI.GetPropertyHeight(element) + EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
@@ -274,7 +393,7 @@ namespace XCharts
|
|||||||
var xWid = dataWid - 4;
|
var xWid = dataWid - 4;
|
||||||
for (int i = 0; i < dimension; i++)
|
for (int i = 0; i < dimension; i++)
|
||||||
{
|
{
|
||||||
if (i >= data.arraySize - 1)
|
while (i >= data.arraySize - 1)
|
||||||
{
|
{
|
||||||
data.InsertArrayElementAtIndex(data.arraySize);
|
data.InsertArrayElementAtIndex(data.arraySize);
|
||||||
}
|
}
|
||||||
@@ -296,37 +415,19 @@ namespace XCharts
|
|||||||
EditorGUIUtility.fieldWidth = lastFieldWid;
|
EditorGUIUtility.fieldWidth = lastFieldWid;
|
||||||
EditorGUIUtility.labelWidth = lastLabelWid;
|
EditorGUIUtility.labelWidth = lastLabelWid;
|
||||||
}
|
}
|
||||||
if (showIconDetail)
|
if (showDetail)
|
||||||
{
|
{
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel += 2;
|
||||||
var m_ShowIcon = serieData.FindPropertyRelative("m_ShowIcon");
|
var m_Icon = serieData.FindPropertyRelative("m_IconStyle");
|
||||||
var m_IconImage = serieData.FindPropertyRelative("m_IconImage");
|
var m_EnableLabel = serieData.FindPropertyRelative("m_EnableLabel");
|
||||||
var m_IconColor = serieData.FindPropertyRelative("m_IconColor");
|
var m_Label = serieData.FindPropertyRelative("m_Label");
|
||||||
var m_IconWidth = serieData.FindPropertyRelative("m_IconWidth");
|
EditorGUI.PropertyField(drawRect, m_Icon);
|
||||||
var m_IconHeight = serieData.FindPropertyRelative("m_IconHeight");
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Icon);
|
||||||
var m_IconOffset = serieData.FindPropertyRelative("m_IconOffset");
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
EditorGUI.PropertyField(drawRect, m_ShowIcon);
|
ChartEditorHelper.MakeBool(ref drawRect, m_EnableLabel, 1, "(enable)");
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||||
EditorGUI.PropertyField(drawRect, m_IconImage);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_IconColor);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_IconWidth);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_IconHeight);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
|
|
||||||
EditorGUI.LabelField(drawRect, "Icon Offset");
|
EditorGUI.indentLevel -= 2;
|
||||||
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
|
||||||
var tempWidth = (drawRect.width - startX + 72) / 2;
|
|
||||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
|
||||||
var centerYRect = new Rect(centerXRect.x + tempWidth - 58, drawRect.y, tempWidth, drawRect.height);
|
|
||||||
var x = EditorGUI.FloatField(centerXRect, m_IconOffset.vector3Value.x);
|
|
||||||
var y = EditorGUI.FloatField(centerYRect, m_IconOffset.vector3Value.y);
|
|
||||||
m_IconOffset.vector3Value = new Vector3(x, y);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
|
|
||||||
EditorGUI.indentLevel--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,48 +441,101 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
|
||||||
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
||||||
var serieType = (SerieType)type.enumValueIndex;
|
var serieType = (SerieType)type.enumValueIndex;
|
||||||
if (serieType == SerieType.Line
|
switch (serieType)
|
||||||
|| serieType == SerieType.Scatter
|
|
||||||
|| serieType == SerieType.EffectScatter
|
|
||||||
|| serieType == SerieType.Radar)
|
|
||||||
{
|
{
|
||||||
|
case SerieType.Line:
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
height += 16 * EditorGUIUtility.singleLineHeight + 15 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||||
if (serieType == SerieType.Pie)
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||||
{
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
}
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||||
if (serieType == SerieType.Line)
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
{
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
break;
|
||||||
}
|
case SerieType.Bar:
|
||||||
if (serieType == SerieType.Bar)
|
height += 17 * EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
{
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
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 += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
|
case SerieType.Ring:
|
||||||
|
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TitleStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
|
case SerieType.Radar:
|
||||||
|
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
|
case SerieType.Scatter:
|
||||||
|
case SerieType.EffectScatter:
|
||||||
|
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_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 += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
|
case SerieType.Gauge:
|
||||||
|
height += 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TitleStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_GaugeAxis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_GaugePointer"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (m_DataFoldout[index])
|
if (m_DataFoldout[index])
|
||||||
{
|
{
|
||||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||||
int num = m_Data.arraySize + 2;
|
height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (num > 30) num = 15;
|
int num = m_Data.arraySize;
|
||||||
|
if (num > 30)
|
||||||
|
{
|
||||||
|
num = 11;
|
||||||
|
height += (num + 1) * EditorGUIUtility.singleLineHeight + (num) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
height += (num) * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
if (prop.FindPropertyRelative("m_ShowDataIcon").boolValue)
|
if (prop.FindPropertyRelative("m_ShowDataIcon").boolValue)
|
||||||
{
|
{
|
||||||
num *= 5;
|
for (int i = 0; i < num; i++)
|
||||||
num += 2;
|
{
|
||||||
|
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_Label"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (m_ShowJsonDataArea)
|
if (m_ShowJsonDataArea)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_Position = prop.FindPropertyRelative("m_Position");
|
SerializedProperty m_Position = prop.FindPropertyRelative("m_Position");
|
||||||
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
||||||
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
||||||
|
SerializedProperty m_Margin = prop.FindPropertyRelative("m_Margin");
|
||||||
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
|
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
|
||||||
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
|
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
|
||||||
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
|
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
|
||||||
@@ -42,6 +43,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_Border = prop.FindPropertyRelative("m_Border");
|
SerializedProperty m_Border = prop.FindPropertyRelative("m_Border");
|
||||||
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
||||||
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
|
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
|
||||||
|
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieLabelToggle, prop, null, show, false);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieLabelToggle, prop, null, show, false);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -61,6 +63,8 @@ namespace XCharts
|
|||||||
m_Offset.vector3Value = new Vector3(x, y);
|
m_Offset.vector3Value = new Vector3(x, y);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Margin);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Formatter);
|
EditorGUI.PropertyField(drawRect, m_Formatter);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
|
||||||
@@ -100,6 +104,8 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_LineLength2);
|
EditorGUI.PropertyField(drawRect, m_LineLength2);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,7 +115,7 @@ namespace XCharts
|
|||||||
float height = 0;
|
float height = 0;
|
||||||
if (ChartEditorHelper.IsToggle(m_SerieLabelToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_SerieLabelToggle, prop))
|
||||||
{
|
{
|
||||||
height += 22 * EditorGUIUtility.singleLineHeight + 21 * EditorGUIUtility.standardVerticalSpacing;
|
height += 24 * EditorGUIUtility.singleLineHeight + 23 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace XCharts
|
|||||||
SerializedProperty m_StartIndex = prop.FindPropertyRelative("m_StartIndex");
|
SerializedProperty m_StartIndex = prop.FindPropertyRelative("m_StartIndex");
|
||||||
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
|
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
|
||||||
SerializedProperty m_ForceShowLast = prop.FindPropertyRelative("m_ForceShowLast");
|
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_Type, false);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -39,6 +40,8 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
|
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Gap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_SizeType);
|
EditorGUI.PropertyField(drawRect, m_SizeType);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
SerieSymbolSizeType sizeType = (SerieSymbolSizeType)m_SizeType.enumValueIndex;
|
SerieSymbolSizeType sizeType = (SerieSymbolSizeType)m_SizeType.enumValueIndex;
|
||||||
@@ -84,13 +87,13 @@ namespace XCharts
|
|||||||
switch (sizeType)
|
switch (sizeType)
|
||||||
{
|
{
|
||||||
case SerieSymbolSizeType.Custom:
|
case SerieSymbolSizeType.Custom:
|
||||||
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
case SerieSymbolSizeType.FromData:
|
|
||||||
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
case SerieSymbolSizeType.FromData:
|
||||||
|
return 11 * EditorGUIUtility.singleLineHeight + 11 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
case SerieSymbolSizeType.Callback:
|
case SerieSymbolSizeType.Callback:
|
||||||
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
return 9 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
return 10 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
53
Assets/XCharts/Editor/PropertyDrawers/TextLimitDrawer.cs
Normal file
53
Assets/XCharts/Editor/PropertyDrawers/TextLimitDrawer.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(TextLimit), true)]
|
||||||
|
public class TextLimitDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_TextLimitToggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty m_Enable = prop.FindPropertyRelative("m_Enable");
|
||||||
|
SerializedProperty m_MaxWidth = prop.FindPropertyRelative("m_MaxWidth");
|
||||||
|
SerializedProperty m_Gap = prop.FindPropertyRelative("m_Gap");
|
||||||
|
SerializedProperty m_LimitSuffix = prop.FindPropertyRelative("m_Suffix");
|
||||||
|
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextLimitToggle, prop, "Text Limit", m_Enable, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_TextLimitToggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_MaxWidth);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Gap);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LimitSuffix);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
float height = 0;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_TextLimitToggle, prop))
|
||||||
|
{
|
||||||
|
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 842d3986d1c1747d8b0668649e8b1a0e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
71
Assets/XCharts/Editor/PropertyDrawers/TextStyleDrawer.cs
Normal file
71
Assets/XCharts/Editor/PropertyDrawers/TextStyleDrawer.cs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(TextStyle), true)]
|
||||||
|
public class TextStyleDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_TextStyleToggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty m_Font = prop.FindPropertyRelative("m_Font");
|
||||||
|
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
|
||||||
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||||
|
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
|
||||||
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||||
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
||||||
|
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
||||||
|
SerializedProperty m_LineSpacing = prop.FindPropertyRelative("m_LineSpacing");
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextStyleToggle, prop, null,null,false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Font);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Rotate);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Offset);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Color);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_FontSize);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineSpacing);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
float height = 0;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop))
|
||||||
|
{
|
||||||
|
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f14c425fb2bff44f2bf9ddb8d6ff1741
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -21,9 +21,9 @@ namespace XCharts
|
|||||||
drawRect.height = EditorGUIUtility.singleLineHeight;
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
SerializedProperty text = prop.FindPropertyRelative("m_Text");
|
SerializedProperty text = prop.FindPropertyRelative("m_Text");
|
||||||
SerializedProperty m_TextFontSize = prop.FindPropertyRelative("m_TextFontSize");
|
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
|
||||||
SerializedProperty subText = prop.FindPropertyRelative("m_SubText");
|
SerializedProperty subText = prop.FindPropertyRelative("m_SubText");
|
||||||
SerializedProperty m_SubTextFontSize = prop.FindPropertyRelative("m_SubTextFontSize");
|
SerializedProperty m_SubTextStyle = prop.FindPropertyRelative("m_SubTextStyle");
|
||||||
SerializedProperty m_ItemGap = prop.FindPropertyRelative("m_ItemGap");
|
SerializedProperty m_ItemGap = prop.FindPropertyRelative("m_ItemGap");
|
||||||
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
||||||
|
|
||||||
@@ -34,19 +34,16 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
EditorGUI.PropertyField(drawRect, text);
|
EditorGUI.PropertyField(drawRect, text);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
++EditorGUI.indentLevel;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_TextFontSize, new GUIContent("Font Size"));
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
--EditorGUI.indentLevel;
|
|
||||||
EditorGUI.PropertyField(drawRect, subText);
|
EditorGUI.PropertyField(drawRect, subText);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
++EditorGUI.indentLevel;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_SubTextFontSize, new GUIContent("Font Size"));
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_ItemGap, new GUIContent("Item Gap"));
|
EditorGUI.PropertyField(drawRect, m_ItemGap, new GUIContent("Item Gap"));
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
--EditorGUI.indentLevel;
|
|
||||||
EditorGUI.PropertyField(drawRect, location);
|
EditorGUI.PropertyField(drawRect, location);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(location);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TextStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_SubTextStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_SubTextStyle);
|
||||||
}
|
}
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
@@ -56,9 +53,10 @@ namespace XCharts
|
|||||||
float height = 0;
|
float height = 0;
|
||||||
if (m_TitleModuleToggle)
|
if (m_TitleModuleToggle)
|
||||||
{
|
{
|
||||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
SerializedProperty location = prop.FindPropertyRelative("m_Location");
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
|
||||||
height += EditorGUI.GetPropertyHeight(location);
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_SubTextStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Location"));
|
||||||
}
|
}
|
||||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
return height;
|
return height;
|
||||||
|
|||||||
51
Assets/XCharts/Editor/PropertyDrawers/TitleStyleDrawer.cs
Normal file
51
Assets/XCharts/Editor/PropertyDrawers/TitleStyleDrawer.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(TitleStyle), true)]
|
||||||
|
public class TitleStyleDrawer : PropertyDrawer
|
||||||
|
{
|
||||||
|
private Dictionary<string, bool> m_TitleStyleToggle = new Dictionary<string, bool>();
|
||||||
|
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
Rect drawRect = pos;
|
||||||
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
|
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
|
||||||
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TitleStyleToggle, prop, "Title Style", show, false);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_TitleStyleToggle, prop))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TextStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
float height = 0;
|
||||||
|
if (ChartEditorHelper.IsToggle(m_TitleStyleToggle, prop))
|
||||||
|
{
|
||||||
|
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e451ee4c9f65a414784fd5fd9cad6ec1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -22,21 +22,33 @@ namespace XCharts
|
|||||||
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
||||||
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
||||||
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
||||||
|
SerializedProperty m_TitleFormatter = prop.FindPropertyRelative("m_TitleFormatter");
|
||||||
|
SerializedProperty m_ItemFormatter = prop.FindPropertyRelative("m_ItemFormatter");
|
||||||
SerializedProperty m_FixedWidth = prop.FindPropertyRelative("m_FixedWidth");
|
SerializedProperty m_FixedWidth = prop.FindPropertyRelative("m_FixedWidth");
|
||||||
SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight");
|
SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight");
|
||||||
SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth");
|
SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth");
|
||||||
SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight");
|
SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight");
|
||||||
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
||||||
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
|
||||||
|
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
|
||||||
|
SerializedProperty m_BackgroundImage = prop.FindPropertyRelative("m_BackgroundImage");
|
||||||
|
SerializedProperty m_IgnoreDataDefaultContent = prop.FindPropertyRelative("m_IgnoreDataDefaultContent");
|
||||||
|
SerializedProperty m_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||||
|
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (m_TooltipModuleToggle)
|
if (m_TooltipModuleToggle)
|
||||||
{
|
{
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
EditorGUI.PropertyField(drawRect, type);
|
EditorGUI.PropertyField(drawRect, type);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Formatter);
|
EditorGUI.PropertyField(drawRect, m_Formatter);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TitleFormatter);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ItemFormatter);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FixedWidth);
|
EditorGUI.PropertyField(drawRect, m_FixedWidth);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FixedHeight);
|
EditorGUI.PropertyField(drawRect, m_FixedHeight);
|
||||||
@@ -45,17 +57,30 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_MinHeight);
|
EditorGUI.PropertyField(drawRect, m_MinHeight);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FontSize);
|
EditorGUI.PropertyField(drawRect, m_PaddingLeftRight);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
EditorGUI.PropertyField(drawRect, m_PaddingTopBottom);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_BackgroundImage);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_IgnoreDataDefaultContent);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_LineStyle);
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TextStyle);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
{
|
{
|
||||||
if (m_TooltipModuleToggle)
|
if (m_TooltipModuleToggle)
|
||||||
return 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
return 14 * EditorGUIUtility.singleLineHeight + 13 * EditorGUIUtility.standardVerticalSpacing +
|
||||||
|
EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle")) +
|
||||||
|
EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
|
||||||
else
|
else
|
||||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,17 +79,32 @@ public class ChartEditorHelper
|
|||||||
float defaultX = drawRect.x;
|
float defaultX = drawRect.x;
|
||||||
drawRect.width = EditorGUIUtility.labelWidth;
|
drawRect.width = EditorGUIUtility.labelWidth;
|
||||||
moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? foldoutStyle : EditorStyles.foldout);
|
moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? foldoutStyle : EditorStyles.foldout);
|
||||||
drawRect.x = EditorGUIUtility.labelWidth - (EditorGUI.indentLevel - 1) * 15 - 2;
|
MakeBool(ref drawRect, prop);
|
||||||
drawRect.width = 40;
|
|
||||||
if (prop != null)
|
|
||||||
{
|
|
||||||
EditorGUI.PropertyField(drawRect, prop, GUIContent.none);
|
|
||||||
}
|
|
||||||
drawRect.width = defaultWidth;
|
drawRect.width = defaultWidth;
|
||||||
drawRect.x = defaultX;
|
drawRect.x = defaultX;
|
||||||
return moduleToggle;
|
return moduleToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void MakeBool(ref 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;
|
||||||
|
if (boolProp != null)
|
||||||
|
{
|
||||||
|
EditorGUI.PropertyField(drawRect, boolProp, GUIContent.none);
|
||||||
|
drawRect.x += 13;
|
||||||
|
drawRect.width = 200;
|
||||||
|
if (!string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
EditorGUI.LabelField(drawRect, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawRect.width = defaultWidth;
|
||||||
|
drawRect.x = defaultX;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool MakeFoldout(ref Rect drawRect, ref Dictionary<string, bool> moduleToggle, SerializedProperty prop,
|
public static bool MakeFoldout(ref Rect drawRect, ref Dictionary<string, bool> moduleToggle, SerializedProperty prop,
|
||||||
string moduleName, SerializedProperty showProp = null, bool bold = true)
|
string moduleName, SerializedProperty showProp = null, bool bold = true)
|
||||||
{
|
{
|
||||||
@@ -102,7 +117,7 @@ public class ChartEditorHelper
|
|||||||
|
|
||||||
float defaultWidth = drawRect.width;
|
float defaultWidth = drawRect.width;
|
||||||
float defaultX = drawRect.x;
|
float defaultX = drawRect.x;
|
||||||
drawRect.width = EditorGUIUtility.labelWidth;
|
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
||||||
var displayName = string.IsNullOrEmpty(moduleName) ? prop.displayName : moduleName;
|
var displayName = string.IsNullOrEmpty(moduleName) ? prop.displayName : moduleName;
|
||||||
toggle = EditorGUI.Foldout(drawRect, toggle, displayName, bold ? foldoutStyle : EditorStyles.foldout);
|
toggle = EditorGUI.Foldout(drawRect, toggle, displayName, bold ? foldoutStyle : EditorStyles.foldout);
|
||||||
if (moduleToggle[key] != toggle)
|
if (moduleToggle[key] != toggle)
|
||||||
@@ -114,7 +129,7 @@ public class ChartEditorHelper
|
|||||||
{
|
{
|
||||||
if (showProp.propertyType == SerializedPropertyType.Boolean)
|
if (showProp.propertyType == SerializedPropertyType.Boolean)
|
||||||
{
|
{
|
||||||
drawRect.width = 60;
|
drawRect.width = 100;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
119
Assets/XCharts/Editor/XChartEditor.cs
Normal file
119
Assets/XCharts/Editor/XChartEditor.cs
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
public class XChartEditor : EditorWindow
|
||||||
|
{
|
||||||
|
private static Transform GetParent()
|
||||||
|
{
|
||||||
|
GameObject selectObj = Selection.activeGameObject;
|
||||||
|
if (selectObj == null)
|
||||||
|
{
|
||||||
|
var canvas = GameObject.FindObjectOfType<Canvas>();
|
||||||
|
if (canvas != null) return canvas.transform;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var canvasObject = new GameObject();
|
||||||
|
canvasObject.name = "Canvas";
|
||||||
|
canvas = canvasObject.AddComponent<Canvas>();
|
||||||
|
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||||
|
canvasObject.AddComponent<CanvasScaler>();
|
||||||
|
canvasObject.AddComponent<GraphicRaycaster>();
|
||||||
|
var eventSystem = new GameObject();
|
||||||
|
eventSystem.name = "EventSystem";
|
||||||
|
eventSystem.AddComponent<EventSystem>();
|
||||||
|
eventSystem.AddComponent<StandaloneInputModule>();
|
||||||
|
return canvas.transform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return selectObj.transform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetName(Transform parent, string name)
|
||||||
|
{
|
||||||
|
if (parent.Find(name) == null) return name;
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
var newName = string.Format("{0} ({1})", name, i);
|
||||||
|
if (parent.Find(newName) == null)
|
||||||
|
{
|
||||||
|
return newName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddChart<T>(string chartName) where T : BaseChart
|
||||||
|
{
|
||||||
|
var parent = GetParent();
|
||||||
|
if (parent == null) return;
|
||||||
|
var chart = new GameObject();
|
||||||
|
chart.name = GetName(parent, chartName);
|
||||||
|
chart.AddComponent<T>();
|
||||||
|
chart.transform.SetParent(parent);
|
||||||
|
chart.transform.localScale = Vector3.one;
|
||||||
|
chart.transform.localPosition = Vector3.zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/LineChart", priority = 44)]
|
||||||
|
public static void AddLineChart()
|
||||||
|
{
|
||||||
|
AddChart<LineChart>("LineChart");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/BarChart", priority = 45)]
|
||||||
|
public static void AddBarChart()
|
||||||
|
{
|
||||||
|
AddChart<BarChart>("BarChart");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/PieChart", priority = 46)]
|
||||||
|
public static void AddPieChart()
|
||||||
|
{
|
||||||
|
AddChart<PieChart>("PieChart");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/RadarChart", priority = 47)]
|
||||||
|
public static void AddRadarChart()
|
||||||
|
{
|
||||||
|
AddChart<RadarChart>("RadarChart");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/ScatterChart", priority = 48)]
|
||||||
|
public static void AddScatterChart()
|
||||||
|
{
|
||||||
|
AddChart<ScatterChart>("ScatterChart");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/HeatmapChart", priority = 49)]
|
||||||
|
public static void AddHeatmapChart()
|
||||||
|
{
|
||||||
|
AddChart<HeatmapChart>("HeatmapChart");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/GaugeChart", priority = 50)]
|
||||||
|
public static void AddGaugeChart()
|
||||||
|
{
|
||||||
|
AddChart<GaugeChart>("GaugeChart");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/XCharts/RingChart", priority = 51)]
|
||||||
|
public static void AddRingChart()
|
||||||
|
{
|
||||||
|
AddChart<RingChart>("RingChart");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Editor/XChartEditor.cs.meta
Normal file
11
Assets/XCharts/Editor/XChartEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 941beb76fdaa64a27a2df6561893157e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
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.
|
||||||
|
|
||||||
一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图等常见图表。
|
一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图、仪表盘、环形图等常见图表。
|
||||||
|
|
||||||
## 特性
|
## 特性
|
||||||
|
|
||||||
* 内置丰富示例和模板,参数可视化配置,效果实时预览,纯代码绘制。
|
* 内置丰富示例和模板,参数可视化配置,效果实时预览,纯代码绘制。
|
||||||
* 支持折线图、柱状图、饼图、雷达图、散点图、热力图等常见图表。
|
* 支持折线图、柱状图、饼图、雷达图、散点图、热力图、仪表盘、环形图等常见图表。
|
||||||
* 支持直线图、曲线图、面积图、阶梯线图等折线图。
|
* 支持直线图、曲线图、面积图、阶梯线图等折线图。
|
||||||
* 支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图等柱状图。
|
* 支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图等柱状图。
|
||||||
* 支持环形图、玫瑰图等饼图。
|
* 支持环形图、玫瑰图等饼图。
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class BaseChart
|
public partial class BaseChart
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The theme info.
|
||||||
|
/// </summary>
|
||||||
|
public ThemeInfo themeInfo { get { return m_ThemeInfo; } set { m_ThemeInfo = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The title setting of chart.
|
/// The title setting of chart.
|
||||||
/// 标题组件
|
/// 标题组件
|
||||||
@@ -88,7 +92,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_Series.ClearData();
|
m_Series.ClearData();
|
||||||
m_Legend.ClearData();
|
m_Legend.ClearData();
|
||||||
|
m_Tooltip.ClearValue();
|
||||||
m_CheckAnimation = false;
|
m_CheckAnimation = false;
|
||||||
|
m_ReinitLabel = true;
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +107,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_Legend.ClearData();
|
m_Legend.ClearData();
|
||||||
m_Series.RemoveAll();
|
m_Series.RemoveAll();
|
||||||
|
m_Tooltip.ClearValue();
|
||||||
m_CheckAnimation = false;
|
m_CheckAnimation = false;
|
||||||
|
m_ReinitLabel = true;
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +224,7 @@ namespace XCharts
|
|||||||
/// <param name="yValue">y data</param>
|
/// <param name="yValue">y data</param>
|
||||||
/// <param name="dataName">the name of data</param>
|
/// <param name="dataName">the name of data</param>
|
||||||
/// <returns>Returns True on success</returns>
|
/// <returns>Returns True on success</returns>
|
||||||
public virtual SerieData AddData(string serieName, float xValue, float yValue, string dataName)
|
public virtual SerieData AddData(string serieName, float xValue, float yValue, string dataName = null)
|
||||||
{
|
{
|
||||||
var serieData = m_Series.AddXYData(serieName, xValue, yValue, dataName);
|
var serieData = m_Series.AddXYData(serieName, xValue, yValue, dataName);
|
||||||
if (serieData != null)
|
if (serieData != null)
|
||||||
@@ -254,10 +262,14 @@ namespace XCharts
|
|||||||
/// <param name="serieName">the name of serie</param>
|
/// <param name="serieName">the name of serie</param>
|
||||||
/// <param name="dataIndex">the index of data</param>
|
/// <param name="dataIndex">the index of data</param>
|
||||||
/// <param name="value">the data will be update</param>
|
/// <param name="value">the data will be update</param>
|
||||||
public virtual void UpdateData(string serieName, int dataIndex, float value)
|
public virtual bool UpdateData(string serieName, int dataIndex, float value)
|
||||||
{
|
{
|
||||||
m_Series.UpdateData(serieName, dataIndex, value);
|
if (m_Series.UpdateData(serieName, dataIndex, value))
|
||||||
RefreshChart();
|
{
|
||||||
|
RefreshChart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -267,10 +279,80 @@ namespace XCharts
|
|||||||
/// <param name="serieIndex">the index of serie</param>
|
/// <param name="serieIndex">the index of serie</param>
|
||||||
/// <param name="dataIndex">the index of data</param>
|
/// <param name="dataIndex">the index of data</param>
|
||||||
/// <param name="value">the data will be update</param>
|
/// <param name="value">the data will be update</param>
|
||||||
public virtual void UpdateData(int serieIndex, int dataIndex, float value)
|
public virtual bool UpdateData(int serieIndex, int dataIndex, float value)
|
||||||
{
|
{
|
||||||
m_Series.UpdateData(serieIndex, dataIndex, value);
|
if (m_Series.UpdateData(serieIndex, dataIndex, value))
|
||||||
RefreshChart();
|
{
|
||||||
|
RefreshChart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列指定索引的数据项的多维数据。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieName"></param>
|
||||||
|
/// <param name="dataIndex"></param>
|
||||||
|
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
|
||||||
|
public virtual bool UpdateData(string serieName, int dataIndex, List<float> multidimensionalData)
|
||||||
|
{
|
||||||
|
if (m_Series.UpdateData(serieName, dataIndex, multidimensionalData))
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列指定索引的数据项的多维数据。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieIndex"></param>
|
||||||
|
/// <param name="dataIndex"></param>
|
||||||
|
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
|
||||||
|
public virtual bool UpdateData(int serieIndex, int dataIndex, List<float> multidimensionalData)
|
||||||
|
{
|
||||||
|
if (m_Series.UpdateData(serieIndex, dataIndex, multidimensionalData))
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列指定索引指定维数的数据。维数从0开始。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieName"></param>
|
||||||
|
/// <param name="dataIndex"></param>
|
||||||
|
/// <param name="dimension">指定维数,从0开始</param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
public virtual bool UpdateData(string serieName, int dataIndex, int dimension, float value)
|
||||||
|
{
|
||||||
|
if (m_Series.UpdateData(serieName, dataIndex, dimension, value))
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列指定索引指定维数的数据。维数从0开始。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieIndex"></param>
|
||||||
|
/// <param name="dataIndex"></param>
|
||||||
|
/// <param name="dimension">指定维数,从0开始</param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
public virtual bool UpdateData(int serieIndex, int dataIndex, int dimension, float value)
|
||||||
|
{
|
||||||
|
if (m_Series.UpdateData(serieIndex, dataIndex, dimension, value))
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -280,9 +362,9 @@ namespace XCharts
|
|||||||
/// <param name="serieName"></param>
|
/// <param name="serieName"></param>
|
||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
public virtual void UpdateDataName(string serieName, int dataIndex, string dataName)
|
public virtual bool UpdateDataName(string serieName, int dataIndex, string dataName)
|
||||||
{
|
{
|
||||||
m_Series.UpdateDataName(serieName, dataIndex, dataName);
|
return m_Series.UpdateDataName(serieName, dataIndex, dataName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -292,9 +374,9 @@ namespace XCharts
|
|||||||
/// <param name="serieIndex"></param>
|
/// <param name="serieIndex"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
public virtual void UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
public virtual bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
||||||
{
|
{
|
||||||
m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
|
return m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -324,9 +406,19 @@ namespace XCharts
|
|||||||
var serie = m_Series.GetSerie(serieIndex);
|
var serie = m_Series.GetSerie(serieIndex);
|
||||||
if (serie != null && !string.IsNullOrEmpty(serie.name))
|
if (serie != null && !string.IsNullOrEmpty(serie.name))
|
||||||
{
|
{
|
||||||
var legendIndex = m_LegendRealShowName.IndexOf(serie.name);
|
UpdateLegendColor(serie.name, active);
|
||||||
var bgColor1 = active ? m_ThemeInfo.GetColor(legendIndex) : m_ThemeInfo.legendUnableColor;
|
}
|
||||||
m_Legend.UpdateButtonColor(serie.name, bgColor1);
|
}
|
||||||
|
|
||||||
|
protected virtual void UpdateLegendColor(string legendName, bool active)
|
||||||
|
{
|
||||||
|
var legendIndex = m_LegendRealShowName.IndexOf(legendName);
|
||||||
|
if (legendIndex >= 0)
|
||||||
|
{
|
||||||
|
var iconColor = LegendHelper.GetIconColor(legend, legendIndex, m_ThemeInfo, active);
|
||||||
|
var contentColor = LegendHelper.GetContentColor(legend, m_ThemeInfo, active);
|
||||||
|
m_Legend.UpdateButtonColor(legendName, iconColor);
|
||||||
|
m_Legend.UpdateContentColor(legendName, contentColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,6 +496,14 @@ namespace XCharts
|
|||||||
m_ReinitLabel = true;
|
m_ReinitLabel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新Tooltip组件。
|
||||||
|
/// </summary>
|
||||||
|
public void RefreshTooltip()
|
||||||
|
{
|
||||||
|
InitTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update chart theme.
|
/// Update chart theme.
|
||||||
/// 切换图表主题。
|
/// 切换图表主题。
|
||||||
@@ -416,6 +516,17 @@ namespace XCharts
|
|||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update chart theme info.
|
||||||
|
/// 切换图表主题。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="themeInfo">themeInfo</param>
|
||||||
|
public void UpdateThemeInfo(ThemeInfo themeInfo)
|
||||||
|
{
|
||||||
|
m_ThemeInfo = themeInfo;
|
||||||
|
UpdateTheme(m_ThemeInfo.theme);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether series animation enabel.
|
/// Whether series animation enabel.
|
||||||
/// 启用或关闭起始动画。
|
/// 启用或关闭起始动画。
|
||||||
@@ -426,32 +537,62 @@ namespace XCharts
|
|||||||
m_Series.AnimationEnable(flag);
|
m_Series.AnimationEnable(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[Obsolete("Use BaseChart.AnimationFadeIn() instead.", true)]
|
||||||
/// Start play animation.
|
|
||||||
/// 开始初始动画。
|
|
||||||
/// </summary>
|
|
||||||
public void AnimationStart()
|
public void AnimationStart()
|
||||||
{
|
{
|
||||||
m_Series.AnimationStart();
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use BaseChart.AnimationFadeOut() instead.", true)]
|
||||||
|
public void MissAnimationStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// fadeIn animation.
|
||||||
|
/// 开始渐入动画。
|
||||||
|
/// </summary>
|
||||||
|
public void AnimationFadeIn()
|
||||||
|
{
|
||||||
|
m_Series.AnimationFadeIn();
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// fadeIn animation.
|
||||||
|
/// 开始渐出动画。
|
||||||
|
/// </summary>
|
||||||
|
public void AnimationFadeOut()
|
||||||
|
{
|
||||||
|
m_Series.AnimationFadeOut();
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pause animation.
|
||||||
|
/// 暂停动画。
|
||||||
|
/// </summary>
|
||||||
|
public void AnimationPause()
|
||||||
|
{
|
||||||
|
m_Series.AnimationPause();
|
||||||
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stop play animation.
|
/// Stop play animation.
|
||||||
/// 停止初始化动画。
|
/// 继续动画。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AnimationStop()
|
public void AnimationResume()
|
||||||
{
|
{
|
||||||
m_CheckAnimation = false;
|
m_Series.AnimationResume();
|
||||||
m_Series.AnimationStop();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset animation to play.
|
/// Reset animation.
|
||||||
/// 重置初始动画,重新播放。
|
/// 重置动画。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AnimationReset()
|
public void AnimationReset()
|
||||||
{
|
{
|
||||||
m_CheckAnimation = false;
|
|
||||||
m_Series.AnimationReset();
|
m_Series.AnimationReset();
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
@@ -467,5 +608,34 @@ namespace XCharts
|
|||||||
OnLegendButtonClick(legendIndex, legendName, show);
|
OnLegendButtonClick(legendIndex, legendName, show);
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 坐标是否在图表范围内
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="local"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsInChart(Vector2 local)
|
||||||
|
{
|
||||||
|
if (local.x < 0 || local.x > chartWidth ||
|
||||||
|
local.y < 0 || local.y > chartHeight)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 ClampInChart(Vector3 pos)
|
||||||
|
{
|
||||||
|
if (IsInChart(pos)) return pos;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var np = new Vector3(pos.x, pos.y);
|
||||||
|
if (np.x < 0) np.x = 0;
|
||||||
|
if (np.x > chartWidth) np.x = chartWidth;
|
||||||
|
if (np.y < 0) np.y = 0;
|
||||||
|
if (np.y > chartHeight) np.y = chartHeight;
|
||||||
|
return np;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ namespace XCharts
|
|||||||
public void AddXAxisData(string category, int xAxisIndex = 0)
|
public void AddXAxisData(string category, int xAxisIndex = 0)
|
||||||
{
|
{
|
||||||
m_XAxises[xAxisIndex].AddData(category);
|
m_XAxises[xAxisIndex].AddData(category);
|
||||||
m_XAxisChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -141,23 +140,22 @@ namespace XCharts
|
|||||||
public void AddYAxisData(string category, int yAxisIndex = 0)
|
public void AddYAxisData(string category, int yAxisIndex = 0)
|
||||||
{
|
{
|
||||||
m_YAxises[yAxisIndex].AddData(category);
|
m_YAxises[yAxisIndex].AddData(category);
|
||||||
m_YAxisChanged = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// reutrn true when all the show axis is `Value` type.
|
/// reutrn true when all the show axis is `Value` type.
|
||||||
/// 纯数值坐标。
|
/// 纯数值坐标轴(数值轴或对数轴)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsValue()
|
public bool IsValue()
|
||||||
{
|
{
|
||||||
foreach (var axis in m_XAxises)
|
foreach (var axis in m_XAxises)
|
||||||
{
|
{
|
||||||
if (axis.show && !axis.IsValue()) return false;
|
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
|
||||||
}
|
}
|
||||||
foreach (var axis in m_YAxises)
|
foreach (var axis in m_YAxises)
|
||||||
{
|
{
|
||||||
if (axis.show && !axis.IsValue()) return false;
|
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -200,6 +198,20 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
CheckMinMaxValue();
|
CheckMinMaxValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vector3 ClampInCoordinate(Vector3 pos)
|
||||||
|
{
|
||||||
|
if (IsInCooridate(pos)) return pos;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var np = new Vector3(pos.x, pos.y);
|
||||||
|
if (np.x < coordinateX) np.x = coordinateX;
|
||||||
|
if (np.x > coordinateX + coordinateWidth) np.x = coordinateX + coordinateWidth;
|
||||||
|
if (np.y < coordinateY) np.y = coordinateY;
|
||||||
|
if (np.y > coordinateY + coordinateHeight) np.y = coordinateY + coordinateHeight;
|
||||||
|
return np;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
130
Assets/XCharts/Runtime/API/RadarChart_API.cs
Normal file
130
Assets/XCharts/Runtime/API/RadarChart_API.cs
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
public partial class RadarChart
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 雷达坐标系组件列表。
|
||||||
|
/// </summary>
|
||||||
|
public List<Radar> radars { get { return m_Radars; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除所有数据,包含雷达坐标系指示器数据。
|
||||||
|
/// </summary>
|
||||||
|
public override void RemoveData()
|
||||||
|
{
|
||||||
|
base.RemoveData();
|
||||||
|
foreach (var radar in m_Radars)
|
||||||
|
{
|
||||||
|
radar.indicatorList.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除所有雷达坐标系组件。
|
||||||
|
/// </summary>
|
||||||
|
public void RemoveRadar()
|
||||||
|
{
|
||||||
|
m_Radars.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加雷达坐标系组件。
|
||||||
|
/// </summary>
|
||||||
|
public void AddRadar(Radar radar)
|
||||||
|
{
|
||||||
|
m_Radars.Add(radar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加雷达坐标系组件。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="shape">形状,圆形还是多边形</param>
|
||||||
|
/// <param name="center">中心点,0-1浮点数时表示百分比</param>
|
||||||
|
/// <param name="radius">半径,0-1浮点数时表示百分比</param>
|
||||||
|
/// <param name="splitNumber">指示器轴的分割段数</param>
|
||||||
|
/// <param name="lineWidth">线条宽</param>
|
||||||
|
/// <param name="showIndicator">是否显示指示器名称</param>
|
||||||
|
/// <param name="showSplitArea">是否显示分割区域</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Radar AddRadar(Radar.Shape shape, Vector2 center, float radius, int splitNumber = 5,
|
||||||
|
float lineWidth = 0.6f, bool showIndicator = true, bool showSplitArea = true)
|
||||||
|
{
|
||||||
|
var radar = new Radar();
|
||||||
|
radar.shape = shape;
|
||||||
|
radar.splitNumber = splitNumber;
|
||||||
|
radar.radius = radius;
|
||||||
|
radar.indicator = showIndicator;
|
||||||
|
radar.center[0] = center.x;
|
||||||
|
radar.center[1] = center.y;
|
||||||
|
radar.splitArea.show = showSplitArea;
|
||||||
|
radar.splitLine.lineStyle.width = lineWidth;
|
||||||
|
m_Radars.Add(radar);
|
||||||
|
return radar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加指示器。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="radarIndex">雷达坐标系组件索引,从0开始</param>
|
||||||
|
/// <param name="name">指示器名称</param>
|
||||||
|
/// <param name="min">指示器最小值</param>
|
||||||
|
/// <param name="max">指示器最大值</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Radar.Indicator AddIndicator(int radarIndex, string name, float min, float max)
|
||||||
|
{
|
||||||
|
var radar = GetRadar(radarIndex);
|
||||||
|
if (radar == null) return null;
|
||||||
|
return radar.AddIndicator(name, min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指示器。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="radarIndex">雷达坐标系组件的索引,从0开始</param>
|
||||||
|
/// <param name="indicatorIndex">指示器索引,从0开始</param>
|
||||||
|
/// <param name="name">指示器名称</param>
|
||||||
|
/// <param name="min">指示器最小值</param>
|
||||||
|
/// <param name="max">指示器最大值</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool UpdateIndicator(int radarIndex, int indicatorIndex, string name, float min, float max)
|
||||||
|
{
|
||||||
|
var radar = GetRadar(radarIndex);
|
||||||
|
if (radar == null) return false;
|
||||||
|
return radar.UpdateIndicator(indicatorIndex, name, min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得指定索引的雷达坐标系组件。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="radarIndex"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Radar GetRadar(int radarIndex)
|
||||||
|
{
|
||||||
|
if (radarIndex < 0 || radarIndex > m_Radars.Count - 1) return null;
|
||||||
|
return m_Radars[radarIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得指定雷达坐标系组件指定索引的指示器。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="radarIndex"></param>
|
||||||
|
/// <param name="indicatorIndex"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Radar.Indicator GetIndicator(int radarIndex, int indicatorIndex)
|
||||||
|
{
|
||||||
|
var radar = GetRadar(radarIndex);
|
||||||
|
if (radar != null) return radar.GetIndicator(indicatorIndex);
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/API/RadarChart_API.cs.meta
Normal file
11
Assets/XCharts/Runtime/API/RadarChart_API.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f17a7aa35fdd3417dab9414f10fe2886
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
95
Assets/XCharts/Runtime/API/RingChart_API.cs
Normal file
95
Assets/XCharts/Runtime/API/RingChart_API.cs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
public partial class RingChart
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列执行数据项的最大值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieIndex"></param>
|
||||||
|
/// <param name="dataIndex"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool UpdateMax(int serieIndex, int dataIndex, float value)
|
||||||
|
{
|
||||||
|
var serie = m_Series.GetSerie(serieIndex);
|
||||||
|
if (serie != null)
|
||||||
|
{
|
||||||
|
var serieData = serie.GetSerieData(dataIndex);
|
||||||
|
if (serieData != null)
|
||||||
|
{
|
||||||
|
return serieData.UpdateData(1, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列的所有数据项的最大值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieIndex"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool UpdateMax(int serieIndex, float value)
|
||||||
|
{
|
||||||
|
var serie = m_Series.GetSerie(serieIndex);
|
||||||
|
if (serie != null)
|
||||||
|
{
|
||||||
|
var flag = true;
|
||||||
|
foreach (var serieData in serie.data)
|
||||||
|
{
|
||||||
|
if (!serieData.UpdateData(1, value)) flag = false;
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新第一个系列第一个数据项的最大值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool UpdateMax(float value)
|
||||||
|
{
|
||||||
|
return UpdateMax(0, 0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the data with the specified maximum value to the specified serie.
|
||||||
|
/// 添加指定最大值的数据到指定系列中。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieName">the name of serie</param>
|
||||||
|
/// <param name="value">the data</param>
|
||||||
|
/// <param name="max">the max data</param>
|
||||||
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <returns>Returns True on success</returns>
|
||||||
|
public override SerieData AddData(string serieName, float value, float max, string dataName = null)
|
||||||
|
{
|
||||||
|
return base.AddData(serieName, value, max, dataName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the data with the specified maximum value to the specified serie.
|
||||||
|
/// 添加指定最大值的数据到指定系列中。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieIndex">the index of serie</param>
|
||||||
|
/// <param name="value">the data</param>
|
||||||
|
/// <param name="max">the max data</param>
|
||||||
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <returns>Returns True on success</returns>
|
||||||
|
public override SerieData AddData(int serieIndex, float value, float max, string dataName = null)
|
||||||
|
{
|
||||||
|
return base.AddData(serieIndex, value, max, dataName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/API/RingChart_API.cs.meta
Normal file
11
Assets/XCharts/Runtime/API/RingChart_API.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7a1cd7e0dade8470cb91d6a7971ff022
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -15,13 +15,27 @@ namespace XCharts
|
|||||||
[SerializeField] protected string m_JsonData;
|
[SerializeField] protected string m_JsonData;
|
||||||
[SerializeField] protected bool m_DataFromJson;
|
[SerializeField] protected bool m_DataFromJson;
|
||||||
|
|
||||||
|
[NonSerialized] protected bool m_VertsDirty;
|
||||||
|
[NonSerialized] protected bool m_ComponentDirty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// json格式的字符串数据
|
/// json格式的字符串数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
|
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
|
||||||
|
/// <summary>
|
||||||
public void OnAfterDeserialize()
|
/// 图表重绘标记。
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool vertsDirty { get { return m_VertsDirty; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 组件重新初始化标记。
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool componentDirty { get { return m_ComponentDirty; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 需要重绘图表或重新初始化组件。
|
||||||
|
/// </summary>
|
||||||
|
public bool anyDirty { get { return vertsDirty || componentDirty; } }
|
||||||
|
internal void OnAfterDeserialize()
|
||||||
{
|
{
|
||||||
if (m_DataFromJson)
|
if (m_DataFromJson)
|
||||||
{
|
{
|
||||||
@@ -30,7 +44,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnBeforeSerialize()
|
internal void OnBeforeSerialize()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,5 +52,37 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
throw new Exception("no support yet");
|
throw new Exception("no support yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal virtual void SetVerticesDirty()
|
||||||
|
{
|
||||||
|
m_VertsDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual void ClearVerticesDirty()
|
||||||
|
{
|
||||||
|
m_VertsDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual void SetComponentDirty()
|
||||||
|
{
|
||||||
|
m_ComponentDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal virtual void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
m_ComponentDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void ClearDirty()
|
||||||
|
{
|
||||||
|
ClearVerticesDirty();
|
||||||
|
ClearComponentDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetAllDirty()
|
||||||
|
{
|
||||||
|
SetVerticesDirty();
|
||||||
|
SetComponentDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace XCharts
|
|||||||
/// 直角坐标系的坐标轴组件。
|
/// 直角坐标系的坐标轴组件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class Axis : MainComponent, IEquatable<Axis>
|
public class Axis : MainComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the type of axis.
|
/// the type of axis.
|
||||||
@@ -27,14 +27,19 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Numerical axis, suitable for continuous data.
|
/// Numerical axis, suitable for continuous data.
|
||||||
/// 数值轴,适用于连续数据。
|
/// 数值轴。适用于连续数据。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Value,
|
Value,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Category axis, suitable for discrete category data. Data should only be set via data for this type.
|
/// Category axis, suitable for discrete category data. Data should only be set via data for this type.
|
||||||
/// 类目轴,适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
|
/// 类目轴。适用于离散的类目数据,为该类型时必须通过 data 设置类目数据。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Category
|
Category,
|
||||||
|
/// <summary>
|
||||||
|
/// Log axis, suitable for log data.
|
||||||
|
/// 对数轴。适用于对数数据。
|
||||||
|
/// </summary>
|
||||||
|
Log
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -60,54 +65,23 @@ namespace XCharts
|
|||||||
Custom
|
Custom
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// the type of split line.
|
|
||||||
/// 分割线类型
|
|
||||||
/// </summary>
|
|
||||||
public enum SplitLineType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 不显示分割线
|
|
||||||
/// </summary>
|
|
||||||
None,
|
|
||||||
/// <summary>
|
|
||||||
/// 实线
|
|
||||||
/// </summary>
|
|
||||||
Solid,
|
|
||||||
/// <summary>
|
|
||||||
/// 虚线
|
|
||||||
/// </summary>
|
|
||||||
Dashed,
|
|
||||||
/// <summary>
|
|
||||||
/// 点线
|
|
||||||
/// </summary>
|
|
||||||
Dotted,
|
|
||||||
/// <summary>
|
|
||||||
/// 点划线
|
|
||||||
/// </summary>
|
|
||||||
DashDot,
|
|
||||||
/// <summary>
|
|
||||||
/// 双点划线
|
|
||||||
/// </summary>
|
|
||||||
DashDotDot
|
|
||||||
}
|
|
||||||
|
|
||||||
[SerializeField] protected bool m_Show = true;
|
[SerializeField] protected bool m_Show = true;
|
||||||
[SerializeField] protected AxisType m_Type;
|
[SerializeField] protected AxisType m_Type;
|
||||||
[SerializeField] protected AxisMinMaxType m_MinMaxType;
|
[SerializeField] protected AxisMinMaxType m_MinMaxType;
|
||||||
[SerializeField] protected int m_Min;
|
[SerializeField] protected float m_Min;
|
||||||
[SerializeField] protected int m_Max;
|
[SerializeField] protected float m_Max;
|
||||||
[SerializeField] protected int m_SplitNumber = 5;
|
[SerializeField] protected int m_SplitNumber = 5;
|
||||||
[SerializeField] protected float m_Interval = 0;
|
[SerializeField] protected float m_Interval = 0;
|
||||||
[SerializeField] protected bool m_ShowSplitLine = false;
|
|
||||||
[SerializeField] protected SplitLineType m_SplitLineType = SplitLineType.Dashed;
|
|
||||||
[SerializeField] protected bool m_BoundaryGap = true;
|
[SerializeField] protected bool m_BoundaryGap = true;
|
||||||
[SerializeField] protected int m_MaxCache = 0;
|
[SerializeField] protected int m_MaxCache = 0;
|
||||||
|
[SerializeField] protected float m_LogBase = 10;
|
||||||
|
[SerializeField] protected bool m_LogBaseE = false;
|
||||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||||
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
||||||
[SerializeField] protected AxisTick m_AxisTick = AxisTick.defaultTick;
|
[SerializeField] protected AxisTick m_AxisTick = AxisTick.defaultTick;
|
||||||
[SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
|
[SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
|
||||||
|
[SerializeField] protected AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||||
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||||
|
|
||||||
[NonSerialized] private float m_ValueRange;
|
[NonSerialized] private float m_ValueRange;
|
||||||
@@ -117,88 +91,187 @@ namespace XCharts
|
|||||||
/// Set this to false to prevent the axis from showing.
|
/// Set this to false to prevent the axis from showing.
|
||||||
/// 是否显示坐标轴。
|
/// 是否显示坐标轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the type of axis.
|
/// the type of axis.
|
||||||
/// 坐标轴类型。
|
/// 坐标轴类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AxisType type { get { return m_Type; } set { m_Type = value; } }
|
public AxisType type
|
||||||
|
{
|
||||||
|
get { return m_Type; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the type of axis minmax.
|
/// the type of axis minmax.
|
||||||
/// 坐标轴刻度最大最小值显示类型。
|
/// 坐标轴刻度最大最小值显示类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AxisMinMaxType minMaxType { get { return m_MinMaxType; } set { m_MinMaxType = value; } }
|
public AxisMinMaxType minMaxType
|
||||||
|
{
|
||||||
|
get { return m_MinMaxType; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The minimun value of axis.
|
/// The minimun value of axis.
|
||||||
/// 设定的坐标轴刻度最小值,当minMaxType为Custom时有效。
|
/// 设定的坐标轴刻度最小值,当minMaxType为Custom时有效。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int min { get { return m_Min; } set { m_Min = value; } }
|
public float min
|
||||||
|
{
|
||||||
|
get { return m_Min; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum value of axis.
|
/// The maximum value of axis.
|
||||||
/// 设定的坐标轴刻度最大值,当minMaxType为Custom时有效。
|
/// 设定的坐标轴刻度最大值,当minMaxType为Custom时有效。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int max { get { return m_Max; } set { m_Max = value; } }
|
public float max
|
||||||
|
{
|
||||||
|
get { return m_Max; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of segments that the axis is split into.
|
/// Number of segments that the axis is split into.
|
||||||
/// 坐标轴的分割段数。
|
/// 坐标轴的分割段数。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
public int splitNumber
|
||||||
|
{
|
||||||
|
get { return m_SplitNumber; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 强制设置坐标轴分割间隔。无法在类目轴中使用。
|
/// 强制设置坐标轴分割间隔。无法在类目轴中使用。
|
||||||
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
|
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float interval { get { return m_Interval; } set { m_Interval = value; } }
|
public float interval
|
||||||
/// <summary>
|
{
|
||||||
/// showSplitLineSet this to false to prevent the splitLine from showing. value type axes are shown by default, while category type axes are hidden.
|
get { return m_Interval; }
|
||||||
/// 是否显示分隔线。默认数值轴显示,类目轴不显示。
|
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetAllDirty(); }
|
||||||
/// </summary>
|
}
|
||||||
public bool showSplitLine { get { return m_ShowSplitLine; } set { m_ShowSplitLine = value; } }
|
|
||||||
/// <summary>
|
|
||||||
/// the type of split line.
|
|
||||||
/// 分割线类型。
|
|
||||||
/// </summary>
|
|
||||||
public SplitLineType splitLineType { get { return m_SplitLineType; } set { m_SplitLineType = value; } }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The boundary gap on both sides of a coordinate axis.
|
/// The boundary gap on both sides of a coordinate axis.
|
||||||
/// 坐标轴两边是否留白。
|
/// 坐标轴两边是否留白。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
|
public bool boundaryGap
|
||||||
|
{
|
||||||
|
get { return m_BoundaryGap; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Base of logarithm, which is valid only for numeric axes with type: 'Log'.
|
||||||
|
/// 对数轴的底数,只在对数轴(type:'Log')中有效。
|
||||||
|
/// </summary>
|
||||||
|
public float logBase
|
||||||
|
{
|
||||||
|
get { return m_LogBase; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 对数轴是否以自然数 e 为底数,为 true 时 logBase 失效。
|
||||||
|
/// </summary>
|
||||||
|
public bool logBaseE
|
||||||
|
{
|
||||||
|
get { return m_LogBaseE; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The max number of axis data cache.
|
/// The max number of axis data cache.
|
||||||
/// The first data will be remove when the size of axis data is larger then maxCache.
|
/// The first data will be remove when the size of axis data is larger then maxCache.
|
||||||
/// 可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
/// 可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int maxCache { get { return m_MaxCache; } set { m_MaxCache = value < 0 ? 0 : value; } }
|
public int maxCache
|
||||||
|
{
|
||||||
|
get { return m_MaxCache; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Category data, available in type: 'Category' axis.
|
/// Category data, available in type: 'Category' axis.
|
||||||
/// 类目数据,在类目轴(type: 'category')中有效。
|
/// 类目数据,在类目轴(type: 'category')中有效。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> data { get { return m_Data; } set { if (value != null) m_Data = value; } }
|
public List<string> data
|
||||||
|
{
|
||||||
|
get { return m_Data; }
|
||||||
|
set { if (value != null) { m_Data = value; SetAllDirty(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// axis Line.
|
/// axis Line.
|
||||||
/// 坐标轴轴线。
|
/// 坐标轴轴线。
|
||||||
/// </summary>
|
/// /// </summary>
|
||||||
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
|
public AxisLine axisLine
|
||||||
|
{
|
||||||
|
get { return m_AxisLine; }
|
||||||
|
set { if (value != null) { m_AxisLine = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// axis name.
|
/// axis name.
|
||||||
/// 坐标轴名称。
|
/// 坐标轴名称。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AxisName axisName { get { return m_AxisName; } set { m_AxisName = value; } }
|
public AxisName axisName
|
||||||
|
{
|
||||||
|
get { return m_AxisName; }
|
||||||
|
set { if (value != null) { m_AxisName = value; SetComponentDirty(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// axis tick.
|
/// axis tick.
|
||||||
/// 坐标轴刻度。
|
/// 坐标轴刻度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
public AxisTick axisTick
|
||||||
|
{
|
||||||
|
get { return m_AxisTick; }
|
||||||
|
set { if (value != null) { m_AxisTick = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// axis label.
|
/// axis label.
|
||||||
/// 坐标轴刻度标签。
|
/// 坐标轴刻度标签。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AxisLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
|
public AxisLabel axisLabel
|
||||||
|
{
|
||||||
|
get { return m_AxisLabel; }
|
||||||
|
set { if (value != null) { m_AxisLabel = value; SetComponentDirty(); } }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// axis split line.
|
||||||
|
/// 坐标轴分割线。
|
||||||
|
/// </summary>
|
||||||
|
public AxisSplitLine splitLine
|
||||||
|
{
|
||||||
|
get { return m_SplitLine; }
|
||||||
|
set { if (value != null) { m_SplitLine = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// axis split area.
|
/// axis split area.
|
||||||
/// 坐标轴分割区域。
|
/// 坐标轴分割区域。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
|
public AxisSplitArea splitArea
|
||||||
|
{
|
||||||
|
get { return m_SplitArea; }
|
||||||
|
set { if (value != null) { m_SplitArea = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
|
public override bool vertsDirty
|
||||||
|
{
|
||||||
|
get { return m_VertsDirty || axisLine.anyDirty || axisTick.anyDirty || splitLine.anyDirty || splitArea.anyDirty; }
|
||||||
|
}
|
||||||
|
public override bool componentDirty
|
||||||
|
{
|
||||||
|
get { return m_ComponentDirty || axisName.anyDirty || axisLabel.anyDirty; }
|
||||||
|
}
|
||||||
|
internal override void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
base.ClearComponentDirty();
|
||||||
|
axisName.ClearComponentDirty();
|
||||||
|
axisLabel.ClearComponentDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void ClearVerticesDirty()
|
||||||
|
{
|
||||||
|
base.ClearVerticesDirty();
|
||||||
|
axisLine.ClearVerticesDirty();
|
||||||
|
axisTick.ClearVerticesDirty();
|
||||||
|
splitLine.ClearVerticesDirty();
|
||||||
|
splitArea.ClearVerticesDirty();
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the axis label text list.
|
/// the axis label text list.
|
||||||
/// 坐标轴刻度标签的Text列表。
|
/// 坐标轴刻度标签的Text列表。
|
||||||
@@ -208,49 +281,63 @@ namespace XCharts
|
|||||||
/// the current minimun value.
|
/// the current minimun value.
|
||||||
/// 当前最小值。
|
/// 当前最小值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float minValue { get; set; }
|
public float runtimeMinValue
|
||||||
|
{
|
||||||
|
get { return m_RuntimeMinValue; }
|
||||||
|
internal set
|
||||||
|
{
|
||||||
|
m_RuntimeMinValue = value;
|
||||||
|
m_RuntimeLastMinValue = value;
|
||||||
|
m_RuntimeMinValueUpdateTime = Time.time;
|
||||||
|
m_RuntimeMinValueChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the current maximum value.
|
/// the current maximum value.
|
||||||
/// 当前最大值。
|
/// 当前最大值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float maxValue { get; set; }
|
public float runtimeMaxValue
|
||||||
|
{
|
||||||
|
get { return m_RuntimeMaxValue; }
|
||||||
|
internal set
|
||||||
|
{
|
||||||
|
m_RuntimeMaxValue = value;
|
||||||
|
m_RuntimeLastMaxValue = value;
|
||||||
|
m_RuntimeMaxValueUpdateTime = Time.time;
|
||||||
|
m_RuntimeMaxValueChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the x offset of zero position.
|
/// the x offset of zero position.
|
||||||
/// 坐标轴原点在X轴的偏移。
|
/// 坐标轴原点在X轴的偏移。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float zeroXOffset { get; set; }
|
public float runtimeZeroXOffset { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the y offset of zero position.
|
/// the y offset of zero position.
|
||||||
/// 坐标轴原点在Y轴的偏移。
|
/// 坐标轴原点在Y轴的偏移。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float zeroYOffset { get; set; }
|
public float runtimeZeroYOffset { get; internal set; }
|
||||||
|
public int runtimeMinLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMinValue) : (int)Mathf.Log(runtimeMinValue, logBase); } }
|
||||||
|
public int runtimeMaxLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMaxValue) : (int)Mathf.Log(runtimeMaxValue, logBase); } }
|
||||||
|
|
||||||
private int filterStart;
|
private int filterStart;
|
||||||
private int filterEnd;
|
private int filterEnd;
|
||||||
|
private int filterMinShow;
|
||||||
private List<string> filterData;
|
private List<string> filterData;
|
||||||
private List<Text> m_AxisLabelTextList = new List<Text>();
|
private List<Text> m_AxisLabelTextList = new List<Text>();
|
||||||
private GameObject m_TooltipLabel;
|
private GameObject m_TooltipLabel;
|
||||||
private Text m_TooltipLabelText;
|
private Text m_TooltipLabelText;
|
||||||
private RectTransform m_TooltipLabelRect;
|
private RectTransform m_TooltipLabelRect;
|
||||||
|
private float m_RuntimeMinValue;
|
||||||
public void Copy(Axis other)
|
private float m_RuntimeLastMinValue;
|
||||||
{
|
private bool m_RuntimeMinValueChanged;
|
||||||
m_Show = other.show;
|
private float m_RuntimeMinValueUpdateTime;
|
||||||
m_Type = other.type;
|
private float m_RuntimeMaxValue;
|
||||||
m_Min = other.min;
|
private float m_RuntimeLastMaxValue;
|
||||||
m_Max = other.max;
|
private bool m_RuntimeMaxValueChanged;
|
||||||
m_SplitNumber = other.splitNumber;
|
private float m_RuntimeMaxValueUpdateTime;
|
||||||
m_Interval = other.interval;
|
private bool m_RuntimeMinValueFirstChanged = true;
|
||||||
|
private bool m_RuntimeMaxValueFirstChanged = true;
|
||||||
m_ShowSplitLine = other.showSplitLine;
|
|
||||||
m_SplitLineType = other.splitLineType;
|
|
||||||
m_BoundaryGap = other.boundaryGap;
|
|
||||||
m_AxisName.Copy(other.axisName);
|
|
||||||
m_AxisLabel.Copy(other.axisLabel);
|
|
||||||
m_Data.Clear();
|
|
||||||
m_Data.Capacity = m_Data.Count;
|
|
||||||
foreach (var d in other.data) m_Data.Add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空类目数据
|
/// 清空类目数据
|
||||||
@@ -258,10 +345,11 @@ namespace XCharts
|
|||||||
public void ClearData()
|
public void ClearData()
|
||||||
{
|
{
|
||||||
m_Data.Clear();
|
m_Data.Clear();
|
||||||
|
SetAllDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前坐标轴是否时类目轴
|
/// 是否为类目轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsCategory()
|
public bool IsCategory()
|
||||||
@@ -270,7 +358,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前坐标轴是否时数值轴
|
/// 是否为数值轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsValue()
|
public bool IsValue()
|
||||||
@@ -278,6 +366,15 @@ namespace XCharts
|
|||||||
return type == AxisType.Value;
|
return type == AxisType.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为对数轴。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsLog()
|
||||||
|
{
|
||||||
|
return type == AxisType.Log;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个类目到类目数据列表
|
/// 添加一个类目到类目数据列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -293,6 +390,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_Data.Add(category);
|
m_Data.Add(category);
|
||||||
|
SetAllDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -301,7 +399,7 @@ namespace XCharts
|
|||||||
/// <param name="index">类目数据索引</param>
|
/// <param name="index">类目数据索引</param>
|
||||||
/// <param name="dataZoom">区域缩放</param>
|
/// <param name="dataZoom">区域缩放</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetData(int index, DataZoom dataZoom)
|
internal string GetData(int index, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
var showData = GetDataList(dataZoom);
|
var showData = GetDataList(dataZoom);
|
||||||
if (index >= 0 && index < showData.Count)
|
if (index >= 0 && index < showData.Count)
|
||||||
@@ -315,7 +413,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataZoom">区域缩放</param>
|
/// <param name="dataZoom">区域缩放</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<string> GetDataList(DataZoom dataZoom)
|
internal List<string> GetDataList(DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
if (dataZoom != null && dataZoom.enable)
|
if (dataZoom != null && dataZoom.enable)
|
||||||
{
|
{
|
||||||
@@ -333,21 +431,33 @@ namespace XCharts
|
|||||||
/// 更新dataZoom对应的类目数据列表
|
/// 更新dataZoom对应的类目数据列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
public void UpdateFilterData(DataZoom dataZoom)
|
internal void UpdateFilterData(DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
if (dataZoom != null && dataZoom.enable)
|
if (dataZoom != null && dataZoom.enable)
|
||||||
{
|
{
|
||||||
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
||||||
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
||||||
if (startIndex != filterStart || endIndex != filterEnd || m_NeedUpdateFilterData)
|
if (endIndex < startIndex) endIndex = startIndex;
|
||||||
|
if (startIndex != filterStart || endIndex != filterEnd || dataZoom.minShowNum != filterMinShow || m_NeedUpdateFilterData)
|
||||||
{
|
{
|
||||||
filterStart = startIndex;
|
filterStart = startIndex;
|
||||||
filterEnd = endIndex;
|
filterEnd = endIndex;
|
||||||
|
filterMinShow = dataZoom.minShowNum;
|
||||||
m_NeedUpdateFilterData = false;
|
m_NeedUpdateFilterData = false;
|
||||||
if (m_Data.Count > 0)
|
if (m_Data.Count > 0)
|
||||||
{
|
{
|
||||||
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
||||||
filterData = m_Data.GetRange(startIndex, count);
|
if (count < dataZoom.minShowNum)
|
||||||
|
{
|
||||||
|
if (dataZoom.minShowNum > m_Data.Count) count = m_Data.Count;
|
||||||
|
else count = dataZoom.minShowNum;
|
||||||
|
}
|
||||||
|
if (startIndex + count > m_Data.Count)
|
||||||
|
{
|
||||||
|
int start = endIndex - count;
|
||||||
|
filterData = m_Data.GetRange(start < 0 ? 0 : start, count);
|
||||||
|
}
|
||||||
|
else filterData = m_Data.GetRange(startIndex, count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -366,7 +476,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int GetSplitNumber(float coordinateWid, DataZoom dataZoom)
|
internal int GetSplitNumber(float coordinateWid, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
if (type == AxisType.Value)
|
if (type == AxisType.Value)
|
||||||
{
|
{
|
||||||
@@ -384,6 +494,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else return m_SplitNumber;
|
else return m_SplitNumber;
|
||||||
}
|
}
|
||||||
|
else if (type == AxisType.Log)
|
||||||
|
{
|
||||||
|
return m_SplitNumber;
|
||||||
|
}
|
||||||
int dataCount = GetDataList(dataZoom).Count;
|
int dataCount = GetDataList(dataZoom).Count;
|
||||||
if (m_SplitNumber <= 0) return dataCount;
|
if (m_SplitNumber <= 0) return dataCount;
|
||||||
if (dataCount > 2 * m_SplitNumber || dataCount <= 0)
|
if (dataCount > 2 * m_SplitNumber || dataCount <= 0)
|
||||||
@@ -398,7 +512,7 @@ namespace XCharts
|
|||||||
/// <param name="coordinateWidth"></param>
|
/// <param name="coordinateWidth"></param>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
|
internal float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
||||||
int segment = (m_BoundaryGap ? split : split - 1);
|
int segment = (m_BoundaryGap ? split : split - 1);
|
||||||
@@ -411,7 +525,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int GetDataNumber(DataZoom dataZoom)
|
internal int GetDataNumber(DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
return GetDataList(dataZoom).Count;
|
return GetDataList(dataZoom).Count;
|
||||||
}
|
}
|
||||||
@@ -422,11 +536,12 @@ namespace XCharts
|
|||||||
/// <param name="coordinateWidth"></param>
|
/// <param name="coordinateWidth"></param>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public float GetDataWidth(float coordinateWidth, DataZoom dataZoom)
|
internal float GetDataWidth(float coordinateWidth, int dataCount, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
var dataCount = GetDataNumber(dataZoom);
|
if (dataCount < 1) dataCount = 1;
|
||||||
int segment = (m_BoundaryGap ? dataCount : dataCount - 1);
|
var categoryCount = GetDataNumber(dataZoom);
|
||||||
segment = segment <= 0 ? 1 : segment;
|
int segment = (m_BoundaryGap ? categoryCount : categoryCount - 1);
|
||||||
|
segment = segment <= 0 ? dataCount : segment;
|
||||||
return coordinateWidth / segment;
|
return coordinateWidth / segment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,12 +553,14 @@ namespace XCharts
|
|||||||
/// <param name="maxValue"></param>
|
/// <param name="maxValue"></param>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetLabelName(float coordinateWidth, int index, float minValue, float maxValue,
|
internal string GetLabelName(float coordinateWidth, int index, float minValue, float maxValue,
|
||||||
DataZoom dataZoom, bool forcePercent)
|
DataZoom dataZoom, bool forcePercent)
|
||||||
{
|
{
|
||||||
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
||||||
|
|
||||||
if (m_Type == AxisType.Value)
|
if (m_Type == AxisType.Value)
|
||||||
{
|
{
|
||||||
|
if (minValue == 0 && maxValue == 0) return string.Empty;
|
||||||
float value = 0;
|
float value = 0;
|
||||||
if (forcePercent) maxValue = 100;
|
if (forcePercent) maxValue = 100;
|
||||||
if (m_Interval > 0)
|
if (m_Interval > 0)
|
||||||
@@ -456,7 +573,13 @@ namespace XCharts
|
|||||||
value = (minValue + (maxValue - minValue) * index / (split - 1));
|
value = (minValue + (maxValue - minValue) * index / (split - 1));
|
||||||
}
|
}
|
||||||
if (forcePercent) return string.Format("{0}%", (int)value);
|
if (forcePercent) return string.Format("{0}%", (int)value);
|
||||||
else return m_AxisLabel.GetFormatterContent(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);
|
var showData = GetDataList(dataZoom);
|
||||||
int dataCount = showData.Count;
|
int dataCount = showData.Count;
|
||||||
@@ -482,9 +605,9 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int GetScaleNumber(float coordinateWidth, DataZoom dataZoom)
|
internal int GetScaleNumber(float coordinateWidth, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
if (type == AxisType.Value)
|
if (type == AxisType.Value || type == AxisType.Log)
|
||||||
{
|
{
|
||||||
int splitNum = GetSplitNumber(coordinateWidth, dataZoom);
|
int splitNum = GetSplitNumber(coordinateWidth, dataZoom);
|
||||||
return m_BoundaryGap ? splitNum + 1 : splitNum;
|
return m_BoundaryGap ? splitNum + 1 : splitNum;
|
||||||
@@ -507,7 +630,7 @@ namespace XCharts
|
|||||||
/// <param name="coordinateWidth"></param>
|
/// <param name="coordinateWidth"></param>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public float GetScaleWidth(float coordinateWidth, int index, DataZoom dataZoom)
|
internal float GetScaleWidth(float coordinateWidth, int index, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
int num = GetScaleNumber(coordinateWidth, dataZoom) - 1;
|
int num = GetScaleNumber(coordinateWidth, dataZoom) - 1;
|
||||||
if (num <= 0) num = 1;
|
if (num <= 0) num = 1;
|
||||||
@@ -527,8 +650,10 @@ namespace XCharts
|
|||||||
/// 更新刻度标签文字
|
/// 更新刻度标签文字
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
public void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent)
|
internal void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent, float duration)
|
||||||
{
|
{
|
||||||
|
var minValue = GetCurrMinValue(duration);
|
||||||
|
var maxValue = GetCurrMaxValue(duration);
|
||||||
for (int i = 0; i < axisLabelTextList.Count; i++)
|
for (int i = 0; i < axisLabelTextList.Count; i++)
|
||||||
{
|
{
|
||||||
if (axisLabelTextList[i] != null)
|
if (axisLabelTextList[i] != null)
|
||||||
@@ -538,7 +663,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTooltipLabel(GameObject label)
|
internal void SetTooltipLabel(GameObject label)
|
||||||
{
|
{
|
||||||
m_TooltipLabel = label;
|
m_TooltipLabel = label;
|
||||||
m_TooltipLabelRect = label.GetComponent<RectTransform>();
|
m_TooltipLabelRect = label.GetComponent<RectTransform>();
|
||||||
@@ -546,13 +671,13 @@ namespace XCharts
|
|||||||
m_TooltipLabel.SetActive(true);
|
m_TooltipLabel.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTooltipLabelColor(Color bgColor, Color textColor)
|
internal void SetTooltipLabelColor(Color bgColor, Color textColor)
|
||||||
{
|
{
|
||||||
m_TooltipLabel.GetComponent<Image>().color = bgColor;
|
m_TooltipLabel.GetComponent<Image>().color = bgColor;
|
||||||
m_TooltipLabelText.color = textColor;
|
m_TooltipLabelText.color = textColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTooltipLabelActive(bool flag)
|
internal void SetTooltipLabelActive(bool flag)
|
||||||
{
|
{
|
||||||
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
|
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
|
||||||
{
|
{
|
||||||
@@ -560,7 +685,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTooptipLabelText(string text)
|
internal void UpdateTooptipLabelText(string text)
|
||||||
{
|
{
|
||||||
if (m_TooltipLabelText)
|
if (m_TooltipLabelText)
|
||||||
{
|
{
|
||||||
@@ -570,7 +695,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTooltipLabelPos(Vector2 pos)
|
internal void UpdateTooltipLabelPos(Vector2 pos)
|
||||||
{
|
{
|
||||||
if (m_TooltipLabel)
|
if (m_TooltipLabel)
|
||||||
{
|
{
|
||||||
@@ -578,13 +703,30 @@ 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>
|
||||||
/// 调整最大最小值
|
/// 调整最大最小值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="minValue"></param>
|
/// <param name="minValue"></param>
|
||||||
/// <param name="maxValue"></param>
|
/// <param name="maxValue"></param>
|
||||||
public void AdjustMinMaxValue(ref int minValue, ref int maxValue)
|
internal void AdjustMinMaxValue(ref float minValue, ref float maxValue, bool needFormat)
|
||||||
{
|
{
|
||||||
|
if (m_Type == AxisType.Log)
|
||||||
|
{
|
||||||
|
int minSplit = 0;
|
||||||
|
int maxSplit = 0;
|
||||||
|
maxValue = ChartHelper.GetMaxLogValue(maxValue, m_LogBase, m_LogBaseE, out maxSplit);
|
||||||
|
minValue = ChartHelper.GetMinLogValue(minValue, m_LogBase, m_LogBaseE, out minSplit);
|
||||||
|
splitNumber = (minSplit > 0 && maxSplit > 0) ? (maxSplit + minSplit - 1) : (maxSplit + minSplit);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (minMaxType == Axis.AxisMinMaxType.Custom)
|
if (minMaxType == Axis.AxisMinMaxType.Custom)
|
||||||
{
|
{
|
||||||
if (min != 0 || max != 0)
|
if (min != 0 || max != 0)
|
||||||
@@ -598,40 +740,136 @@ namespace XCharts
|
|||||||
switch (minMaxType)
|
switch (minMaxType)
|
||||||
{
|
{
|
||||||
case Axis.AxisMinMaxType.Default:
|
case Axis.AxisMinMaxType.Default:
|
||||||
if (minValue > 0 && maxValue > 0)
|
if (minValue == 0 && maxValue == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (minValue > 0 && maxValue > 0)
|
||||||
{
|
{
|
||||||
minValue = 0;
|
minValue = 0;
|
||||||
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
|
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue) : maxValue;
|
||||||
}
|
}
|
||||||
else if (minValue < 0 && maxValue < 0)
|
else if (minValue < 0 && maxValue < 0)
|
||||||
{
|
{
|
||||||
minValue = ChartHelper.GetMinDivisibleValue(minValue);
|
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue) : minValue;
|
||||||
maxValue = 0;
|
maxValue = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
minValue = ChartHelper.GetMinDivisibleValue(minValue);
|
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue) : minValue;
|
||||||
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
|
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue) : maxValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Axis.AxisMinMaxType.MinMax:
|
case Axis.AxisMinMaxType.MinMax:
|
||||||
minValue = ChartHelper.GetMinDivisibleValue(minValue);
|
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue) : minValue;
|
||||||
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue);
|
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue) : maxValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_ValueRange = maxValue - minValue;
|
m_ValueRange = maxValue - minValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
internal void UpdateMinValue(float value, bool check)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, obj))
|
if (value != m_RuntimeMaxValue)
|
||||||
{
|
{
|
||||||
return false;
|
if (check && Application.isPlaying)
|
||||||
|
{
|
||||||
|
if (m_RuntimeMinValueFirstChanged)
|
||||||
|
{
|
||||||
|
m_RuntimeMinValueFirstChanged = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeLastMinValue = m_RuntimeMinValue;
|
||||||
|
m_RuntimeMinValueChanged = true;
|
||||||
|
m_RuntimeMinValueUpdateTime = Time.time;
|
||||||
|
}
|
||||||
|
m_RuntimeMinValue = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeMinValue = value;
|
||||||
|
m_RuntimeLastMinValue = value;
|
||||||
|
m_RuntimeMinValueUpdateTime = Time.time;
|
||||||
|
m_RuntimeMinValueChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (obj is Axis)
|
}
|
||||||
|
|
||||||
|
internal void UpdateMaxValue(float value, bool check)
|
||||||
|
{
|
||||||
|
if (value != m_RuntimeMaxValue)
|
||||||
{
|
{
|
||||||
return Equals((Axis)obj);
|
if (check && Application.isPlaying)
|
||||||
|
{
|
||||||
|
if (m_RuntimeMaxValueFirstChanged)
|
||||||
|
{
|
||||||
|
m_RuntimeMaxValueFirstChanged = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeLastMaxValue = m_RuntimeMaxValue;
|
||||||
|
m_RuntimeMaxValueChanged = true;
|
||||||
|
m_RuntimeMaxValueUpdateTime = Time.time;
|
||||||
|
}
|
||||||
|
m_RuntimeMaxValue = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeMaxValue = value;
|
||||||
|
m_RuntimeLastMaxValue = value;
|
||||||
|
m_RuntimeMaxValueUpdateTime = Time.time;
|
||||||
|
m_RuntimeMaxValueChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal float GetCurrMinValue(float duration)
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return m_RuntimeMinValue;
|
||||||
|
if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
|
||||||
|
if (!m_RuntimeMinValueChanged) return m_RuntimeMinValue;
|
||||||
|
var time = Time.time - m_RuntimeMinValueUpdateTime;
|
||||||
|
if (time == 0) return m_RuntimeMinValue;
|
||||||
|
var total = duration / 1000;
|
||||||
|
if (duration > 0 && time <= total)
|
||||||
|
{
|
||||||
|
var curr = Mathf.Lerp(m_RuntimeLastMinValue, m_RuntimeMinValue, time / total);
|
||||||
|
return curr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeMinValueChanged = false;
|
||||||
|
return m_RuntimeMinValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal float GetCurrMaxValue(float duration)
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return m_RuntimeMaxValue;
|
||||||
|
if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
|
||||||
|
if (!m_RuntimeMaxValueChanged) return m_RuntimeMaxValue;
|
||||||
|
var time = Time.time - m_RuntimeMaxValueUpdateTime;
|
||||||
|
if (time == 0) return m_RuntimeMaxValue;
|
||||||
|
var total = duration / 1000;
|
||||||
|
if (duration > 0 && time < total)
|
||||||
|
{
|
||||||
|
var curr = Mathf.Lerp(m_RuntimeLastMaxValue, m_RuntimeMaxValue, time / total);
|
||||||
|
return curr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeMaxValueChanged = false;
|
||||||
|
return m_RuntimeMaxValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsValueChanging(float duration)
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return false;
|
||||||
|
if (GetCurrMinValue(duration) != m_RuntimeMinValue || GetCurrMaxValue(duration) != m_RuntimeMaxValue)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -639,47 +877,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(Axis other)
|
public float GetLogValue(float value)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, other))
|
if (value <= 0) return 0;
|
||||||
{
|
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return show == other.show &&
|
|
||||||
type == other.type &&
|
|
||||||
min == other.min &&
|
|
||||||
max == other.max &&
|
|
||||||
splitNumber == other.splitNumber &&
|
|
||||||
interval == other.interval &&
|
|
||||||
showSplitLine == other.showSplitLine &&
|
|
||||||
m_AxisLabel.Equals(other.axisLabel) &&
|
|
||||||
splitLineType == other.splitLineType &&
|
|
||||||
boundaryGap == other.boundaryGap &&
|
|
||||||
axisName.Equals(other.axisName) &&
|
|
||||||
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Axis left, Axis right)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Axis left, Axis right)
|
|
||||||
{
|
|
||||||
return !(left == right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ParseJsonData(string jsonData)
|
public override void ParseJsonData(string jsonData)
|
||||||
@@ -697,27 +898,6 @@ namespace XCharts
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class XAxis : Axis
|
public class XAxis : Axis
|
||||||
{
|
{
|
||||||
public XAxis Clone()
|
|
||||||
{
|
|
||||||
var axis = XAxisPool.Get();
|
|
||||||
axis.show = show;
|
|
||||||
axis.type = type;
|
|
||||||
axis.min = min;
|
|
||||||
axis.max = max;
|
|
||||||
axis.splitNumber = splitNumber;
|
|
||||||
axis.interval = interval;
|
|
||||||
|
|
||||||
axis.showSplitLine = showSplitLine;
|
|
||||||
axis.splitLineType = splitLineType;
|
|
||||||
axis.boundaryGap = boundaryGap;
|
|
||||||
axis.axisName.Copy(axisName);
|
|
||||||
axis.axisLabel.Copy(axisLabel);
|
|
||||||
axis.data.Clear();
|
|
||||||
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
|
|
||||||
foreach (var d in data) axis.data.Add(d);
|
|
||||||
return axis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static XAxis defaultXAxis
|
public static XAxis defaultXAxis
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -729,14 +909,15 @@ namespace XCharts
|
|||||||
m_Min = 0,
|
m_Min = 0,
|
||||||
m_Max = 0,
|
m_Max = 0,
|
||||||
m_SplitNumber = 5,
|
m_SplitNumber = 5,
|
||||||
m_ShowSplitLine = false,
|
|
||||||
m_SplitLineType = SplitLineType.Dashed,
|
|
||||||
m_BoundaryGap = true,
|
m_BoundaryGap = true,
|
||||||
m_Data = new List<string>()
|
m_Data = new List<string>()
|
||||||
{
|
{
|
||||||
"x1","x2","x3","x4","x5"
|
"x1","x2","x3","x4","x5"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
axis.splitLine.show = false;
|
||||||
|
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
|
||||||
|
axis.axisLabel.textLimit.enable = true;
|
||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -750,27 +931,6 @@ namespace XCharts
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class YAxis : Axis
|
public class YAxis : Axis
|
||||||
{
|
{
|
||||||
public YAxis Clone()
|
|
||||||
{
|
|
||||||
var axis = YAxisPool.Get();
|
|
||||||
axis.show = show;
|
|
||||||
axis.type = type;
|
|
||||||
axis.min = min;
|
|
||||||
axis.max = max;
|
|
||||||
axis.splitNumber = splitNumber;
|
|
||||||
axis.interval = interval;
|
|
||||||
|
|
||||||
axis.showSplitLine = showSplitLine;
|
|
||||||
axis.splitLineType = splitLineType;
|
|
||||||
axis.boundaryGap = boundaryGap;
|
|
||||||
axis.axisName.Copy(axisName);
|
|
||||||
axis.axisLabel.Copy(axisLabel);
|
|
||||||
axis.data.Clear();
|
|
||||||
if (axis.data.Capacity < data.Count) axis.data.Capacity = data.Count;
|
|
||||||
foreach (var d in data) axis.data.Add(d);
|
|
||||||
return axis;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static YAxis defaultYAxis
|
public static YAxis defaultYAxis
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -782,11 +942,12 @@ namespace XCharts
|
|||||||
m_Min = 0,
|
m_Min = 0,
|
||||||
m_Max = 0,
|
m_Max = 0,
|
||||||
m_SplitNumber = 5,
|
m_SplitNumber = 5,
|
||||||
m_ShowSplitLine = true,
|
|
||||||
m_SplitLineType = SplitLineType.Dashed,
|
|
||||||
m_BoundaryGap = false,
|
m_BoundaryGap = false,
|
||||||
m_Data = new List<string>(5),
|
m_Data = new List<string>(5),
|
||||||
};
|
};
|
||||||
|
axis.splitLine.show = true;
|
||||||
|
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
|
||||||
|
axis.axisLabel.textLimit.enable = false;
|
||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ namespace XCharts
|
|||||||
[SerializeField] private float m_End;
|
[SerializeField] private float m_End;
|
||||||
[SerializeField] private float m_StartValue;
|
[SerializeField] private float m_StartValue;
|
||||||
[SerializeField] private float m_EndValue;
|
[SerializeField] private float m_EndValue;
|
||||||
|
[SerializeField] private int m_MinShowNum = 1;
|
||||||
[Range(1f, 20f)]
|
[Range(1f, 20f)]
|
||||||
[SerializeField] private float m_ScrollSensitivity = 1.1f;
|
[SerializeField] private float m_ScrollSensitivity = 1.1f;
|
||||||
[SerializeField] private int m_FontSize = 18;
|
[SerializeField] private int m_FontSize = 18;
|
||||||
@@ -89,52 +90,92 @@ namespace XCharts
|
|||||||
/// Whether to show dataZoom.
|
/// Whether to show dataZoom.
|
||||||
/// 是否显示缩放区域。
|
/// 是否显示缩放区域。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
|
public bool enable
|
||||||
|
{
|
||||||
|
get { return m_Enable; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The mode of data filter.
|
/// The mode of data filter.
|
||||||
/// 数据过滤类型。
|
/// 数据过滤类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FilterMode filterMode { get { return m_FilterMode; } set { m_FilterMode = value; } }
|
public FilterMode filterMode
|
||||||
|
{
|
||||||
|
get { return m_FilterMode; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FilterMode, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify which xAxis is controlled by the dataZoom.
|
/// Specify which xAxis is controlled by the dataZoom.
|
||||||
/// 控制哪一个 x 轴。
|
/// 控制哪一个 x 轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int xAxisIndex { get { return m_XAxisIndex; } set { m_XAxisIndex = value; } }
|
public int xAxisIndex
|
||||||
|
{
|
||||||
|
get { return m_XAxisIndex; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify which yAxis is controlled by the dataZoom.
|
/// Specify which yAxis is controlled by the dataZoom.
|
||||||
/// 控制哪一个 y 轴。
|
/// 控制哪一个 y 轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int yAxisIndex { get { return m_YAxisIndex; } set { m_YAxisIndex = value; } }
|
public int yAxisIndex
|
||||||
|
{
|
||||||
|
get { return m_YAxisIndex; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否支持内置。内置于坐标系中,使用户可以在坐标系上通过鼠标拖拽、鼠标滚轮、手指滑动(触屏上)来缩放或漫游坐标系。
|
/// 是否支持内置。内置于坐标系中,使用户可以在坐标系上通过鼠标拖拽、鼠标滚轮、手指滑动(触屏上)来缩放或漫游坐标系。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool supportInside { get { return m_SupportInside; } set { m_SupportInside = value; } }
|
public bool supportInside
|
||||||
|
{
|
||||||
|
get { return m_SupportInside; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SupportInside, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否支持滑动条。有单独的滑动条,用户在滑动条上进行缩放或漫游。
|
/// 是否支持滑动条。有单独的滑动条,用户在滑动条上进行缩放或漫游。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool supportSlider { get { return m_SupportSlider; } set { m_SupportSlider = value; } }
|
public bool supportSlider
|
||||||
|
{
|
||||||
|
get { return m_SupportSlider; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SupportSlider, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否支持框选。提供一个选框进行数据区域缩放。
|
/// 是否支持框选。提供一个选框进行数据区域缩放。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool supportSelect { get { return m_SupportSelect; } set { m_SupportSelect = value; } }
|
private bool supportSelect
|
||||||
|
{
|
||||||
|
get { return m_SupportSelect; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SupportSelect, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show data shadow, to indicate the data tendency in brief.
|
/// Whether to show data shadow, to indicate the data tendency in brief.
|
||||||
/// default:true
|
/// default:true
|
||||||
/// 是否显示数据阴影。数据阴影可以简单地反应数据走势。
|
/// 是否显示数据阴影。数据阴影可以简单地反应数据走势。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool showDataShadow { get { return m_ShowDataShadow; } set { m_ShowDataShadow = value; } }
|
public bool showDataShadow
|
||||||
|
{
|
||||||
|
get { return m_ShowDataShadow; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ShowDataShadow, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show detail, that is, show the detailed data information when dragging.
|
/// Whether to show detail, that is, show the detailed data information when dragging.
|
||||||
/// 是否显示detail,即拖拽时候显示详细数值信息。
|
/// 是否显示detail,即拖拽时候显示详细数值信息。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool showDetail { get { return m_ShowDetail; } set { m_ShowDetail = value; } }
|
public bool showDetail
|
||||||
|
{
|
||||||
|
get { return m_ShowDetail; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ShowDetail, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify whether to lock the size of window (selected area).
|
/// Specify whether to lock the size of window (selected area).
|
||||||
/// default:false
|
/// default:false
|
||||||
/// 是否锁定选择区域(或叫做数据窗口)的大小。
|
/// 是否锁定选择区域(或叫做数据窗口)的大小。
|
||||||
/// 如果设置为 true 则锁定选择区域的大小,也就是说,只能平移,不能缩放。
|
/// 如果设置为 true 则锁定选择区域的大小,也就是说,只能平移,不能缩放。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool zoomLock { get { return m_ZoomLock; } set { m_ZoomLock = value; } }
|
public bool zoomLock
|
||||||
|
{
|
||||||
|
get { return m_ZoomLock; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ZoomLock, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show data shadow in dataZoom-silder component, to indicate the data tendency in brief.
|
/// Whether to show data shadow in dataZoom-silder component, to indicate the data tendency in brief.
|
||||||
/// default:true
|
/// default:true
|
||||||
@@ -145,27 +186,43 @@ namespace XCharts
|
|||||||
/// The background color of the component.
|
/// The background color of the component.
|
||||||
/// 组件的背景颜色。
|
/// 组件的背景颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
|
private Color backgroundColor
|
||||||
|
{
|
||||||
|
get { return m_BackgroundColor; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between dataZoom component and the bottom side of the container.
|
/// Distance between dataZoom component and the bottom side of the container.
|
||||||
/// bottom value is a instant pixel value like 10.
|
/// bottom value is a instant pixel value like 10.
|
||||||
/// default:10
|
/// default:10
|
||||||
/// 组件离容器下侧的距离。
|
/// 组件离容器下侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
public float bottom
|
||||||
|
{
|
||||||
|
get { return m_Bottom; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The height of dataZoom component.
|
/// The height of dataZoom component.
|
||||||
/// height value is a instant pixel value like 10.
|
/// height value is a instant pixel value like 10.
|
||||||
/// default:50
|
/// default:50
|
||||||
/// 组件高度。
|
/// 组件高度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float height { get { return m_Height; } set { m_Height = value; } }
|
public float height
|
||||||
|
{
|
||||||
|
get { return m_Height; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Use absolute value or percent value in DataZoom.start and DataZoom.end.
|
/// Use absolute value or percent value in DataZoom.start and DataZoom.end.
|
||||||
/// default:RangeMode.Percent.
|
/// default:RangeMode.Percent.
|
||||||
/// 取绝对值还是百分比。
|
/// 取绝对值还是百分比。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RangeMode rangeMode { get { return m_RangeMode; } set { m_RangeMode = value; } }
|
public RangeMode rangeMode
|
||||||
|
{
|
||||||
|
get { return m_RangeMode; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_RangeMode, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The start percentage of the window out of the data extent, in the range of 0 ~ 100.
|
/// The start percentage of the window out of the data extent, in the range of 0 ~ 100.
|
||||||
/// default:30
|
/// default:30
|
||||||
@@ -174,7 +231,7 @@ namespace XCharts
|
|||||||
public float start
|
public float start
|
||||||
{
|
{
|
||||||
get { return m_Start; }
|
get { return m_Start; }
|
||||||
set { m_Start = value; if (m_Start < 0) m_Start = 0; if (m_Start > 100) m_Start = 100; }
|
set { m_Start = value; if (m_Start < 0) m_Start = 0; if (m_Start > 100) m_Start = 100; SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The end percentage of the window out of the data extent, in the range of 0 ~ 100.
|
/// The end percentage of the window out of the data extent, in the range of 0 ~ 100.
|
||||||
@@ -184,7 +241,15 @@ namespace XCharts
|
|||||||
public float end
|
public float end
|
||||||
{
|
{
|
||||||
get { return m_End; }
|
get { return m_End; }
|
||||||
set { m_End = value; if (m_End < 0) m_End = 0; if (m_End > 100) m_End = 100; }
|
set { m_End = value; if (m_End < 0) m_End = 0; if (m_End > 100) m_End = 100; SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 最小显示数据个数。当DataZoom放大到最大时,最小显示的数据个数。
|
||||||
|
/// </summary>
|
||||||
|
public int minShowNum
|
||||||
|
{
|
||||||
|
get { return m_MinShowNum; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The sensitivity of dataZoom scroll.
|
/// The sensitivity of dataZoom scroll.
|
||||||
@@ -192,28 +257,40 @@ namespace XCharts
|
|||||||
/// default:10
|
/// default:10
|
||||||
/// 缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
/// 缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float scrollSensitivity { get { return m_ScrollSensitivity; } set { m_ScrollSensitivity = value; } }
|
public float scrollSensitivity
|
||||||
|
{
|
||||||
|
get { return m_ScrollSensitivity; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ScrollSensitivity, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font size.
|
/// font size.
|
||||||
/// 文字的字体大小。
|
/// 文字的字体大小。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
public int fontSize
|
||||||
|
{
|
||||||
|
get { return m_FontSize; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font style.
|
/// font style.
|
||||||
/// 文字字体的风格。
|
/// 文字字体的风格。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
public FontStyle fontStyle
|
||||||
|
{
|
||||||
|
get { return m_FontStyle; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The start label.
|
/// The start label.
|
||||||
/// 组件的开始信息文本。
|
/// 组件的开始信息文本。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Text startLabel { get; set; }
|
private Text m_StartLabel { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The end label.
|
/// The end label.
|
||||||
/// 组件的结束信息文本。
|
/// 组件的结束信息文本。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Text endLabel { get; set; }
|
private Text m_EndLabel { get; set; }
|
||||||
|
|
||||||
public static DataZoom defaultDataZoom
|
public static DataZoom defaultDataZoom
|
||||||
{
|
{
|
||||||
@@ -297,15 +374,15 @@ namespace XCharts
|
|||||||
/// 是否显示文本
|
/// 是否显示文本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="flag"></param>
|
/// <param name="flag"></param>
|
||||||
public void SetLabelActive(bool flag)
|
internal void SetLabelActive(bool flag)
|
||||||
{
|
{
|
||||||
if (startLabel && startLabel.gameObject.activeInHierarchy != flag)
|
if (m_StartLabel && m_StartLabel.gameObject.activeInHierarchy != flag)
|
||||||
{
|
{
|
||||||
startLabel.gameObject.SetActive(flag);
|
m_StartLabel.gameObject.SetActive(flag);
|
||||||
}
|
}
|
||||||
if (endLabel && endLabel.gameObject.activeInHierarchy != flag)
|
if (m_EndLabel && m_EndLabel.gameObject.activeInHierarchy != flag)
|
||||||
{
|
{
|
||||||
endLabel.gameObject.SetActive(flag);
|
m_EndLabel.gameObject.SetActive(flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,18 +390,18 @@ namespace XCharts
|
|||||||
/// 设置开始文本内容
|
/// 设置开始文本内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text"></param>
|
/// <param name="text"></param>
|
||||||
public void SetStartLabelText(string text)
|
internal void SetStartLabelText(string text)
|
||||||
{
|
{
|
||||||
if (startLabel) startLabel.text = text;
|
if (m_StartLabel) m_StartLabel.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置结束文本内容
|
/// 设置结束文本内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text"></param>
|
/// <param name="text"></param>
|
||||||
public void SetEndLabelText(string text)
|
internal void SetEndLabelText(string text)
|
||||||
{
|
{
|
||||||
if (endLabel) endLabel.text = text;
|
if (m_EndLabel) m_EndLabel.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -332,7 +409,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gridBottom"></param>
|
/// <param name="gridBottom"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public float GetHeight(float gridBottom)
|
internal float GetHeight(float gridBottom)
|
||||||
{
|
{
|
||||||
if (height <= 0)
|
if (height <= 0)
|
||||||
{
|
{
|
||||||
@@ -342,5 +419,25 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else return height;
|
else return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void SetStartLabel(Text startLabel)
|
||||||
|
{
|
||||||
|
m_StartLabel = startLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void SetEndLabel(Text endLabel)
|
||||||
|
{
|
||||||
|
m_EndLabel = endLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void UpdateStartLabelPosition(Vector3 pos)
|
||||||
|
{
|
||||||
|
m_StartLabel.transform.localPosition = pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void UpdateEndLabelPosition(Vector3 pos)
|
||||||
|
{
|
||||||
|
m_EndLabel.transform.localPosition = pos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,8 @@
|
|||||||
/* */
|
/* */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
@@ -17,7 +15,7 @@ namespace XCharts
|
|||||||
/// 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
/// 图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class Legend : MainComponent, IPropertyChanged, IEquatable<Legend>
|
public class Legend : MainComponent, IPropertyChanged
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
||||||
@@ -43,61 +41,108 @@ namespace XCharts
|
|||||||
[SerializeField] private SelectedMode m_SelectedMode;
|
[SerializeField] private SelectedMode m_SelectedMode;
|
||||||
[SerializeField] private Orient m_Orient = Orient.Horizonal;
|
[SerializeField] private Orient m_Orient = Orient.Horizonal;
|
||||||
[SerializeField] private Location m_Location = Location.defaultRight;
|
[SerializeField] private Location m_Location = Location.defaultRight;
|
||||||
[SerializeField] private float m_ItemWidth = 50.0f;
|
[SerializeField] private float m_ItemWidth = 24.0f;
|
||||||
[SerializeField] private float m_ItemHeight = 20.0f;
|
[SerializeField] private float m_ItemHeight = 12.0f;
|
||||||
[SerializeField] private float m_ItemGap = 5;
|
[SerializeField] private float m_ItemGap = 10f;
|
||||||
[SerializeField] private int m_ItemFontSize = 18;
|
[SerializeField] private bool m_ItemAutoColor = true;
|
||||||
[SerializeField] private string m_Formatter;
|
[SerializeField] private string m_Formatter;
|
||||||
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18);
|
||||||
[SerializeField] private List<string> m_Data = new List<string>();
|
[SerializeField] private List<string> m_Data = new List<string>();
|
||||||
|
[SerializeField] private List<Sprite> m_Icons = new List<Sprite>();
|
||||||
|
|
||||||
private Dictionary<string, Button> m_DataBtnList = new Dictionary<string, Button>();
|
private Dictionary<string, LegendItem> m_DataBtnList = new Dictionary<string, LegendItem>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show legend component.
|
/// Whether to show legend component.
|
||||||
/// 是否显示图例组件。
|
/// 是否显示图例组件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
||||||
/// 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
|
/// 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public SelectedMode selectedMode { get { return m_SelectedMode; } set { m_SelectedMode = value; } }
|
public SelectedMode selectedMode
|
||||||
|
{
|
||||||
|
get { return m_SelectedMode; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify whether the layout of legend component is horizontal or vertical.
|
/// Specify whether the layout of legend component is horizontal or vertical.
|
||||||
/// 布局方式是横还是竖。
|
/// 布局方式是横还是竖。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
|
public Orient orient
|
||||||
|
{
|
||||||
|
get { return m_Orient; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The location of legend.
|
/// The location of legend.
|
||||||
/// 图例显示的位置。
|
/// 图例显示的位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Location location { get { return m_Location; } set { m_Location = value; } }
|
public Location location
|
||||||
|
{
|
||||||
|
get { return m_Location; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the width of legend item.
|
/// Image width of legend symbol.
|
||||||
/// 每个图例项的宽度。
|
/// 图例标记的图形宽度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float itemWidth { get { return m_ItemWidth; } set { m_ItemWidth = value; } }
|
public float itemWidth
|
||||||
|
{
|
||||||
|
get { return m_ItemWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the height of legend item.
|
/// Image height of legend symbol.
|
||||||
/// 每个图例项的高度。
|
/// 图例标记的图形高度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float itemHeight { get { return m_ItemHeight; } set { m_ItemHeight = value; } }
|
public float itemHeight
|
||||||
|
{
|
||||||
|
get { return m_ItemHeight; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
|
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
|
||||||
/// 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
|
/// 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
|
public float itemGap
|
||||||
|
{
|
||||||
|
get { return m_ItemGap; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font size of item text.
|
/// Whether the legend symbol matches the color automatically.
|
||||||
/// 图例项的字体大小。
|
/// 图例标记的图形是否自动匹配颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int itemFontSize { get { return m_ItemFontSize; } set { m_ItemFontSize = value; } }
|
public bool itemAutoColor
|
||||||
|
{
|
||||||
|
get { return m_ItemAutoColor; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图例内容字符串模版格式器。支持用 \n 换行。
|
/// 图例内容字符串模版格式器。支持用 \n 换行。
|
||||||
/// 模板变量为图例名称 {name}
|
/// 模板变量为图例名称 {name}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
|
public string formatter
|
||||||
|
{
|
||||||
|
get { return m_Formatter; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// the style of text.
|
||||||
|
/// 文本样式。
|
||||||
|
/// </summary>
|
||||||
|
public TextStyle textStyle
|
||||||
|
{
|
||||||
|
get { return m_TextStyle; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,
|
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,
|
||||||
/// it could also be the name of a single data in the pie chart) of a series.
|
/// it could also be the name of a single data in the pie chart) of a series.
|
||||||
@@ -105,13 +150,76 @@ namespace XCharts
|
|||||||
/// 图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 name(如果是饼图,也可以是饼图单个数据的 name)。
|
/// 图例的数据数组。数组项通常为一个字符串,每一项代表一个系列的 name(如果是饼图,也可以是饼图单个数据的 name)。
|
||||||
/// 如果 data 没有被指定,会自动从当前系列中获取。指定data时里面的数据项和serie匹配时才会生效。
|
/// 如果 data 没有被指定,会自动从当前系列中获取。指定data时里面的数据项和serie匹配时才会生效。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> data { get { return m_Data; } }
|
public List<string> data
|
||||||
|
{
|
||||||
|
get { return m_Data; }
|
||||||
|
set { if (value != null) { m_Data = value; SetComponentDirty(); } }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义的图例标记图形。
|
||||||
|
/// </summary>
|
||||||
|
public List<Sprite> icons
|
||||||
|
{
|
||||||
|
get { return m_Icons; }
|
||||||
|
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 图表是否需要刷新(图例组件不需要刷新图表)
|
||||||
|
/// </summary>
|
||||||
|
public override bool vertsDirty { get { return false; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 组件是否需要刷新
|
||||||
|
/// </summary>
|
||||||
|
public override bool componentDirty
|
||||||
|
{
|
||||||
|
get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
base.ClearComponentDirty();
|
||||||
|
location.ClearComponentDirty();
|
||||||
|
textStyle.ClearComponentDirty();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the button list of legend.
|
/// the button list of legend.
|
||||||
/// 图例按钮列表。
|
/// 图例按钮列表。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public Dictionary<string, Button> buttonList { get { return m_DataBtnList; } }
|
public Dictionary<string, LegendItem> buttonList { get { return m_DataBtnList; } }
|
||||||
|
|
||||||
|
public float runtimeWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var width = 0f;
|
||||||
|
foreach (var kv in buttonList)
|
||||||
|
{
|
||||||
|
if (orient == Orient.Horizonal)
|
||||||
|
width += kv.Value.width + m_ItemGap;
|
||||||
|
else if (kv.Value.width > width)
|
||||||
|
width = kv.Value.width;
|
||||||
|
}
|
||||||
|
return orient == Orient.Horizonal ? width - m_ItemGap : width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float runtimeHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var height = 0f;
|
||||||
|
foreach (var kv in buttonList)
|
||||||
|
{
|
||||||
|
if (orient == Orient.Vertical)
|
||||||
|
height += kv.Value.height + m_ItemGap;
|
||||||
|
else if (kv.Value.height > height)
|
||||||
|
height = kv.Value.height;
|
||||||
|
}
|
||||||
|
return orient == Orient.Vertical ? height - m_ItemGap : height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 一个在顶部居中显示的默认图例。
|
/// 一个在顶部居中显示的默认图例。
|
||||||
@@ -126,84 +234,16 @@ namespace XCharts
|
|||||||
m_SelectedMode = SelectedMode.Multiple,
|
m_SelectedMode = SelectedMode.Multiple,
|
||||||
m_Orient = Orient.Horizonal,
|
m_Orient = Orient.Horizonal,
|
||||||
m_Location = Location.defaultTop,
|
m_Location = Location.defaultTop,
|
||||||
m_ItemWidth = 60.0f,
|
m_ItemWidth = 24.0f,
|
||||||
m_ItemHeight = 20.0f,
|
m_ItemHeight = 12.0f,
|
||||||
m_ItemGap = 5,
|
m_ItemGap = 10f,
|
||||||
m_ItemFontSize = 16
|
|
||||||
};
|
};
|
||||||
legend.location.top = 30;
|
legend.location.top = 30;
|
||||||
|
legend.textStyle.offset = new Vector2(2, 0);
|
||||||
|
legend.textStyle.fontSize = 18;
|
||||||
return legend;
|
return legend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Copy(Legend legend)
|
|
||||||
{
|
|
||||||
m_Show = legend.show;
|
|
||||||
m_SelectedMode = legend.selectedMode;
|
|
||||||
m_Orient = legend.orient;
|
|
||||||
m_Location.Copy(legend.location);
|
|
||||||
m_ItemWidth = legend.itemWidth;
|
|
||||||
m_ItemHeight = legend.itemHeight;
|
|
||||||
m_ItemGap = legend.itemGap;
|
|
||||||
m_ItemFontSize = legend.itemFontSize;
|
|
||||||
m_Data.Clear();
|
|
||||||
foreach (var d in legend.data) m_Data.Add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is Legend)
|
|
||||||
{
|
|
||||||
return Equals((Legend)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Legend other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return show == other.show &&
|
|
||||||
selectedMode == other.selectedMode &&
|
|
||||||
orient == other.orient &&
|
|
||||||
location == other.location &&
|
|
||||||
itemWidth == other.itemWidth &&
|
|
||||||
itemHeight == other.itemHeight &&
|
|
||||||
itemGap == other.itemGap &&
|
|
||||||
itemFontSize == other.itemFontSize &&
|
|
||||||
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Legend left, Legend right)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Legend left, Legend right)
|
|
||||||
{
|
|
||||||
return !(left == right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空
|
/// 清空
|
||||||
@@ -211,6 +251,7 @@ namespace XCharts
|
|||||||
public void ClearData()
|
public void ClearData()
|
||||||
{
|
{
|
||||||
m_Data.Clear();
|
m_Data.Clear();
|
||||||
|
SetComponentDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -232,6 +273,7 @@ namespace XCharts
|
|||||||
if (m_Data.Contains(name))
|
if (m_Data.Contains(name))
|
||||||
{
|
{
|
||||||
m_Data.Remove(name);
|
m_Data.Remove(name);
|
||||||
|
SetComponentDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,6 +286,7 @@ namespace XCharts
|
|||||||
if (!m_Data.Contains(name) && !string.IsNullOrEmpty(name))
|
if (!m_Data.Contains(name) && !string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
m_Data.Add(name);
|
m_Data.Add(name);
|
||||||
|
SetComponentDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,13 +328,11 @@ namespace XCharts
|
|||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
/// <param name="btn"></param>
|
/// <param name="btn"></param>
|
||||||
/// <param name="total"></param>
|
/// <param name="total"></param>
|
||||||
public void SetButton(string name, Button btn, int total)
|
public void SetButton(string name, LegendItem item, int total)
|
||||||
{
|
{
|
||||||
|
m_DataBtnList[name] = item;
|
||||||
int index = m_DataBtnList.Values.Count;
|
int index = m_DataBtnList.Values.Count;
|
||||||
btn.transform.localPosition = GetButtonLocationPosition(total, index);
|
item.SetActive(show);
|
||||||
m_DataBtnList[name] = btn;
|
|
||||||
btn.gameObject.SetActive(show);
|
|
||||||
btn.GetComponentInChildren<Text>().text = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -303,7 +344,27 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (m_DataBtnList.ContainsKey(name))
|
if (m_DataBtnList.ContainsKey(name))
|
||||||
{
|
{
|
||||||
m_DataBtnList[name].GetComponent<Image>().color = color;
|
m_DataBtnList[name].SetIconColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateContentColor(string name, Color color)
|
||||||
|
{
|
||||||
|
if (m_DataBtnList.ContainsKey(name))
|
||||||
|
{
|
||||||
|
m_DataBtnList[name].SetContentColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sprite GetIcon(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_Icons.Count)
|
||||||
|
{
|
||||||
|
return m_Icons[index];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,62 +376,6 @@ namespace XCharts
|
|||||||
m_Location.OnChanged();
|
m_Location.OnChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据图例的布局和位置类型获得具体位置
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="size"></param>
|
|
||||||
/// <param name="index"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private Vector2 GetButtonLocationPosition(int size, int index)
|
|
||||||
{
|
|
||||||
switch (m_Orient)
|
|
||||||
{
|
|
||||||
case Orient.Vertical:
|
|
||||||
switch (m_Location.align)
|
|
||||||
{
|
|
||||||
case Location.Align.TopCenter:
|
|
||||||
case Location.Align.TopLeft:
|
|
||||||
case Location.Align.TopRight:
|
|
||||||
return new Vector2(0, -index * (itemHeight + itemGap));
|
|
||||||
|
|
||||||
case Location.Align.Center:
|
|
||||||
case Location.Align.CenterLeft:
|
|
||||||
case Location.Align.CenterRight:
|
|
||||||
float totalHeight = size * itemHeight + (size - 1) * itemGap;
|
|
||||||
float startY = totalHeight / 2;
|
|
||||||
return new Vector2(0, startY - index * (itemHeight + itemGap));
|
|
||||||
|
|
||||||
case Location.Align.BottomCenter:
|
|
||||||
case Location.Align.BottomLeft:
|
|
||||||
case Location.Align.BottomRight:
|
|
||||||
return new Vector2(0, (size - index - 1) * (itemHeight + itemGap));
|
|
||||||
}
|
|
||||||
return Vector2.zero;
|
|
||||||
|
|
||||||
case Orient.Horizonal:
|
|
||||||
switch (m_Location.align)
|
|
||||||
{
|
|
||||||
case Location.Align.TopLeft:
|
|
||||||
case Location.Align.CenterLeft:
|
|
||||||
case Location.Align.BottomLeft:
|
|
||||||
return new Vector2(index * (itemWidth + itemGap), 0);
|
|
||||||
|
|
||||||
case Location.Align.TopCenter:
|
|
||||||
case Location.Align.Center:
|
|
||||||
case Location.Align.BottomCenter:
|
|
||||||
float totalWidth = size * itemWidth + (size - 1) * itemGap;
|
|
||||||
float startX = totalWidth / 2;
|
|
||||||
return new Vector2(-startX + itemWidth / 2 + index * (itemWidth + itemGap), 0);
|
|
||||||
case Location.Align.TopRight:
|
|
||||||
case Location.Align.CenterRight:
|
|
||||||
case Location.Align.BottomRight:
|
|
||||||
return new Vector2(-(size - index - 1) * (itemWidth + itemGap), 0);
|
|
||||||
}
|
|
||||||
return Vector2.zero;
|
|
||||||
}
|
|
||||||
return Vector2.zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从json字符串解析数据,json格式如:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
|
/// 从json字符串解析数据,json格式如:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -379,6 +384,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||||
m_Data = ChartHelper.ParseStringFromString(jsonData);
|
m_Data = ChartHelper.ParseStringFromString(jsonData);
|
||||||
|
SetComponentDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatterContent(string category)
|
public string GetFormatterContent(string category)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace XCharts
|
|||||||
/// 雷达图坐标系组件,只适用于雷达图。
|
/// 雷达图坐标系组件,只适用于雷达图。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class Radar : MainComponent, IEquatable<Radar>
|
public class Radar : MainComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
||||||
@@ -30,16 +30,31 @@ namespace XCharts
|
|||||||
Circle
|
Circle
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 显示位置。
|
||||||
|
/// </summary>
|
||||||
|
public enum PositionType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 显示在顶点处。
|
||||||
|
/// </summary>
|
||||||
|
Vertice,
|
||||||
|
/// <summary>
|
||||||
|
/// 显示在两者之间。
|
||||||
|
/// </summary>
|
||||||
|
Between,
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// Indicator of radar chart, which is used to assign multiple variables(dimensions) in radar chart.
|
/// Indicator of radar chart, which is used to assign multiple variables(dimensions) in radar chart.
|
||||||
/// 雷达图的指示器,用来指定雷达图中的多个变量(维度)。
|
/// 雷达图的指示器,用来指定雷达图中的多个变量(维度)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class Indicator : IEquatable<Indicator>
|
public class Indicator
|
||||||
{
|
{
|
||||||
[SerializeField] private string m_Name;
|
[SerializeField] private string m_Name;
|
||||||
[SerializeField] private float m_Max;
|
[SerializeField] private float m_Max;
|
||||||
[SerializeField] private float m_Min;
|
[SerializeField] private float m_Min;
|
||||||
[SerializeField] private Color m_Color;
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指示器名称。
|
/// 指示器名称。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -55,103 +70,107 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float min { get { return m_Min; } set { m_Min = value; } }
|
public float min { get { return m_Min; } set { m_Min = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specfy a color the the indicator.
|
/// the style of text.
|
||||||
/// 标签特定的颜色。默认取自主题的axisTextColor。
|
/// 文本样式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
public TextStyle textStyle { get { return m_TextStyle; } set { m_TextStyle = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the text conponent of indicator.
|
/// the text conponent of indicator.
|
||||||
/// 指示器的文本组件。
|
/// 指示器的文本组件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Text text { get; set; }
|
public Text text { get; set; }
|
||||||
|
|
||||||
public Indicator Clone()
|
|
||||||
{
|
|
||||||
return new Indicator()
|
|
||||||
{
|
|
||||||
m_Name = name,
|
|
||||||
m_Max = max,
|
|
||||||
m_Min = min,
|
|
||||||
m_Color = color
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is Indicator)
|
|
||||||
{
|
|
||||||
return Equals((Indicator)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Indicator other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return m_Name.Equals(other.name) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_Color, other.color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[SerializeField] private Shape m_Shape;
|
[SerializeField] private Shape m_Shape;
|
||||||
[SerializeField] private float m_Radius = 100;
|
[SerializeField] private float m_Radius = 100;
|
||||||
[SerializeField] private int m_SplitNumber = 5;
|
[SerializeField] private int m_SplitNumber = 5;
|
||||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
||||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
[SerializeField] private AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||||
[SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
[SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||||
[SerializeField] private bool m_Indicator = true;
|
[SerializeField] private bool m_Indicator = true;
|
||||||
|
[SerializeField] private PositionType m_PositionType = PositionType.Vertice;
|
||||||
|
[SerializeField] private float m_IndicatorGap = 10;
|
||||||
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
||||||
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
|
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public Shape shape { get { return m_Shape; } set { m_Shape = value; } }
|
public Shape shape
|
||||||
|
{
|
||||||
|
get { return m_Shape; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the radius of radar.
|
/// the radius of radar.
|
||||||
/// 雷达图的半径。
|
/// 雷达图的半径。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float radius { get { return m_Radius; } set { m_Radius = value; } }
|
public float radius
|
||||||
|
{
|
||||||
|
get { return m_Radius; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Segments of indicator axis.
|
/// Segments of indicator axis.
|
||||||
/// 指示器轴的分割段数。
|
/// 指示器轴的分割段数。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
public int splitNumber
|
||||||
|
{
|
||||||
|
get { return m_SplitNumber; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the center of radar chart.
|
/// the center of radar chart.
|
||||||
/// 雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。
|
/// 雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。
|
||||||
/// 当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
/// 当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float[] center { get { return m_Center; } set { m_Center = value; } }
|
public float[] center
|
||||||
|
{
|
||||||
|
get { return m_Center; }
|
||||||
|
set { if (value != null) { m_Center = value; SetAllDirty(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the line style of radar.
|
/// split line.
|
||||||
/// 线条样式。
|
/// 分割线。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
public AxisSplitLine splitLine
|
||||||
|
{
|
||||||
|
get { return m_SplitLine; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Split area of axis in grid area.
|
/// Split area of axis in grid area.
|
||||||
/// 分割区域。
|
/// 分割区域。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AxisSplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
|
public AxisSplitArea splitArea
|
||||||
|
{
|
||||||
|
get { return m_SplitArea; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show indicator.
|
/// Whether to show indicator.
|
||||||
/// 是否显示指示器。
|
/// 是否显示指示器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool indicator { get { return m_Indicator; } set { m_Indicator = value; } }
|
public bool indicator
|
||||||
|
{
|
||||||
|
get { return m_Indicator; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 指示器和雷达的间距。
|
||||||
|
/// </summary>
|
||||||
|
public float indicatorGap
|
||||||
|
{
|
||||||
|
get { return m_IndicatorGap; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// /// 显示位置类型。
|
||||||
|
/// </summary>
|
||||||
|
public PositionType positionType
|
||||||
|
{
|
||||||
|
get { return m_PositionType; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the indicator list.
|
/// the indicator list.
|
||||||
/// 指示器列表。
|
/// 指示器列表。
|
||||||
@@ -162,20 +181,18 @@ namespace XCharts
|
|||||||
/// the center position of radar in container.
|
/// the center position of radar in container.
|
||||||
/// 雷达图在容器中的具体中心点。
|
/// 雷达图在容器中的具体中心点。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
public Vector2 runtimeCenterPos { get; internal set; }
|
||||||
public Vector2 centerPos { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the true radius of radar.
|
/// the true radius of radar.
|
||||||
/// 雷达图的运行时实际半径。
|
/// 雷达图的运行时实际半径。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
public float runtimeRadius { get; internal set; }
|
||||||
public float actualRadius { get; set; }
|
public float runtimeDataRadius { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the data position list of radar.
|
/// the data position list of radar.
|
||||||
/// 雷达图的所有数据坐标点列表。
|
/// 雷达图的所有数据坐标点列表。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
public Dictionary<int, List<Vector3>> runtimeDataPosList = new Dictionary<int, List<Vector3>>();
|
||||||
public Dictionary<int, List<Vector3>> dataPosList = new Dictionary<int, List<Vector3>>();
|
|
||||||
|
|
||||||
public static Radar defaultRadar
|
public static Radar defaultRadar
|
||||||
{
|
{
|
||||||
@@ -184,7 +201,7 @@ namespace XCharts
|
|||||||
var radar = new Radar
|
var radar = new Radar
|
||||||
{
|
{
|
||||||
m_Shape = Shape.Polygon,
|
m_Shape = Shape.Polygon,
|
||||||
m_Radius = 0.4f,
|
m_Radius = 0.35f,
|
||||||
m_SplitNumber = 5,
|
m_SplitNumber = 5,
|
||||||
m_Indicator = true,
|
m_Indicator = true,
|
||||||
m_IndicatorList = new List<Indicator>(5){
|
m_IndicatorList = new List<Indicator>(5){
|
||||||
@@ -196,70 +213,14 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
radar.center[0] = 0.5f;
|
radar.center[0] = 0.5f;
|
||||||
radar.center[1] = 0.45f;
|
radar.center[1] = 0.4f;
|
||||||
|
radar.splitLine.show = true;
|
||||||
radar.splitArea.show = true;
|
radar.splitArea.show = true;
|
||||||
radar.lineStyle.width = 0.6f;
|
radar.splitLine.lineStyle.width = 0.6f;
|
||||||
return radar;
|
return radar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Copy(Radar other)
|
|
||||||
{
|
|
||||||
m_Shape = other.shape;
|
|
||||||
m_Radius = other.radius;
|
|
||||||
m_SplitNumber = other.splitNumber;
|
|
||||||
m_Center[0] = other.center[0];
|
|
||||||
m_Center[1] = other.center[1];
|
|
||||||
m_Indicator = other.indicator;
|
|
||||||
indicatorList.Clear();
|
|
||||||
foreach (var d in other.indicatorList) indicatorList.Add(d.Clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Radar Clone()
|
|
||||||
{
|
|
||||||
var radar = new Radar();
|
|
||||||
radar.shape = shape;
|
|
||||||
radar.radius = radius;
|
|
||||||
radar.splitNumber = splitNumber;
|
|
||||||
radar.center[0] = center[0];
|
|
||||||
radar.center[1] = center[1];
|
|
||||||
radar.indicatorList.Clear();
|
|
||||||
radar.indicator = indicator;
|
|
||||||
foreach (var d in indicatorList) radar.indicatorList.Add(d.Clone());
|
|
||||||
return radar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is Radar)
|
|
||||||
{
|
|
||||||
return Equals((Radar)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Radar other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return radius == other.radius &&
|
|
||||||
shape == other.shape &&
|
|
||||||
splitNumber == other.splitNumber &&
|
|
||||||
center[0] == other.center[0] &&
|
|
||||||
center[1] == other.center[1] &&
|
|
||||||
indicator == other.indicator &&
|
|
||||||
IsEqualsIndicatorList(indicatorList, other.indicatorList);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsEqualsIndicatorList(List<Indicator> indicators1, List<Indicator> indicators2)
|
private bool IsEqualsIndicatorList(List<Indicator> indicators1, List<Indicator> indicators2)
|
||||||
{
|
{
|
||||||
if (indicators1.Count != indicators2.Count) return false;
|
if (indicators1.Count != indicators2.Count) return false;
|
||||||
@@ -272,29 +233,6 @@ namespace XCharts
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(Radar left, Radar right)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Radar left, Radar right)
|
|
||||||
{
|
|
||||||
return !(left == right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ParseJsonData(string jsonData)
|
public override void ParseJsonData(string jsonData)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||||
@@ -344,33 +282,79 @@ namespace XCharts
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateRadarCenter(float chartWidth, float chartHeight)
|
internal void UpdateRadarCenter(float chartWidth, float chartHeight)
|
||||||
{
|
{
|
||||||
if (center.Length < 2) return;
|
if (center.Length < 2) return;
|
||||||
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
||||||
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
||||||
centerPos = new Vector2(centerX, centerY);
|
runtimeCenterPos = new Vector2(centerX, centerY);
|
||||||
if (radius <= 0)
|
if (radius <= 0)
|
||||||
{
|
{
|
||||||
actualRadius = 0;
|
runtimeRadius = 0;
|
||||||
}
|
}
|
||||||
else if (radius <= 1)
|
else if (radius <= 1)
|
||||||
{
|
{
|
||||||
actualRadius = Mathf.Min(chartWidth, chartHeight) * radius;
|
runtimeRadius = Mathf.Min(chartWidth, chartHeight) * radius;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
actualRadius = radius;
|
runtimeRadius = radius;
|
||||||
|
}
|
||||||
|
if (shape == Radar.Shape.Polygon && positionType == PositionType.Between)
|
||||||
|
{
|
||||||
|
var angle = Mathf.PI / indicatorList.Count;
|
||||||
|
runtimeDataRadius = runtimeRadius * Mathf.Cos(angle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
runtimeDataRadius = runtimeRadius;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 GetIndicatorPosition(int index)
|
public Vector3 GetIndicatorPosition(int index)
|
||||||
{
|
{
|
||||||
int indicatorNum = indicatorList.Count;
|
int indicatorNum = indicatorList.Count;
|
||||||
var angle = 2 * Mathf.PI / indicatorNum * index;
|
var angle = 0f;
|
||||||
var x = centerPos.x + actualRadius * Mathf.Sin(angle);
|
switch (positionType)
|
||||||
var y = centerPos.y + actualRadius * Mathf.Cos(angle);
|
{
|
||||||
|
case PositionType.Vertice:
|
||||||
|
angle = 2 * Mathf.PI / indicatorNum * index;
|
||||||
|
break;
|
||||||
|
case PositionType.Between:
|
||||||
|
angle = 2 * Mathf.PI / indicatorNum * (index + 0.5f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var x = runtimeCenterPos.x + (runtimeRadius + indicatorGap) * Mathf.Sin(angle);
|
||||||
|
var y = runtimeCenterPos.y + (runtimeRadius + indicatorGap) * Mathf.Cos(angle);
|
||||||
return new Vector3(x, y);
|
return new Vector3(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Radar.Indicator AddIndicator(string name, float min, float max)
|
||||||
|
{
|
||||||
|
var indicator = new Radar.Indicator();
|
||||||
|
indicator.name = name;
|
||||||
|
indicator.min = min;
|
||||||
|
indicator.max = max;
|
||||||
|
indicatorList.Add(indicator);
|
||||||
|
SetAllDirty();
|
||||||
|
return indicator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateIndicator(int indicatorIndex, string name, float min, float max)
|
||||||
|
{
|
||||||
|
var indicator = GetIndicator(indicatorIndex);
|
||||||
|
if (indicator == null) return false;
|
||||||
|
indicator.name = name;
|
||||||
|
indicator.min = min;
|
||||||
|
indicator.max = max;
|
||||||
|
SetAllDirty();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Radar.Indicator GetIndicator(int indicatorIndex)
|
||||||
|
{
|
||||||
|
if (indicatorIndex < 0 || indicatorIndex > indicatorList.Count - 1) return null;
|
||||||
|
return indicatorList[indicatorIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -18,12 +18,13 @@ namespace XCharts
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class Series : MainComponent
|
public class Series : MainComponent
|
||||||
{
|
{
|
||||||
|
|
||||||
[SerializeField] protected List<Serie> m_Series;
|
[SerializeField] protected List<Serie> m_Series;
|
||||||
|
[NonSerialized] private bool m_LabelDirty;
|
||||||
|
|
||||||
[Obsolete("Use Series.list instead.", true)]
|
[Obsolete("Use Series.list instead.", true)]
|
||||||
public List<Serie> series { get { return m_Series; } }
|
public List<Serie> series { get { return m_Series; } }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the list of serie
|
/// the list of serie
|
||||||
/// 系列列表。
|
/// 系列列表。
|
||||||
@@ -51,12 +52,80 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool vertsDirty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_VertsDirty) return true;
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.vertsDirty) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool labelDirty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_LabelDirty) return true;
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.label.componentDirty) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool labelUpdate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.label.vertsDirty) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SetLabelDirty()
|
||||||
|
{
|
||||||
|
m_LabelDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void ClearVerticesDirty()
|
||||||
|
{
|
||||||
|
base.ClearVerticesDirty();
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
serie.ClearVerticesDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ClearLabelDirty()
|
||||||
|
{
|
||||||
|
m_LabelDirty = false;
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
serie.label.ClearVerticesDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetAllDirty()
|
||||||
|
{
|
||||||
|
base.SetAllDirty();
|
||||||
|
SetLabelDirty();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有系列的数据
|
/// 清空所有系列的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearData()
|
public void ClearData()
|
||||||
{
|
{
|
||||||
AnimationStop();
|
AnimationFadeIn();
|
||||||
foreach (var serie in m_Series)
|
foreach (var serie in m_Series)
|
||||||
{
|
{
|
||||||
serie.ClearData();
|
serie.ClearData();
|
||||||
@@ -81,6 +150,18 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetCurrData(int serieIndex, int dataIndex)
|
||||||
|
{
|
||||||
|
if (serieIndex >= 0 && serieIndex < Count)
|
||||||
|
{
|
||||||
|
return m_Series[serieIndex].GetYCurrData(dataIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得指定系列名的第一个系列
|
/// 获得指定系列名的第一个系列
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -143,7 +224,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Serie GetLastStackSerie(int index)
|
internal Serie GetLastStackSerie(int index)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(index);
|
var serie = GetSerie(index);
|
||||||
return GetLastStackSerie(serie);
|
return GetLastStackSerie(serie);
|
||||||
@@ -154,7 +235,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stack"></param>
|
/// <param name="stack"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsAnyGradientSerie(string stack)
|
internal bool IsAnyGradientSerie(string stack)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(stack)) return false;
|
if (string.IsNullOrEmpty(stack)) return false;
|
||||||
foreach (var serie in m_Series)
|
foreach (var serie in m_Series)
|
||||||
@@ -167,12 +248,37 @@ namespace XCharts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有需裁剪的serie。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
internal bool IsAnyClipSerie()
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.clip) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool IsAnyUpdateAnimationSerie()
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.animation.enable && serie.animation.dataChangeEnable)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得上一个同堆叠且显示的serie。
|
/// 获得上一个同堆叠且显示的serie。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="serie"></param>
|
/// <param name="serie"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Serie GetLastStackSerie(Serie serie)
|
internal Serie GetLastStackSerie(Serie serie)
|
||||||
{
|
{
|
||||||
if (serie == null || string.IsNullOrEmpty(serie.stack)) return null;
|
if (serie == null || string.IsNullOrEmpty(serie.stack)) return null;
|
||||||
for (int i = serie.index - 1; i >= 0; i--)
|
for (int i = serie.index - 1; i >= 0; i--)
|
||||||
@@ -220,7 +326,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void RemoveAll()
|
public void RemoveAll()
|
||||||
{
|
{
|
||||||
AnimationStop();
|
AnimationFadeIn();
|
||||||
m_Series.Clear();
|
m_Series.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,8 +361,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
serie.symbol.type = SerieSymbolType.None;
|
serie.symbol.type = SerieSymbolType.None;
|
||||||
}
|
}
|
||||||
serie.animation.Reset();
|
serie.animation.Restart();
|
||||||
m_Series.Add(serie);
|
m_Series.Add(serie);
|
||||||
|
SetVerticesDirty();
|
||||||
return serie;
|
return serie;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,13 +477,14 @@ namespace XCharts
|
|||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
public void UpdateData(string serieName, int dataIndex, float value)
|
public bool UpdateData(string serieName, int dataIndex, float value)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.UpdateYData(dataIndex, value);
|
return serie.UpdateYData(dataIndex, value);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -385,13 +493,14 @@ namespace XCharts
|
|||||||
/// <param name="serieName"></param>
|
/// <param name="serieName"></param>
|
||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
public void UpdateDataName(string serieName, int dataIndex, string dataName)
|
public bool UpdateDataName(string serieName, int dataIndex, string dataName)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.UpdateDataName(dataIndex, dataName);
|
return serie.UpdateDataName(dataIndex, dataName);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -400,13 +509,14 @@ namespace XCharts
|
|||||||
/// <param name="serieIndex"></param>
|
/// <param name="serieIndex"></param>
|
||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
public void UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
public bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.UpdateDataName(dataIndex, dataName);
|
return serie.UpdateDataName(dataIndex, dataName);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -415,13 +525,67 @@ namespace XCharts
|
|||||||
/// <param name="serieIndex"></param>
|
/// <param name="serieIndex"></param>
|
||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public void UpdateData(int serieIndex, int dataIndex, float value)
|
public bool UpdateData(int serieIndex, int dataIndex, float value)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.UpdateYData(dataIndex, value);
|
return serie.UpdateYData(dataIndex, value);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateData(string serieName, int dataIndex, List<float> values)
|
||||||
|
{
|
||||||
|
var serie = GetSerie(serieName);
|
||||||
|
if (serie != null)
|
||||||
|
{
|
||||||
|
return serie.UpdateData(dataIndex, values);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public bool UpdateData(int serieIndex, int dataIndex, List<float> values)
|
||||||
|
{
|
||||||
|
var serie = GetSerie(serieIndex);
|
||||||
|
if (serie != null)
|
||||||
|
{
|
||||||
|
return serie.UpdateData(dataIndex, values);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列指定数据项指定维度的数据值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieIndex">系列</param>
|
||||||
|
/// <param name="dataIndex">数据项</param>
|
||||||
|
/// <param name="dimension">数据维数,从0开始</param>
|
||||||
|
/// <param name="value">值</param>
|
||||||
|
public bool UpdateData(int serieIndex, int dataIndex, int dimension, float value)
|
||||||
|
{
|
||||||
|
var serie = GetSerie(serieIndex);
|
||||||
|
if (serie != null)
|
||||||
|
{
|
||||||
|
return serie.UpdateData(dataIndex, dimension, value);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定系列指定数据项指定维度的数据值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serieName"></param>
|
||||||
|
/// <param name="dataIndex"></param>
|
||||||
|
/// <param name="dimension">数据维数,从0开始</param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
public bool UpdateData(string serieName, int dataIndex, int dimension, float value)
|
||||||
|
{
|
||||||
|
var serie = GetSerie(serieName);
|
||||||
|
if (serie != null)
|
||||||
|
{
|
||||||
|
return serie.UpdateData(dataIndex, dimension, value);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -432,13 +596,14 @@ namespace XCharts
|
|||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
/// <param name="xValue"></param>
|
/// <param name="xValue"></param>
|
||||||
/// <param name="yValue"></param>
|
/// <param name="yValue"></param>
|
||||||
public void UpdateXYData(string serieName, int dataIndex, float xValue, float yValue)
|
public bool UpdateXYData(string serieName, int dataIndex, float xValue, float yValue)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.UpdateXYData(dataIndex, xValue, yValue);
|
return serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -448,20 +613,21 @@ namespace XCharts
|
|||||||
/// <param name="dataIndex"></param>
|
/// <param name="dataIndex"></param>
|
||||||
/// <param name="xValue"></param>
|
/// <param name="xValue"></param>
|
||||||
/// <param name="yValue"></param>
|
/// <param name="yValue"></param>
|
||||||
public void UpdateXYData(int serieIndex, int dataIndex, float xValue, float yValue)
|
public bool UpdateXYData(int serieIndex, int dataIndex, float xValue, float yValue)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.UpdateXYData(dataIndex, xValue, yValue);
|
return serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// dataZoom由变化是更新系列的缓存数据
|
/// dataZoom由变化是更新系列的缓存数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataZoom"></param>
|
/// <param name="dataZoom"></param>
|
||||||
public void UpdateFilterData(DataZoom dataZoom)
|
internal void UpdateFilterData(DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
if (dataZoom != null && dataZoom.enable)
|
if (dataZoom != null && dataZoom.enable)
|
||||||
{
|
{
|
||||||
@@ -519,6 +685,8 @@ namespace XCharts
|
|||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
serie.show = active;
|
serie.show = active;
|
||||||
|
serie.animation.Reset();
|
||||||
|
if (active) serie.animation.FadeIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,7 +695,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="axisIndex"></param>
|
/// <param name="axisIndex"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsUsedAxisIndex(int axisIndex)
|
internal bool IsUsedAxisIndex(int axisIndex)
|
||||||
{
|
{
|
||||||
foreach (var serie in list)
|
foreach (var serie in list)
|
||||||
{
|
{
|
||||||
@@ -555,8 +723,8 @@ namespace XCharts
|
|||||||
/// <param name="axisIndex"></param>
|
/// <param name="axisIndex"></param>
|
||||||
/// <param name="minVaule"></param>
|
/// <param name="minVaule"></param>
|
||||||
/// <param name="maxValue"></param>
|
/// <param name="maxValue"></param>
|
||||||
public void GetXMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
internal void GetXMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||||
out int minVaule, out int maxValue)
|
out float minVaule, out float maxValue)
|
||||||
{
|
{
|
||||||
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, false, out minVaule, out maxValue);
|
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, false, out minVaule, out maxValue);
|
||||||
}
|
}
|
||||||
@@ -568,16 +736,16 @@ namespace XCharts
|
|||||||
/// <param name="axisIndex"></param>
|
/// <param name="axisIndex"></param>
|
||||||
/// <param name="minVaule"></param>
|
/// <param name="minVaule"></param>
|
||||||
/// <param name="maxValue"></param>
|
/// <param name="maxValue"></param>
|
||||||
public void GetYMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
internal void GetYMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||||
out int minVaule, out int maxValue)
|
out float minVaule, out float maxValue)
|
||||||
{
|
{
|
||||||
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, true, out minVaule, out maxValue);
|
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, true, out minVaule, out maxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<int, List<Serie>> _stackSeriesForMinMax = new Dictionary<int, List<Serie>>();
|
private Dictionary<int, List<Serie>> _stackSeriesForMinMax = new Dictionary<int, List<Serie>>();
|
||||||
private Dictionary<int, float> _serieTotalValueForMinMax = new Dictionary<int, float>();
|
private Dictionary<int, float> _serieTotalValueForMinMax = new Dictionary<int, float>();
|
||||||
public void GetMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool yValue,
|
internal void GetMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool yValue,
|
||||||
out int minVaule, out int maxValue)
|
out float minVaule, out float maxValue)
|
||||||
{
|
{
|
||||||
float min = int.MaxValue;
|
float min = int.MaxValue;
|
||||||
float max = int.MinValue;
|
float max = int.MinValue;
|
||||||
@@ -593,7 +761,6 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (isPercentStack && IsPercentStack(serie.name, SerieType.Bar))
|
if (isPercentStack && IsPercentStack(serie.name, SerieType.Bar))
|
||||||
{
|
{
|
||||||
Debug.LogError("minmax:" + serie.name);
|
|
||||||
if (100 > max) max = 100;
|
if (100 > max) max = 100;
|
||||||
if (0 < min) min = 0;
|
if (0 < min) min = 0;
|
||||||
}
|
}
|
||||||
@@ -604,8 +771,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (yValue)
|
if (yValue)
|
||||||
{
|
{
|
||||||
if (data.data[1] > max) max = data.data[1];
|
var currData = data.GetData(1);
|
||||||
if (data.data[1] < min) min = data.data[1];
|
if (currData > max) max = currData;
|
||||||
|
if (currData < min) min = currData;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -642,7 +810,7 @@ namespace XCharts
|
|||||||
if (!_serieTotalValueForMinMax.ContainsKey(j))
|
if (!_serieTotalValueForMinMax.ContainsKey(j))
|
||||||
_serieTotalValueForMinMax[j] = 0;
|
_serieTotalValueForMinMax[j] = 0;
|
||||||
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] +
|
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] +
|
||||||
(yValue ? showData[j].data[1] : showData[i].data[0]);
|
(yValue ? showData[j].GetData(1) : showData[i].data[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,8 +833,8 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
minVaule = Mathf.FloorToInt(min);
|
minVaule = min > 1 ? Mathf.FloorToInt(min) : min;
|
||||||
maxValue = Mathf.CeilToInt(max);
|
maxValue = max > 1 ? Mathf.CeilToInt(max) : max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,7 +843,7 @@ namespace XCharts
|
|||||||
/// 是否由数据堆叠
|
/// 是否由数据堆叠
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsStack()
|
internal bool IsStack()
|
||||||
{
|
{
|
||||||
_setForStack.Clear();
|
_setForStack.Clear();
|
||||||
foreach (var serie in m_Series)
|
foreach (var serie in m_Series)
|
||||||
@@ -696,7 +864,7 @@ namespace XCharts
|
|||||||
/// <param name="stackName"></param>
|
/// <param name="stackName"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsStack(string stackName, SerieType type)
|
internal bool IsStack(string stackName, SerieType type)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(stackName)) return false;
|
if (string.IsNullOrEmpty(stackName)) return false;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -716,7 +884,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsPercentStack(SerieType type)
|
internal bool IsPercentStack(SerieType type)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool isPercentStack = false;
|
bool isPercentStack = false;
|
||||||
@@ -741,7 +909,7 @@ namespace XCharts
|
|||||||
/// <param name="stackName"></param>
|
/// <param name="stackName"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsPercentStack(string stackName, SerieType type)
|
internal bool IsPercentStack(string stackName, SerieType type)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(stackName)) return false;
|
if (string.IsNullOrEmpty(stackName)) return false;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -765,7 +933,7 @@ namespace XCharts
|
|||||||
/// 获得堆叠系列列表
|
/// 获得堆叠系列列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Dictionary<int, List<Serie>> GetStackSeries()
|
internal Dictionary<int, List<Serie>> GetStackSeries()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Dictionary<string, int> sets = new Dictionary<string, int>();
|
Dictionary<string, int> sets = new Dictionary<string, int>();
|
||||||
@@ -805,7 +973,7 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Dictionary<int"></param>
|
/// <param name="Dictionary<int"></param>
|
||||||
/// <param name="stackSeries"></param>
|
/// <param name="stackSeries"></param>
|
||||||
public void GetStackSeries(ref Dictionary<int, List<Serie>> stackSeries)
|
internal void GetStackSeries(ref Dictionary<int, List<Serie>> stackSeries)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
sets.Clear();
|
sets.Clear();
|
||||||
@@ -855,7 +1023,7 @@ namespace XCharts
|
|||||||
/// 获得所有系列名,不包含空名字。
|
/// 获得所有系列名,不包含空名字。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<string> GetSerieNameList()
|
internal List<string> GetSerieNameList()
|
||||||
{
|
{
|
||||||
serieNameList.Clear();
|
serieNameList.Clear();
|
||||||
for (int n = 0; n < m_Series.Count; n++)
|
for (int n = 0; n < m_Series.Count; n++)
|
||||||
@@ -865,6 +1033,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
case SerieType.Pie:
|
case SerieType.Pie:
|
||||||
case SerieType.Radar:
|
case SerieType.Radar:
|
||||||
|
case SerieType.Ring:
|
||||||
for (int i = 0; i < serie.data.Count; i++)
|
for (int i = 0; i < serie.data.Count; i++)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(serie.data[i].name))
|
if (string.IsNullOrEmpty(serie.data[i].name))
|
||||||
@@ -910,32 +1079,54 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始初始动画
|
/// 渐入动画
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AnimationStart()
|
public void AnimationFadeIn()
|
||||||
{
|
{
|
||||||
foreach (var serie in m_Series)
|
foreach (var serie in m_Series)
|
||||||
{
|
{
|
||||||
if (serie.animation.enable)
|
if (serie.animation.enable)
|
||||||
{
|
{
|
||||||
serie.animation.Start();
|
serie.animation.FadeIn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 停止初始动画
|
/// 渐出动画
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AnimationStop()
|
public void AnimationFadeOut()
|
||||||
{
|
{
|
||||||
foreach (var serie in m_Series)
|
foreach (var serie in m_Series)
|
||||||
{
|
{
|
||||||
if (serie.animation.enable) serie.animation.Stop();
|
if (serie.animation.enable) serie.animation.FadeOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 重置初始动画
|
/// 暂停动画
|
||||||
|
/// </summary>
|
||||||
|
public void AnimationPause()
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.animation.enable) serie.animation.Pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 继续动画
|
||||||
|
/// </summary>
|
||||||
|
public void AnimationResume()
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.animation.enable) serie.animation.Resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重置动画
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AnimationReset()
|
public void AnimationReset()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,14 +30,22 @@ namespace XCharts
|
|||||||
/// and different curves with slightly different appearance can be obtained.
|
/// and different curves with slightly different appearance can be obtained.
|
||||||
/// 曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
|
/// 曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float lineSmoothStyle { get { return m_LineSmoothStyle; } set { m_LineSmoothStyle = value <= 0 ? 1f : value; } }
|
public float lineSmoothStyle
|
||||||
|
{
|
||||||
|
get { return m_LineSmoothStyle; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Smoothness of curve. The smaller the value, the smoother the curve, but the number of vertices will increase.
|
/// Smoothness of curve. The smaller the value, the smoother the curve, but the number of vertices will increase.
|
||||||
/// When the area with gradient is filled, the larger the value, the worse the transition effect.
|
/// When the area with gradient is filled, the larger the value, the worse the transition effect.
|
||||||
/// 曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
/// 曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public float lineSmoothness { get { return m_LineSmoothness; } set { m_LineSmoothness = value <= 0 ? 1f : value; } }
|
public float lineSmoothness
|
||||||
|
{
|
||||||
|
get { return m_LineSmoothness; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The partition distance of a line segment. A line in a normal line chart is made up of many segments,
|
/// The partition distance of a line segment. A line in a normal line chart is made up of many segments,
|
||||||
/// the number of which is determined by the change in value. The smaller the number of segments,
|
/// the number of which is determined by the change in value. The smaller the number of segments,
|
||||||
@@ -45,25 +53,44 @@ namespace XCharts
|
|||||||
/// 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
/// 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public float lineSegmentDistance { get { return m_LineSegmentDistance; } set { m_LineSegmentDistance = value <= 0 ? 1f : value; } }
|
public float lineSegmentDistance
|
||||||
|
{
|
||||||
|
get { return m_LineSegmentDistance; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the smoothess of cricle.
|
/// the smoothess of cricle.
|
||||||
/// 圆形的平滑度。数越小圆越平滑,但顶点数也会随之增加。
|
/// 圆形的平滑度。数越小圆越平滑,但顶点数也会随之增加。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float cicleSmoothness { get { return m_CicleSmoothness; } set { m_CicleSmoothness = value <= 0 ? 1f : value; } }
|
public float cicleSmoothness
|
||||||
|
{
|
||||||
|
get { return m_CicleSmoothness; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可视化组件的调节三角形变长。
|
/// 可视化组件的调节三角形边长。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public float visualMapTriangeLen { get { return m_VisualMapTriangeLen; } set { m_VisualMapTriangeLen = value <= 0 ? 1f : value; } }
|
public float visualMapTriangeLen
|
||||||
|
{
|
||||||
|
get { return m_VisualMapTriangeLen; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_VisualMapTriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图鼠标移到高亮时的额外半径
|
/// 饼图鼠标移到高亮时的额外半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieTooltipExtraRadius { get { return m_PieTooltipExtraRadius; } set { m_PieTooltipExtraRadius = value <= 0 ? 0 : value; } }
|
public float pieTooltipExtraRadius
|
||||||
|
{
|
||||||
|
get { return m_PieTooltipExtraRadius; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图选中时的中心点偏移
|
/// 饼图选中时的中心点偏移
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieSelectedOffset { get { return m_PieSelectedOffset; } set { m_PieSelectedOffset = value <= 0 ? 0 : value; } }
|
public float pieSelectedOffset
|
||||||
|
{
|
||||||
|
get { return m_PieSelectedOffset; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ namespace XCharts
|
|||||||
/// Theme.
|
/// Theme.
|
||||||
/// 主题相关配置。
|
/// 主题相关配置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ThemeInfo : MainComponent, IEquatable<ThemeInfo>
|
public class ThemeInfo : MainComponent
|
||||||
{
|
{
|
||||||
[SerializeField] private Theme m_Theme = Theme.Default;
|
[SerializeField] private Theme m_Theme = Theme.Default;
|
||||||
[SerializeField] private Font m_Font;
|
[SerializeField] private Font m_Font;
|
||||||
@@ -86,7 +86,11 @@ namespace XCharts
|
|||||||
/// the theme of chart.
|
/// the theme of chart.
|
||||||
/// 主题类型。
|
/// 主题类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Theme theme { get { return m_Theme; } set { m_Theme = value; } }
|
public Theme theme
|
||||||
|
{
|
||||||
|
get { return m_Theme; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Theme, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the font of chart text。
|
/// the font of chart text。
|
||||||
/// 字体。
|
/// 字体。
|
||||||
@@ -94,7 +98,7 @@ namespace XCharts
|
|||||||
public Font font
|
public Font font
|
||||||
{
|
{
|
||||||
get { return m_CustomFont != null ? m_CustomFont : m_Font; }
|
get { return m_CustomFont != null ? m_CustomFont : m_Font; }
|
||||||
set { m_CustomFont = value; }
|
set { if (PropertyUtility.SetClass(ref m_CustomFont, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the background color of chart.
|
/// the background color of chart.
|
||||||
@@ -103,7 +107,7 @@ namespace XCharts
|
|||||||
public Color32 backgroundColor
|
public Color32 backgroundColor
|
||||||
{
|
{
|
||||||
get { return m_CustomBackgroundColor != Color.clear ? m_CustomBackgroundColor : m_BackgroundColor; }
|
get { return m_CustomBackgroundColor != Color.clear ? m_CustomBackgroundColor : m_BackgroundColor; }
|
||||||
set { m_CustomBackgroundColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomBackgroundColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the main title text color.
|
/// the main title text color.
|
||||||
@@ -112,7 +116,7 @@ namespace XCharts
|
|||||||
public Color32 titleTextColor
|
public Color32 titleTextColor
|
||||||
{
|
{
|
||||||
get { return m_CustomTitleTextColor != Color.clear ? m_CustomTitleTextColor : m_TitleTextColor; }
|
get { return m_CustomTitleTextColor != Color.clear ? m_CustomTitleTextColor : m_TitleTextColor; }
|
||||||
set { m_CustomTitleTextColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomTitleTextColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the subtitie text color.
|
/// the subtitie text color.
|
||||||
@@ -121,7 +125,7 @@ namespace XCharts
|
|||||||
public Color32 titleSubTextColor
|
public Color32 titleSubTextColor
|
||||||
{
|
{
|
||||||
get { return m_CustomTitleSubTextColor != Color.clear ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
|
get { return m_CustomTitleSubTextColor != Color.clear ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
|
||||||
set { m_CustomTitleSubTextColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomTitleSubTextColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the legend text color.
|
/// the legend text color.
|
||||||
@@ -130,7 +134,7 @@ namespace XCharts
|
|||||||
public Color32 legendTextColor
|
public Color32 legendTextColor
|
||||||
{
|
{
|
||||||
get { return m_CustomLegendTextColor != Color.clear ? m_CustomLegendTextColor : m_LegendTextColor; }
|
get { return m_CustomLegendTextColor != Color.clear ? m_CustomLegendTextColor : m_LegendTextColor; }
|
||||||
set { m_CustomLegendTextColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomLegendTextColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the legend unable text color.
|
/// the legend unable text color.
|
||||||
@@ -139,7 +143,7 @@ namespace XCharts
|
|||||||
public Color32 legendUnableColor
|
public Color32 legendUnableColor
|
||||||
{
|
{
|
||||||
get { return m_CustomLegendUnableColor != Color.clear ? m_CustomLegendUnableColor : m_LegendUnableColor; }
|
get { return m_CustomLegendUnableColor != Color.clear ? m_CustomLegendUnableColor : m_LegendUnableColor; }
|
||||||
set { m_CustomLegendUnableColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomLegendUnableColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the axis text color.
|
/// the axis text color.
|
||||||
@@ -148,7 +152,7 @@ namespace XCharts
|
|||||||
public Color32 axisTextColor
|
public Color32 axisTextColor
|
||||||
{
|
{
|
||||||
get { return m_CustomAxisTextColor != Color.clear ? m_CustomAxisTextColor : m_AxisTextColor; }
|
get { return m_CustomAxisTextColor != Color.clear ? m_CustomAxisTextColor : m_AxisTextColor; }
|
||||||
set { m_CustomAxisTextColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomAxisTextColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of axis line.
|
/// the color of axis line.
|
||||||
@@ -157,7 +161,7 @@ namespace XCharts
|
|||||||
public Color32 axisLineColor
|
public Color32 axisLineColor
|
||||||
{
|
{
|
||||||
get { return m_CustomAxisLineColor != Color.clear ? m_CustomAxisLineColor : m_AxisLineColor; }
|
get { return m_CustomAxisLineColor != Color.clear ? m_CustomAxisLineColor : m_AxisLineColor; }
|
||||||
set { m_CustomAxisLineColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomAxisLineColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of axis split line.
|
/// the color of axis split line.
|
||||||
@@ -166,7 +170,7 @@ namespace XCharts
|
|||||||
public Color32 axisSplitLineColor
|
public Color32 axisSplitLineColor
|
||||||
{
|
{
|
||||||
get { return m_CustomAxisSplitLineColor != Color.clear ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
|
get { return m_CustomAxisSplitLineColor != Color.clear ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
|
||||||
set { m_CustomAxisSplitLineColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomAxisSplitLineColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the tooltip background color.
|
/// the tooltip background color.
|
||||||
@@ -175,7 +179,7 @@ namespace XCharts
|
|||||||
public Color32 tooltipBackgroundColor
|
public Color32 tooltipBackgroundColor
|
||||||
{
|
{
|
||||||
get { return m_CustomTooltipBackgroundColor != Color.clear ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
|
get { return m_CustomTooltipBackgroundColor != Color.clear ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
|
||||||
set { m_CustomTooltipBackgroundColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomTooltipBackgroundColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of tooltip shadow crosshair indicator.
|
/// the color of tooltip shadow crosshair indicator.
|
||||||
@@ -184,7 +188,7 @@ namespace XCharts
|
|||||||
public Color32 tooltipFlagAreaColor
|
public Color32 tooltipFlagAreaColor
|
||||||
{
|
{
|
||||||
get { return m_CustomTooltipFlagAreaColor != Color.clear ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
|
get { return m_CustomTooltipFlagAreaColor != Color.clear ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
|
||||||
set { m_CustomTooltipFlagAreaColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomTooltipFlagAreaColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of tooltip text.
|
/// the color of tooltip text.
|
||||||
@@ -193,7 +197,7 @@ namespace XCharts
|
|||||||
public Color32 tooltipTextColor
|
public Color32 tooltipTextColor
|
||||||
{
|
{
|
||||||
get { return m_CustomTooltipTextColor != Color.clear ? m_CustomTooltipTextColor : m_TooltipTextColor; }
|
get { return m_CustomTooltipTextColor != Color.clear ? m_CustomTooltipTextColor : m_TooltipTextColor; }
|
||||||
set { m_CustomTooltipTextColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomTooltipTextColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the background color of tooltip cross indicator's axis label.
|
/// the background color of tooltip cross indicator's axis label.
|
||||||
@@ -202,7 +206,7 @@ namespace XCharts
|
|||||||
public Color32 tooltipLabelColor
|
public Color32 tooltipLabelColor
|
||||||
{
|
{
|
||||||
get { return m_CustomTooltipLabelColor != Color.clear ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
|
get { return m_CustomTooltipLabelColor != Color.clear ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
|
||||||
set { m_CustomTooltipLabelColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLabelColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color tooltip indicator line.
|
/// the color tooltip indicator line.
|
||||||
@@ -211,7 +215,7 @@ namespace XCharts
|
|||||||
public Color32 tooltipLineColor
|
public Color32 tooltipLineColor
|
||||||
{
|
{
|
||||||
get { return m_CustomTooltipLineColor != Color.clear ? m_CustomTooltipLineColor : m_TooltipLineColor; }
|
get { return m_CustomTooltipLineColor != Color.clear ? m_CustomTooltipLineColor : m_TooltipLineColor; }
|
||||||
set { m_CustomTooltipLineColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLineColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of datazoom text.
|
/// the color of datazoom text.
|
||||||
@@ -220,7 +224,7 @@ namespace XCharts
|
|||||||
public Color32 dataZoomTextColor
|
public Color32 dataZoomTextColor
|
||||||
{
|
{
|
||||||
get { return m_CustomDataZoomTextColor != Color.clear ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
|
get { return m_CustomDataZoomTextColor != Color.clear ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
|
||||||
set { m_CustomDataZoomTextColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomTextColor, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of datazoom line.
|
/// the color of datazoom line.
|
||||||
@@ -229,7 +233,7 @@ namespace XCharts
|
|||||||
public Color32 dataZoomLineColor
|
public Color32 dataZoomLineColor
|
||||||
{
|
{
|
||||||
get { return m_CustomDataZoomLineColor != Color.clear ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
|
get { return m_CustomDataZoomLineColor != Color.clear ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
|
||||||
set { m_CustomDataZoomLineColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomLineColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of datazoom selected area.
|
/// the color of datazoom selected area.
|
||||||
@@ -238,7 +242,7 @@ namespace XCharts
|
|||||||
public Color32 dataZoomSelectedColor
|
public Color32 dataZoomSelectedColor
|
||||||
{
|
{
|
||||||
get { return m_CustomDataZoomSelectedColor != Color.clear ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
|
get { return m_CustomDataZoomSelectedColor != Color.clear ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
|
||||||
set { m_CustomDataZoomSelectedColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomSelectedColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -247,7 +251,7 @@ namespace XCharts
|
|||||||
public Color32 visualMapBackgroundColor
|
public Color32 visualMapBackgroundColor
|
||||||
{
|
{
|
||||||
get { return m_CustomVisualMapBackgroundColor != Color.clear ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
|
get { return m_CustomVisualMapBackgroundColor != Color.clear ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
|
||||||
set { m_CustomVisualMapBackgroundColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBackgroundColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -256,14 +260,14 @@ namespace XCharts
|
|||||||
public Color32 visualMapBorderColor
|
public Color32 visualMapBorderColor
|
||||||
{
|
{
|
||||||
get { return m_CustomVisualMapBorderColor != Color.clear ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
|
get { return m_CustomVisualMapBorderColor != Color.clear ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
|
||||||
set { m_CustomVisualMapBorderColor = value; }
|
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBorderColor, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series.
|
/// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series.
|
||||||
/// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。
|
/// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Color32> colorPalette { set { m_CustomColorPalette = value; } }
|
public List<Color32> colorPalette { set { m_CustomColorPalette = value; SetVerticesDirty(); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the color of the specified index from the palette.
|
/// Gets the color of the specified index from the palette.
|
||||||
@@ -310,6 +314,22 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Copy(Theme theme)
|
||||||
|
{
|
||||||
|
switch (theme)
|
||||||
|
{
|
||||||
|
case Theme.Dark:
|
||||||
|
Copy(ThemeInfo.Dark);
|
||||||
|
break;
|
||||||
|
case Theme.Default:
|
||||||
|
Copy(ThemeInfo.Default);
|
||||||
|
break;
|
||||||
|
case Theme.Light:
|
||||||
|
Copy(ThemeInfo.Light);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// copy all configurations from theme.
|
/// copy all configurations from theme.
|
||||||
/// 复制主题的所有配置。
|
/// 复制主题的所有配置。
|
||||||
@@ -391,7 +411,7 @@ namespace XCharts
|
|||||||
m_LegendUnableColor = GetColor("#cccccc"),
|
m_LegendUnableColor = GetColor("#cccccc"),
|
||||||
m_TitleTextColor = GetColor("#514D4D"),
|
m_TitleTextColor = GetColor("#514D4D"),
|
||||||
m_TitleSubTextColor = GetColor("#514D4D"),
|
m_TitleSubTextColor = GetColor("#514D4D"),
|
||||||
m_LegendTextColor = GetColor("#eee"),
|
m_LegendTextColor = GetColor("#514D4D"),
|
||||||
m_AxisTextColor = GetColor("#514D4D"),
|
m_AxisTextColor = GetColor("#514D4D"),
|
||||||
m_AxisLineColor = GetColor("#514D4D"),
|
m_AxisLineColor = GetColor("#514D4D"),
|
||||||
m_AxisSplitLineColor = GetColor("#51515120"),
|
m_AxisSplitLineColor = GetColor("#51515120"),
|
||||||
@@ -577,64 +597,6 @@ namespace XCharts
|
|||||||
return (Color32)color;
|
return (Color32)color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is ThemeInfo)
|
|
||||||
{
|
|
||||||
return Equals((ThemeInfo)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(ThemeInfo other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return m_Font == other.m_Font &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_LegendUnableColor, other.m_LegendUnableColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.m_BackgroundColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_TitleTextColor, other.m_TitleTextColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_TitleSubTextColor, other.m_TitleSubTextColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_AxisTextColor, other.m_AxisTextColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_AxisLineColor, other.m_AxisLineColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_TooltipBackgroundColor, other.m_TooltipBackgroundColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_TooltipTextColor, other.m_TooltipTextColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_TooltipFlagAreaColor, other.m_TooltipFlagAreaColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_DataZoomLineColor, other.m_DataZoomLineColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_DataZoomSelectedColor, other.m_DataZoomSelectedColor) &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_DataZoomTextColor, other.m_DataZoomTextColor) &&
|
|
||||||
m_ColorPalette.Length == other.m_ColorPalette.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(ThemeInfo left, ThemeInfo right)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(ThemeInfo left, ThemeInfo right)
|
|
||||||
{
|
|
||||||
return !(left == right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return base.GetHashCode();
|
return base.GetHashCode();
|
||||||
|
|||||||
@@ -15,55 +15,76 @@ namespace XCharts
|
|||||||
/// 标题组件,包含主标题和副标题。
|
/// 标题组件,包含主标题和副标题。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Title : MainComponent, IPropertyChanged, IEquatable<Title>
|
public class Title : MainComponent, IPropertyChanged
|
||||||
{
|
{
|
||||||
[SerializeField] private bool m_Show = true;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private string m_Text;
|
[SerializeField] private string m_Text;
|
||||||
[SerializeField] private int m_TextFontSize;
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle(16);
|
||||||
[SerializeField] private string m_SubText;
|
[SerializeField] private string m_SubText;
|
||||||
[SerializeField] private int m_SubTextFontSize;
|
[SerializeField] private TextStyle m_SubTextStyle = new TextStyle(14);
|
||||||
[SerializeField] private float m_ItemGap;
|
[SerializeField] private float m_ItemGap = 8;
|
||||||
[SerializeField] private Location m_Location;
|
[SerializeField] private Location m_Location = Location.defaultTop;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// [default:true]
|
/// [default:true]
|
||||||
/// Set this to false to prevent the title from showing.
|
/// Set this to false to prevent the title from showing.
|
||||||
/// 是否显示标题组件。
|
/// 是否显示标题组件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show { get { return m_Show; } set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main title text, supporting for \n for newlines.
|
/// The main title text, supporting for \n for newlines.
|
||||||
/// 主标题文本,支持使用 \n 换行。
|
/// 主标题文本,支持使用 \n 换行。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string text { get { return m_Text; } set { m_Text = value; } }
|
public string text { get { return m_Text; } set { if (PropertyUtility.SetClass(ref m_Text, value)) SetComponentDirty(); } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// [default:16]
|
/// [default:16]
|
||||||
/// main title font size.
|
/// main title font size.
|
||||||
/// 主标题文字的字体大小。
|
/// 主标题文字的字体大小。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int textFontSize { get { return m_TextFontSize; } set { m_TextFontSize = value; } }
|
[Obsolete("use textStyle instead.", true)]
|
||||||
|
public int textFontSize { get { return m_TextStyle.fontSize; } set { m_TextStyle.fontSize = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 主标题文本样式。
|
||||||
|
/// </summary>
|
||||||
|
public TextStyle textStyle { get { return m_TextStyle; } set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Subtitle text, supporting for \n for newlines.
|
/// Subtitle text, supporting for \n for newlines.
|
||||||
/// 副标题文本,支持使用 \n 换行。
|
/// 副标题文本,支持使用 \n 换行。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string subText { get { return m_SubText; } set { m_SubText = value; } }
|
public string subText { get { return m_SubText; } set { if (PropertyUtility.SetClass(ref m_SubText, value)) SetComponentDirty(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// 副标题文本样式。
|
||||||
|
/// </summary>
|
||||||
|
public TextStyle subTextStyle { get { return m_SubTextStyle; } set { if (PropertyUtility.SetClass(ref m_SubTextStyle, value)) SetComponentDirty(); } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// [default:14]
|
/// [default:14]
|
||||||
/// subtitle font size.
|
/// subtitle font size.
|
||||||
/// 副标题文字的字体大小。
|
/// 副标题文字的字体大小。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int subTextFontSize { get { return m_SubTextFontSize; } set { m_SubTextFontSize = value; } }
|
[Obsolete("use subTextStyle instead.", true)]
|
||||||
|
public int subTextFontSize { get { return m_SubTextStyle.fontSize; } set { m_SubTextStyle.fontSize = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// [default:14]
|
/// [default:8]
|
||||||
/// The gap between the main title and subtitle.
|
/// The gap between the main title and subtitle.
|
||||||
/// 主副标题之间的间距。
|
/// 主副标题之间的间距。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float itemGap { get { return m_ItemGap; } set { m_ItemGap = value; } }
|
public float itemGap { get { return m_ItemGap; } set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The location of title component.
|
/// The location of title component.
|
||||||
/// 标题显示位置。
|
/// 标题显示位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Location location { get { return m_Location; } set { m_Location = value; } }
|
public Location location { get { return m_Location; } set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); } }
|
||||||
|
|
||||||
|
public override bool vertsDirty { get { return false; } }
|
||||||
|
public override bool componentDirty { get { return m_ComponentDirty || location.componentDirty || textStyle.componentDirty || subTextStyle.componentDirty; } }
|
||||||
|
|
||||||
|
internal override void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
base.ClearComponentDirty();
|
||||||
|
location.ClearComponentDirty();
|
||||||
|
textStyle.ClearComponentDirty();
|
||||||
|
subTextStyle.ClearComponentDirty();
|
||||||
|
}
|
||||||
|
|
||||||
public static Title defaultTitle
|
public static Title defaultTitle
|
||||||
{
|
{
|
||||||
@@ -73,79 +94,15 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_Show = true,
|
m_Show = true,
|
||||||
m_Text = "Chart Title",
|
m_Text = "Chart Title",
|
||||||
m_TextFontSize = 16,
|
m_TextStyle = new TextStyle(16),
|
||||||
m_SubText = "",
|
m_SubText = "",
|
||||||
m_SubTextFontSize = 14,
|
m_SubTextStyle = new TextStyle(14),
|
||||||
m_ItemGap = 8,
|
m_ItemGap = 8,
|
||||||
m_Location = Location.defaultTop
|
m_Location = Location.defaultTop
|
||||||
};
|
};
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Copy(Title title)
|
|
||||||
{
|
|
||||||
m_Show = title.show;
|
|
||||||
m_Text = title.text;
|
|
||||||
m_TextFontSize = title.textFontSize;
|
|
||||||
m_SubText = title.subText;
|
|
||||||
m_SubTextFontSize = title.subTextFontSize;
|
|
||||||
m_ItemGap = title.itemGap;
|
|
||||||
m_Location.Copy(title.location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is Title)
|
|
||||||
{
|
|
||||||
return Equals((Title)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Title other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return m_Show == other.show &&
|
|
||||||
m_Text.Equals(other.text) &&
|
|
||||||
m_TextFontSize == other.textFontSize &&
|
|
||||||
m_SubText.Equals(other.subText) &&
|
|
||||||
m_SubTextFontSize == other.subTextFontSize &&
|
|
||||||
m_ItemGap == other.itemGap &&
|
|
||||||
m_Location.Equals(other.location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Title left, Title right)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Title left, Title right)
|
|
||||||
{
|
|
||||||
return !(left == right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnChanged()
|
public void OnChanged()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/******************************************/
|
using System.Collections.ObjectModel;
|
||||||
|
/******************************************/
|
||||||
/* */
|
/* */
|
||||||
/* Copyright (c) 2018 monitor1394 */
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
/* https://github.com/monitor1394 */
|
/* https://github.com/monitor1394 */
|
||||||
@@ -8,6 +9,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using System;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
@@ -49,32 +52,74 @@ namespace XCharts
|
|||||||
[SerializeField] private bool m_Show;
|
[SerializeField] private bool m_Show;
|
||||||
[SerializeField] private Type m_Type;
|
[SerializeField] private Type m_Type;
|
||||||
[SerializeField] private string m_Formatter;
|
[SerializeField] private string m_Formatter;
|
||||||
|
[SerializeField] private string m_ItemFormatter;
|
||||||
|
[SerializeField] private string m_TitleFormatter;
|
||||||
[SerializeField] private float m_FixedWidth = 0;
|
[SerializeField] private float m_FixedWidth = 0;
|
||||||
[SerializeField] private float m_FixedHeight = 0;
|
[SerializeField] private float m_FixedHeight = 0;
|
||||||
[SerializeField] private float m_MinWidth = 0;
|
[SerializeField] private float m_MinWidth = 0;
|
||||||
[SerializeField] private float m_MinHeight = 0;
|
[SerializeField] private float m_MinHeight = 0;
|
||||||
[SerializeField] private int m_FontSize = 18;
|
[SerializeField] private bool m_ForceENotation = false;
|
||||||
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
[SerializeField] private float m_PaddingLeftRight = 5f;
|
||||||
|
[SerializeField] private float m_PaddingTopBottom = 5f;
|
||||||
|
[SerializeField] private string m_IgnoreDataDefaultContent = "-";
|
||||||
|
[SerializeField] private Sprite m_BackgroundImage;
|
||||||
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18, FontStyle.Normal);
|
||||||
|
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f);
|
||||||
|
|
||||||
private GameObject m_GameObject;
|
private GameObject m_GameObject;
|
||||||
private GameObject m_Content;
|
private GameObject m_Content;
|
||||||
private Text m_ContentText;
|
private Text m_ContentText;
|
||||||
|
private Image m_ContentImage;
|
||||||
private RectTransform m_ContentRect;
|
private RectTransform m_ContentRect;
|
||||||
|
private RectTransform m_ContentTextRect;
|
||||||
private List<int> lastDataIndex { get; set; }
|
private List<int> lastDataIndex { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show the tooltip component.
|
/// Whether to show the tooltip component.
|
||||||
/// 是否显示提示框组件。
|
/// 是否显示提示框组件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
public bool show
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; SetActive(value); } }
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetAllDirty(); SetActive(value); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicator type.
|
/// Indicator type.
|
||||||
/// 提示框指示器类型。
|
/// 提示框指示器类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
public Type type
|
||||||
|
{
|
||||||
|
get { return m_Type; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 提示框内容字符串模版格式器。支持用 \n 或 "<br/>" 换行。
|
/// 提示框总内容的字符串模版格式器。支持用 \n 或 "<br/>" 换行。当formatter不为空时,优先使用formatter,否则使用itemFormatter。
|
||||||
|
/// 模板变量有 {a}, {b},{c},{d},{e},分别表示系列名,数据名,数据值等。{a0},{b1},c{1}等可指定serie。
|
||||||
|
/// 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
|
||||||
|
/// <list type="bullet">
|
||||||
|
/// <item><description>折线(区域)图、柱状(条形)图、K线图 : {a}(系列名称),{b}(类目值),{c}(数值), {d}(无)。</description></item>
|
||||||
|
/// <item><description>散点图(气泡)图 : {a}(系列名称),{b}(数据名称),{c}(数值数组), {d}(无)。</description></item>
|
||||||
|
/// <item><description>地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)。</description></item>
|
||||||
|
/// <item><description>饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)。</description></item>
|
||||||
|
/// </list>
|
||||||
|
/// 示例:"{a}:{c}","{a1}:{c1:f1}"
|
||||||
|
/// </summary>
|
||||||
|
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 提示框标题内容的字符串模版格式器。支持用 \n 或 "<br/>" 换行。仅当itemFormatter生效时才有效。
|
||||||
|
/// 模板变量有 {a}, {b},{c},{d},{e},分别表示系列名,数据名,数据值等。{a0},{b1},c{1}等可指定serie。
|
||||||
|
/// 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
|
||||||
|
/// <list type="bullet">
|
||||||
|
/// <item><description>折线(区域)图、柱状(条形)图、K线图 : {a}(系列名称),{b}(类目值),{c}(数值), {d}(无)。</description></item>
|
||||||
|
/// <item><description>散点图(气泡)图 : {a}(系列名称),{b}(数据名称),{c}(数值数组), {d}(无)。</description></item>
|
||||||
|
/// <item><description>地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)。</description></item>
|
||||||
|
/// <item><description>饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)。</description></item>
|
||||||
|
/// </list>
|
||||||
|
/// 示例:"{a}:{c}","{a1}:{c1:f1}"
|
||||||
|
/// </summary>
|
||||||
|
public string titleFormatter { get { return m_TitleFormatter; } set { m_TitleFormatter = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 或 "<br/>" 换行。当formatter不为空时,优先使用formatter,否则使用itemFormatter。
|
||||||
/// 模板变量有 {a}, {b},{c},{d},{e},分别表示系列名,数据名,数据值等。
|
/// 模板变量有 {a}, {b},{c},{d},{e},分别表示系列名,数据名,数据值等。
|
||||||
/// 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
|
/// 其中变量{a}, {b}, {c}, {d}在不同图表类型下代表数据含义为:
|
||||||
/// <list type="bullet">
|
/// <list type="bullet">
|
||||||
@@ -83,11 +128,10 @@ namespace XCharts
|
|||||||
/// <item><description>地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)。</description></item>
|
/// <item><description>地图 : {a}(系列名称),{b}(区域名称),{c}(合并数值), {d}(无)。</description></item>
|
||||||
/// <item><description>饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)。</description></item>
|
/// <item><description>饼图、仪表盘、漏斗图: {a}(系列名称),{b}(数据项名称),{c}(数值), {d}(百分比)。</description></item>
|
||||||
/// </list>
|
/// </list>
|
||||||
|
/// 示例:"{a}:{c}","{a}:{c:f1}"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <example>
|
public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } }
|
||||||
/// 示例:“{a}:{c}”
|
|
||||||
/// </example>
|
|
||||||
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 固定宽度。比 minWidth 优先。
|
/// 固定宽度。比 minWidth 优先。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -104,57 +148,105 @@ namespace XCharts
|
|||||||
/// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。
|
/// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } }
|
public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } }
|
||||||
|
[Obsolete("Use Tooltip.textStyle.fontSize instead.", true)]
|
||||||
|
public int fontSize { get; set; }
|
||||||
|
[Obsolete("Use Tooltip.textStyle.fontStyle instead.", true)]
|
||||||
|
public FontStyle fontStyle { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font size.
|
/// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
/// 文字的字体大小。
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
public bool forceENotation { get { return m_ForceENotation; } set { m_ForceENotation = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font style.
|
/// the text padding of left and right. defaut:5.
|
||||||
/// 文字的字体风格。
|
/// 左右边距。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
public float paddingLeftRight { get { return m_PaddingLeftRight; } set { m_PaddingLeftRight = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// the text padding of top and bottom. defaut:5.
|
||||||
|
/// 上下边距。
|
||||||
|
/// </summary>
|
||||||
|
public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 被忽略数据的默认显示字符信息。
|
||||||
|
/// </summary>
|
||||||
|
public string ignoreDataDefaultContent { get { return m_IgnoreDataDefaultContent; } set { m_IgnoreDataDefaultContent = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// The image of icon.
|
||||||
|
/// 图标的图片。
|
||||||
|
/// </summary>
|
||||||
|
public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetBackground(m_BackgroundImage); } }
|
||||||
|
/// <summary>
|
||||||
|
/// 提示框内容文本样式。
|
||||||
|
/// </summary>
|
||||||
|
public TextStyle textStyle
|
||||||
|
{
|
||||||
|
get { return m_TextStyle; }
|
||||||
|
set { if (value != null) { m_TextStyle = value; SetComponentDirty(); } }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 指示线样式。
|
||||||
|
/// </summary>
|
||||||
|
public LineStyle lineStyle
|
||||||
|
{
|
||||||
|
get { return m_LineStyle; }
|
||||||
|
set { if (value != null) m_LineStyle = value; SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 组件是否需要刷新
|
||||||
|
/// </summary>
|
||||||
|
public override bool componentDirty
|
||||||
|
{
|
||||||
|
get { return m_ComponentDirty || lineStyle.componentDirty || textStyle.componentDirty; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
base.ClearComponentDirty();
|
||||||
|
lineStyle.ClearComponentDirty();
|
||||||
|
textStyle.ClearComponentDirty();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The data index currently indicated by Tooltip.
|
/// The data index currently indicated by Tooltip.
|
||||||
/// 当前提示框所指示的数据项索引。
|
/// 当前提示框所指示的数据项索引。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<int> dataIndex { get; set; }
|
public List<int> runtimeDataIndex { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the value for x indicator label.
|
/// the value for x indicator label.
|
||||||
/// 指示器X轴上要显示的值。
|
/// 指示器X轴上要显示的值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float[] xValues { get; set; }
|
public float[] runtimeXValues { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the value for y indicator label.
|
/// the value for y indicator label.
|
||||||
/// 指示器Y轴上要显示的值。
|
/// 指示器Y轴上要显示的值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float[] yValues { get; set; }
|
public float[] runtimeYValues { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the current pointer position.
|
/// the current pointer position.
|
||||||
/// 当前鼠标位置。
|
/// 当前鼠标位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 pointerPos { get; set; }
|
public Vector2 runtimePointerPos { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the width of tooltip.
|
/// the width of tooltip.
|
||||||
/// 提示框宽。
|
/// 提示框宽。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float width { get { return m_ContentRect.sizeDelta.x; } }
|
public float runtimeWidth { get { return m_ContentRect.sizeDelta.x; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the height of tooltip.
|
/// the height of tooltip.
|
||||||
/// 提示框高。
|
/// 提示框高。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float height { get { return m_ContentRect.sizeDelta.y; } }
|
public float runtimeHeight { get { return m_ContentRect.sizeDelta.y; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the tooltip has been initialized.
|
/// Whether the tooltip has been initialized.
|
||||||
/// 提示框是否已初始化。
|
/// 提示框是否已初始化。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool inited { get { return m_GameObject != null; } }
|
public bool runtimeInited { get { return m_GameObject != null; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the gameObject of tooltip.
|
/// the gameObject of tooltip.
|
||||||
/// 提示框的gameObject。
|
/// 提示框的gameObject。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GameObject gameObject { get { return m_GameObject; } }
|
public GameObject runtimeGameObject { get { return m_GameObject; } }
|
||||||
|
|
||||||
public static Tooltip defaultTooltip
|
public static Tooltip defaultTooltip
|
||||||
{
|
{
|
||||||
@@ -163,9 +255,9 @@ namespace XCharts
|
|||||||
var tooltip = new Tooltip
|
var tooltip = new Tooltip
|
||||||
{
|
{
|
||||||
m_Show = true,
|
m_Show = true,
|
||||||
xValues = new float[2] { -1, -1 },
|
runtimeXValues = new float[2] { -1, -1 },
|
||||||
yValues = new float[2] { -1, -1 },
|
runtimeYValues = new float[2] { -1, -1 },
|
||||||
dataIndex = new List<int>() { -1, -1 },
|
runtimeDataIndex = new List<int>() { -1, -1 },
|
||||||
lastDataIndex = new List<int>() { -1, -1 }
|
lastDataIndex = new List<int>() { -1, -1 }
|
||||||
};
|
};
|
||||||
return tooltip;
|
return tooltip;
|
||||||
@@ -190,7 +282,13 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_Content = content;
|
m_Content = content;
|
||||||
m_ContentRect = m_Content.GetComponent<RectTransform>();
|
m_ContentRect = m_Content.GetComponent<RectTransform>();
|
||||||
|
m_ContentImage = m_Content.GetComponent<Image>();
|
||||||
m_ContentText = m_Content.GetComponentInChildren<Text>();
|
m_ContentText = m_Content.GetComponentInChildren<Text>();
|
||||||
|
if (m_ContentText != null)
|
||||||
|
{
|
||||||
|
m_ContentTextRect = m_ContentText.gameObject.GetComponentInChildren<RectTransform>();
|
||||||
|
}
|
||||||
|
SetBackground(backgroundImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -209,7 +307,21 @@ namespace XCharts
|
|||||||
/// <param name="color"></param>
|
/// <param name="color"></param>
|
||||||
public void SetContentBackgroundColor(Color color)
|
public void SetContentBackgroundColor(Color color)
|
||||||
{
|
{
|
||||||
m_Content.GetComponent<Image>().color = color;
|
if (m_ContentImage != null)
|
||||||
|
m_ContentImage.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置提示框文本背景图片
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sprite"></param>
|
||||||
|
public void SetBackground(Sprite sprite)
|
||||||
|
{
|
||||||
|
if (m_ContentImage != null)
|
||||||
|
{
|
||||||
|
m_ContentImage.type = Image.Type.Sliced;
|
||||||
|
m_ContentImage.sprite = sprite;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -236,22 +348,26 @@ namespace XCharts
|
|||||||
float wid, hig;
|
float wid, hig;
|
||||||
if (m_FixedWidth > 0) wid = m_FixedWidth;
|
if (m_FixedWidth > 0) wid = m_FixedWidth;
|
||||||
else if (m_MinWidth > 0 && m_ContentText.preferredWidth < m_MinWidth) wid = m_MinWidth;
|
else if (m_MinWidth > 0 && m_ContentText.preferredWidth < m_MinWidth) wid = m_MinWidth;
|
||||||
else wid = m_ContentText.preferredWidth + 8;
|
else wid = m_ContentText.preferredWidth + m_PaddingLeftRight * 2;
|
||||||
if (m_FixedHeight > 0) hig = m_FixedHeight;
|
if (m_FixedHeight > 0) hig = m_FixedHeight;
|
||||||
else if (m_MinHeight > 0 && m_ContentText.preferredHeight < m_MinHeight) hig = m_MinHeight;
|
else if (m_MinHeight > 0 && m_ContentText.preferredHeight < m_MinHeight) hig = m_MinHeight;
|
||||||
else hig = m_ContentText.preferredHeight + 8;
|
else hig = m_ContentText.preferredHeight + m_PaddingTopBottom * 2;
|
||||||
m_ContentRect.sizeDelta = new Vector2(wid, hig);
|
if (m_ContentRect != null) m_ContentRect.sizeDelta = new Vector2(wid, hig);
|
||||||
|
if (m_ContentTextRect != null)
|
||||||
|
{
|
||||||
|
m_ContentTextRect.anchoredPosition = new Vector3(m_PaddingLeftRight, -m_PaddingTopBottom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清除提示框指示数据
|
/// 清除提示框指示数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearValue()
|
internal void ClearValue()
|
||||||
{
|
{
|
||||||
dataIndex[0] = dataIndex[1] = -1;
|
runtimeDataIndex[0] = runtimeDataIndex[1] = -1;
|
||||||
xValues[0] = xValues[1] = -1;
|
runtimeXValues[0] = runtimeXValues[1] = -1;
|
||||||
yValues[0] = yValues[1] = -1;
|
runtimeYValues[0] = runtimeYValues[1] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -303,17 +419,17 @@ namespace XCharts
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsDataIndexChanged()
|
public bool IsDataIndexChanged()
|
||||||
{
|
{
|
||||||
return dataIndex[0] != lastDataIndex[0] ||
|
return runtimeDataIndex[0] != lastDataIndex[0] ||
|
||||||
dataIndex[1] != lastDataIndex[1];
|
runtimeDataIndex[1] != lastDataIndex[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前索引缓存
|
/// 当前索引缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateLastDataIndex()
|
internal void UpdateLastDataIndex()
|
||||||
{
|
{
|
||||||
lastDataIndex[0] = dataIndex[0];
|
lastDataIndex[0] = runtimeDataIndex[0];
|
||||||
lastDataIndex[1] = dataIndex[1];
|
lastDataIndex[1] = runtimeDataIndex[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -322,7 +438,7 @@ namespace XCharts
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsSelected()
|
public bool IsSelected()
|
||||||
{
|
{
|
||||||
return dataIndex[0] >= 0 || dataIndex[1] >= 0;
|
return runtimeDataIndex[0] >= 0 || runtimeDataIndex[1] >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -332,14 +448,72 @@ namespace XCharts
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsSelected(int index)
|
public bool IsSelected(int index)
|
||||||
{
|
{
|
||||||
return dataIndex[0] == index || dataIndex[1] == index;
|
return runtimeDataIndex[0] == index || runtimeDataIndex[1] == index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatterContent(int dataIndex, Series series, string category, DataZoom dataZoom = null)
|
public bool IsNoFormatter()
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(m_Formatter) && string.IsNullOrEmpty(m_ItemFormatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string GetFormatterContent(int dataIndex, Series series, string category, ThemeInfo themeInfo = null, DataZoom dataZoom = null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(m_Formatter))
|
if (string.IsNullOrEmpty(m_Formatter))
|
||||||
{
|
{
|
||||||
return "";
|
if (string.IsNullOrEmpty(m_ItemFormatter)) return "";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var sb = ChartHelper.sb;
|
||||||
|
var title = m_TitleFormatter;
|
||||||
|
var formatTitle = !string.IsNullOrEmpty(title);
|
||||||
|
var needCategory = false;
|
||||||
|
var first = true;
|
||||||
|
sb.Length = 0;
|
||||||
|
for (int i = 0; i < series.Count; i++)
|
||||||
|
{
|
||||||
|
var serie = series.GetSerie(i);
|
||||||
|
var serieData = serie.GetSerieData(dataIndex, dataZoom);
|
||||||
|
var percent = serieData.GetData(1) / serie.yTotal * 100;
|
||||||
|
needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar);
|
||||||
|
if (serie.show)
|
||||||
|
{
|
||||||
|
string content = m_ItemFormatter;
|
||||||
|
content = content.Replace("{a}", serie.name);
|
||||||
|
content = content.Replace("{b}", needCategory ? category : serieData.name);
|
||||||
|
content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation));
|
||||||
|
content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1));
|
||||||
|
if (!first) sb.Append("\n");
|
||||||
|
sb.Append("<color=#").Append(themeInfo.GetColorStr(i)).Append(">● </color>");
|
||||||
|
sb.Append(content);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
if (formatTitle)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
title = title.Replace("{a}", serie.name);
|
||||||
|
title = title.Replace("{b}", needCategory ? category : serieData.name);
|
||||||
|
title = title.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation));
|
||||||
|
title = title.Replace("{d}", ChartCached.FloatToStr(percent, 1));
|
||||||
|
}
|
||||||
|
title = title.Replace("{a" + i + "}", serie.name);
|
||||||
|
title = title.Replace("{b" + i + "}", needCategory ? category : serieData.name);
|
||||||
|
title = title.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation));
|
||||||
|
title = title.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
if (needCategory) return category + "\n" + sb.ToString();
|
||||||
|
else return sb.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
title = title.Replace("\\n", "\n");
|
||||||
|
title = title.Replace("<br/>", "\n");
|
||||||
|
return title + "\n" + sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -351,25 +525,18 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar;
|
var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar;
|
||||||
var serieData = serie.GetSerieData(dataIndex, dataZoom);
|
var serieData = serie.GetSerieData(dataIndex, dataZoom);
|
||||||
|
var percent = serieData.GetData(1) / serie.yTotal * 100;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
content = content.Replace("{a}", serie.name);
|
content = content.Replace("{a}", serie.name);
|
||||||
content = content.Replace("{b}", needCategory ? category : serieData.name);
|
content = content.Replace("{b}", needCategory ? category : serieData.name);
|
||||||
content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1)));
|
content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation));
|
||||||
//if (serie.type == SerieType.Pie)
|
content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1));
|
||||||
{
|
|
||||||
var percent = serieData.GetData(1) / serie.yTotal * 100;
|
|
||||||
content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
content = content.Replace("{a" + i + "}", serie.name);
|
content = content.Replace("{a" + i + "}", serie.name);
|
||||||
content = content.Replace("{b" + i + "}", needCategory ? category : serieData.name);
|
content = content.Replace("{b" + i + "}", needCategory ? category : serieData.name);
|
||||||
content = content.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1)));
|
content = content.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation));
|
||||||
//if (serie.type == SerieType.Pie)
|
content = content.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1));
|
||||||
{
|
|
||||||
var percent = serieData.GetData(1) / serie.yTotal * 100;
|
|
||||||
content = content.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content = content.Replace("\\n", "\n");
|
content = content.Replace("\\n", "\n");
|
||||||
@@ -378,19 +545,35 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatterContent(string serieName, string dataName, float dataValue)
|
internal string GetFormatterContent(string serieName, string dataName, float dataValue)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(m_Formatter))
|
if (string.IsNullOrEmpty(m_Formatter))
|
||||||
return ChartCached.FloatToStr(dataValue);
|
return ChartCached.FloatToStr(dataValue, 0, m_ForceENotation);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var content = m_Formatter.Replace("{a}", serieName);
|
var content = m_Formatter.Replace("{a}", serieName);
|
||||||
content = content.Replace("{b}", dataName);
|
content = content.Replace("{b}", dataName);
|
||||||
content = content.Replace("{c}", ChartCached.FloatToStr(dataValue));
|
content = content.Replace("{c}", ChartCached.FloatToStr(dataValue, 0, m_ForceENotation));
|
||||||
content = content.Replace("\\n", "\n");
|
content = content.Replace("\\n", "\n");
|
||||||
content = content.Replace("<br/>", "\n");
|
content = content.Replace("<br/>", "\n");
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal Color GetLineColor(ThemeInfo theme)
|
||||||
|
{
|
||||||
|
if (lineStyle.color != Color.clear)
|
||||||
|
{
|
||||||
|
var color = lineStyle.color;
|
||||||
|
color.a *= lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var color = (Color)theme.tooltipLineColor;
|
||||||
|
color.a *= lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,27 +73,51 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否开启组件功能。
|
/// 是否开启组件功能。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
|
public bool enable
|
||||||
|
{
|
||||||
|
get { return m_Enable; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示组件。如果设置为 false,不会显示,但是数据映射的功能还存在。
|
/// 是否显示组件。如果设置为 false,不会显示,但是数据映射的功能还存在。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组件类型。
|
/// 组件类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
public Type type
|
||||||
|
{
|
||||||
|
get { return m_Type; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 选择模式。
|
/// 选择模式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SelectedMode selectedMode { get { return m_SelectedMode; } set { m_SelectedMode = value; } }
|
public SelectedMode selectedMode
|
||||||
|
{
|
||||||
|
get { return m_SelectedMode; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 允许的最小值。'min' 必须用户指定。[visualMap.min, visualMap.max] 形成了视觉映射的『定义域』。
|
/// 允许的最小值。'min' 必须用户指定。[visualMap.min, visualMap.max] 形成了视觉映射的『定义域』。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float min { get { return m_Min; } set { m_Min = value; } }
|
public float min
|
||||||
|
{
|
||||||
|
get { return m_Min; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 允许的最大值。'max' 必须用户指定。[visualMap.min, visualMax.max] 形成了视觉映射的『定义域』。
|
/// 允许的最大值。'max' 必须用户指定。[visualMap.min, visualMax.max] 形成了视觉映射的『定义域』。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float max { get { return m_Max; } set { m_Max = value < min ? min + 1 : value; } }
|
public float max
|
||||||
|
{
|
||||||
|
get { return m_Max; }
|
||||||
|
set { m_Max = value < min ? min + 1 : value; SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指定手柄对应数值的位置。range 应在 min max 范围内。
|
/// 指定手柄对应数值的位置。range 应在 min max 范围内。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -110,68 +134,129 @@ namespace XCharts
|
|||||||
/// 对于连续型数据,自动平均切分成几段,默认为0时自动匹配inRange颜色列表大小。
|
/// 对于连续型数据,自动平均切分成几段,默认为0时自动匹配inRange颜色列表大小。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
public int splitNumber
|
||||||
|
{
|
||||||
|
get { return m_SplitNumber; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示拖拽用的手柄(手柄能拖拽调整选中范围)。
|
/// 是否显示拖拽用的手柄(手柄能拖拽调整选中范围)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool calculable { get { return m_Calculable; } set { m_Calculable = value; } }
|
public bool calculable
|
||||||
|
{
|
||||||
|
get { return m_Calculable; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拖拽时,是否实时更新。
|
/// 拖拽时,是否实时更新。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool realtime { get { return m_Realtime; } set { m_Realtime = value; } }
|
public bool realtime
|
||||||
|
{
|
||||||
|
get { return m_Realtime; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图形的宽度,即颜色条的宽度。
|
/// 图形的宽度,即颜色条的宽度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float itemWidth { get { return m_ItemWidth; } set { m_ItemWidth = value; } }
|
public float itemWidth
|
||||||
|
{
|
||||||
|
get { return m_ItemWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图形的高度,即颜色条的高度。
|
/// 图形的高度,即颜色条的高度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float itemHeight { get { return m_ItemHeight; } set { m_ItemHeight = value; } }
|
public float itemHeight
|
||||||
|
{
|
||||||
|
get { return m_ItemHeight; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 边框线宽,单位px。
|
/// 边框线宽,单位px。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float borderWidth { get { return m_BorderWidth; } set { m_BorderWidth = value; } }
|
public float borderWidth
|
||||||
|
{
|
||||||
|
get { return m_BorderWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指定用数据的『哪个维度』,映射到视觉元素上。『数据』即 series.data。从1开始,默认为0取 data 中最后一个维度。
|
/// 指定用数据的『哪个维度』,映射到视觉元素上。『数据』即 series.data。从1开始,默认为0取 data 中最后一个维度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int dimension { get { return m_Dimension; } set { m_Dimension = value; } }
|
public int dimension
|
||||||
|
{
|
||||||
|
get { return m_Dimension; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打开 hoverLink 功能时,鼠标悬浮到 visualMap 组件上时,鼠标位置对应的数值 在 图表中对应的图形元素,会高亮。
|
/// 打开 hoverLink 功能时,鼠标悬浮到 visualMap 组件上时,鼠标位置对应的数值 在 图表中对应的图形元素,会高亮。
|
||||||
/// 反之,鼠标悬浮到图表中的图形元素上时,在 visualMap 组件的相应位置会有三角提示其所对应的数值。
|
/// 反之,鼠标悬浮到图表中的图形元素上时,在 visualMap 组件的相应位置会有三角提示其所对应的数值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public bool hoverLink { get { return m_HoverLink; } set { m_HoverLink = value; } }
|
public bool hoverLink
|
||||||
|
{
|
||||||
|
get { return m_HoverLink; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify whether the layout of component is horizontal or vertical.
|
/// Specify whether the layout of component is horizontal or vertical.
|
||||||
/// 布局方式是横还是竖。
|
/// 布局方式是横还是竖。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Orient orient { get { return m_Orient; } set { m_Orient = value; } }
|
public Orient orient
|
||||||
|
{
|
||||||
|
get { return m_Orient; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The location of component.
|
/// The location of component.
|
||||||
/// 组件显示的位置。
|
/// 组件显示的位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Location location { get { return m_Location; } set { m_Location = value; } }
|
public Location location
|
||||||
|
{
|
||||||
|
get { return m_Location; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 定义 在选中范围中 的视觉颜色。
|
/// 定义 在选中范围中 的视觉颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Color> inRange { get { return m_InRange; } set { if (value != null) m_InRange = value; } }
|
public List<Color> inRange
|
||||||
|
{
|
||||||
|
get { return m_InRange; }
|
||||||
|
set { if (value != null) { m_InRange = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 定义 在选中范围外 的视觉颜色。
|
/// 定义 在选中范围外 的视觉颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Color> outOfRange { get { return m_OutOfRange; } set { if (value != null) m_OutOfRange = value; } }
|
public List<Color> outOfRange
|
||||||
|
{
|
||||||
|
get { return m_OutOfRange; }
|
||||||
|
set { if (value != null) { m_OutOfRange = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool vertsDirty { get { return m_VertsDirty || location.anyDirty; } }
|
||||||
|
internal override void ClearVerticesDirty()
|
||||||
|
{
|
||||||
|
base.ClearVerticesDirty();
|
||||||
|
location.ClearVerticesDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
base.ClearComponentDirty();
|
||||||
|
location.ClearComponentDirty();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 鼠标悬停选中的index
|
/// 鼠标悬停选中的index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public int rtSelectedIndex { get; set; }
|
public int runtimeSelectedIndex { get; internal set; }
|
||||||
public float rtSelectedValue { get; set; }
|
public float runtimeSelectedValue { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the current pointer position.
|
/// the current pointer position.
|
||||||
/// 当前鼠标位置。
|
/// 当前鼠标位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 pointerPos { get; set; }
|
public Vector2 runtimePointerPos { get; internal set; }
|
||||||
public bool isVertical { get { return orient == Orient.Vertical; } }
|
public bool runtimeIsVertical { get { return orient == Orient.Vertical; } }
|
||||||
public float rangeMin
|
public float rangeMin
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -198,7 +283,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int rtSplitNumber
|
public int runtimeSplitNumber
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -207,18 +292,18 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float rangeMinHeight { get { return (rangeMin - min) / (max - min) * itemHeight; } }
|
public float runtimeRangeMinHeight { get { return (rangeMin - min) / (max - min) * itemHeight; } }
|
||||||
public float rangeMaxHeight { get { return (rangeMax - min) / (max - min) * itemHeight; } }
|
public float runtimeRangeMaxHeight { get { return (rangeMax - min) / (max - min) * itemHeight; } }
|
||||||
|
|
||||||
private List<Color> m_RtInRange = new List<Color>();
|
private List<Color> m_RtInRange = new List<Color>();
|
||||||
public List<Color> rtInRange
|
public List<Color> runtimeInRange
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (splitNumber == 0 || m_InRange.Count >= splitNumber || m_InRange.Count < 1) return m_InRange;
|
if (splitNumber == 0 || m_InRange.Count >= splitNumber || m_InRange.Count < 1) return m_InRange;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_RtInRange.Count != rtSplitNumber)
|
if (m_RtInRange.Count != runtimeSplitNumber)
|
||||||
{
|
{
|
||||||
m_RtInRange.Clear();
|
m_RtInRange.Clear();
|
||||||
var total = max - min;
|
var total = max - min;
|
||||||
@@ -256,7 +341,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public Color GetColor(float value)
|
public Color GetColor(float value)
|
||||||
{
|
{
|
||||||
int splitNumber = rtInRange.Count;
|
int splitNumber = runtimeInRange.Count;
|
||||||
if (splitNumber <= 0) return Color.clear;
|
if (splitNumber <= 0) return Color.clear;
|
||||||
value = Mathf.Clamp(value, min, max);
|
value = Mathf.Clamp(value, min, max);
|
||||||
|
|
||||||
@@ -264,13 +349,13 @@ namespace XCharts
|
|||||||
var index = GetIndex(value);
|
var index = GetIndex(value);
|
||||||
var nowMin = min + index * diff;
|
var nowMin = min + index * diff;
|
||||||
var rate = (value - nowMin) / diff;
|
var rate = (value - nowMin) / diff;
|
||||||
if (index == splitNumber - 1) return rtInRange[index];
|
if (index == splitNumber - 1) return runtimeInRange[index];
|
||||||
else return Color.Lerp(rtInRange[index], rtInRange[index + 1], rate);
|
else return Color.Lerp(runtimeInRange[index], runtimeInRange[index + 1], rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetIndex(float value)
|
public int GetIndex(float value)
|
||||||
{
|
{
|
||||||
int splitNumber = rtInRange.Count;
|
int splitNumber = runtimeInRange.Count;
|
||||||
if (splitNumber <= 0) return -1;
|
if (splitNumber <= 0) return -1;
|
||||||
value = Mathf.Clamp(value, min, max);
|
value = Mathf.Clamp(value, min, max);
|
||||||
|
|
||||||
@@ -289,19 +374,19 @@ namespace XCharts
|
|||||||
|
|
||||||
public bool IsInSelectedValue(float value)
|
public bool IsInSelectedValue(float value)
|
||||||
{
|
{
|
||||||
if (rtSelectedIndex < 0) return true;
|
if (runtimeSelectedIndex < 0) return true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return rtSelectedIndex == GetIndex(value);
|
return runtimeSelectedIndex == GetIndex(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetValue(Vector3 pos, float chartWidth, float chartHeight)
|
public float GetValue(Vector3 pos, float chartWidth, float chartHeight)
|
||||||
{
|
{
|
||||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
||||||
var pos1 = centerPos + (isVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
|
var pos1 = centerPos + (runtimeIsVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
|
||||||
var pos2 = centerPos + (isVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
|
var pos2 = centerPos + (runtimeIsVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
|
||||||
if (isVertical)
|
if (runtimeIsVertical)
|
||||||
{
|
{
|
||||||
if (pos.y < pos1.y) return min;
|
if (pos.y < pos1.y) return min;
|
||||||
else if (pos.y > pos2.y) return max;
|
else if (pos.y > pos2.y) return max;
|
||||||
@@ -337,12 +422,12 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
||||||
return local.x >= centerPos.x - itemWidth / 2 && local.x <= centerPos.x + itemWidth / 2 &&
|
return local.x >= centerPos.x - itemWidth / 2 && local.x <= centerPos.x + itemWidth / 2 &&
|
||||||
local.y >= pos1.y + rangeMinHeight && local.y <= pos1.y + rangeMaxHeight;
|
local.y >= pos1.y + runtimeRangeMinHeight && local.y <= pos1.y + runtimeRangeMaxHeight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var pos1 = centerPos + Vector3.left * itemHeight / 2;
|
var pos1 = centerPos + Vector3.left * itemHeight / 2;
|
||||||
return local.x >= pos1.x + rangeMinHeight && local.x <= pos1.x + rangeMaxHeight &&
|
return local.x >= pos1.x + runtimeRangeMinHeight && local.x <= pos1.x + runtimeRangeMaxHeight &&
|
||||||
local.y >= centerPos.y - itemWidth / 2 && local.y <= centerPos.y + itemWidth / 2;
|
local.y >= centerPos.y - itemWidth / 2 && local.y <= centerPos.y + itemWidth / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,7 +439,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var radius = triangleLen / 2;
|
var radius = triangleLen / 2;
|
||||||
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
||||||
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + rangeMinHeight - radius);
|
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMinHeight - radius);
|
||||||
|
|
||||||
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
||||||
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
||||||
@@ -363,7 +448,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var radius = triangleLen / 2;
|
var radius = triangleLen / 2;
|
||||||
var pos1 = centerPos + Vector3.left * itemHeight / 2;
|
var pos1 = centerPos + Vector3.left * itemHeight / 2;
|
||||||
var cpos = new Vector3(pos1.x + rangeMinHeight, pos1.y + itemWidth / 2 + radius);
|
var cpos = new Vector3(pos1.x + runtimeRangeMinHeight, pos1.y + itemWidth / 2 + radius);
|
||||||
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
||||||
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
||||||
}
|
}
|
||||||
@@ -376,7 +461,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var radius = triangleLen / 2;
|
var radius = triangleLen / 2;
|
||||||
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
||||||
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + rangeMaxHeight + radius);
|
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMaxHeight + radius);
|
||||||
|
|
||||||
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
||||||
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
||||||
@@ -385,7 +470,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var radius = triangleLen / 2;
|
var radius = triangleLen / 2;
|
||||||
var pos1 = centerPos + Vector3.left * itemHeight / 2;
|
var pos1 = centerPos + Vector3.left * itemHeight / 2;
|
||||||
var cpos = new Vector3(pos1.x + rangeMaxHeight + radius, pos1.y + itemWidth / 2 + radius);
|
var cpos = new Vector3(pos1.x + runtimeRangeMaxHeight + radius, pos1.y + itemWidth / 2 + radius);
|
||||||
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
return local.x >= cpos.x - radius && local.x <= cpos.x + radius &&
|
||||||
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
local.y >= cpos.y - radius && local.y <= cpos.y + radius;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace XCharts
|
|||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Grid : MainComponent, IEquatable<Grid>
|
public class Grid : MainComponent
|
||||||
{
|
{
|
||||||
[SerializeField] private bool m_Show = true;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private float m_Left;
|
[SerializeField] private float m_Left;
|
||||||
@@ -35,32 +35,56 @@ namespace XCharts
|
|||||||
/// Whether to show the grid in rectangular coordinate.
|
/// Whether to show the grid in rectangular coordinate.
|
||||||
/// 是否显示直角坐标系网格。
|
/// 是否显示直角坐标系网格。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between grid component and the left side of the container.
|
/// Distance between grid component and the left side of the container.
|
||||||
/// grid 组件离容器左侧的距离。
|
/// grid 组件离容器左侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float left { get { return m_Left; } set { m_Left = value; } }
|
public float left
|
||||||
|
{
|
||||||
|
get { return m_Left; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Left, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between grid component and the right side of the container.
|
/// Distance between grid component and the right side of the container.
|
||||||
/// grid 组件离容器右侧的距离。
|
/// grid 组件离容器右侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float right { get { return m_Right; } set { m_Right = value; } }
|
public float right
|
||||||
|
{
|
||||||
|
get { return m_Right; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Right, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between grid component and the top side of the container.
|
/// Distance between grid component and the top side of the container.
|
||||||
/// grid 组件离容器上侧的距离。
|
/// grid 组件离容器上侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float top { get { return m_Top; } set { m_Top = value; } }
|
public float top
|
||||||
|
{
|
||||||
|
get { return m_Top; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Top, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between grid component and the bottom side of the container.
|
/// Distance between grid component and the bottom side of the container.
|
||||||
/// grid 组件离容器下侧的距离。
|
/// grid 组件离容器下侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
public float bottom
|
||||||
|
{
|
||||||
|
get { return m_Bottom; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Background color of grid, which is transparent by default.
|
/// Background color of grid, which is transparent by default.
|
||||||
/// 网格背景色,默认透明。
|
/// 网格背景色,默认透明。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
|
public Color backgroundColor
|
||||||
|
{
|
||||||
|
get { return m_BackgroundColor; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
public static Grid defaultGrid
|
public static Grid defaultGrid
|
||||||
{
|
{
|
||||||
@@ -77,67 +101,5 @@ namespace XCharts
|
|||||||
return coordinate;
|
return coordinate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Copy(Grid other)
|
|
||||||
{
|
|
||||||
m_Show = other.show;
|
|
||||||
m_Left = other.left;
|
|
||||||
m_Right = other.right;
|
|
||||||
m_Top = other.top;
|
|
||||||
m_Bottom = other.bottom;
|
|
||||||
m_BackgroundColor = other.backgroundColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is Grid)
|
|
||||||
{
|
|
||||||
return Equals((Grid)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Grid other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return m_Show == other.show &&
|
|
||||||
m_Left == other.left &&
|
|
||||||
m_Right == other.right &&
|
|
||||||
m_Top == other.top &&
|
|
||||||
m_Bottom == other.bottom &&
|
|
||||||
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.backgroundColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Grid left, Grid right)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Grid left, Grid right)
|
|
||||||
{
|
|
||||||
return !(left == right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
11
Assets/XCharts/Runtime/Component/Main/XGrid.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Main/XGrid.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 17af60587e8a04a44a1e166cff567af8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -52,41 +52,73 @@ namespace XCharts
|
|||||||
/// Set this to false to prevent the areafrom showing.
|
/// Set this to false to prevent the areafrom showing.
|
||||||
/// 是否显示区域填充。
|
/// 是否显示区域填充。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the origin of area.
|
/// the origin of area.
|
||||||
/// 区域填充的起始位置。
|
/// 区域填充的起始位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AreaOrigin origin { get { return m_Origin; } set { m_Origin = value; } }
|
public AreaOrigin origin
|
||||||
|
{
|
||||||
|
get { return m_Origin; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of area,default use serie color.
|
/// the color of area,default use serie color.
|
||||||
/// 区域填充的颜色,如果toColor不是默认值,则表示渐变色的起点颜色。
|
/// 区域填充的颜色,如果toColor不是默认值,则表示渐变色的起点颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
public Color color
|
||||||
|
{
|
||||||
|
get { return m_Color; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gradient color, start color to toColor.
|
/// Gradient color, start color to toColor.
|
||||||
/// 渐变色的终点颜色。
|
/// 渐变色的终点颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color toColor { get { return m_ToColor; } set { m_ToColor = value; } }
|
public Color toColor
|
||||||
|
{
|
||||||
|
get { return m_ToColor; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
||||||
/// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
/// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
public float opacity
|
||||||
|
{
|
||||||
|
get { return m_Opacity; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 鼠标悬浮时是否高亮之前的区域
|
/// 鼠标悬浮时是否高亮之前的区域
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool tooltipHighlight { get { return m_TooltipHighlight; } set { m_TooltipHighlight = value; } }
|
public bool tooltipHighlight
|
||||||
|
{
|
||||||
|
get { return m_TooltipHighlight; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_TooltipHighlight, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of area,default use serie color.
|
/// the color of area,default use serie color.
|
||||||
/// 高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。
|
/// 高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color highlightColor { get { return m_HighlightColor; } set { m_HighlightColor = value; } }
|
public Color highlightColor
|
||||||
|
{
|
||||||
|
get { return m_HighlightColor; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gradient color, start highlightColor to highlightToColor.
|
/// Gradient color, start highlightColor to highlightToColor.
|
||||||
/// 高亮时渐变色的终点颜色。
|
/// 高亮时渐变色的终点颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color highlightToColor { get { return m_HighlightToColor; } set { m_HighlightToColor = value; } }
|
public Color highlightToColor
|
||||||
|
{
|
||||||
|
get { return m_HighlightToColor; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
public static AreaStyle defaultAreaStyle
|
public static AreaStyle defaultAreaStyle
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
@@ -26,52 +27,113 @@ namespace XCharts
|
|||||||
[SerializeField] private Color m_Color;
|
[SerializeField] private Color m_Color;
|
||||||
[SerializeField] private int m_FontSize;
|
[SerializeField] private int m_FontSize;
|
||||||
[SerializeField] private FontStyle m_FontStyle;
|
[SerializeField] private FontStyle m_FontStyle;
|
||||||
|
[SerializeField] private bool m_ForceENotation = false;
|
||||||
|
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this to false to prevent the axis label from appearing.
|
/// Set this to false to prevent the axis label from appearing.
|
||||||
/// 是否显示刻度标签。
|
/// 是否显示刻度标签。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The display interval of the axis label.
|
/// The display interval of the axis label.
|
||||||
/// 坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
/// 坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int interval { get { return m_Interval; } set { m_Interval = value; } }
|
public int interval
|
||||||
|
{
|
||||||
|
get { return m_Interval; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this to true so the axis labels face the inside direction.
|
/// Set this to true so the axis labels face the inside direction.
|
||||||
/// 刻度标签是否朝内,默认朝外。
|
/// 刻度标签是否朝内,默认朝外。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool inside { get { return m_Inside; } set { m_Inside = value; } }
|
public bool inside
|
||||||
|
{
|
||||||
|
get { return m_Inside; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rotation degree of axis label, which is especially useful when there is no enough space for category axis.
|
/// Rotation degree of axis label, which is especially useful when there is no enough space for category axis.
|
||||||
/// 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠。
|
/// 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
public float rotate
|
||||||
|
{
|
||||||
|
get { return m_Rotate; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The margin between the axis label and the axis line.
|
/// The margin between the axis label and the axis line.
|
||||||
/// 刻度标签与轴线之间的距离。
|
/// 刻度标签与轴线之间的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float margin { get { return m_Margin; } set { m_Margin = value; } }
|
public float margin
|
||||||
|
{
|
||||||
|
get { return m_Margin; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of axis label text.
|
/// the color of axis label text.
|
||||||
/// 刻度标签文字的颜色,默认取Theme的axisTextColor。
|
/// 刻度标签文字的颜色,默认取Theme的axisTextColor。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
public Color color
|
||||||
|
{
|
||||||
|
get { return m_Color; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font size.
|
/// font size.
|
||||||
/// 文字的字体大小。
|
/// 文字的字体大小。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
public int fontSize
|
||||||
|
{
|
||||||
|
get { return m_FontSize; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font style.
|
/// font style.
|
||||||
/// 文字字体的风格。
|
/// 文字字体的风格。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
public FontStyle fontStyle
|
||||||
|
{
|
||||||
|
get { return m_FontStyle; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图例内容字符串模版格式器。支持用 \n 换行。
|
/// 图例内容字符串模版格式器。支持用 \n 换行。
|
||||||
/// 模板变量为图例名称 {value},{value:f1} 表示取1为小数
|
/// 模板变量为图例名称 {value},支持{value:f0},{value:f1},{value:f2}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
|
public string formatter
|
||||||
|
{
|
||||||
|
get { return m_Formatter; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
/// </summary>
|
||||||
|
public bool forceENotation
|
||||||
|
{
|
||||||
|
get { return m_ForceENotation; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ForceENotation, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 文本限制。
|
||||||
|
/// </summary>
|
||||||
|
public TextLimit textLimit
|
||||||
|
{
|
||||||
|
get { return m_TextLimit; }
|
||||||
|
set { if (value != null) { m_TextLimit = value; SetComponentDirty(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool componentDirty { get { return m_ComponentDirty || m_TextLimit.componentDirty; } }
|
||||||
|
internal override void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
base.ClearComponentDirty();
|
||||||
|
textLimit.ClearComponentDirty();
|
||||||
|
}
|
||||||
|
|
||||||
public static AxisLabel defaultAxisLabel
|
public static AxisLabel defaultAxisLabel
|
||||||
{
|
{
|
||||||
@@ -90,65 +152,57 @@ namespace XCharts
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Copy(AxisLabel other)
|
|
||||||
{
|
|
||||||
m_Show = other.show;
|
|
||||||
m_Interval = other.interval;
|
|
||||||
m_Inside = other.inside;
|
|
||||||
m_Rotate = other.rotate;
|
|
||||||
m_Margin = other.margin;
|
|
||||||
m_Color = other.color;
|
|
||||||
m_FontSize = other.fontSize;
|
|
||||||
m_FontStyle = other.fontStyle;
|
|
||||||
m_Formatter = other.formatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public void SetRelatedText(Text txt, float labelWidth)
|
||||||
{
|
{
|
||||||
if (obj == null || GetType() != obj.GetType())
|
m_TextLimit.SetRelatedText(txt, labelWidth);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var other = (AxisLabel)obj;
|
|
||||||
return m_Show == other.show &&
|
|
||||||
m_Interval.Equals(other.interval) &&
|
|
||||||
m_Inside == other.inside &&
|
|
||||||
m_Rotate == other.rotate &&
|
|
||||||
m_Margin == other.margin &&
|
|
||||||
m_Color == other.color &&
|
|
||||||
m_FontSize == other.fontSize &&
|
|
||||||
m_FontStyle == other.fontStyle &&
|
|
||||||
m_Formatter == other.formatter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatterContent(string category)
|
public string GetFormatterContent(string category)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(category)) return category;
|
||||||
if (string.IsNullOrEmpty(m_Formatter))
|
if (string.IsNullOrEmpty(m_Formatter))
|
||||||
return category;
|
{
|
||||||
|
return m_TextLimit.GetLimitContent(category);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var content = m_Formatter.Replace("{value}", category);
|
var content = m_Formatter.Replace("{value}", category);
|
||||||
content = content.Replace("\\n", "\n");
|
content = content.Replace("\\n", "\n");
|
||||||
content = content.Replace("<br/>", "\n");
|
content = content.Replace("<br/>", "\n");
|
||||||
return content;
|
return m_TextLimit.GetLimitContent(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatterContent(float value)
|
public string GetFormatterContent(float value, float minValue, float maxValue, bool isLog = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(m_Formatter))
|
if (string.IsNullOrEmpty(m_Formatter))
|
||||||
if (value - (int)value == 0)
|
{
|
||||||
|
if (isLog)
|
||||||
|
{
|
||||||
|
if (value - (int)value == 0)
|
||||||
|
return ChartCached.IntToStr((int)value);
|
||||||
|
else
|
||||||
|
return ChartCached.FloatToStr(value);
|
||||||
|
}
|
||||||
|
if (minValue >= -1 && minValue <= 1 && maxValue >= -1 && maxValue <= 1)
|
||||||
|
{
|
||||||
|
int minAcc = ChartHelper.GetFloatAccuracy(minValue);
|
||||||
|
int maxAcc = ChartHelper.GetFloatAccuracy(maxValue);
|
||||||
|
int curAcc = ChartHelper.GetFloatAccuracy(value);
|
||||||
|
int acc = Mathf.Max(Mathf.Max(minAcc, maxAcc), curAcc);
|
||||||
|
return ChartCached.FloatToStr(value, acc, m_ForceENotation);
|
||||||
|
}
|
||||||
|
else if (value - (int)value == 0)
|
||||||
return ChartCached.IntToStr((int)value);
|
return ChartCached.IntToStr((int)value);
|
||||||
else
|
else
|
||||||
return ChartCached.FloatToStr(value, 1);
|
return ChartCached.FloatToStr(value, 1);
|
||||||
else
|
}
|
||||||
|
else if (m_Formatter.Contains("{value"))
|
||||||
{
|
{
|
||||||
var content = m_Formatter;
|
var content = m_Formatter;
|
||||||
|
if (content.Contains("{value:f0}"))
|
||||||
|
content = m_Formatter.Replace("{value:f0}", ChartCached.IntToStr((int)value));
|
||||||
if (content.Contains("{value:f2}"))
|
if (content.Contains("{value:f2}"))
|
||||||
content = m_Formatter.Replace("{value:f2}", ChartCached.FloatToStr(value, 2));
|
content = m_Formatter.Replace("{value:f2}", ChartCached.FloatToStr(value, 2));
|
||||||
else if (content.Contains("{value:f1}"))
|
else if (content.Contains("{value:f1}"))
|
||||||
@@ -156,7 +210,6 @@ namespace XCharts
|
|||||||
else if (content.Contains("{value}"))
|
else if (content.Contains("{value}"))
|
||||||
{
|
{
|
||||||
if (value - (int)value == 0)
|
if (value - (int)value == 0)
|
||||||
|
|
||||||
content = m_Formatter.Replace("{value}", ChartCached.IntToStr((int)value));
|
content = m_Formatter.Replace("{value}", ChartCached.IntToStr((int)value));
|
||||||
else
|
else
|
||||||
content = m_Formatter.Replace("{value}", ChartCached.FloatToStr(value, 1));
|
content = m_Formatter.Replace("{value}", ChartCached.FloatToStr(value, 1));
|
||||||
@@ -166,6 +219,10 @@ namespace XCharts
|
|||||||
content = content.Replace("<br/>", "\n");
|
content = content.Replace("<br/>", "\n");
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return value.ToString(m_Formatter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace XCharts
|
|||||||
/// Settings related to axis line.
|
/// Settings related to axis line.
|
||||||
/// 坐标轴的分隔线。
|
/// 坐标轴的分隔线。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class AxisLine : SubComponent
|
public class AxisLine : SubComponent
|
||||||
{
|
{
|
||||||
[SerializeField] private bool m_Show;
|
[SerializeField] private bool m_Show;
|
||||||
@@ -29,42 +29,74 @@ namespace XCharts
|
|||||||
/// Set this to false to prevent the axis line from showing.
|
/// Set this to false to prevent the axis line from showing.
|
||||||
/// 是否显示坐标轴轴线。
|
/// 是否显示坐标轴轴线。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When mutiple axes exists, this option can be used to specify which axis can be "onZero" to.
|
/// When mutiple axes exists, this option can be used to specify which axis can be "onZero" to.
|
||||||
/// X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
/// X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool onZero { get { return m_OnZero; } set { m_OnZero = value; } }
|
public bool onZero
|
||||||
|
{
|
||||||
|
get { return m_OnZero; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// line style line width.
|
/// line style line width.
|
||||||
/// 坐标轴线线宽。
|
/// 坐标轴线线宽。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
public float width
|
||||||
|
{
|
||||||
|
get { return m_Width; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show the arrow symbol of axis.
|
/// Whether to show the arrow symbol of axis.
|
||||||
/// 是否显示箭头。
|
/// 是否显示箭头。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool symbol { get { return m_Symbol; } set { m_Symbol = value; } }
|
public bool symbol
|
||||||
|
{
|
||||||
|
get { return m_Symbol; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Symbol, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the width of arrow symbol.
|
/// the width of arrow symbol.
|
||||||
/// 箭头宽。
|
/// 箭头宽。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float symbolWidth { get { return m_SymbolWidth; } set { m_SymbolWidth = value; } }
|
public float symbolWidth
|
||||||
|
{
|
||||||
|
get { return m_SymbolWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SymbolWidth, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the height of arrow symbol.
|
/// the height of arrow symbol.
|
||||||
/// 箭头高。
|
/// 箭头高。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float symbolHeight { get { return m_SymbolHeight; } set { m_SymbolHeight = value; } }
|
public float symbolHeight
|
||||||
|
{
|
||||||
|
get { return m_SymbolHeight; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SymbolHeight, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the offset of arrow symbol.
|
/// the offset of arrow symbol.
|
||||||
/// 箭头偏移。
|
/// 箭头偏移。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float symbolOffset { get { return m_SymbolOffset; } set { m_SymbolOffset = value; } }
|
public float symbolOffset
|
||||||
|
{
|
||||||
|
get { return m_SymbolOffset; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SymbolOffset, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the dent of arrow symbol.
|
/// the dent of arrow symbol.
|
||||||
/// 箭头的凹陷程度。
|
/// 箭头的凹陷程度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float symbolDent { get { return m_SymbolDent; } set { m_SymbolDent = value; } }
|
public float symbolDent
|
||||||
|
{
|
||||||
|
get { return m_SymbolDent; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_SymbolDent, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
public static AxisLine defaultAxisLine
|
public static AxisLine defaultAxisLine
|
||||||
{
|
{
|
||||||
@@ -78,7 +110,7 @@ namespace XCharts
|
|||||||
m_Symbol = false,
|
m_Symbol = false,
|
||||||
m_SymbolWidth = 10,
|
m_SymbolWidth = 10,
|
||||||
m_SymbolHeight = 15,
|
m_SymbolHeight = 15,
|
||||||
m_SymbolOffset = 0,
|
m_SymbolOffset = -5f,
|
||||||
m_SymbolDent = 3,
|
m_SymbolDent = 3,
|
||||||
};
|
};
|
||||||
return axisLine;
|
return axisLine;
|
||||||
|
|||||||
@@ -40,42 +40,74 @@ namespace XCharts
|
|||||||
/// Whether to show axis name.
|
/// Whether to show axis name.
|
||||||
/// 是否显示坐标名称。
|
/// 是否显示坐标名称。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the name of axis.
|
/// the name of axis.
|
||||||
/// 坐标轴名称。
|
/// 坐标轴名称。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
public string name
|
||||||
|
{
|
||||||
|
get { return m_Name; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_Name, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Location of axis name.
|
/// Location of axis name.
|
||||||
/// 坐标轴名称显示位置。
|
/// 坐标轴名称显示位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Location location { get { return m_Location; } set { m_Location = value; } }
|
public Location location
|
||||||
|
{
|
||||||
|
get { return m_Location; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Location, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the offset of axis name and axis line.
|
/// the offset of axis name and axis line.
|
||||||
/// 坐标轴名称与轴线之间的偏移。
|
/// 坐标轴名称与轴线之间的偏移。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } }
|
public Vector2 offset
|
||||||
|
{
|
||||||
|
get { return m_Offset; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rotation of axis name.
|
/// Rotation of axis name.
|
||||||
/// 坐标轴名字旋转,角度值。
|
/// 坐标轴名字旋转,角度值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
public float rotate
|
||||||
|
{
|
||||||
|
get { return m_Rotate; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Color of axis name.
|
/// Color of axis name.
|
||||||
/// 坐标轴名称的文字颜色。
|
/// 坐标轴名称的文字颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
public Color color
|
||||||
|
{
|
||||||
|
get { return m_Color; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// axis name font size.
|
/// axis name font size.
|
||||||
/// 坐标轴名称的文字大小。
|
/// 坐标轴名称的文字大小。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
public int fontSize
|
||||||
|
{
|
||||||
|
get { return m_FontSize; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// axis name font style.
|
/// axis name font style.
|
||||||
/// 坐标轴名称的文字风格。
|
/// 坐标轴名称的文字风格。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
public FontStyle fontStyle
|
||||||
|
{
|
||||||
|
get { return m_FontStyle; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
public static AxisName defaultAxisName
|
public static AxisName defaultAxisName
|
||||||
{
|
{
|
||||||
@@ -93,39 +125,5 @@ namespace XCharts
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Copy(AxisName other)
|
|
||||||
{
|
|
||||||
m_Show = other.show;
|
|
||||||
m_Name = other.name;
|
|
||||||
m_Location = other.location;
|
|
||||||
m_Offset = other.offset;
|
|
||||||
m_Rotate = other.rotate;
|
|
||||||
m_Color = other.color;
|
|
||||||
m_FontSize = other.fontSize;
|
|
||||||
m_FontStyle = other.fontStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (obj == null || GetType() != obj.GetType())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var other = (AxisName)obj;
|
|
||||||
return m_Show == other.show &&
|
|
||||||
m_Name.Equals(other.name) &&
|
|
||||||
m_Location == other.location &&
|
|
||||||
m_Rotate == other.rotate &&
|
|
||||||
m_Color == other.color &&
|
|
||||||
m_Offset == other.offset &&
|
|
||||||
m_FontSize == other.fontSize &&
|
|
||||||
m_FontStyle == other.fontStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,14 +25,22 @@ namespace XCharts
|
|||||||
/// Set this to true to show the splitArea.
|
/// Set this to true to show the splitArea.
|
||||||
/// 是否显示分隔区域。
|
/// 是否显示分隔区域。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Color of split area. SplitArea color could also be set in color array,
|
/// Color of split area. SplitArea color could also be set in color array,
|
||||||
/// which the split lines would take as their colors in turns.
|
/// which the split lines would take as their colors in turns.
|
||||||
/// Dark and light colors in turns are used by default.
|
/// Dark and light colors in turns are used by default.
|
||||||
/// 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
/// 分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Color> color { get { return m_Color; } set { m_Color = value; } }
|
public List<Color> color
|
||||||
|
{
|
||||||
|
get { return m_Color; }
|
||||||
|
set { if (value != null) { m_Color = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
|
|
||||||
public static AxisSplitArea defaultSplitArea
|
public static AxisSplitArea defaultSplitArea
|
||||||
{
|
{
|
||||||
|
|||||||
85
Assets/XCharts/Runtime/Component/Sub/AxisSplitLine.cs
Normal file
85
Assets/XCharts/Runtime/Component/Sub/AxisSplitLine.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Split line of axis in grid area.
|
||||||
|
/// 坐标轴在 grid 区域中的分隔线。
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class AxisSplitLine : SubComponent
|
||||||
|
{
|
||||||
|
[SerializeField] private bool m_Show;
|
||||||
|
[SerializeField] private int m_Interval;
|
||||||
|
[SerializeField] private LineStyle m_LineStyle = new LineStyle(0.7f);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set this to true to show the split line.
|
||||||
|
/// 是否显示分隔线。
|
||||||
|
/// </summary>
|
||||||
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
public int interval
|
||||||
|
{
|
||||||
|
get { return m_Interval; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 线条样式
|
||||||
|
/// </summary>
|
||||||
|
public LineStyle lineStyle
|
||||||
|
{
|
||||||
|
get { return m_LineStyle; }
|
||||||
|
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
|
||||||
|
internal override void ClearVerticesDirty()
|
||||||
|
{
|
||||||
|
base.ClearVerticesDirty();
|
||||||
|
m_LineStyle.ClearVerticesDirty();
|
||||||
|
}
|
||||||
|
public static AxisSplitLine defaultSplitLine
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AxisSplitLine()
|
||||||
|
{
|
||||||
|
m_Show = false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Color GetColor(ThemeInfo theme)
|
||||||
|
{
|
||||||
|
if (lineStyle.color != Color.clear)
|
||||||
|
{
|
||||||
|
var color = lineStyle.color;
|
||||||
|
color.a *= lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var color = (Color)theme.axisSplitLineColor;
|
||||||
|
color.a *= lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool NeedShow(int index)
|
||||||
|
{
|
||||||
|
return show && (interval == 0 || index % (interval + 1) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Component/Sub/AxisSplitLine.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Sub/AxisSplitLine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 62c6ea03f6ffe431a9c4730cce152c80
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -26,22 +26,38 @@ namespace XCharts
|
|||||||
/// Set this to false to prevent the axis tick from showing.
|
/// Set this to false to prevent the axis tick from showing.
|
||||||
/// 是否显示坐标轴刻度。
|
/// 是否显示坐标轴刻度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
|
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
|
||||||
/// 类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
/// 类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool alignWithLabel { get { return m_AlignWithLabel; } set { m_AlignWithLabel = value; } }
|
public bool alignWithLabel
|
||||||
|
{
|
||||||
|
get { return m_AlignWithLabel; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this to true so the axis labels face the inside direction.
|
/// Set this to true so the axis labels face the inside direction.
|
||||||
/// 坐标轴刻度是否朝内,默认朝外。
|
/// 坐标轴刻度是否朝内,默认朝外。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool inside { get { return m_Inside; } set { m_Inside = value; } }
|
public bool inside
|
||||||
|
{
|
||||||
|
get { return m_Inside; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the axis tick.
|
/// The length of the axis tick.
|
||||||
/// 坐标轴刻度的长度。
|
/// 坐标轴刻度的长度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float length { get { return m_Length; } set { m_Length = value; } }
|
public float length
|
||||||
|
{
|
||||||
|
get { return m_Length; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
public static AxisTick defaultTick
|
public static AxisTick defaultTick
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,14 +22,43 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用高亮样式。
|
/// 是否启用高亮样式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { m_Show = value; }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图形文本标签。
|
/// 图形文本标签。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SerieLabel label { get { return m_Label; } }
|
public SerieLabel label
|
||||||
|
{
|
||||||
|
get { return m_Label; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_Label, value, true)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图形样式。
|
/// 图形样式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ItemStyle itemStyle { get { return m_ItemStyle; } }
|
public ItemStyle itemStyle
|
||||||
|
{
|
||||||
|
get { return m_ItemStyle; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool vertsDirty { get { return m_VertsDirty || label.vertsDirty || itemStyle.vertsDirty; } }
|
||||||
|
|
||||||
|
public override bool componentDirty { get { return m_ComponentDirty || label.componentDirty; } }
|
||||||
|
|
||||||
|
internal override void ClearVerticesDirty()
|
||||||
|
{
|
||||||
|
base.ClearVerticesDirty();
|
||||||
|
label.ClearVerticesDirty();
|
||||||
|
itemStyle.ClearVerticesDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void ClearComponentDirty()
|
||||||
|
{
|
||||||
|
base.ClearComponentDirty();
|
||||||
|
label.ClearComponentDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
304
Assets/XCharts/Runtime/Component/Sub/GaugeAxis.cs
Normal file
304
Assets/XCharts/Runtime/Component/Sub/GaugeAxis.cs
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Settings related to gauge axis line.
|
||||||
|
/// 仪表盘轴线相关设置。
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class GaugeAxis : SubComponent
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class AxisLine
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class StageColor
|
||||||
|
{
|
||||||
|
[SerializeField] private float m_Percent;
|
||||||
|
[SerializeField] private Color m_Color;
|
||||||
|
/// <summary>
|
||||||
|
/// 结束位置百分比。
|
||||||
|
/// </summary>
|
||||||
|
public float percent { get { return m_Percent; } set { m_Percent = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||||
|
|
||||||
|
public StageColor(float percent, Color color)
|
||||||
|
{
|
||||||
|
m_Percent = percent;
|
||||||
|
m_Color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[SerializeField] private bool m_Show = true;
|
||||||
|
[SerializeField] private float m_Width = 15f;
|
||||||
|
[SerializeField] private float m_Opacity = 1f;
|
||||||
|
[SerializeField] private Color m_BarColor;
|
||||||
|
[SerializeField] private Color m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||||
|
[SerializeField]
|
||||||
|
private List<StageColor> m_StageColor = new List<StageColor>()
|
||||||
|
{
|
||||||
|
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||||
|
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||||
|
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set this to false to prevent the axis line from showing.
|
||||||
|
/// 是否显示坐标轴轴线。
|
||||||
|
/// </summary>
|
||||||
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// line style line width.
|
||||||
|
/// 坐标轴线线宽。
|
||||||
|
/// </summary>
|
||||||
|
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// The opacity of axis line.
|
||||||
|
/// 透明度。
|
||||||
|
/// </summary>
|
||||||
|
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 进度条颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color barColor { get { return m_BarColor; } set { m_BarColor = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 进度条背景颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 阶段颜色。
|
||||||
|
/// </summary>
|
||||||
|
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 分割线
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class SplitLine
|
||||||
|
{
|
||||||
|
[SerializeField] private bool m_Show = true;
|
||||||
|
[SerializeField] private float m_Length = 15;
|
||||||
|
[SerializeField]
|
||||||
|
private LineStyle m_LineStyle = new LineStyle()
|
||||||
|
{
|
||||||
|
width = 1.5f,
|
||||||
|
type = LineStyle.Type.Solid,
|
||||||
|
color = new Color32(238, 238, 238, 255)
|
||||||
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示分割线。
|
||||||
|
/// </summary>
|
||||||
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 分割线长度。
|
||||||
|
/// </summary>
|
||||||
|
public float length { get { return m_Length; } set { m_Length = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 分割线样式。
|
||||||
|
/// </summary>
|
||||||
|
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 刻度
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class AxisTick
|
||||||
|
{
|
||||||
|
[SerializeField] private bool m_Show = true;
|
||||||
|
[SerializeField] private float m_Length = 5;
|
||||||
|
[SerializeField] private float m_SplitNumber = 5;
|
||||||
|
[SerializeField]
|
||||||
|
private LineStyle m_LineStyle = new LineStyle()
|
||||||
|
{
|
||||||
|
width = 1f,
|
||||||
|
type = LineStyle.Type.Solid,
|
||||||
|
color = new Color32(238, 238, 238, 255)
|
||||||
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示刻度。
|
||||||
|
/// </summary>
|
||||||
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 刻度长度。当为0-1的浮点数时表示半径的百分比。
|
||||||
|
/// </summary>
|
||||||
|
public float length { get { return m_Length; } set { m_Length = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 分割线之间的分割段数。
|
||||||
|
/// </summary>
|
||||||
|
public float splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 刻度线样式。
|
||||||
|
/// </summary>
|
||||||
|
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
||||||
|
}
|
||||||
|
[SerializeField] private bool m_Show = true;
|
||||||
|
[SerializeField] private AxisLine m_AxisLine = new AxisLine();
|
||||||
|
[SerializeField] private SplitLine m_SplitLine = new SplitLine();
|
||||||
|
[SerializeField] private AxisTick m_AxisTick = new AxisTick();
|
||||||
|
[SerializeField] private SerieLabel m_AxisLabel = new SerieLabel();
|
||||||
|
[SerializeField] private List<string> m_AxisLabelText = new List<string>();
|
||||||
|
|
||||||
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 仪表盘轴线。
|
||||||
|
/// </summary>
|
||||||
|
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 分割线。
|
||||||
|
/// </summary>
|
||||||
|
public SplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 刻度。
|
||||||
|
/// </summary>
|
||||||
|
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 文本标签。
|
||||||
|
/// </summary>
|
||||||
|
public SerieLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义Label的内容。
|
||||||
|
/// </summary>
|
||||||
|
public List<string> axisLabelText { get { return m_AxisLabelText; } set { m_AxisLabelText = value; } }
|
||||||
|
|
||||||
|
public List<float> runtimeStageAngle = new List<float>();
|
||||||
|
public List<Vector3> runtimeLabelPosition = new List<Vector3>();
|
||||||
|
private List<LabelObject> m_RuntimeLabelList = new List<LabelObject>();
|
||||||
|
|
||||||
|
internal Color GetAxisLineColor(ThemeInfo theme, int index)
|
||||||
|
{
|
||||||
|
var color = axisLine.barColor != Color.clear ? axisLine.barColor : (Color)theme.GetColor(index);
|
||||||
|
color.a *= axisLine.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Color GetAxisLineBackgroundColor(ThemeInfo theme, int index)
|
||||||
|
{
|
||||||
|
var color = axisLine.barBackgroundColor != Color.clear ? axisLine.barBackgroundColor : Color.grey;
|
||||||
|
color.a *= axisLine.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Color GetSplitLineColor(ThemeInfo theme, int serieIndex, float angle)
|
||||||
|
{
|
||||||
|
Color color;
|
||||||
|
if (splitLine.lineStyle.color != Color.clear)
|
||||||
|
{
|
||||||
|
color = splitLine.lineStyle.color;
|
||||||
|
color.a *= splitLine.lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < runtimeStageAngle.Count; i++)
|
||||||
|
{
|
||||||
|
if (angle < runtimeStageAngle[i])
|
||||||
|
{
|
||||||
|
color = axisLine.stageColor[i].color;
|
||||||
|
color.a *= splitLine.lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
color = theme.GetColor(serieIndex);
|
||||||
|
color.a *= splitLine.lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Color GetAxisTickColor(ThemeInfo theme, int serieIndex, float angle)
|
||||||
|
{
|
||||||
|
Color color;
|
||||||
|
if (axisTick.lineStyle.color != Color.clear)
|
||||||
|
{
|
||||||
|
color = axisTick.lineStyle.color;
|
||||||
|
color.a *= axisTick.lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < runtimeStageAngle.Count; i++)
|
||||||
|
{
|
||||||
|
if (angle < runtimeStageAngle[i])
|
||||||
|
{
|
||||||
|
color = axisLine.stageColor[i].color;
|
||||||
|
color.a *= axisTick.lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
color = theme.GetColor(serieIndex);
|
||||||
|
color.a *= axisTick.lineStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Color GetPointerColor(ThemeInfo theme, int serieIndex, float angle, ItemStyle itemStyle)
|
||||||
|
{
|
||||||
|
Color color;
|
||||||
|
if (itemStyle.color != Color.clear)
|
||||||
|
{
|
||||||
|
color = itemStyle.color;
|
||||||
|
color.a *= itemStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < runtimeStageAngle.Count; i++)
|
||||||
|
{
|
||||||
|
if (angle < runtimeStageAngle[i])
|
||||||
|
{
|
||||||
|
color = axisLine.stageColor[i].color;
|
||||||
|
color.a *= itemStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
color = theme.GetColor(serieIndex);
|
||||||
|
color.a *= itemStyle.opacity;
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearLabelObject()
|
||||||
|
{
|
||||||
|
m_RuntimeLabelList.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLabelObject(LabelObject label)
|
||||||
|
{
|
||||||
|
m_RuntimeLabelList.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LabelObject GetLabelObject(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_RuntimeLabelList.Count)
|
||||||
|
{
|
||||||
|
return m_RuntimeLabelList[index];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLabelObjectPosition(int index, Vector3 pos)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_RuntimeLabelList.Count)
|
||||||
|
{
|
||||||
|
m_RuntimeLabelList[index].SetPosition(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLabelObjectText(int index, string text)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_RuntimeLabelList.Count)
|
||||||
|
{
|
||||||
|
m_RuntimeLabelList[index].SetText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLabelObjectActive(bool flag)
|
||||||
|
{
|
||||||
|
foreach (var label in m_RuntimeLabelList)
|
||||||
|
{
|
||||||
|
label.SetActive(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Component/Sub/GaugeAxis.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Sub/GaugeAxis.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 67cba46d89b9b478fa6dcf067e7b49b7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
52
Assets/XCharts/Runtime/Component/Sub/GaugePointer.cs
Normal file
52
Assets/XCharts/Runtime/Component/Sub/GaugePointer.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Settings related to gauge pointer.
|
||||||
|
/// 仪表盘指针相关设置。
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class GaugePointer : SubComponent
|
||||||
|
{
|
||||||
|
[SerializeField] private bool m_Show = true;
|
||||||
|
[SerializeField] private float m_Length = 0.8f;
|
||||||
|
[SerializeField] private float m_Width = 15;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示指针。
|
||||||
|
/// </summary>
|
||||||
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 指针长度。可以是绝对值,也可以是相对于半径的百分比(0-1的浮点数)
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public float length
|
||||||
|
{
|
||||||
|
get { return m_Length; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 指针宽度。
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public float width
|
||||||
|
{
|
||||||
|
get { return m_Width; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Component/Sub/GaugePointer.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Sub/GaugePointer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 55e453b57f6514da09e98571439d4dcc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
105
Assets/XCharts/Runtime/Component/Sub/IconStyle.cs
Normal file
105
Assets/XCharts/Runtime/Component/Sub/IconStyle.cs
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 系列数据项的图标
|
||||||
|
/// </summary>
|
||||||
|
[System.Serializable]
|
||||||
|
public class IconStyle : SubComponent
|
||||||
|
{
|
||||||
|
public enum Layer
|
||||||
|
{
|
||||||
|
UnderLabel,
|
||||||
|
AboveLabel
|
||||||
|
}
|
||||||
|
[SerializeField] private bool m_Show;
|
||||||
|
[SerializeField] private Layer m_Layer;
|
||||||
|
[SerializeField] private Sprite m_Sprite;
|
||||||
|
[SerializeField] private Color m_Color = Color.white;
|
||||||
|
[SerializeField] private float m_Width = 40;
|
||||||
|
[SerializeField] private float m_Height = 40;
|
||||||
|
[SerializeField] private Vector3 m_Offset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the data icon is show.
|
||||||
|
/// 是否显示图标。
|
||||||
|
/// </summary>
|
||||||
|
public bool show { get { return m_Show; } set { m_Show = value; UpdateIcon(); } }
|
||||||
|
/// <summary>
|
||||||
|
/// 显示在上层还是在下层。
|
||||||
|
/// </summary>
|
||||||
|
public Layer layer { get { return m_Layer; } set { m_Layer = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// The image of icon.
|
||||||
|
/// 图标的图片。
|
||||||
|
/// </summary>
|
||||||
|
public Sprite sprite { get { return m_Sprite; } set { m_Sprite = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 图标颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 图标宽。
|
||||||
|
/// </summary>
|
||||||
|
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 图标高。
|
||||||
|
/// </summary>
|
||||||
|
public float height { get { return m_Height; } set { m_Height = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 图标偏移。
|
||||||
|
/// </summary>
|
||||||
|
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||||
|
|
||||||
|
public Image image { get; private set; }
|
||||||
|
public RectTransform rect { get; private set; }
|
||||||
|
|
||||||
|
public void SetImage(Image image)
|
||||||
|
{
|
||||||
|
this.image = image;
|
||||||
|
if (image)
|
||||||
|
{
|
||||||
|
rect = image.GetComponent<RectTransform>();
|
||||||
|
if (m_Layer == Layer.UnderLabel)
|
||||||
|
rect.SetSiblingIndex(0);
|
||||||
|
else
|
||||||
|
rect.SetSiblingIndex(image.transform.childCount - 1);
|
||||||
|
UpdateIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetActive(bool flag)
|
||||||
|
{
|
||||||
|
if (image)
|
||||||
|
{
|
||||||
|
ChartHelper.SetActive(image.gameObject, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateIcon()
|
||||||
|
{
|
||||||
|
if (image == null) return;
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
ChartHelper.SetActive(image.gameObject, true);
|
||||||
|
image.sprite = m_Sprite;
|
||||||
|
image.color = m_Color;
|
||||||
|
rect.sizeDelta = new Vector2(m_Width, m_Height);
|
||||||
|
image.transform.localPosition = m_Offset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ChartHelper.SetActive(image.gameObject, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Component/Sub/IconStyle.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Sub/IconStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 82c4d360f7b5b4ee7845e9bbe611c8a3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -36,6 +36,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
[SerializeField] private bool m_Show = false;
|
[SerializeField] private bool m_Show = false;
|
||||||
[SerializeField] private Color m_Color;
|
[SerializeField] private Color m_Color;
|
||||||
|
[SerializeField] private Color m_BackgroundColor;
|
||||||
|
[SerializeField] private float m_BackgroundWidth;
|
||||||
|
[SerializeField] private Color m_CenterColor;
|
||||||
|
[SerializeField] private float m_CenterGap;
|
||||||
[SerializeField] private Type m_BorderType = Type.Solid;
|
[SerializeField] private Type m_BorderType = Type.Solid;
|
||||||
[SerializeField] private float m_BorderWidth = 0;
|
[SerializeField] private float m_BorderWidth = 0;
|
||||||
[SerializeField] private Color m_BorderColor;
|
[SerializeField] private Color m_BorderColor;
|
||||||
@@ -44,26 +48,96 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用。
|
/// 是否启用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据项颜色。
|
/// 数据项颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
public Color color
|
||||||
|
{
|
||||||
|
get { return m_Color; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 数据项背景颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color backgroundColor
|
||||||
|
{
|
||||||
|
get { return m_BackgroundColor; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 中心区域颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color centerColor
|
||||||
|
{
|
||||||
|
get { return m_CenterColor; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 中心区域间隙。
|
||||||
|
/// </summary>
|
||||||
|
public float centerGap
|
||||||
|
{
|
||||||
|
get { return m_CenterGap; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 数据项背景颜色。
|
||||||
|
/// </summary>
|
||||||
|
public float backgroundWidth
|
||||||
|
{
|
||||||
|
get { return m_BackgroundWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 边框的类型。
|
/// 边框的类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type borderType { get { return m_BorderType; } set { m_BorderType = value; } }
|
public Type borderType
|
||||||
|
{
|
||||||
|
get { return m_BorderType; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 边框的颜色。
|
/// 边框的颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color borderColor { get { return m_BorderColor; } set { m_BorderColor = value; } }
|
public Color borderColor
|
||||||
|
{
|
||||||
|
get { return m_BorderColor; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 边框宽。
|
/// 边框宽。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float borderWidth { get { return m_BorderWidth; } set { m_BorderWidth = value; } }
|
public float borderWidth
|
||||||
|
{
|
||||||
|
get { return m_BorderWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
/// 透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
public float opacity
|
||||||
|
{
|
||||||
|
get { return m_Opacity; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 实际边框宽。边框不显示时为0。
|
||||||
|
/// </summary>
|
||||||
|
public float runtimeBorderWidth { get { return NeedShowBorder() ? borderWidth : 0; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否需要显示边框。
|
||||||
|
/// </summary>
|
||||||
|
public bool NeedShowBorder()
|
||||||
|
{
|
||||||
|
return borderWidth != 0 && borderColor != Color.clear;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,31 +37,55 @@ namespace XCharts
|
|||||||
/// Whether to show the arrow.
|
/// Whether to show the arrow.
|
||||||
/// 是否显示箭头。
|
/// 是否显示箭头。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The position of arrow.
|
/// The position of arrow.
|
||||||
/// 箭头位置。
|
/// 箭头位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Position position { get { return m_Position; } set { m_Position = value; } }
|
public Position position
|
||||||
|
{
|
||||||
|
get { return m_Position; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The widht of arrow.
|
/// The widht of arrow.
|
||||||
/// 箭头宽。
|
/// 箭头宽。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
public float width
|
||||||
|
{
|
||||||
|
get { return m_Width; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The height of arrow.
|
/// The height of arrow.
|
||||||
/// 箭头高。
|
/// 箭头高。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float height { get { return m_Height; } set { m_Height = value; } }
|
public float height
|
||||||
|
{
|
||||||
|
get { return m_Height; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The offset of arrow.
|
/// The offset of arrow.
|
||||||
/// 箭头偏移。
|
/// 箭头偏移。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float offset { get { return m_Offset; } set { m_Offset = value; } }
|
public float offset
|
||||||
|
{
|
||||||
|
get { return m_Offset; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The dent of arrow.
|
/// The dent of arrow.
|
||||||
/// 箭头的凹度。
|
/// 箭头的凹度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float dent { get { return m_Dent; } set { m_Dent = value; } }
|
public float dent
|
||||||
|
{
|
||||||
|
get { return m_Dent; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,28 +52,92 @@ namespace XCharts
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether show line.
|
/// Whether show line.
|
||||||
/// 是否显示线条。在折线图中无效。
|
/// 是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the type of line.
|
/// the type of line.
|
||||||
/// 线的类型。
|
/// 线的类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
public Type type
|
||||||
|
{
|
||||||
|
get { return m_Type; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of line, default use serie color.
|
/// the color of line, default use serie color.
|
||||||
/// 线的颜色。
|
/// 线的颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
public Color color
|
||||||
|
{
|
||||||
|
get { return m_Color; }
|
||||||
|
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the width of line.
|
/// the width of line.
|
||||||
/// 线宽。
|
/// 线宽。
|
||||||
/// </summary>
|
/// /// </summary>
|
||||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
public float width
|
||||||
|
{
|
||||||
|
get { return m_Width; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opacity of the line. Supports value from 0 to 1, and the line will not be drawn when set to 0.
|
/// Opacity of the line. Supports value from 0 to 1, and the line will not be drawn when set to 0.
|
||||||
/// 线的透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
/// 线的透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
public float opacity
|
||||||
|
{
|
||||||
|
get { return m_Opacity; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineStyle()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineStyle(float width)
|
||||||
|
{
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LineStyle(LineStyle.Type type, float width)
|
||||||
|
{
|
||||||
|
this.type = type;
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Copy(LineStyle other)
|
||||||
|
{
|
||||||
|
m_Show = other.show;
|
||||||
|
m_Type = other.type;
|
||||||
|
m_Color = other.color;
|
||||||
|
m_Width = other.width;
|
||||||
|
m_Opacity = other.opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null || GetType() != obj.GetType())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var other = (LineStyle)obj;
|
||||||
|
return m_Show == other.show &&
|
||||||
|
m_Type == other.type &&
|
||||||
|
m_Width == other.width &&
|
||||||
|
m_Opacity == other.opacity &&
|
||||||
|
ChartHelper.IsValueEqualsColor(m_Color, other.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return base.GetHashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ namespace XCharts
|
|||||||
/// 位置类型。通过Align快速设置大体位置,再通过left,right,top,bottom微调具体位置。
|
/// 位置类型。通过Align快速设置大体位置,再通过left,right,top,bottom微调具体位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Location : SubComponent, IPropertyChanged, IEquatable<Location>
|
public class Location : SubComponent, IPropertyChanged
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 对齐方式
|
/// 对齐方式
|
||||||
@@ -47,52 +47,72 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 对齐方式。
|
/// 对齐方式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Align align { get { return m_Align; } set { m_Align = value; UpdateAlign(); } }
|
public Align align
|
||||||
|
{
|
||||||
|
get { return m_Align; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between component and the left side of the container.
|
/// Distance between component and the left side of the container.
|
||||||
/// 离容器左侧的距离。
|
/// 离容器左侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float left { get { return m_Left; } set { m_Left = value; UpdateAlign(); } }
|
public float left
|
||||||
|
{
|
||||||
|
get { return m_Left; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between component and the left side of the container.
|
/// Distance between component and the left side of the container.
|
||||||
/// 离容器右侧的距离。
|
/// 离容器右侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float right { get { return m_Right; } set { m_Right = value; UpdateAlign(); } }
|
public float right
|
||||||
|
{
|
||||||
|
get { return m_Right; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between component and the left side of the container.
|
/// Distance between component and the left side of the container.
|
||||||
/// 离容器上侧的距离。
|
/// 离容器上侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float top { get { return m_Top; } set { m_Top = value; UpdateAlign(); } }
|
public float top
|
||||||
|
{
|
||||||
|
get { return m_Top; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Distance between component and the left side of the container.
|
/// Distance between component and the left side of the container.
|
||||||
/// 离容器下侧的距离。
|
/// 离容器下侧的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float bottom { get { return m_Bottom; } set { m_Bottom = value; UpdateAlign(); } }
|
public float bottom
|
||||||
|
{
|
||||||
|
get { return m_Bottom; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the anchor of text.
|
/// the anchor of text.
|
||||||
/// Location对应的Anchor锚点
|
/// Location对应的Anchor锚点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public TextAnchor textAnchor { get { return m_TextAnchor; } }
|
public TextAnchor runtimeTextAnchor { get { return m_TextAnchor; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the minimum achor.
|
/// the minimum achor.
|
||||||
/// Location对应的anchorMin。
|
/// Location对应的anchorMin。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public Vector2 anchorMin { get { return m_AnchorMin; } }
|
public Vector2 runtimeAnchorMin { get { return m_AnchorMin; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the maximun achor.
|
/// the maximun achor.
|
||||||
/// Location对应的anchorMax.
|
/// Location对应的anchorMax.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public Vector2 anchorMax { get { return m_AnchorMax; } }
|
public Vector2 runtimeAnchorMax { get { return m_AnchorMax; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the povot.
|
/// the povot.
|
||||||
/// Loation对应的中心点。
|
/// Loation对应的中心点。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public Vector2 pivot { get { return m_Pivot; } }
|
public Vector2 runtimePivot { get { return m_Pivot; } }
|
||||||
|
|
||||||
public static Location defaultLeft
|
public static Location defaultLeft
|
||||||
{
|
{
|
||||||
@@ -250,67 +270,6 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Copy(Location location)
|
|
||||||
{
|
|
||||||
m_Align = location.align;
|
|
||||||
m_Left = location.left;
|
|
||||||
m_Right = location.right;
|
|
||||||
m_Top = location.top;
|
|
||||||
m_Bottom = location.bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, obj))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (obj is Location)
|
|
||||||
{
|
|
||||||
return Equals((Location)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(Location other)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(null, other))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return align == other.align &&
|
|
||||||
left == other.left &&
|
|
||||||
right == other.right &&
|
|
||||||
top == other.top &&
|
|
||||||
bottom == other.bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator ==(Location left, Location right)
|
|
||||||
{
|
|
||||||
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(Location left, Location right)
|
|
||||||
{
|
|
||||||
return !(left == right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return base.GetHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/******************************************/
|
using System.Threading;
|
||||||
|
/******************************************/
|
||||||
/* */
|
/* */
|
||||||
/* Copyright (c) 2018 monitor1394 */
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
/* https://github.com/monitor1394 */
|
/* https://github.com/monitor1394 */
|
||||||
@@ -23,10 +24,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
[SerializeField] private bool m_Enable = true;
|
[SerializeField] private bool m_Enable = true;
|
||||||
[SerializeField] private Easing m_Easting;
|
[SerializeField] private Easing m_Easting;
|
||||||
[SerializeField] private int m_Duration = 1000;
|
|
||||||
[SerializeField] private int m_Threshold = 2000;
|
[SerializeField] private int m_Threshold = 2000;
|
||||||
[SerializeField] private int m_Delay = 0;
|
[SerializeField] private float m_FadeInDuration = 1000;
|
||||||
[SerializeField] private int m_ActualDuration;
|
[SerializeField] private float m_FadeInDelay = 0;
|
||||||
|
[SerializeField] private float m_FadeOutDuration = 1000f;
|
||||||
|
[SerializeField] private bool m_DataChangeEnable = true;
|
||||||
|
[SerializeField] private float m_DataChangeDuration = 500;
|
||||||
|
[SerializeField] private float m_ActualDuration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to enable animation.
|
/// Whether to enable animation.
|
||||||
@@ -37,37 +41,49 @@ namespace XCharts
|
|||||||
/// Easing method used for the first animation.
|
/// Easing method used for the first animation.
|
||||||
/// 动画的缓动效果。
|
/// 动画的缓动效果。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
//public Easing easing { get { return m_Easting; } set { m_Easting = value; } }
|
||||||
public Easing easing { get { return m_Easting; } set { m_Easting = value; } }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The milliseconds duration of the first animation.
|
/// The milliseconds duration of the fadeIn animation.
|
||||||
/// 设定的动画时长(毫秒)。
|
/// 设定的渐入动画时长(毫秒)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
public float fadeInDuration { get { return m_FadeInDuration; } set { m_FadeInDuration = value < 0 ? 0 : value; } }
|
||||||
public int duration { get { return m_Duration; } set { m_Duration = value; } }
|
/// <summary>
|
||||||
|
/// The milliseconds duration of the fadeOut animation.
|
||||||
|
/// 设定的渐出动画时长(毫秒)。
|
||||||
|
/// </summary>
|
||||||
|
public float fadeOutDuration { get { return m_FadeOutDuration; } set { m_FadeOutDuration = value < 0 ? 0 : value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The milliseconds actual duration of the first animation.
|
/// The milliseconds actual duration of the first animation.
|
||||||
/// 实际的动画时长(毫秒)。
|
/// 实际的动画时长(毫秒)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
public float actualDuration { get { return m_ActualDuration; } }
|
||||||
public int actualDuration { get { return m_ActualDuration; } }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to set graphic number threshold to animation. Animation will be disabled when graphic number is larger than threshold.
|
/// Whether to set graphic number threshold to animation. Animation will be disabled when graphic number is larger than threshold.
|
||||||
/// 是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。
|
/// 是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
|
||||||
public int threshold { get { return m_Threshold; } set { m_Threshold = value; } }
|
public int threshold { get { return m_Threshold; } set { m_Threshold = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The milliseconds delay before updating the first animation.
|
/// The milliseconds delay before updating the first animation.
|
||||||
/// 动画延时(毫秒)。
|
/// 动画延时(毫秒)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
public float delay { get { return m_FadeInDelay; } set { m_FadeInDelay = value < 0 ? 0 : value; } }
|
||||||
public int delay { get { return m_Delay; } set { m_Delay = value; if (m_Delay < 0) m_Delay = 0; } }
|
/// <summary>
|
||||||
|
/// 是否开启数据变更动画。
|
||||||
|
/// </summary>
|
||||||
|
public bool dataChangeEnable { get { return m_DataChangeEnable; } set { m_DataChangeEnable = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// The milliseconds duration of the data change animation.
|
||||||
|
/// 数据变更的动画时长(毫秒)。
|
||||||
|
/// </summary>
|
||||||
|
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
|
||||||
|
|
||||||
private Dictionary<int, float> m_DataAnimationState = new Dictionary<int, float>();
|
private Dictionary<int, float> m_DataAnimationState = new Dictionary<int, float>();
|
||||||
private bool m_IsStart = false;
|
private bool m_FadeIn = false;
|
||||||
private bool m_IsEnd = true;
|
private bool m_IsEnd = true;
|
||||||
private bool m_Inited = false;
|
private bool m_IsPause = false;
|
||||||
|
private bool m_FadeOut = false;
|
||||||
|
private bool m_FadeOuted = false;
|
||||||
|
private bool m_IsInit = false;
|
||||||
|
|
||||||
private float startTime { get; set; }
|
private float startTime { get; set; }
|
||||||
private int m_CurrDataProgress { get; set; }
|
private int m_CurrDataProgress { get; set; }
|
||||||
@@ -76,13 +92,21 @@ namespace XCharts
|
|||||||
[SerializeField] private float m_DestDetailProgress;
|
[SerializeField] private float m_DestDetailProgress;
|
||||||
private float m_CurrSymbolProgress;
|
private float m_CurrSymbolProgress;
|
||||||
|
|
||||||
public void Start()
|
public void FadeIn()
|
||||||
{
|
{
|
||||||
if (m_IsStart) return;
|
if (m_FadeOut) return;
|
||||||
|
if (m_IsPause)
|
||||||
|
{
|
||||||
|
m_IsPause = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_FadeIn) return;
|
||||||
startTime = Time.time;
|
startTime = Time.time;
|
||||||
m_IsStart = true;
|
m_FadeIn = true;
|
||||||
m_IsEnd = false;
|
m_IsEnd = false;
|
||||||
m_Inited = false;
|
m_IsInit = false;
|
||||||
|
m_IsPause = false;
|
||||||
|
m_FadeOuted = false;
|
||||||
m_CurrDataProgress = 1;
|
m_CurrDataProgress = 1;
|
||||||
m_DestDataProgress = 1;
|
m_DestDataProgress = 1;
|
||||||
m_CurrDetailProgress = 0;
|
m_CurrDetailProgress = 0;
|
||||||
@@ -91,34 +115,89 @@ namespace XCharts
|
|||||||
m_DataAnimationState.Clear();
|
m_DataAnimationState.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Restart()
|
||||||
{
|
{
|
||||||
m_IsStart = false;
|
Reset();
|
||||||
m_IsEnd = true;
|
FadeIn();
|
||||||
m_Inited = false;
|
}
|
||||||
|
|
||||||
|
public void FadeOut()
|
||||||
|
{
|
||||||
|
if (m_IsPause)
|
||||||
|
{
|
||||||
|
m_IsPause = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_FadeOut = true;
|
||||||
|
startTime = Time.time;
|
||||||
|
m_FadeIn = true;
|
||||||
|
m_IsEnd = false;
|
||||||
|
m_IsInit = false;
|
||||||
|
m_IsPause = false;
|
||||||
|
m_CurrDataProgress = 0;
|
||||||
|
m_DestDataProgress = 0;
|
||||||
|
m_CurrDetailProgress = 0;
|
||||||
|
m_DestDetailProgress = 1;
|
||||||
|
m_CurrSymbolProgress = 0;
|
||||||
m_DataAnimationState.Clear();
|
m_DataAnimationState.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void End()
|
public void Pause()
|
||||||
|
{
|
||||||
|
if (!m_IsPause)
|
||||||
|
{
|
||||||
|
m_IsPause = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resume()
|
||||||
|
{
|
||||||
|
if (m_IsPause)
|
||||||
|
{
|
||||||
|
m_IsPause = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void End()
|
||||||
{
|
{
|
||||||
if (m_IsEnd) return;
|
if (m_IsEnd) return;
|
||||||
m_ActualDuration = (int)((Time.time - startTime) * 1000) - delay;
|
m_ActualDuration = (int)((Time.time - startTime) * 1000) - delay;
|
||||||
m_CurrDataProgress = m_DestDataProgress + 1;
|
m_CurrDataProgress = m_DestDataProgress + (m_FadeOut ? -1 : 1);
|
||||||
|
m_FadeIn = false;
|
||||||
m_IsEnd = true;
|
m_IsEnd = true;
|
||||||
|
m_IsInit = false;
|
||||||
|
if (m_FadeOut)
|
||||||
|
{
|
||||||
|
m_FadeOut = false;
|
||||||
|
m_FadeOuted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
Stop();
|
m_FadeIn = false;
|
||||||
Start();
|
m_IsEnd = true;
|
||||||
|
m_IsInit = false;
|
||||||
|
m_IsPause = false;
|
||||||
|
m_FadeOut = false;
|
||||||
|
m_FadeOuted = false;
|
||||||
|
m_DataAnimationState.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitProgress(int data, float curr, float dest)
|
public void InitProgress(int data, float curr, float dest)
|
||||||
{
|
{
|
||||||
if (!m_Inited && !m_IsEnd)
|
if (m_IsInit || m_IsEnd) return;
|
||||||
|
if (curr > dest) return;
|
||||||
|
m_IsInit = true;
|
||||||
|
m_DestDataProgress = data;
|
||||||
|
|
||||||
|
if (m_FadeOut)
|
||||||
|
{
|
||||||
|
m_CurrDetailProgress = dest;
|
||||||
|
m_DestDetailProgress = curr;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
m_Inited = true;
|
|
||||||
m_DestDataProgress = data;
|
|
||||||
m_CurrDetailProgress = curr;
|
m_CurrDetailProgress = curr;
|
||||||
m_DestDetailProgress = dest;
|
m_DestDetailProgress = dest;
|
||||||
}
|
}
|
||||||
@@ -126,23 +205,21 @@ namespace XCharts
|
|||||||
|
|
||||||
public void SetDataFinish(int dataIndex)
|
public void SetDataFinish(int dataIndex)
|
||||||
{
|
{
|
||||||
if (!m_IsEnd)
|
if (m_IsEnd) return;
|
||||||
{
|
m_CurrDataProgress = dataIndex + (m_FadeOut ? -1 : 1);
|
||||||
m_CurrDataProgress = dataIndex + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDataState(int index, float state)
|
private void SetDataState(int index, float state)
|
||||||
{
|
{
|
||||||
m_DataAnimationState[index] = state;
|
m_DataAnimationState[index] = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetDataState(int index)
|
private float GetDataState(int index, float dest)
|
||||||
{
|
{
|
||||||
if (IsInDelay()) return 0;
|
if (IsInDelay()) return dest;
|
||||||
if (!m_DataAnimationState.ContainsKey(index))
|
if (!m_DataAnimationState.ContainsKey(index))
|
||||||
{
|
{
|
||||||
m_DataAnimationState.Add(index, 0);
|
m_DataAnimationState.Add(index, dest);
|
||||||
}
|
}
|
||||||
return m_DataAnimationState[index];
|
return m_DataAnimationState[index];
|
||||||
}
|
}
|
||||||
@@ -152,7 +229,7 @@ namespace XCharts
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying) return true;
|
if (!Application.isPlaying) return true;
|
||||||
#endif
|
#endif
|
||||||
return !enable || (m_CurrDataProgress > m_DestDataProgress && m_CurrDetailProgress > m_DestDetailProgress);
|
return !enable || m_IsEnd || (m_CurrDataProgress > m_DestDataProgress && m_CurrDetailProgress > m_DestDetailProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsInDelay()
|
public bool IsInDelay()
|
||||||
@@ -160,7 +237,7 @@ namespace XCharts
|
|||||||
return (delay > 0 && Time.time - startTime < delay / 1000);
|
return (delay > 0 && Time.time - startTime < delay / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckDetailBreak(int dataIndex, float detail)
|
public bool CheckDetailBreak(float detail)
|
||||||
{
|
{
|
||||||
return !IsFinish() && detail > m_CurrDetailProgress;
|
return !IsFinish() && detail > m_CurrDetailProgress;
|
||||||
}
|
}
|
||||||
@@ -176,29 +253,95 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!m_Enable || m_IsEnd) return true;
|
if (!m_Enable || m_IsEnd) return true;
|
||||||
if (IsInDelay()) return false;
|
if (IsInDelay()) return false;
|
||||||
return dataIndex <= m_CurrDataProgress;
|
if (m_FadeOut) return dataIndex > 0;
|
||||||
|
else return dataIndex <= m_CurrDataProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckProgress(float delta)
|
internal void CheckProgress(float total)
|
||||||
{
|
{
|
||||||
if (!enable) return;
|
if (IsFinish()) return;
|
||||||
|
if (!m_IsInit || m_IsPause || m_IsEnd) return;
|
||||||
if (IsInDelay()) return;
|
if (IsInDelay()) return;
|
||||||
if (m_IsEnd) return;
|
m_ActualDuration = (int)((Time.time - startTime) * 1000) - delay;
|
||||||
if (m_CurrDetailProgress > m_DestDetailProgress)
|
var duration = GetCurrAnimationDuration();
|
||||||
|
var delta = total / duration * Time.deltaTime;
|
||||||
|
if (m_FadeOut)
|
||||||
{
|
{
|
||||||
End();
|
m_CurrDetailProgress -= delta;
|
||||||
|
if (m_CurrDetailProgress <= m_DestDetailProgress)
|
||||||
|
{
|
||||||
|
m_CurrDetailProgress = m_DestDetailProgress;
|
||||||
|
End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ActualDuration = (int)((Time.time - startTime) * 1000) - delay;
|
|
||||||
m_CurrDetailProgress += delta;
|
m_CurrDetailProgress += delta;
|
||||||
|
if (m_CurrDetailProgress >= m_DestDetailProgress)
|
||||||
|
{
|
||||||
|
m_CurrDetailProgress = m_DestDetailProgress;
|
||||||
|
End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckSymbol(float delta, float dest)
|
internal float GetCurrAnimationDuration()
|
||||||
{
|
{
|
||||||
m_CurrSymbolProgress += delta;
|
if (m_FadeOut) return m_FadeOutDuration > 0 ? m_FadeOutDuration / 1000 : 1;
|
||||||
if (m_CurrSymbolProgress > dest) m_CurrSymbolProgress = dest;
|
else return m_FadeInDuration > 0 ? m_FadeInDuration / 1000 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal float CheckBarProgress(int dataIndex, float barHig)
|
||||||
|
{
|
||||||
|
//if (!m_IsInit) return barHig;
|
||||||
|
var destHig = m_FadeOut ? barHig : 0;
|
||||||
|
if (IsInDelay() || IsFinish() || m_IsEnd)
|
||||||
|
{
|
||||||
|
return m_FadeOuted ? 0 : barHig;
|
||||||
|
}
|
||||||
|
else if (m_IsPause)
|
||||||
|
{
|
||||||
|
return GetDataState(dataIndex, destHig);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var duration = GetCurrAnimationDuration();
|
||||||
|
var delta = barHig / duration * Time.deltaTime;
|
||||||
|
var currHig = GetDataState(dataIndex, destHig) + (m_FadeOut ? -delta : delta);
|
||||||
|
SetDataState(dataIndex, currHig);
|
||||||
|
if (m_FadeOut)
|
||||||
|
{
|
||||||
|
if (currHig <= 0)
|
||||||
|
{
|
||||||
|
End();
|
||||||
|
currHig = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Mathf.Abs(currHig) >= Mathf.Abs(barHig))
|
||||||
|
{
|
||||||
|
End();
|
||||||
|
currHig = barHig;
|
||||||
|
}
|
||||||
|
return currHig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void CheckSymbol(float dest)
|
||||||
|
{
|
||||||
|
if (!enable || m_IsEnd || m_IsPause || !m_IsInit) return;
|
||||||
|
if (IsInDelay()) return;
|
||||||
|
var duration = GetCurrAnimationDuration();
|
||||||
|
var delta = dest / duration * Time.deltaTime;
|
||||||
|
if (m_FadeOut)
|
||||||
|
{
|
||||||
|
m_CurrSymbolProgress -= delta;
|
||||||
|
if (m_CurrSymbolProgress < 0) m_CurrSymbolProgress = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_CurrSymbolProgress += delta;
|
||||||
|
if (m_CurrSymbolProgress > dest) m_CurrSymbolProgress = dest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetSysmbolSize(float dest)
|
public float GetSysmbolSize(float dest)
|
||||||
@@ -206,7 +349,8 @@ namespace XCharts
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying) return dest;
|
if (!Application.isPlaying) return dest;
|
||||||
#endif
|
#endif
|
||||||
if (!enable || m_IsEnd) return dest;
|
if (!enable) return dest;
|
||||||
|
if (m_IsEnd) return m_FadeOut ? 0 : dest;
|
||||||
return m_CurrSymbolProgress;
|
return m_CurrSymbolProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,5 +381,16 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
return m_CurrDataProgress;
|
return m_CurrDataProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetUpdateAnimationDuration()
|
||||||
|
{
|
||||||
|
if (m_Enable && m_DataChangeEnable && IsFinish()) return m_DataChangeDuration;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasFadeOut()
|
||||||
|
{
|
||||||
|
return enable && m_FadeOuted && m_IsEnd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ using System.Linq;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
@@ -22,13 +23,9 @@ namespace XCharts
|
|||||||
[SerializeField] private string m_Name;
|
[SerializeField] private string m_Name;
|
||||||
[SerializeField] private bool m_Selected;
|
[SerializeField] private bool m_Selected;
|
||||||
[SerializeField] private float m_Radius;
|
[SerializeField] private float m_Radius;
|
||||||
[SerializeField] private bool m_ShowIcon;
|
[SerializeField] private IconStyle m_IconStyle = new IconStyle();
|
||||||
[SerializeField] private Sprite m_IconImage;
|
[SerializeField] private bool m_EnableLabel = false;
|
||||||
[SerializeField] private Color m_IconColor = Color.white;
|
[SerializeField] private SerieLabel m_Label = new SerieLabel();
|
||||||
[SerializeField] private float m_IconWidth = 40;
|
|
||||||
[SerializeField] private float m_IconHeight = 40;
|
|
||||||
[SerializeField] private Vector3 m_IconOffset;
|
|
||||||
|
|
||||||
[SerializeField] private List<float> m_Data = new List<float>();
|
[SerializeField] private List<float> m_Data = new List<float>();
|
||||||
|
|
||||||
private bool m_Show = true;
|
private bool m_Show = true;
|
||||||
@@ -58,32 +55,18 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
|
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the data icon is show.
|
/// the icon of data.
|
||||||
/// 是否显示图标。
|
/// 数据项图标样式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool showIcon { get { return m_ShowIcon; } set { m_ShowIcon = value; } }
|
public IconStyle iconStyle { get { return m_IconStyle; } set { m_IconStyle = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The image of icon.
|
/// 是否启用单个数据项的标签设置。
|
||||||
/// 图标的图片。
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Sprite iconImage { get { return m_IconImage; } set { m_IconImage = value; } }
|
public bool enableLabel { get { return m_EnableLabel; } set { m_EnableLabel = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 图标颜色。
|
/// 单个数据项的标签设置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color iconColor { get { return m_IconColor; } set { m_IconColor = value; } }
|
public SerieLabel label { get { return m_Label; } set { m_Label = value; } }
|
||||||
/// <summary>
|
|
||||||
/// 图标宽。
|
|
||||||
/// </summary>
|
|
||||||
public float iconWidth { get { return m_IconWidth; } set { m_IconWidth = value; } }
|
|
||||||
/// <summary>
|
|
||||||
/// 图标高。
|
|
||||||
/// </summary>
|
|
||||||
public float iconHeight { get { return m_IconHeight; } set { m_IconHeight = value; } }
|
|
||||||
/// <summary>
|
|
||||||
/// 图标偏移。
|
|
||||||
/// </summary>
|
|
||||||
public Vector3 iconOffset { get { return m_IconOffset; } set { m_IconOffset = value; } }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An arbitrary dimension data list of data item.
|
/// An arbitrary dimension data list of data item.
|
||||||
/// 可指定任意维数的数值列表。
|
/// 可指定任意维数的数值列表。
|
||||||
@@ -109,7 +92,7 @@ namespace XCharts
|
|||||||
/// 标志位置。
|
/// 标志位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 labelPosition { get; set; }
|
public Vector3 labelPosition { get; set; }
|
||||||
public bool m_CanShowLabel = true;
|
private bool m_CanShowLabel = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否可以显示Label
|
/// 是否可以显示Label
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -124,8 +107,7 @@ namespace XCharts
|
|||||||
/// 最小值。
|
/// 最小值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float min { get { return m_Data.Min(); } }
|
public float min { get { return m_Data.Min(); } }
|
||||||
public Image icon { get; private set; }
|
|
||||||
public RectTransform iconRect { get; private set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关联的gameObject
|
/// 关联的gameObject
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -133,34 +115,34 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的开始角度(运行时自动计算)
|
/// 饼图数据项的开始角度(运行时自动计算)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieStartAngle { get; set; }
|
public float runtimePieStartAngle { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的结束角度(运行时自动计算)
|
/// 饼图数据项的结束角度(运行时自动计算)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieToAngle { get; set; }
|
public float runtimePieToAngle { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的一半时的角度(运行时自动计算)
|
/// 饼图数据项的一半时的角度(运行时自动计算)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieHalfAngle { get; set; }
|
public float runtimePieHalfAngle { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的当前角度(运行时自动计算)
|
/// 饼图数据项的当前角度(运行时自动计算)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieCurrAngle { get; set; }
|
public float runtimePieCurrAngle { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的内半径
|
/// 饼图数据项的内半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieInsideRadius { get; set; }
|
public float runtimePieInsideRadius { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的外半径
|
/// 饼图数据项的外半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieOutsideRadius
|
public float runtimePieOutsideRadius
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (radius > 0) return radius;
|
if (radius > 0) return radius;
|
||||||
else return m_RtPieOutsideRadius;
|
else return m_RtPieOutsideRadius;
|
||||||
}
|
}
|
||||||
set
|
internal set
|
||||||
{
|
{
|
||||||
m_RtPieOutsideRadius = value;
|
m_RtPieOutsideRadius = value;
|
||||||
}
|
}
|
||||||
@@ -168,15 +150,104 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的偏移半径
|
/// 饼图数据项的偏移半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieOffsetRadius { get; set; }
|
public float runtimePieOffsetRadius { get; internal set; }
|
||||||
public Vector3 pieOffsetCenter { get; set; }
|
public Vector3 runtiemPieOffsetCenter { get; internal set; }
|
||||||
|
|
||||||
|
private List<float> m_PreviousData = new List<float>();
|
||||||
|
private List<float> m_DataUpdateTime = new List<float>();
|
||||||
|
private List<bool> m_DataUpdateFlag = new List<bool>();
|
||||||
|
|
||||||
public float GetData(int index)
|
public float GetData(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < m_Data.Count) return m_Data[index];
|
if (index >= 0 && index < m_Data.Count)
|
||||||
|
{
|
||||||
|
return m_Data[index];
|
||||||
|
}
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetPreviousData(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_PreviousData.Count)
|
||||||
|
{
|
||||||
|
return m_PreviousData[index];
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetFirstData(float animationDuration = 500f)
|
||||||
|
{
|
||||||
|
if (m_Data.Count > 0) return GetCurrData(0, animationDuration);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetLastData()
|
||||||
|
{
|
||||||
|
if (m_Data.Count > 0) return m_Data[m_Data.Count - 1];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetCurrData(int index, float animationDuration = 500f)
|
||||||
|
{
|
||||||
|
if (index < m_DataUpdateFlag.Count && m_DataUpdateFlag[index] && animationDuration > 0)
|
||||||
|
{
|
||||||
|
var time = Time.time - m_DataUpdateTime[index];
|
||||||
|
var total = animationDuration / 1000;
|
||||||
|
if (time <= total)
|
||||||
|
{
|
||||||
|
CheckLastData();
|
||||||
|
var curr = Mathf.Lerp(GetPreviousData(index), GetData(index), time / total);
|
||||||
|
return curr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_DataUpdateFlag[index] = false;
|
||||||
|
return GetData(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetData(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateData(int dimension, float value)
|
||||||
|
{
|
||||||
|
if (dimension >= 0 && dimension < data.Count)
|
||||||
|
{
|
||||||
|
CheckLastData();
|
||||||
|
m_PreviousData[dimension] = data[dimension];
|
||||||
|
m_DataUpdateTime[dimension] = Time.time;
|
||||||
|
m_DataUpdateFlag[dimension] = true;
|
||||||
|
data[dimension] = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckLastData()
|
||||||
|
{
|
||||||
|
if (m_PreviousData.Count != m_Data.Count)
|
||||||
|
{
|
||||||
|
m_PreviousData.Clear();
|
||||||
|
m_DataUpdateTime.Clear();
|
||||||
|
m_DataUpdateFlag.Clear();
|
||||||
|
for (int i = 0; i < m_Data.Count; i++)
|
||||||
|
{
|
||||||
|
m_PreviousData.Add(m_Data[i]);
|
||||||
|
m_DataUpdateTime.Add(Time.time);
|
||||||
|
m_DataUpdateFlag.Add(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDataChanged()
|
||||||
|
{
|
||||||
|
foreach (var b in m_DataUpdateFlag)
|
||||||
|
if (b) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void InitLabel(GameObject labelObj, bool autoSize, float paddingLeftRight, float paddingTopBottom)
|
public void InitLabel(GameObject labelObj, bool autoSize, float paddingLeftRight, float paddingTopBottom)
|
||||||
{
|
{
|
||||||
gameObject = labelObj;
|
gameObject = labelObj;
|
||||||
@@ -197,12 +268,13 @@ namespace XCharts
|
|||||||
|
|
||||||
public bool SetLabelText(string text)
|
public bool SetLabelText(string text)
|
||||||
{
|
{
|
||||||
if (labelText)
|
if (labelText && !labelText.text.Equals(text))
|
||||||
{
|
{
|
||||||
labelText.text = text;
|
labelText.text = text;
|
||||||
if (m_LabelAutoSize)
|
if (m_LabelAutoSize)
|
||||||
{
|
{
|
||||||
var newSize = new Vector2(labelText.preferredWidth + m_LabelPaddingLeftRight * 2,
|
var newSize = string.IsNullOrEmpty(text) ? Vector2.zero :
|
||||||
|
new Vector2(labelText.preferredWidth + m_LabelPaddingLeftRight * 2,
|
||||||
labelText.preferredHeight + m_LabelPaddingTopBottom * 2);
|
labelText.preferredHeight + m_LabelPaddingTopBottom * 2);
|
||||||
var sizeChange = newSize.x != labelRect.sizeDelta.x || newSize.y != labelRect.sizeDelta.y;
|
var sizeChange = newSize.x != labelRect.sizeDelta.x || newSize.y != labelRect.sizeDelta.y;
|
||||||
if (sizeChange) labelRect.sizeDelta = newSize;
|
if (sizeChange) labelRect.sizeDelta = newSize;
|
||||||
@@ -212,6 +284,14 @@ namespace XCharts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetLabelColor(Color color)
|
||||||
|
{
|
||||||
|
if (labelText)
|
||||||
|
{
|
||||||
|
labelText.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public float GetLabelWidth()
|
public float GetLabelWidth()
|
||||||
{
|
{
|
||||||
if (labelRect) return labelRect.sizeDelta.x;
|
if (labelRect) return labelRect.sizeDelta.x;
|
||||||
@@ -237,28 +317,30 @@ namespace XCharts
|
|||||||
if (labelRect) labelRect.localPosition = position;
|
if (labelRect) labelRect.localPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetIconObj(GameObject iconObj)
|
[Obsolete("Use SerieData.SetIconImage() instead.", true)]
|
||||||
|
public void SetIconObj(GameObject iconObj) { }
|
||||||
|
|
||||||
|
public void SetIconImage(Image image)
|
||||||
{
|
{
|
||||||
icon = iconObj.GetComponent<Image>();
|
if (iconStyle == null) return;
|
||||||
iconRect = iconObj.GetComponent<RectTransform>();
|
iconStyle.SetImage(image);
|
||||||
UpdateIcon();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateIcon()
|
public void UpdateIcon()
|
||||||
{
|
{
|
||||||
if (icon == null) return;
|
if (iconStyle == null) return;
|
||||||
if (m_ShowIcon)
|
iconStyle.UpdateIcon();
|
||||||
{
|
}
|
||||||
ChartHelper.SetActive(icon.gameObject, true);
|
|
||||||
icon.sprite = m_IconImage;
|
public bool IsInitLabel()
|
||||||
icon.color = m_IconColor;
|
{
|
||||||
iconRect.sizeDelta = new Vector2(m_IconWidth, m_IconHeight);
|
return labelText != null;
|
||||||
icon.transform.localPosition = m_IconOffset;
|
}
|
||||||
}
|
|
||||||
else
|
public SerieLabel GetSerieLabel(SerieLabel parentLabel)
|
||||||
{
|
{
|
||||||
ChartHelper.SetActive(icon.gameObject, false);
|
if (enableLabel) return label;
|
||||||
}
|
else return parentLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/******************************************/
|
/******************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
@@ -80,6 +81,7 @@ namespace XCharts
|
|||||||
[SerializeField] private bool m_Show = false;
|
[SerializeField] private bool m_Show = false;
|
||||||
[SerializeField] Position m_Position;
|
[SerializeField] Position m_Position;
|
||||||
[SerializeField] private Vector3 m_Offset;
|
[SerializeField] private Vector3 m_Offset;
|
||||||
|
[SerializeField] private float m_Margin;
|
||||||
[SerializeField] private string m_Formatter;
|
[SerializeField] private string m_Formatter;
|
||||||
[SerializeField] private float m_Rotate = 0;
|
[SerializeField] private float m_Rotate = 0;
|
||||||
[SerializeField] private float m_PaddingLeftRight = 2f;
|
[SerializeField] private float m_PaddingLeftRight = 2f;
|
||||||
@@ -99,16 +101,27 @@ namespace XCharts
|
|||||||
[SerializeField] private bool m_Border = true;
|
[SerializeField] private bool m_Border = true;
|
||||||
[SerializeField] private float m_BorderWidth = 0.5f;
|
[SerializeField] private float m_BorderWidth = 0.5f;
|
||||||
[SerializeField] private Color m_BorderColor = Color.grey;
|
[SerializeField] private Color m_BorderColor = Color.grey;
|
||||||
|
[SerializeField] private bool m_ForceENotation = false;
|
||||||
|
[NonSerialized] private bool m_LabelDirty = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the label is showed.
|
/// Whether the label is showed.
|
||||||
/// 是否显示文本标签。
|
/// 是否显示文本标签。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
public bool show
|
||||||
|
{
|
||||||
|
get { return m_Show; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The position of label.
|
/// The position of label.
|
||||||
/// 标签的位置。
|
/// 标签的位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Position position { get { return m_Position; } set { m_Position = value; } }
|
public Position position
|
||||||
|
{
|
||||||
|
get { return m_Position; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标签内容字符串模版格式器。支持用 \n 换行。
|
/// 标签内容字符串模版格式器。支持用 \n 换行。
|
||||||
/// 模板变量有:
|
/// 模板变量有:
|
||||||
@@ -122,114 +135,210 @@ namespace XCharts
|
|||||||
/// <example>
|
/// <example>
|
||||||
/// 示例:“{b}:{c}”
|
/// 示例:“{b}:{c}”
|
||||||
/// </example>
|
/// </example>
|
||||||
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
|
public string formatter
|
||||||
|
{
|
||||||
|
get { return m_Formatter; }
|
||||||
|
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// offset to the host graphic element.
|
/// offset to the host graphic element.
|
||||||
/// 距离图形元素的偏移
|
/// 距离图形元素的偏移
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
public Vector3 offset
|
||||||
|
{
|
||||||
|
get { return m_Offset; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 距离轴线的距离。
|
||||||
|
/// </summary>
|
||||||
|
public float margin
|
||||||
|
{
|
||||||
|
get { return m_Margin; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Text color,If set as default ,the color will assigned as series color.
|
/// Text color,If set as default ,the color will assigned as series color.
|
||||||
/// 自定义文字颜色,默认和系列的颜色一致。
|
/// 自定义文字颜色,默认和系列的颜色一致。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
public Color color
|
||||||
|
{
|
||||||
|
get { return m_Color; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Color, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the background color. If set as default, it means than don't show background.
|
/// the background color. If set as default, it means than don't show background.
|
||||||
/// 标签的背景色,默认无颜色。
|
/// 标签的背景色,默认无颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
|
public Color backgroundColor
|
||||||
|
{
|
||||||
|
get { return m_BackgroundColor; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the width of background. If set as default value 0, it means than the background width auto set as the text width.
|
/// the width of background. If set as default value 0, it means than the background width auto set as the text width.
|
||||||
/// 标签的背景宽度。一般不用指定,不指定时则自动是文字的宽度。
|
/// 标签的背景宽度。一般不用指定,不指定时则自动是文字的宽度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public float backgroundWidth { get { return m_BackgroundWidth; } set { m_BackgroundWidth = value; } }
|
public float backgroundWidth
|
||||||
|
{
|
||||||
|
get { return m_BackgroundWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the height of background. If set as default value 0, it means than the background height auto set as the text height.
|
/// the height of background. If set as default value 0, it means than the background height auto set as the text height.
|
||||||
/// 标签的背景高度。一般不用指定,不指定时则自动是文字的高度。
|
/// 标签的背景高度。一般不用指定,不指定时则自动是文字的高度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
/// <value></value>
|
||||||
public float backgroundHeight { get { return m_BackgroundHeight; } set { m_BackgroundHeight = value; } }
|
public float backgroundHeight
|
||||||
|
{
|
||||||
|
get { return m_BackgroundHeight; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BackgroundHeight, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rotate label.
|
/// Rotate label.
|
||||||
/// 标签旋转。
|
/// 标签旋转。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
public float rotate
|
||||||
|
{
|
||||||
|
get { return m_Rotate; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the text padding of left and right. defaut:2.
|
/// the text padding of left and right. defaut:2.
|
||||||
/// 左右边距。
|
/// 左右边距。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float paddingLeftRight { get { return m_PaddingLeftRight; } set { m_PaddingLeftRight = value; } }
|
public float paddingLeftRight
|
||||||
|
{
|
||||||
|
get { return m_PaddingLeftRight; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_PaddingLeftRight, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the text padding of top and bottom. defaut:2.
|
/// the text padding of top and bottom. defaut:2.
|
||||||
/// 上下边距。
|
/// 上下边距。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float paddingTopBottom { get { return m_PaddingTopBottom; } set { m_PaddingTopBottom = value; } }
|
public float paddingTopBottom
|
||||||
|
{
|
||||||
|
get { return m_PaddingTopBottom; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_PaddingTopBottom, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font size.
|
/// font size.
|
||||||
/// 文字的字体大小。
|
/// 文字的字体大小。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
public int fontSize
|
||||||
|
{
|
||||||
|
get { return m_FontSize; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// font style.
|
/// font style.
|
||||||
/// 文字的字体风格。
|
/// 文字的字体风格。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
public FontStyle fontStyle
|
||||||
|
{
|
||||||
|
get { return m_FontStyle; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show visual guide line.Will show when label position is set as 'outside'.
|
/// Whether to show visual guide line.Will show when label position is set as 'outside'.
|
||||||
/// 是否显示视觉引导线。在 label 位置 设置为'outside'的时候会显示视觉引导线。
|
/// 是否显示视觉引导线。在 label 位置 设置为'outside'的时候会显示视觉引导线。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool line { get { return m_Line; } set { m_Line = value; } }
|
public bool line
|
||||||
|
{
|
||||||
|
get { return m_Line; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Line, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the type of visual guide line.
|
/// the type of visual guide line.
|
||||||
/// 视觉引导线类型。
|
/// 视觉引导线类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LineType lineType { get { return m_LineType; } set { m_LineType = value; } }
|
public LineType lineType
|
||||||
|
{
|
||||||
|
get { return m_LineType; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of visual guild line.
|
/// the color of visual guild line.
|
||||||
/// 视觉引导线颜色。默认和serie一致取自调色板。
|
/// 视觉引导线颜色。默认和serie一致取自调色板。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color lineColor { get { return m_LineColor; } set { m_LineColor = value; } }
|
public Color lineColor
|
||||||
|
{
|
||||||
|
get { return m_LineColor; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the width of visual guild line.
|
/// the width of visual guild line.
|
||||||
/// 视觉引导线的宽度。
|
/// 视觉引导线的宽度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float lineWidth { get { return m_LineWidth; } set { m_LineWidth = value; } }
|
public float lineWidth
|
||||||
|
{
|
||||||
|
get { return m_LineWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the first segment of visual guide line.
|
/// The length of the first segment of visual guide line.
|
||||||
/// 视觉引导线第一段的长度。
|
/// 视觉引导线第一段的长度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float lineLength1 { get { return m_LineLength1; } set { m_LineLength1 = value; } }
|
public float lineLength1
|
||||||
|
{
|
||||||
|
get { return m_LineLength1; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineLength1, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of the second segment of visual guide line.
|
/// The length of the second segment of visual guide line.
|
||||||
/// 视觉引导线第二段的长度。
|
/// 视觉引导线第二段的长度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float lineLength2 { get { return m_LineLength2; } set { m_LineLength2 = value; } }
|
public float lineLength2
|
||||||
|
{
|
||||||
|
get { return m_LineLength2; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show border.
|
/// Whether to show border.
|
||||||
/// 是否显示边框。
|
/// 是否显示边框。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool border { get { return m_Border; } set { m_Border = value; } }
|
public bool border
|
||||||
|
{
|
||||||
|
get { return m_Border; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_Border, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the width of border.
|
/// the width of border.
|
||||||
/// 边框宽度。
|
/// 边框宽度。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float borderWidth { get { return m_BorderWidth; } set { m_BorderWidth = value; } }
|
public float borderWidth
|
||||||
|
{
|
||||||
|
get { return m_BorderWidth; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the color of border.
|
/// the color of border.
|
||||||
/// 边框颜色。
|
/// 边框颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color borderColor { get { return m_BorderColor; } set { m_BorderColor = value; } }
|
public Color borderColor
|
||||||
|
{
|
||||||
|
get { return m_BorderColor; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
/// </summary>
|
||||||
|
public bool forceENotation
|
||||||
|
{
|
||||||
|
get { return m_ForceENotation; }
|
||||||
|
set { if (PropertyUtility.SetStruct(ref m_ForceENotation, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
|
||||||
public string GetFormatterContent(string serieName, string dataName, float dataValue, float dataTotal = 0)
|
public string GetFormatterContent(string serieName, string dataName, float dataValue, float dataTotal = 0)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(m_Formatter))
|
if (string.IsNullOrEmpty(m_Formatter))
|
||||||
return ChartCached.FloatToStr(dataValue);
|
return ChartCached.FloatToStr(dataValue, 0, m_ForceENotation);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var content = m_Formatter.Replace("{a}", serieName);
|
var content = m_Formatter.Replace("{a}", serieName);
|
||||||
content = content.Replace("{b}", dataName);
|
content = content.Replace("{b}", dataName);
|
||||||
content = content.Replace("{c}", ChartCached.FloatToStr(dataValue));
|
content = content.Replace("{c}", ChartCached.FloatToStr(dataValue, 0, m_ForceENotation));
|
||||||
content = content.Replace("{c:f0}", ChartCached.IntToStr((int)Mathf.Round(dataValue)));
|
content = content.Replace("{c:f0}", ChartCached.IntToStr((int)Mathf.Round(dataValue)));
|
||||||
content = content.Replace("{c:f1}", ChartCached.FloatToStr(dataValue, 1));
|
content = content.Replace("{c:f1}", ChartCached.FloatToStr(dataValue, 1));
|
||||||
content = content.Replace("{c:f2}", ChartCached.FloatToStr(dataValue, 2));
|
content = content.Replace("{c:f2}", ChartCached.FloatToStr(dataValue, 2));
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user