mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-06-17 00:03:51 +00:00
Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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,51 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
|
* (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.updateAnimation`
|
||||||
|
* (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.updateAnimation = 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
|
||||||
@@ -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.updateAnimation = true;
|
||||||
|
serie.arcShaped = 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,34 @@ 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)
|
|
||||||
{
|
|
||||||
chart = gameObject.AddComponent<LineChart>();
|
|
||||||
}
|
|
||||||
|
|
||||||
var buttom = transform.parent.gameObject.GetComponentInChildren<Button>();
|
|
||||||
buttom.onClick.AddListener(AddData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddData()
|
void Update()
|
||||||
{
|
{
|
||||||
chart.series.list[0].ClearData();
|
updateTime += Time.deltaTime;
|
||||||
chart.series.list[1].ClearData();
|
if (chart && updateTime > 2)
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
{
|
||||||
chart.AddData(0, Random.Range(20, 100));
|
updateTime = 0;
|
||||||
chart.AddData(1, Random.Range(1, 10));
|
var serie = chart.series.GetSerie(0);
|
||||||
|
serie.animation.updateAnimation = true;
|
||||||
|
var dataCount = serie.dataCount;
|
||||||
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)`:设置指定系列是否显示。
|
||||||
@@ -46,8 +49,6 @@
|
|||||||
|
|
||||||
## `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 +70,41 @@
|
|||||||
|
|
||||||
## `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`。
|
||||||
|
|
||||||
[返回首页](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,15 @@
|
|||||||
* [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)
|
||||||
* [Settings 设置](#Settings)
|
* [Settings 设置](#Settings)
|
||||||
* [Theme 主题](#Theme)
|
* [Theme 主题](#Theme)
|
||||||
* [Tooltip 提示框](#Tooltip)
|
* [Tooltip 提示框](#Tooltip)
|
||||||
@@ -34,10 +42,10 @@
|
|||||||
* [SerieData 数据项](#SerieData)
|
* [SerieData 数据项](#SerieData)
|
||||||
* [SerieLabel 图形上的文本标签](#SerieLabel)
|
* [SerieLabel 图形上的文本标签](#SerieLabel)
|
||||||
* [SerieSymbol 图形标记](#SerieSymbol)
|
* [SerieSymbol 图形标记](#SerieSymbol)
|
||||||
|
* [TextStyle 文本样式](#TextStyle)
|
||||||
|
|
||||||
## `Theme`
|
## `Theme`
|
||||||
|
|
||||||
---
|
|
||||||
主题组件。主题用来配置图表的全局配色等其他参数。
|
主题组件。主题用来配置图表的全局配色等其他参数。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -70,22 +78,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`
|
||||||
|
|
||||||
---
|
|
||||||
图例组件。图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
图例组件。图例组件展现了不同系列的标记,颜色和名字。可以通过点击图例控制哪些系列不显示。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -115,9 +132,38 @@
|
|||||||
* `GetData(int index)`:获得指定索引的图例。
|
* `GetData(int index)`:获得指定索引的图例。
|
||||||
* `GetIndex(string legendName)`:获得指定图例的索引。
|
* `GetIndex(string legendName)`:获得指定图例的索引。
|
||||||
|
|
||||||
## `Tooltip`
|
## `Radar`
|
||||||
|
|
||||||
---
|
* `shape`:雷达图绘制类型。
|
||||||
|
* `Polygon`:多边形。
|
||||||
|
* `Circle`:圆形。
|
||||||
|
* `positionType`:显示位置类型。
|
||||||
|
* `Vertice`:显示在顶点处。
|
||||||
|
* `Between`:显示在顶点之间。
|
||||||
|
* `radius`:雷达图的半径。
|
||||||
|
* `center`:雷达图的中心点。数组的第一项是横坐标,第二项是纵坐标。当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||||
|
* `lineStyle`:线条样式 [LineStyle](#LineStyle)。
|
||||||
|
* `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。
|
||||||
|
* `indicator`:是否显示指示器。
|
||||||
|
* `indicatorGap`:指示器和雷达的间距。
|
||||||
|
* `indicatorList`指示器列表 [Radar.Indicator](#Radar.Indicator)。
|
||||||
|
|
||||||
|
## `Radar.Indicator`
|
||||||
|
|
||||||
|
* `name`:指示器名称。
|
||||||
|
* `max`:指示器的最大值,默认为 0 无限制。
|
||||||
|
* `min`:指示器的最小值,默认为 0 无限制。
|
||||||
|
* `textStyle`:文本样式 [TextStyle](#TextStyle)。
|
||||||
|
|
||||||
|
## `TextStyle`
|
||||||
|
|
||||||
|
* `rotate`:旋转。
|
||||||
|
* `offset`:偏移。
|
||||||
|
* `color`:颜色。
|
||||||
|
* `fontSize`:字体大小。
|
||||||
|
* `fontStyle`:字体风格。
|
||||||
|
|
||||||
|
## `Tooltip`
|
||||||
|
|
||||||
提示框组件。
|
提示框组件。
|
||||||
|
|
||||||
@@ -129,20 +175,23 @@
|
|||||||
* `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` 优先级高。
|
||||||
|
* `fontSize`:文字的字体大小。
|
||||||
|
* `fontStyle`:文字的字体风格。
|
||||||
|
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
|
||||||
## `DataZoom`
|
## `DataZoom`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
区域缩放组件。用于区域缩放,从而能自由关注细节的数据信息,或者概览数据整体,或者去除离群点的影响。
|
区域缩放组件。用于区域缩放,从而能自由关注细节的数据信息,或者概览数据整体,或者去除离群点的影响。
|
||||||
目前只支持控制 `X` 轴。
|
目前只支持控制 `X` 轴。
|
||||||
|
|
||||||
@@ -172,11 +221,10 @@
|
|||||||
* `scrollSensitivity`:缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
* `scrollSensitivity`:缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
||||||
* `fontSize`:字体大小。
|
* `fontSize`:字体大小。
|
||||||
* `fontStyle`:字体样式。
|
* `fontStyle`:字体样式。
|
||||||
|
* `minShowNum`:最小显示数据个数。当DataZoom放大到最大时,最小显示的数据个数。
|
||||||
|
|
||||||
## `VisualMap`
|
## `VisualMap`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
视觉映射组件。用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)。
|
视觉映射组件。用于进行『视觉编码』,也就是将数据映射到视觉元素(视觉通道)。
|
||||||
|
|
||||||
* `enable`:开启或关闭视觉映射功能。
|
* `enable`:开启或关闭视觉映射功能。
|
||||||
@@ -207,8 +255,6 @@
|
|||||||
|
|
||||||
## `Grid`
|
## `Grid`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
网格组件。直角坐标系内绘图网格,单个 `grid` 内最多可以放置上下两个 `X` 轴,左右两个 `Y` 轴。可以在网格上绘制折线图,柱状图,散点图(气泡图)。目前最多只能存在一个 `grid` 组件。
|
网格组件。直角坐标系内绘图网格,单个 `grid` 内最多可以放置上下两个 `X` 轴,左右两个 `Y` 轴。可以在网格上绘制折线图,柱状图,散点图(气泡图)。目前最多只能存在一个 `grid` 组件。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -220,18 +266,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`:最小值-最大值。
|
||||||
@@ -265,8 +329,6 @@
|
|||||||
|
|
||||||
## `YAxis`
|
## `YAxis`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
直角坐标系 `grid` 中的 `Y` 轴。单个 `grid` 组件最多只能放左右两个 `Y` 轴。两个 `Y` 轴存储在 `yAxises` 中。
|
直角坐标系 `grid` 中的 `Y` 轴。单个 `grid` 组件最多只能放左右两个 `Y` 轴。两个 `Y` 轴存储在 `yAxises` 中。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -307,8 +369,6 @@
|
|||||||
|
|
||||||
## `Series`
|
## `Series`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
系列列表。每个系列通过 type 决定自己的图表类型。
|
系列列表。每个系列通过 type 决定自己的图表类型。
|
||||||
|
|
||||||
相关参数:
|
相关参数:
|
||||||
@@ -365,18 +425,169 @@
|
|||||||
* `pieSpace`:饼图项间的空隙留白。
|
* `pieSpace`:饼图项间的空隙留白。
|
||||||
* `pieCenter`:饼图的中心点。
|
* `pieCenter`:饼图的中心点。
|
||||||
* `pieRadius`:饼图的半径。`radius[0]` 表示内径,`radius[1]` 表示外径。
|
* `pieRadius`:饼图的半径。`radius[0]` 表示内径,`radius[1]` 表示外径。
|
||||||
|
* `arcShaped`:启用弧形圆角效果。目前只在仪表盘和圆环饼图中有效。
|
||||||
* `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`时会实时计算所有数据的平均值。
|
||||||
|
* `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` 时有效。
|
||||||
|
* `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时即为圆环图。
|
||||||
|
* `arcShaped`:是否启用圆角效果。只在圆环图中有效。
|
||||||
|
* `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)。
|
||||||
|
* `animation`:起始动画 [SerieAnimation](#SerieAnimation)。
|
||||||
|
* `data`:系列中的数据项 [SerieData](#SerieData) 数组,可以设置`1`到`n`维数据。
|
||||||
|
|
||||||
|
## `Serie-Scatter`
|
||||||
|
|
||||||
|
散点图系列。
|
||||||
|
|
||||||
|
* `show`:系列是否显示在图表上。
|
||||||
|
* `type`:`Scatter`。
|
||||||
|
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||||
|
* `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`:仪表盘刻度分割段数。
|
||||||
|
* `arcShaped`:是否启用圆角效果。
|
||||||
|
* `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`样式显示。
|
||||||
|
|
||||||
## `Settings`
|
## `Settings`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
|
全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
|
||||||
|
|
||||||
* `lineSmoothStyle`:曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
|
* `lineSmoothStyle`:曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
|
||||||
@@ -384,21 +595,19 @@
|
|||||||
* `lineSegmentDistance`: 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
* `lineSegmentDistance`: 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
|
||||||
* `cicleSmoothness`:圆形(包括扇形、环形等)的平滑度。数越小圆越平滑,但顶点数也会随之增加。
|
* `cicleSmoothness`:圆形(包括扇形、环形等)的平滑度。数越小圆越平滑,但顶点数也会随之增加。
|
||||||
|
|
||||||
## `Animation`
|
## `SerieAnimation`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `enable`:是否开起始画效果。
|
* `enable`:是否开起始画效果。
|
||||||
* `easing`:动画的缓动效果。支持以下动画效果:
|
* `easing`:动画的缓动效果。支持以下动画效果:
|
||||||
* `Linear`:线性效果。
|
* `Linear`:线性效果。
|
||||||
* `duration`:设定的动画时长,单位毫秒。
|
* `duration`:设定的动画时长,单位毫秒。
|
||||||
|
* `updateAnimation`:是否开启数据变更动画。
|
||||||
|
* `updateDuration`:数据变更动画时长,单位毫秒。
|
||||||
* `threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。
|
* `threshold`:是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。
|
||||||
* `delay`:动画延时,单位毫秒。
|
* `delay`:动画延时,单位毫秒。
|
||||||
|
|
||||||
## `AreaStyle`
|
## `AreaStyle`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示区域填充。
|
* `show`:是否显示区域填充。
|
||||||
* `origin`:区域填充的起始位置 `AreaOrigin`。有以下三种填充方式:
|
* `origin`:区域填充的起始位置 `AreaOrigin`。有以下三种填充方式:
|
||||||
* `Auto`:填充坐标轴轴线到数据间的区域。
|
* `Auto`:填充坐标轴轴线到数据间的区域。
|
||||||
@@ -413,8 +622,6 @@
|
|||||||
|
|
||||||
## `AxisLabel`
|
## `AxisLabel`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示刻度标签。
|
* `show`:是否显示刻度标签。
|
||||||
* `interval`:坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
* `interval`:坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||||
* `inside`:刻度标签是否朝内,默认朝外。
|
* `inside`:刻度标签是否朝内,默认朝外。
|
||||||
@@ -423,12 +630,11 @@
|
|||||||
* `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时才采用科学计数法。
|
||||||
|
|
||||||
## `AxisLine`
|
## `AxisLine`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示坐标轴轴线。
|
* `show`:是否显示坐标轴轴线。
|
||||||
* `onZero`:X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
* `onZero`:X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
||||||
* `width`:坐标轴线线宽。
|
* `width`:坐标轴线线宽。
|
||||||
@@ -440,8 +646,6 @@
|
|||||||
|
|
||||||
## `AxisName`
|
## `AxisName`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示坐标名称。
|
* `show`:是否显示坐标名称。
|
||||||
* `name`:坐标轴名称。
|
* `name`:坐标轴名称。
|
||||||
* `location`:坐标轴名称的位置。支持以下类型:
|
* `location`:坐标轴名称的位置。支持以下类型:
|
||||||
@@ -456,15 +660,11 @@
|
|||||||
|
|
||||||
## `AxisSplitArea`
|
## `AxisSplitArea`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示坐标分割区域。
|
* `show`:是否显示坐标分割区域。
|
||||||
* `color`:分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
* `color`:分隔区域颜色。分隔区域会按数组中颜色的顺序依次循环设置颜色。默认是一个深浅的间隔色。
|
||||||
|
|
||||||
## `AxisTick`
|
## `AxisTick`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示坐标轴刻度。
|
* `show`:是否显示坐标轴刻度。
|
||||||
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
* `alignWithLabel`:类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
||||||
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
||||||
@@ -472,16 +672,12 @@
|
|||||||
|
|
||||||
## `Emphasis`
|
## `Emphasis`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否启用高亮样式。
|
* `show`:是否启用高亮样式。
|
||||||
* `label`:图形文本标签样式 [SerieLabel](#SerieLabel)。
|
* `label`:图形文本标签样式 [SerieLabel](#SerieLabel)。
|
||||||
* `itemStyle`:图形样式 [ItemStyle](#ItemStyle)。
|
* `itemStyle`:图形样式 [ItemStyle](#ItemStyle)。
|
||||||
|
|
||||||
## `ItemStyle`
|
## `ItemStyle`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否启用。
|
* `show`:是否启用。
|
||||||
* `color`:颜色。
|
* `color`:颜色。
|
||||||
* `borderType`:边框的类型。
|
* `borderType`:边框的类型。
|
||||||
@@ -491,8 +687,6 @@
|
|||||||
|
|
||||||
## `LineArrow`
|
## `LineArrow`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示箭头。
|
* `show`:是否显示箭头。
|
||||||
* `position`:箭头显示位置。支持以下两种位置:
|
* `position`:箭头显示位置。支持以下两种位置:
|
||||||
* `End`:末端显示。最后一个数据上显示箭头。
|
* `End`:末端显示。最后一个数据上显示箭头。
|
||||||
@@ -504,8 +698,6 @@
|
|||||||
|
|
||||||
## `LineStyle`
|
## `LineStyle`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示线条。在折线图中无效。
|
* `show`:是否显示线条。在折线图中无效。
|
||||||
* `type`:线条类型。支持以下五种类型:
|
* `type`:线条类型。支持以下五种类型:
|
||||||
* `None`:不显示分割线。
|
* `None`:不显示分割线。
|
||||||
@@ -520,8 +712,6 @@
|
|||||||
|
|
||||||
## `Location`
|
## `Location`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `align`:对齐方式。有以下对齐方式。
|
* `align`:对齐方式。有以下对齐方式。
|
||||||
* `TopLeft`:左上角对齐。
|
* `TopLeft`:左上角对齐。
|
||||||
* `TopRight`:右上角对齐。
|
* `TopRight`:右上角对齐。
|
||||||
@@ -539,8 +729,6 @@
|
|||||||
|
|
||||||
## `SerieData`
|
## `SerieData`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `name`:数据项名称。
|
* `name`:数据项名称。
|
||||||
* `selected`:该数据项是否被选中。
|
* `selected`:该数据项是否被选中。
|
||||||
* `radius`:自定义半径。可用在饼图中自定义某个数据项的半径。
|
* `radius`:自定义半径。可用在饼图中自定义某个数据项的半径。
|
||||||
@@ -553,8 +741,6 @@
|
|||||||
|
|
||||||
## `SerieLabel`
|
## `SerieLabel`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `show`:是否显示文本标签。
|
* `show`:是否显示文本标签。
|
||||||
* `position`:标签的位置。折线图时强制默认为 `Center`,支持以下 `5` 种位置:
|
* `position`:标签的位置。折线图时强制默认为 `Center`,支持以下 `5` 种位置:
|
||||||
* `Outside`:饼图扇区外侧,通过视觉引导线连到相应的扇区。只在饼图种可用。
|
* `Outside`:饼图扇区外侧,通过视觉引导线连到相应的扇区。只在饼图种可用。
|
||||||
@@ -585,11 +771,10 @@
|
|||||||
* `border`:是否显示边框。
|
* `border`:是否显示边框。
|
||||||
* `borderWidth`:边框宽度。
|
* `borderWidth`:边框宽度。
|
||||||
* `borderColor`:边框颜色。
|
* `borderColor`:边框颜色。
|
||||||
|
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
|
||||||
## `SerieSymbol`
|
## `SerieSymbol`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `type`:标记类型。支持以下六种类型:
|
* `type`:标记类型。支持以下六种类型:
|
||||||
* `EmptyCircle`:空心圆。
|
* `EmptyCircle`:空心圆。
|
||||||
* `Circle`:实心圆。
|
* `Circle`:实心圆。
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -24,11 +24,13 @@ namespace XCharts
|
|||||||
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_Duration = prop.FindPropertyRelative("m_Duration");
|
||||||
|
SerializedProperty m_UpdateAnimation = prop.FindPropertyRelative("m_UpdateAnimation");
|
||||||
|
SerializedProperty m_UpdateDuration = prop.FindPropertyRelative("m_UpdateDuration");
|
||||||
SerializedProperty m_Delay = prop.FindPropertyRelative("m_Delay");
|
SerializedProperty m_Delay = prop.FindPropertyRelative("m_Delay");
|
||||||
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;
|
||||||
@@ -37,20 +39,26 @@ namespace XCharts
|
|||||||
++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_Delay);
|
||||||
|
if (m_Delay.floatValue < 0) m_Delay.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_Duration);
|
||||||
|
if (m_Duration.floatValue < 0) m_Duration.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_UpdateAnimation);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_UpdateDuration);
|
||||||
|
if (m_UpdateDuration.floatValue < 0) m_UpdateDuration.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,6 +33,8 @@ 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");
|
||||||
@@ -59,6 +61,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,6 +89,7 @@ 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);
|
||||||
@@ -180,6 +190,15 @@ 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);
|
||||||
@@ -192,7 +211,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,7 @@ 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");
|
||||||
|
|
||||||
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 +52,8 @@ 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.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,7 +63,7 @@ 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 += 9 * EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -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_LineStyle;
|
||||||
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_LineStyle = prop.FindPropertyRelative("m_LineStyle");
|
||||||
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;
|
||||||
@@ -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,9 +107,9 @@ 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_LineStyle"));
|
||||||
@@ -110,7 +118,7 @@ namespace XCharts
|
|||||||
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,17 @@ 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_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
|
||||||
|
//SerializedProperty m_Clockwise = prop.FindPropertyRelative("m_Clockwise");
|
||||||
|
SerializedProperty m_ArcShaped = prop.FindPropertyRelative("m_ArcShaped");
|
||||||
|
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_Datas = prop.FindPropertyRelative("m_Data");
|
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
||||||
|
|
||||||
int index = InitToggle(prop);
|
int index = InitToggle(prop);
|
||||||
@@ -82,87 +93,155 @@ 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_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_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_ArcShaped);
|
||||||
|
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.Radar:
|
||||||
|
EditorGUI.PropertyField(drawRect, m_RadarIndex);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||||
|
break;
|
||||||
|
case SerieType.Scatter:
|
||||||
|
case SerieType.EffectScatter:
|
||||||
|
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_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_ArcShaped);
|
||||||
|
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 +252,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 +260,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 +311,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 +332,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 +340,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 +353,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,35 +375,23 @@ namespace XCharts
|
|||||||
EditorGUIUtility.fieldWidth = lastFieldWid;
|
EditorGUIUtility.fieldWidth = lastFieldWid;
|
||||||
EditorGUIUtility.labelWidth = lastLabelWid;
|
EditorGUIUtility.labelWidth = lastLabelWid;
|
||||||
}
|
}
|
||||||
if (showIconDetail)
|
if (showDetail)
|
||||||
{
|
{
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
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_EnableLabel);
|
||||||
EditorGUI.PropertyField(drawRect, m_ShowIcon);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_IconImage);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_IconColor);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_IconWidth);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
EditorGUI.PropertyField(drawRect, m_IconHeight);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
||||||
|
|
||||||
EditorGUI.LabelField(drawRect, "Icon Offset");
|
|
||||||
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
|
||||||
var tempWidth = (drawRect.width - startX + 72) / 2;
|
|
||||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
|
||||||
var centerYRect = new Rect(centerXRect.x + tempWidth - 58, drawRect.y, tempWidth, drawRect.height);
|
|
||||||
var x = EditorGUI.FloatField(centerXRect, m_IconOffset.vector3Value.x);
|
|
||||||
var y = EditorGUI.FloatField(centerYRect, m_IconOffset.vector3Value.y);
|
|
||||||
m_IconOffset.vector3Value = new Vector3(x, y);
|
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
if (m_EnableLabel.boolValue)
|
||||||
|
{
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_Label);
|
||||||
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Label);
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
|
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
@@ -340,48 +407,93 @@ 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
|
|
||||||
|| serieType == SerieType.Scatter
|
|
||||||
|| serieType == SerieType.EffectScatter
|
|
||||||
|| serieType == SerieType.Radar)
|
|
||||||
{
|
|
||||||
|
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
|
||||||
}
|
switch (serieType)
|
||||||
if (serieType == SerieType.Pie)
|
|
||||||
{
|
{
|
||||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
case SerieType.Line:
|
||||||
}
|
height += 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
if (serieType == SerieType.Line)
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||||
{
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||||
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
}
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||||
if (serieType == SerieType.Bar)
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
{
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
|
case SerieType.Bar:
|
||||||
|
height += 16 * EditorGUIUtility.singleLineHeight + 15 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
|
case SerieType.Pie:
|
||||||
|
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += 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 += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||||
|
break;
|
||||||
|
case SerieType.Scatter:
|
||||||
|
case SerieType.EffectScatter:
|
||||||
|
height += 4 * EditorGUIUtility.singleLineHeight + 3 * 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_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"));
|
||||||
|
if (item.FindPropertyRelative("m_EnableLabel").boolValue)
|
||||||
|
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
|
||||||
{
|
{
|
||||||
|
|||||||
63
Assets/XCharts/Editor/PropertyDrawers/TextStyleDrawer.cs
Normal file
63
Assets/XCharts/Editor/PropertyDrawers/TextStyleDrawer.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* 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_Rotate = prop.FindPropertyRelative("m_Rotate");
|
||||||
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||||
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
||||||
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
||||||
|
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
||||||
|
// ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TextStyleToggle, prop, "Text Style");
|
||||||
|
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
// if (ChartEditorHelper.IsToggle(m_TextStyleToggle, prop))
|
||||||
|
// {
|
||||||
|
// ++EditorGUI.indentLevel;
|
||||||
|
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_FontSize);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
||||||
|
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 += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
// }
|
||||||
|
float height = 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
|
||||||
|
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");
|
||||||
|
|
||||||
@@ -35,17 +35,17 @@ 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.indentLevel;
|
||||||
EditorGUI.PropertyField(drawRect, m_TextFontSize, new GUIContent("Font Size"));
|
EditorGUI.PropertyField(drawRect, m_TextStyle);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
|
||||||
--EditorGUI.indentLevel;
|
--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.indentLevel;
|
||||||
EditorGUI.PropertyField(drawRect, m_SubTextFontSize, new GUIContent("Font Size"));
|
EditorGUI.PropertyField(drawRect, m_SubTextStyle);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUI.GetPropertyHeight(m_SubTextStyle);
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
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);
|
||||||
}
|
}
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
@@ -56,9 +56,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,12 +22,15 @@ 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_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");
|
||||||
|
|
||||||
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;
|
||||||
@@ -37,6 +40,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_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);
|
||||||
@@ -49,13 +56,15 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 12 * EditorGUIUtility.singleLineHeight + 11 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
else
|
else
|
||||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public class ChartEditorHelper
|
|||||||
{
|
{
|
||||||
if (showProp.propertyType == SerializedPropertyType.Boolean)
|
if (showProp.propertyType == SerializedPropertyType.Boolean)
|
||||||
{
|
{
|
||||||
drawRect.width = 60;
|
drawRect.width = 80;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
108
Assets/XCharts/Editor/XChartEditor.cs
Normal file
108
Assets/XCharts/Editor/XChartEditor.cs
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
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>();
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The title setting of chart.
|
/// The title setting of chart.
|
||||||
/// 标题组件
|
/// 标题组件
|
||||||
@@ -254,10 +258,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 +275,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 +358,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 +370,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>
|
||||||
@@ -416,6 +494,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.
|
||||||
/// 启用或关闭起始动画。
|
/// 启用或关闭起始动画。
|
||||||
|
|||||||
@@ -146,18 +146,18 @@ namespace XCharts
|
|||||||
|
|
||||||
/// <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;
|
||||||
}
|
}
|
||||||
|
|||||||
131
Assets/XCharts/Runtime/API/RadarChart_API.cs
Normal file
131
Assets/XCharts/Runtime/API/RadarChart_API.cs
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* 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();
|
||||||
|
}
|
||||||
|
m_CheckRadars.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.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:
|
||||||
@@ -21,7 +21,7 @@ namespace XCharts
|
|||||||
/// <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); } }
|
||||||
|
|
||||||
public void OnAfterDeserialize()
|
internal void OnAfterDeserialize()
|
||||||
{
|
{
|
||||||
if (m_DataFromJson)
|
if (m_DataFromJson)
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnBeforeSerialize()
|
internal void OnBeforeSerialize()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -95,14 +100,16 @@ namespace XCharts
|
|||||||
[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 bool m_ShowSplitLine = false;
|
||||||
[SerializeField] protected SplitLineType m_SplitLineType = SplitLineType.Dashed;
|
[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;
|
||||||
@@ -132,12 +139,12 @@ namespace XCharts
|
|||||||
/// 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 { m_Min = value; } }
|
||||||
/// <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 { m_Max = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of segments that the axis is split into.
|
/// Number of segments that the axis is split into.
|
||||||
/// 坐标轴的分割段数。
|
/// 坐标轴的分割段数。
|
||||||
@@ -164,6 +171,15 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
|
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
|
||||||
/// <summary>
|
/// <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 { m_LogBase = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 对数轴是否以自然数 e 为底数,为 true 时 logBase 失效。
|
||||||
|
/// </summary>
|
||||||
|
public bool logBaseE { get { return m_LogBaseE; } set { m_LogBaseE = value; } }
|
||||||
|
/// <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时超过指定值会移除旧数据再插入新数据。
|
||||||
@@ -208,30 +224,83 @@ 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
|
||||||
|
{
|
||||||
|
if (value != m_RuntimeMinValue)
|
||||||
|
{
|
||||||
|
if (m_RuntimeMinValueFirstChanged)
|
||||||
|
{
|
||||||
|
m_RuntimeMinValueFirstChanged = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeLastMinValue = m_RuntimeMinValue;
|
||||||
|
m_RuntimeMinValueChanged = true;
|
||||||
|
m_RuntimeMinValueUpdateTime = Time.time;
|
||||||
|
}
|
||||||
|
m_RuntimeMinValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <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
|
||||||
|
{
|
||||||
|
if (value != m_RuntimeMaxValue)
|
||||||
|
{
|
||||||
|
if (m_RuntimeMaxValueFirstChanged)
|
||||||
|
{
|
||||||
|
m_RuntimeMaxValueFirstChanged = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_RuntimeLastMaxValue = m_RuntimeMaxValue;
|
||||||
|
m_RuntimeMaxValueChanged = true;
|
||||||
|
m_RuntimeMaxValueUpdateTime = Time.time;
|
||||||
|
}
|
||||||
|
m_RuntimeMaxValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <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;
|
||||||
|
private float m_RuntimeLastMinValue;
|
||||||
|
private bool m_RuntimeMinValueChanged;
|
||||||
|
private float m_RuntimeMinValueUpdateTime;
|
||||||
|
private float m_RuntimeMaxValue;
|
||||||
|
private float m_RuntimeLastMaxValue;
|
||||||
|
private bool m_RuntimeMaxValueChanged;
|
||||||
|
private float m_RuntimeMaxValueUpdateTime;
|
||||||
|
private bool m_RuntimeMinValueFirstChanged = true;
|
||||||
|
private bool m_RuntimeMaxValueFirstChanged = true;
|
||||||
|
|
||||||
public void Copy(Axis other)
|
public void Copy(Axis other)
|
||||||
{
|
{
|
||||||
@@ -261,7 +330,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前坐标轴是否时类目轴
|
/// 是否为类目轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsCategory()
|
public bool IsCategory()
|
||||||
@@ -270,7 +339,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前坐标轴是否时数值轴
|
/// 是否为数值轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsValue()
|
public bool IsValue()
|
||||||
@@ -278,6 +347,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>
|
||||||
@@ -301,7 +379,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 +393,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 +411,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 +456,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 +474,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 +492,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 +505,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 +516,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 +533,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 +553,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 +585,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 +610,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 +630,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 +643,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 +651,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 +665,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTooptipLabelText(string text)
|
internal void UpdateTooptipLabelText(string text)
|
||||||
{
|
{
|
||||||
if (m_TooltipLabelText)
|
if (m_TooltipLabelText)
|
||||||
{
|
{
|
||||||
@@ -570,7 +675,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTooltipLabelPos(Vector2 pos)
|
internal void UpdateTooltipLabelPos(Vector2 pos)
|
||||||
{
|
{
|
||||||
if (m_TooltipLabel)
|
if (m_TooltipLabel)
|
||||||
{
|
{
|
||||||
@@ -578,13 +683,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,31 +720,88 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal float GetCurrMinValue(float duration)
|
||||||
|
{
|
||||||
|
if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
|
||||||
|
if (!m_RuntimeMinValueChanged) return m_RuntimeMinValue;
|
||||||
|
var time = Time.time - m_RuntimeMinValueUpdateTime;
|
||||||
|
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 (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0;
|
||||||
|
if (!m_RuntimeMaxValueChanged) return m_RuntimeMaxValue;
|
||||||
|
var time = Time.time - m_RuntimeMaxValueUpdateTime;
|
||||||
|
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 (GetCurrMinValue(duration) != m_RuntimeMinValue || GetCurrMaxValue(duration) != m_RuntimeMaxValue)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetLogValue(float value)
|
||||||
|
{
|
||||||
|
if (value <= 0) return 0;
|
||||||
|
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
|
||||||
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, obj))
|
if (ReferenceEquals(null, obj))
|
||||||
@@ -655,6 +834,8 @@ namespace XCharts
|
|||||||
m_AxisLabel.Equals(other.axisLabel) &&
|
m_AxisLabel.Equals(other.axisLabel) &&
|
||||||
splitLineType == other.splitLineType &&
|
splitLineType == other.splitLineType &&
|
||||||
boundaryGap == other.boundaryGap &&
|
boundaryGap == other.boundaryGap &&
|
||||||
|
runtimeMinValue == other.runtimeMinValue &&
|
||||||
|
runtimeMaxValue == other.runtimeMaxValue &&
|
||||||
axisName.Equals(other.axisName) &&
|
axisName.Equals(other.axisName) &&
|
||||||
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
|
ChartHelper.IsValueEqualsList<string>(m_Data, other.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -187,6 +188,10 @@ namespace XCharts
|
|||||||
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; }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 最小显示数据个数。当DataZoom放大到最大时,最小显示的数据个数。
|
||||||
|
/// </summary>
|
||||||
|
public int minShowNum { get { return m_MinShowNum; } set { m_MinShowNum = value; } }
|
||||||
|
/// <summary>
|
||||||
/// The sensitivity of dataZoom scroll.
|
/// The sensitivity of dataZoom scroll.
|
||||||
/// The larger the number, the more sensitive it is.
|
/// The larger the number, the more sensitive it is.
|
||||||
/// default:10
|
/// default:10
|
||||||
@@ -208,12 +213,12 @@ namespace XCharts
|
|||||||
/// 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 +302,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 +318,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 +337,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 +347,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,20 @@ 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>
|
||||||
@@ -39,7 +53,8 @@ namespace XCharts
|
|||||||
[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,10 +70,10 @@ 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.
|
||||||
/// 指示器的文本组件。
|
/// 指示器的文本组件。
|
||||||
@@ -72,7 +87,7 @@ namespace XCharts
|
|||||||
m_Name = name,
|
m_Name = name,
|
||||||
m_Max = max,
|
m_Max = max,
|
||||||
m_Min = min,
|
m_Min = min,
|
||||||
m_Color = color
|
m_TextStyle = textStyle.Clone()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +114,7 @@ namespace XCharts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_Name.Equals(other.name) &&
|
return m_Name.Equals(other.name) &&
|
||||||
ChartHelper.IsValueEqualsColor(m_Color, other.color);
|
m_TextStyle.Equals(other.textStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
@@ -114,6 +129,8 @@ namespace XCharts
|
|||||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
||||||
[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.
|
||||||
@@ -153,6 +170,14 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool indicator { get { return m_Indicator; } set { m_Indicator = value; } }
|
public bool indicator { get { return m_Indicator; } set { m_Indicator = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 指示器和雷达的间距。
|
||||||
|
/// </summary>
|
||||||
|
public float indicatorGap { get { return m_IndicatorGap; } set { m_IndicatorGap = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 显示位置类型。
|
||||||
|
/// </summary>
|
||||||
|
public PositionType positionType { get { return m_PositionType; } set { m_PositionType = value; } }
|
||||||
|
/// <summary>
|
||||||
/// the indicator list.
|
/// the indicator list.
|
||||||
/// 指示器列表。
|
/// 指示器列表。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -162,20 +187,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
|
||||||
{
|
{
|
||||||
@@ -219,12 +242,14 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var radar = new Radar();
|
var radar = new Radar();
|
||||||
radar.shape = shape;
|
radar.shape = shape;
|
||||||
|
radar.positionType = positionType;
|
||||||
radar.radius = radius;
|
radar.radius = radius;
|
||||||
radar.splitNumber = splitNumber;
|
radar.splitNumber = splitNumber;
|
||||||
radar.center[0] = center[0];
|
radar.center[0] = center[0];
|
||||||
radar.center[1] = center[1];
|
radar.center[1] = center[1];
|
||||||
radar.indicatorList.Clear();
|
radar.indicatorList.Clear();
|
||||||
radar.indicator = indicator;
|
radar.indicator = indicator;
|
||||||
|
radar.indicatorGap = indicatorGap;
|
||||||
foreach (var d in indicatorList) radar.indicatorList.Add(d.Clone());
|
foreach (var d in indicatorList) radar.indicatorList.Add(d.Clone());
|
||||||
return radar;
|
return radar;
|
||||||
}
|
}
|
||||||
@@ -253,10 +278,12 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return radius == other.radius &&
|
return radius == other.radius &&
|
||||||
shape == other.shape &&
|
shape == other.shape &&
|
||||||
|
positionType == other.positionType &&
|
||||||
splitNumber == other.splitNumber &&
|
splitNumber == other.splitNumber &&
|
||||||
center[0] == other.center[0] &&
|
center[0] == other.center[0] &&
|
||||||
center[1] == other.center[1] &&
|
center[1] == other.center[1] &&
|
||||||
indicator == other.indicator &&
|
indicator == other.indicator &&
|
||||||
|
indicatorGap == other.indicatorGap &&
|
||||||
IsEqualsIndicatorList(indicatorList, other.indicatorList);
|
IsEqualsIndicatorList(indicatorList, other.indicatorList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,33 +371,77 @@ 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);
|
||||||
|
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;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Radar.Indicator GetIndicator(int indicatorIndex)
|
||||||
|
{
|
||||||
|
if (indicatorIndex < 0 || indicatorIndex > indicatorList.Count - 1) return null;
|
||||||
|
return indicatorList[indicatorIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,6 +48,10 @@ namespace XCharts
|
|||||||
/// 热力图。主要通过颜色去表现数值的大小,必须要配合 visualMap 组件使用。
|
/// 热力图。主要通过颜色去表现数值的大小,必须要配合 visualMap 组件使用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Heatmap,
|
Heatmap,
|
||||||
|
/// <summary>
|
||||||
|
/// 仪表盘。
|
||||||
|
/// </summary>
|
||||||
|
Gauge,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -142,6 +146,21 @@ namespace XCharts
|
|||||||
Capsule
|
Capsule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 仪表盘类型
|
||||||
|
/// </summary>
|
||||||
|
public enum GaugeType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 指针型
|
||||||
|
/// </summary>
|
||||||
|
Pointer,
|
||||||
|
/// <summary>
|
||||||
|
/// 进度条型
|
||||||
|
/// </summary>
|
||||||
|
ProgressBar
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 采样类型
|
/// 采样类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -202,6 +221,16 @@ namespace XCharts
|
|||||||
[SerializeField] private float m_BarZebraWidth = 4f;
|
[SerializeField] private float m_BarZebraWidth = 4f;
|
||||||
[SerializeField] private float m_BarZebraGap = 2f;
|
[SerializeField] private float m_BarZebraGap = 2f;
|
||||||
|
|
||||||
|
[SerializeField] private float m_Min;
|
||||||
|
[SerializeField] private float m_Max;
|
||||||
|
[SerializeField] private float m_StartAngle;
|
||||||
|
[SerializeField] private float m_EndAngle;
|
||||||
|
[SerializeField] private bool m_Clockwise;
|
||||||
|
[SerializeField] private bool m_ArcShaped;
|
||||||
|
[SerializeField] private int m_SplitNumber;
|
||||||
|
[SerializeField] private GaugeType m_GaugeType = GaugeType.Pointer;
|
||||||
|
[SerializeField] private GaugeAxis m_GaugeAxis = new GaugeAxis();
|
||||||
|
[SerializeField] private GaugePointer m_GaugePointer = new GaugePointer();
|
||||||
|
|
||||||
[SerializeField] private bool m_ClickOffset = true;
|
[SerializeField] private bool m_ClickOffset = true;
|
||||||
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
||||||
@@ -213,6 +242,7 @@ namespace XCharts
|
|||||||
[SerializeField] private LineArrow m_LineArrow = new LineArrow();
|
[SerializeField] private LineArrow m_LineArrow = new LineArrow();
|
||||||
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
||||||
[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
||||||
|
[SerializeField] private TitleStyle m_TitleStyle = new TitleStyle();
|
||||||
[SerializeField] [Range(1, 10)] private int m_ShowDataDimension;
|
[SerializeField] [Range(1, 10)] private int m_ShowDataDimension;
|
||||||
[SerializeField] private bool m_ShowDataName;
|
[SerializeField] private bool m_ShowDataName;
|
||||||
[SerializeField] private bool m_ShowDataIcon;
|
[SerializeField] private bool m_ShowDataIcon;
|
||||||
@@ -221,6 +251,7 @@ namespace XCharts
|
|||||||
|
|
||||||
[NonSerialized] private int m_FilterStart;
|
[NonSerialized] private int m_FilterStart;
|
||||||
[NonSerialized] private int m_FilterEnd;
|
[NonSerialized] private int m_FilterEnd;
|
||||||
|
[NonSerialized] private int m_FilterMinShow;
|
||||||
[NonSerialized] private List<SerieData> m_FilterData;
|
[NonSerialized] private List<SerieData> m_FilterData;
|
||||||
[NonSerialized] private Dictionary<int, List<Vector3>> m_UpSmoothPoints = new Dictionary<int, List<Vector3>>();
|
[NonSerialized] private Dictionary<int, List<Vector3>> m_UpSmoothPoints = new Dictionary<int, List<Vector3>>();
|
||||||
[NonSerialized] private Dictionary<int, List<Vector3>> m_DownSmoothPoints = new Dictionary<int, List<Vector3>>();
|
[NonSerialized] private Dictionary<int, List<Vector3>> m_DownSmoothPoints = new Dictionary<int, List<Vector3>>();
|
||||||
@@ -383,15 +414,59 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieSpace { get { return m_Space; } set { m_Space = value; } }
|
public float pieSpace { get { return m_Space; } set { m_Space = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the center of pie chart.
|
/// the center of chart.
|
||||||
/// 饼图的中心点。
|
/// 中心点。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float[] pieCenter { get { return m_Center; } set { m_Center = value; } }
|
public float[] center { get { return m_Center; } set { m_Center = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the radius of pie chart.
|
/// the radius of chart.
|
||||||
/// 饼图的半径。radius[0]表示内径,radius[1]表示外径。
|
/// 半径。radius[0]表示内径,radius[1]表示外径。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float[] pieRadius { get { return m_Radius; } set { m_Radius = value; } }
|
public float[] radius { get { return m_Radius; } set { m_Radius = value; } }
|
||||||
|
[Obsolete("Use Serie.center instead.", true)]
|
||||||
|
public float[] pieCenter { get { return center; } set { center = value; } }
|
||||||
|
[Obsolete("Use Serie.radius instead.", true)]
|
||||||
|
public float[] pieRadius { get { return radius; } set { radius = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 最小值,映射到 startAngle。
|
||||||
|
/// </summary>
|
||||||
|
public float min { get { return m_Min; } set { m_Min = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 最大值,映射到 endAngle。
|
||||||
|
/// </summary>
|
||||||
|
public float max { get { return m_Max; } set { m_Max = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||||
|
/// </summary>
|
||||||
|
public float startAngle { get { return m_StartAngle; } set { m_StartAngle = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 结束角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||||
|
/// </summary>
|
||||||
|
public float endAngle { get { return m_EndAngle; } set { m_EndAngle = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否顺时针。
|
||||||
|
/// </summary>
|
||||||
|
public bool clockwise { get { return m_Clockwise; } set { m_Clockwise = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 刻度分割段数。
|
||||||
|
/// </summary>
|
||||||
|
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value > 36 ? 36 : value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否开启圆弧形边角。
|
||||||
|
/// </summary>
|
||||||
|
public bool arcShaped { get { return m_ArcShaped; } set { m_ArcShaped = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 仪表盘轴线。
|
||||||
|
/// </summary>
|
||||||
|
public GaugeAxis gaugeAxis { get { return m_GaugeAxis; } set { m_GaugeAxis = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 仪表盘指针。
|
||||||
|
/// </summary>
|
||||||
|
public GaugePointer gaugePointer { get { return m_GaugePointer; } set { m_GaugePointer = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 仪表盘类型。
|
||||||
|
/// </summary>
|
||||||
|
public GaugeType gaugeType { get { return m_GaugeType; } set { m_GaugeType = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
||||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||||
@@ -416,7 +491,15 @@ namespace XCharts
|
|||||||
/// 高亮的图形样式和文本标签样式。
|
/// 高亮的图形样式和文本标签样式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Emphasis emphasis { get { return m_Emphasis; } set { m_Emphasis = value; } }
|
public Emphasis emphasis { get { return m_Emphasis; } set { m_Emphasis = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 标题样式。
|
||||||
|
/// </summary>
|
||||||
|
public TitleStyle titleStyle { get { return m_TitleStyle; } set { m_TitleStyle = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 数据项里的数据维数。
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public int showDataDimension { get { return m_ShowDataDimension; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -426,12 +509,12 @@ namespace XCharts
|
|||||||
/// The index of serie,start at 0.
|
/// The index of serie,start at 0.
|
||||||
/// 系列的索引,从0开始。
|
/// 系列的索引,从0开始。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int index { get; set; }
|
public int index { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the serie is highlighted.
|
/// Whether the serie is highlighted.
|
||||||
/// 该系列是否高亮,一般由图例悬停触发。
|
/// 该系列是否高亮,一般由图例悬停触发。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool highlighted { get; set; }
|
public bool highlighted { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the count of data list.
|
/// the count of data list.
|
||||||
/// 数据项个数。
|
/// 数据项个数。
|
||||||
@@ -444,25 +527,26 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图的中心点位置。
|
/// 饼图的中心点位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 pieCenterPos { get; set; }
|
public Vector3 runtimeCenterPos { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图的内径
|
/// 饼图的内径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieInsideRadius { get; set; }
|
public float runtimeInsideRadius { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图的外径
|
/// 饼图的外径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieOutsideRadius { get; set; }
|
public float runtimeOutsideRadius { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图的数据项最大值
|
/// 饼图的数据项最大值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieDataMax { get; set; }
|
public float runtimePieDataMax { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图的数据项之和
|
/// 饼图的数据项之和
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieDataTotal { get; set; }
|
public float runtimePieDataTotal { get; internal set; }
|
||||||
|
internal int runtimeLastCheckDataCount { get; set; }
|
||||||
|
|
||||||
public List<Vector3> GetUpSmoothList(int dataIndex, int size = 100)
|
internal List<Vector3> GetUpSmoothList(int dataIndex, int size = 100)
|
||||||
{
|
{
|
||||||
if (m_UpSmoothPoints.ContainsKey(dataIndex))
|
if (m_UpSmoothPoints.ContainsKey(dataIndex))
|
||||||
{
|
{
|
||||||
@@ -476,7 +560,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Vector3> GetDownSmoothList(int dataIndex, int size = 100)
|
internal List<Vector3> GetDownSmoothList(int dataIndex, int size = 100)
|
||||||
{
|
{
|
||||||
if (m_DownSmoothPoints.ContainsKey(dataIndex))
|
if (m_DownSmoothPoints.ContainsKey(dataIndex))
|
||||||
{
|
{
|
||||||
@@ -490,7 +574,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearSmoothList(int dataIndex)
|
internal void ClearSmoothList(int dataIndex)
|
||||||
{
|
{
|
||||||
if (m_UpSmoothPoints.ContainsKey(dataIndex))
|
if (m_UpSmoothPoints.ContainsKey(dataIndex))
|
||||||
{
|
{
|
||||||
@@ -589,7 +673,7 @@ namespace XCharts
|
|||||||
foreach (var sdata in data)
|
foreach (var sdata in data)
|
||||||
{
|
{
|
||||||
if (sdata.show)
|
if (sdata.show)
|
||||||
total += sdata.data[1];
|
total += sdata.GetCurrData(1, animation.GetUpdateAnimationDuration());
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -645,9 +729,14 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int xValue = m_Data.Count;
|
int xValue = m_Data.Count;
|
||||||
var serieData = new SerieData() { data = new List<float>() { xValue, value }, name = dataName };
|
var serieData = new SerieData()
|
||||||
|
{
|
||||||
|
data = new List<float>() { xValue, value },
|
||||||
|
name = dataName
|
||||||
|
};
|
||||||
serieData.index = xValue;
|
serieData.index = xValue;
|
||||||
m_Data.Add(serieData);
|
m_Data.Add(serieData);
|
||||||
|
m_ShowDataDimension = 1;
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -668,9 +757,14 @@ namespace XCharts
|
|||||||
m_Data.RemoveAt(0);
|
m_Data.RemoveAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var serieData = new SerieData() { data = new List<float>() { xValue, yValue }, name = dataName };
|
var serieData = new SerieData()
|
||||||
|
{
|
||||||
|
data = new List<float>() { xValue, yValue },
|
||||||
|
name = dataName
|
||||||
|
};
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
m_Data.Add(serieData);
|
m_Data.Add(serieData);
|
||||||
|
m_ShowDataDimension = 2;
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,6 +796,7 @@ namespace XCharts
|
|||||||
m_Data.RemoveAt(0);
|
m_Data.RemoveAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_ShowDataDimension = valueList.Count;
|
||||||
var serieData = new SerieData();
|
var serieData = new SerieData();
|
||||||
serieData.name = dataName;
|
serieData.name = dataName;
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
@@ -731,6 +826,17 @@ namespace XCharts
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetYCurrData(int index, DataZoom dataZoom = null)
|
||||||
|
{
|
||||||
|
if (index < 0) return 0;
|
||||||
|
var serieData = GetDataList(dataZoom);
|
||||||
|
if (index < serieData.Count)
|
||||||
|
{
|
||||||
|
return serieData[index].GetCurrData(1, animation.GetUpdateAnimationDuration());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得维度Y索引对应的数据和数据名
|
/// 获得维度Y索引对应的数据和数据名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -767,6 +873,24 @@ namespace XCharts
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得指定索引的数据项的Label
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="dataZoom"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SerieLabel GetSerieLabel(int index, DataZoom dataZoom = null)
|
||||||
|
{
|
||||||
|
var data = GetDataList(dataZoom);
|
||||||
|
if (index >= 0 && index <= data.Count - 1)
|
||||||
|
{
|
||||||
|
var serieData = data[index];
|
||||||
|
if (serieData.enableLabel) return serieData.label;
|
||||||
|
else return label;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得指定索引的维度X和维度Y的数据
|
/// 获得指定索引的维度X和维度Y的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -836,21 +960,34 @@ 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 != m_FilterStart || endIndex != m_FilterEnd || m_NeedUpdateFilterData)
|
if (endIndex < startIndex) endIndex = startIndex;
|
||||||
|
|
||||||
|
if (startIndex != m_FilterStart || endIndex != m_FilterEnd || dataZoom.minShowNum != m_FilterMinShow || m_NeedUpdateFilterData)
|
||||||
{
|
{
|
||||||
m_FilterStart = startIndex;
|
m_FilterStart = startIndex;
|
||||||
m_FilterEnd = endIndex;
|
m_FilterEnd = endIndex;
|
||||||
|
m_FilterMinShow = dataZoom.minShowNum;
|
||||||
m_NeedUpdateFilterData = false;
|
m_NeedUpdateFilterData = false;
|
||||||
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
||||||
|
if (count < dataZoom.minShowNum)
|
||||||
|
{
|
||||||
|
if (dataZoom.minShowNum > m_Data.Count) count = m_Data.Count;
|
||||||
|
else count = dataZoom.minShowNum;
|
||||||
|
}
|
||||||
if (m_Data.Count > 0)
|
if (m_Data.Count > 0)
|
||||||
{
|
{
|
||||||
m_FilterData = m_Data.GetRange(startIndex, count);
|
if (startIndex + count > m_Data.Count)
|
||||||
|
{
|
||||||
|
int start = endIndex - count;
|
||||||
|
m_FilterData = m_Data.GetRange(start < 0 ? 0 : start, count);
|
||||||
|
}
|
||||||
|
else m_FilterData = m_Data.GetRange(startIndex, count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -869,9 +1006,10 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public void UpdateYData(int index, float value)
|
public bool UpdateYData(int index, float value)
|
||||||
{
|
{
|
||||||
UpdateData(index, 1, value);
|
UpdateData(index, 1, value);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -880,10 +1018,11 @@ namespace XCharts
|
|||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="xValue"></param>
|
/// <param name="xValue"></param>
|
||||||
/// <param name="yValue"></param>
|
/// <param name="yValue"></param>
|
||||||
public void UpdateXYData(int index, float xValue, float yValue)
|
public bool UpdateXYData(int index, float xValue, float yValue)
|
||||||
{
|
{
|
||||||
UpdateData(index, 0, xValue);
|
var flag1 = UpdateData(index, 0, xValue);
|
||||||
UpdateData(index, 1, yValue);
|
var flag2 = UpdateData(index, 1, yValue);
|
||||||
|
return flag1 || flag2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -892,16 +1031,36 @@ namespace XCharts
|
|||||||
/// <param name="index">要更新数据的索引</param>
|
/// <param name="index">要更新数据的索引</param>
|
||||||
/// <param name="dimension">要更新数据的维数</param>
|
/// <param name="dimension">要更新数据的维数</param>
|
||||||
/// <param name="value">新的数据值</param>
|
/// <param name="value">新的数据值</param>
|
||||||
public void UpdateData(int index, int dimension, float value)
|
public bool UpdateData(int index, int dimension, float value)
|
||||||
{
|
{
|
||||||
if (index < 0) return;
|
if (index >= 0 && index < m_Data.Count)
|
||||||
if (index < m_Data.Count && dimension < m_Data[index].data.Count)
|
|
||||||
{
|
{
|
||||||
m_Data[index].data[dimension] = value;
|
return m_Data[index].UpdateData(dimension, value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateDataName(int index, string name)
|
/// <summary>
|
||||||
|
/// 更新指定索引的数据项数据列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="values"></param>
|
||||||
|
public bool UpdateData(int index, List<float> values)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_Data.Count && values != null)
|
||||||
|
{
|
||||||
|
var serieData = m_Data[index];
|
||||||
|
for (int i = 0; i < values.Count; i++)
|
||||||
|
serieData.UpdateData(i, values[i]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateDataName(int index, string name)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < m_Data.Count)
|
if (index >= 0 && index < m_Data.Count)
|
||||||
{
|
{
|
||||||
@@ -911,7 +1070,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
serieData.labelText.text = name == null ? "" : name;
|
serieData.labelText.text = name == null ? "" : name;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -939,7 +1100,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetAreaColor(ThemeInfo theme, int index, bool highlight)
|
internal Color GetAreaColor(ThemeInfo theme, int index, bool highlight)
|
||||||
{
|
{
|
||||||
var color = areaStyle.color != Color.clear ? areaStyle.color : (Color)theme.GetColor(index);
|
var color = areaStyle.color != Color.clear ? areaStyle.color : (Color)theme.GetColor(index);
|
||||||
if (highlight)
|
if (highlight)
|
||||||
@@ -951,7 +1112,7 @@ namespace XCharts
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetAreaToColor(ThemeInfo theme, int index, bool highlight)
|
internal Color GetAreaToColor(ThemeInfo theme, int index, bool highlight)
|
||||||
{
|
{
|
||||||
if (areaStyle.toColor != Color.clear)
|
if (areaStyle.toColor != Color.clear)
|
||||||
{
|
{
|
||||||
@@ -970,7 +1131,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetLineColor(ThemeInfo theme, int index, bool highlight)
|
internal Color GetLineColor(ThemeInfo theme, int index, bool highlight)
|
||||||
{
|
{
|
||||||
if (lineStyle.color != Color.clear)
|
if (lineStyle.color != Color.clear)
|
||||||
{
|
{
|
||||||
@@ -988,7 +1149,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetSymbolColor(ThemeInfo theme, int index, bool highlight)
|
internal Color GetSymbolColor(ThemeInfo theme, int index, bool highlight)
|
||||||
{
|
{
|
||||||
if (symbol.color != Color.clear)
|
if (symbol.color != Color.clear)
|
||||||
{
|
{
|
||||||
@@ -1006,13 +1167,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetBarWidth(float categoryWidth)
|
internal float GetBarWidth(float categoryWidth)
|
||||||
{
|
{
|
||||||
if (m_BarWidth > 1) return m_BarWidth;
|
if (m_BarWidth > 1) return m_BarWidth;
|
||||||
else return m_BarWidth * categoryWidth;
|
else return m_BarWidth * categoryWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetBarGap(float categoryWidth)
|
internal float GetBarGap(float categoryWidth)
|
||||||
{
|
{
|
||||||
if (m_BarGap == -1) return 0;
|
if (m_BarGap == -1) return 0;
|
||||||
else if (m_BarGap <= 1) return GetBarWidth(categoryWidth) * m_BarGap;
|
else if (m_BarGap <= 1) return GetBarWidth(categoryWidth) * m_BarGap;
|
||||||
@@ -1027,7 +1188,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
foreach (var data in m_Data)
|
foreach (var data in m_Data)
|
||||||
{
|
{
|
||||||
data.showIcon = flag;
|
data.iconStyle.show = flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1041,7 +1202,7 @@ namespace XCharts
|
|||||||
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
||||||
{
|
{
|
||||||
var data = m_Data[dataIndex];
|
var data = m_Data[dataIndex];
|
||||||
data.showIcon = flag;
|
data.iconStyle.show = flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1054,8 +1215,8 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
foreach (var data in m_Data)
|
foreach (var data in m_Data)
|
||||||
{
|
{
|
||||||
data.iconWidth = width;
|
data.iconStyle.width = width;
|
||||||
data.iconHeight = height;
|
data.iconStyle.height = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1069,19 +1230,35 @@ namespace XCharts
|
|||||||
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
||||||
{
|
{
|
||||||
var data = m_Data[dataIndex];
|
var data = m_Data[dataIndex];
|
||||||
data.iconImage = image;
|
data.iconStyle.sprite = image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsNeedShowDataIcon()
|
internal bool IsNeedShowDataIcon()
|
||||||
{
|
{
|
||||||
foreach (var data in m_Data)
|
foreach (var data in m_Data)
|
||||||
{
|
{
|
||||||
if (data.showIcon) return true;
|
if (data.iconStyle.show) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新运行时中心点和半径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="chartWidth"></param>
|
||||||
|
/// <param name="chartHeight"></param>
|
||||||
|
internal void UpdateCenter(float chartWidth, float chartHeight)
|
||||||
|
{
|
||||||
|
if (center.Length < 2) return;
|
||||||
|
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
||||||
|
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
||||||
|
runtimeCenterPos = new Vector2(centerX, centerY);
|
||||||
|
var minWidth = Mathf.Min(chartWidth, chartHeight);
|
||||||
|
runtimeInsideRadius = radius[0] <= 1 ? minWidth * radius[0] : radius[0];
|
||||||
|
runtimeOutsideRadius = radius[1] <= 1 ? minWidth * radius[1] : radius[1];
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置指定index的数据图标的尺寸
|
/// 设置指定index的数据图标的尺寸
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1093,8 +1270,8 @@ namespace XCharts
|
|||||||
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
||||||
{
|
{
|
||||||
var data = m_Data[dataIndex];
|
var data = m_Data[dataIndex];
|
||||||
data.iconWidth = width;
|
data.iconStyle.width = width;
|
||||||
data.iconHeight = height;
|
data.iconStyle.height = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1108,7 +1285,7 @@ namespace XCharts
|
|||||||
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
if (dataIndex >= 0 && dataIndex < m_Data.Count)
|
||||||
{
|
{
|
||||||
var data = m_Data[dataIndex];
|
var data = m_Data[dataIndex];
|
||||||
data.iconColor = color;
|
data.iconStyle.color = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,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 +155,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 +166,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 +179,24 @@ namespace XCharts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal bool IsAnyUpdateAnimationSerie()
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
{
|
||||||
|
if (serie.animation.enable && serie.animation.updateAnimation)
|
||||||
|
{
|
||||||
|
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--)
|
||||||
@@ -370,13 +394,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 +410,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 +426,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 +442,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 +513,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 +530,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)
|
||||||
{
|
{
|
||||||
@@ -527,7 +610,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 +638,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 +651,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 +676,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 +686,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 +725,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 +748,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 +758,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 +779,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 +799,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 +824,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 +848,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 +888,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 +938,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++)
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
[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]
|
||||||
@@ -41,20 +41,30 @@ namespace XCharts
|
|||||||
/// 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.", false)]
|
||||||
|
public int textFontSize { get { return m_TextStyle.fontSize; } set { m_TextStyle.fontSize = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 主标题文本样式。
|
||||||
|
/// </summary>
|
||||||
|
public TextStyle textStyle { get { return m_TextStyle; } set { m_TextStyle = value; } }
|
||||||
/// <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 { m_SubText = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 副标题文本样式。
|
||||||
|
/// </summary>
|
||||||
|
public TextStyle subTextStyle { get { return m_SubTextStyle; } set { m_SubTextStyle = value; } }
|
||||||
|
/// <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.", false)]
|
||||||
|
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>
|
||||||
@@ -73,9 +83,9 @@ 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
|
||||||
};
|
};
|
||||||
@@ -86,9 +96,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_Show = title.show;
|
m_Show = title.show;
|
||||||
m_Text = title.text;
|
m_Text = title.text;
|
||||||
m_TextFontSize = title.textFontSize;
|
m_TextStyle.Copy(title.textStyle);
|
||||||
|
m_SubTextStyle.Copy(title.subTextStyle);
|
||||||
m_SubText = title.subText;
|
m_SubText = title.subText;
|
||||||
m_SubTextFontSize = title.subTextFontSize;
|
|
||||||
m_ItemGap = title.itemGap;
|
m_ItemGap = title.itemGap;
|
||||||
m_Location.Copy(title.location);
|
m_Location.Copy(title.location);
|
||||||
}
|
}
|
||||||
@@ -117,9 +127,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return m_Show == other.show &&
|
return m_Show == other.show &&
|
||||||
m_Text.Equals(other.text) &&
|
m_Text.Equals(other.text) &&
|
||||||
m_TextFontSize == other.textFontSize &&
|
m_TextStyle.Equals(other.textStyle) &&
|
||||||
m_SubText.Equals(other.subText) &&
|
m_SubText.Equals(other.subText) &&
|
||||||
m_SubTextFontSize == other.subTextFontSize &&
|
m_SubTextStyle.Equals(other.subTextStyle) &&
|
||||||
m_ItemGap == other.itemGap &&
|
m_ItemGap == other.itemGap &&
|
||||||
m_Location.Equals(other.location);
|
m_Location.Equals(other.location);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,12 +49,15 @@ 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 int m_FontSize = 18;
|
||||||
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
||||||
|
[SerializeField] private bool m_ForceENotation = false;
|
||||||
|
|
||||||
private GameObject m_GameObject;
|
private GameObject m_GameObject;
|
||||||
private GameObject m_Content;
|
private GameObject m_Content;
|
||||||
@@ -74,7 +77,33 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
public Type type { get { return m_Type; } set { m_Type = value; } }
|
||||||
/// <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 +112,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>
|
||||||
@@ -114,47 +142,51 @@ namespace XCharts
|
|||||||
/// 文字的字体风格。
|
/// 文字的字体风格。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
/// </summary>
|
||||||
|
public bool forceENotation { get { return m_ForceENotation; } set { m_ForceENotation = value; } }
|
||||||
|
|
||||||
/// <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 +195,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;
|
||||||
@@ -209,7 +241,8 @@ 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_Content != null && m_Content.GetComponent<Image>() != null)
|
||||||
|
m_Content.GetComponent<Image>().color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -247,11 +280,11 @@ namespace XCharts
|
|||||||
/// <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 +336,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 +355,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 +365,71 @@ 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, 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(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 +441,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,15 +461,15 @@ 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;
|
||||||
|
|||||||
@@ -164,14 +164,14 @@ namespace XCharts
|
|||||||
/// 鼠标悬停选中的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 +198,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int rtSplitNumber
|
public int runtimeSplitNumber
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -207,18 +207,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 +256,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 +264,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 +289,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 +337,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 +354,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 +363,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 +376,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 +385,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;
|
||||||
}
|
}
|
||||||
|
|||||||
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:
|
||||||
@@ -26,6 +26,8 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this to false to prevent the axis label from appearing.
|
/// Set this to false to prevent the axis label from appearing.
|
||||||
@@ -69,9 +71,13 @@ namespace XCharts
|
|||||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||||
/// <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 { m_Formatter = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
/// </summary>
|
||||||
|
public bool forceENotation { get { return m_ForceENotation; } set { m_ForceENotation = value; } }
|
||||||
|
|
||||||
public static AxisLabel defaultAxisLabel
|
public static AxisLabel defaultAxisLabel
|
||||||
{
|
{
|
||||||
@@ -118,6 +124,7 @@ namespace XCharts
|
|||||||
m_Color == other.color &&
|
m_Color == other.color &&
|
||||||
m_FontSize == other.fontSize &&
|
m_FontSize == other.fontSize &&
|
||||||
m_FontStyle == other.fontStyle &&
|
m_FontStyle == other.fontStyle &&
|
||||||
|
m_ForceENotation == other.forceENotation &&
|
||||||
m_Formatter == other.formatter;
|
m_Formatter == other.formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,16 +146,35 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +182,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 +191,10 @@ namespace XCharts
|
|||||||
content = content.Replace("<br/>", "\n");
|
content = content.Replace("<br/>", "\n");
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return value.ToString(m_Formatter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
305
Assets/XCharts/Runtime/Component/Sub/GaugeAxis.cs
Normal file
305
Assets/XCharts/Runtime/Component/Sub/GaugeAxis.cs
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* 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:
|
||||||
40
Assets/XCharts/Runtime/Component/Sub/GaugePointer.cs
Normal file
40
Assets/XCharts/Runtime/Component/Sub/GaugePointer.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* 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 { m_Show = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 指针长度。可以是绝对值,也可以是相对于半径的百分比(0-1的浮点数)
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public float length { get { return m_Length; } set { m_Length = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 指针宽度。
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
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:
|
||||||
@@ -74,25 +74,25 @@ namespace XCharts
|
|||||||
/// 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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ 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 float 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_Delay = 0;
|
||||||
[SerializeField] private int m_ActualDuration;
|
[SerializeField] private bool m_UpdateAnimation = true;
|
||||||
|
[SerializeField] private float m_UpdateDuration = 500;
|
||||||
|
[SerializeField] private float m_ActualDuration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to enable animation.
|
/// Whether to enable animation.
|
||||||
@@ -37,32 +39,36 @@ 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 first animation.
|
||||||
/// 设定的动画时长(毫秒)。
|
/// 设定的动画时长(毫秒)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
public float duration { get { return m_Duration; } set { m_Duration = value < 0 ? 0 : value; } }
|
||||||
public int duration { get { return m_Duration; } set { m_Duration = 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_Delay; } set { m_Delay = 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 updateAnimation { get { return m_UpdateAnimation; } set { m_UpdateAnimation = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// The milliseconds duration of the first animation.
|
||||||
|
/// 数据变更的动画时长(毫秒)。
|
||||||
|
/// </summary>
|
||||||
|
public float updateDuration { get { return m_UpdateDuration; } set { m_UpdateDuration = 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_IsStart = false;
|
||||||
@@ -152,7 +158,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()
|
||||||
@@ -179,7 +185,7 @@ namespace XCharts
|
|||||||
return dataIndex <= m_CurrDataProgress;
|
return dataIndex <= m_CurrDataProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckProgress(float delta)
|
internal void CheckProgress(float delta)
|
||||||
{
|
{
|
||||||
if (!enable) return;
|
if (!enable) return;
|
||||||
if (IsInDelay()) return;
|
if (IsInDelay()) return;
|
||||||
@@ -195,7 +201,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckSymbol(float delta, float dest)
|
internal void CheckSymbol(float delta, float dest)
|
||||||
{
|
{
|
||||||
m_CurrSymbolProgress += delta;
|
m_CurrSymbolProgress += delta;
|
||||||
if (m_CurrSymbolProgress > dest) m_CurrSymbolProgress = dest;
|
if (m_CurrSymbolProgress > dest) m_CurrSymbolProgress = dest;
|
||||||
@@ -237,5 +243,11 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
return m_CurrDataProgress;
|
return m_CurrDataProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetUpdateAnimationDuration()
|
||||||
|
{
|
||||||
|
if (m_Enable && m_UpdateAnimation && IsFinish()) return m_UpdateDuration;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,92 @@ 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_LastData = 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 GetLastData(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < m_LastData.Count)
|
||||||
|
{
|
||||||
|
return m_LastData[index];
|
||||||
|
}
|
||||||
|
else 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(GetLastData(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_LastData[dimension] = data[dimension];
|
||||||
|
m_DataUpdateTime[dimension] = Time.time;
|
||||||
|
m_DataUpdateFlag[dimension] = true;
|
||||||
|
data[dimension] = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckLastData()
|
||||||
|
{
|
||||||
|
if (m_LastData.Count != m_Data.Count)
|
||||||
|
{
|
||||||
|
m_LastData.Clear();
|
||||||
|
m_DataUpdateTime.Clear();
|
||||||
|
m_DataUpdateFlag.Clear();
|
||||||
|
for (int i = 0; i < m_Data.Count; i++)
|
||||||
|
{
|
||||||
|
m_LastData.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 +256,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 +272,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 +305,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,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,6 +100,7 @@ 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;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the label is showed.
|
/// Whether the label is showed.
|
||||||
/// 是否显示文本标签。
|
/// 是否显示文本标签。
|
||||||
@@ -129,6 +131,10 @@ namespace XCharts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 距离轴线的距离。
|
||||||
|
/// </summary>
|
||||||
|
public float margin { get { return m_Margin; } set { m_Margin = value; } }
|
||||||
|
/// <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>
|
||||||
@@ -220,16 +226,20 @@ namespace XCharts
|
|||||||
/// 边框颜色。
|
/// 边框颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color borderColor { get { return m_BorderColor; } set { m_BorderColor = value; } }
|
public Color borderColor { get { return m_BorderColor; } set { m_BorderColor = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
/// </summary>
|
||||||
|
public bool forceENotation { get { return m_ForceENotation; } set { m_ForceENotation = value; } }
|
||||||
|
|
||||||
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));
|
||||||
|
|||||||
140
Assets/XCharts/Runtime/Component/Sub/TextStyle.cs
Normal file
140
Assets/XCharts/Runtime/Component/Sub/TextStyle.cs
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
using System.Threading;
|
||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Settings related to text.
|
||||||
|
/// 文本的相关设置。
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class TextStyle : SubComponent, IEquatable<TextStyle>
|
||||||
|
{
|
||||||
|
[SerializeField] private float m_Rotate = 0;
|
||||||
|
[SerializeField] private Vector2 m_Offset = Vector2.zero;
|
||||||
|
[SerializeField] private Color m_Color = Color.clear;
|
||||||
|
[SerializeField] private int m_FontSize = 18;
|
||||||
|
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rotation of text.
|
||||||
|
/// 文本的旋转。
|
||||||
|
/// </summary>
|
||||||
|
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// the offset of position.
|
||||||
|
/// 坐标偏移。
|
||||||
|
/// </summary>
|
||||||
|
public Vector2 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||||
|
|
||||||
|
public Vector3 offsetv3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the color of text.
|
||||||
|
/// 文本的颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// font size.
|
||||||
|
/// 文本字体大小。
|
||||||
|
/// </summary>
|
||||||
|
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// font style.
|
||||||
|
/// 文本字体的风格。
|
||||||
|
/// </summary>
|
||||||
|
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||||
|
|
||||||
|
public TextStyle()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextStyle(int fontSize)
|
||||||
|
{
|
||||||
|
this.fontSize = fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextStyle(int fontSize, FontStyle fontStyle)
|
||||||
|
{
|
||||||
|
this.fontSize = fontSize;
|
||||||
|
this.fontStyle = fontStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextStyle(int fontSize, FontStyle fontStyle, Color color)
|
||||||
|
{
|
||||||
|
this.fontSize = fontSize;
|
||||||
|
this.fontStyle = fontStyle;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextStyle(int fontSize, FontStyle fontStyle, Color color, int rorate)
|
||||||
|
{
|
||||||
|
this.fontSize = fontSize;
|
||||||
|
this.fontStyle = fontStyle;
|
||||||
|
this.color = color;
|
||||||
|
this.rotate = rotate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Copy(TextStyle style)
|
||||||
|
{
|
||||||
|
this.fontSize = style.fontSize;
|
||||||
|
this.fontStyle = style.fontStyle;
|
||||||
|
this.color = style.color;
|
||||||
|
this.rotate = style.rotate;
|
||||||
|
this.offset = style.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextStyle Clone()
|
||||||
|
{
|
||||||
|
var textStyle = new TextStyle();
|
||||||
|
textStyle.rotate = rotate;
|
||||||
|
textStyle.color = color;
|
||||||
|
textStyle.fontSize = fontSize;
|
||||||
|
textStyle.fontStyle = fontStyle;
|
||||||
|
textStyle.offset = offset;
|
||||||
|
return textStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, obj))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (obj is TextStyle)
|
||||||
|
{
|
||||||
|
return Equals((TextStyle)obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(TextStyle other)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, other))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return rotate == other.rotate &&
|
||||||
|
fontSize == other.fontSize &&
|
||||||
|
fontStyle == other.fontStyle &&
|
||||||
|
offset == other.offset &&
|
||||||
|
ChartHelper.IsValueEqualsColor(m_Color, other.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return base.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Component/Sub/TextStyle.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Sub/TextStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e8f6b652968894ab195666501dda672c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
109
Assets/XCharts/Runtime/Component/Sub/TitleStyle.cs
Normal file
109
Assets/XCharts/Runtime/Component/Sub/TitleStyle.cs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// the title of serie.
|
||||||
|
/// 标题相关设置。
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public class TitleStyle : SubComponent, IEquatable<TitleStyle>
|
||||||
|
{
|
||||||
|
[SerializeField] private bool m_Show;
|
||||||
|
[SerializeField] private TextStyle m_textStyle = new TextStyle(18);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to show title.
|
||||||
|
/// 是否显示标题。
|
||||||
|
/// </summary>
|
||||||
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the color of text.
|
||||||
|
/// 文本的颜色。
|
||||||
|
/// </summary>
|
||||||
|
public TextStyle textStyle { get { return m_textStyle; } set { m_textStyle = value; } }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Text runtimeText { get; set; }
|
||||||
|
|
||||||
|
public TitleStyle Clone()
|
||||||
|
{
|
||||||
|
var title = new TitleStyle();
|
||||||
|
title.show = show;
|
||||||
|
title.textStyle = textStyle.Clone();
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, obj))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (obj is TitleStyle)
|
||||||
|
{
|
||||||
|
return Equals((TitleStyle)obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(TitleStyle other)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, other))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return textStyle.Equals(other.textStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return base.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsInited()
|
||||||
|
{
|
||||||
|
return runtimeText != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetActive(bool active)
|
||||||
|
{
|
||||||
|
if (runtimeText)
|
||||||
|
{
|
||||||
|
ChartHelper.SetActive(runtimeText, active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdatePosition(Vector3 pos)
|
||||||
|
{
|
||||||
|
if (runtimeText)
|
||||||
|
{
|
||||||
|
runtimeText.transform.localPosition = pos + new Vector3(m_textStyle.offset.x, m_textStyle.offset.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetText(string text)
|
||||||
|
{
|
||||||
|
if (runtimeText)
|
||||||
|
{
|
||||||
|
if (textStyle.color != Color.clear) runtimeText.color = textStyle.color;
|
||||||
|
runtimeText.text = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Component/Sub/TitleStyle.cs.meta
Normal file
11
Assets/XCharts/Runtime/Component/Sub/TitleStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0f3865dea73ae403581fe83cfeca13f0
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
430
Assets/XCharts/Runtime/GaugeChart.cs
Normal file
430
Assets/XCharts/Runtime/GaugeChart.cs
Normal file
@@ -0,0 +1,430 @@
|
|||||||
|
using System;
|
||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
[AddComponentMenu("XCharts/GaugeChart", 19)]
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
[RequireComponent(typeof(RectTransform))]
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
public class GaugeChart : BaseChart
|
||||||
|
{
|
||||||
|
private static readonly string s_AxisLabelObjectName = "axis_label";
|
||||||
|
private bool m_UpdateTitleText = false;
|
||||||
|
private bool m_UpdateLabelText = false;
|
||||||
|
|
||||||
|
protected override void Awake()
|
||||||
|
{
|
||||||
|
base.Awake();
|
||||||
|
InitAxisLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Start()
|
||||||
|
{
|
||||||
|
base.Start();
|
||||||
|
foreach (var serie in m_Series.list)
|
||||||
|
{
|
||||||
|
UpdateTitle(serie);
|
||||||
|
UpdateLabel(serie);
|
||||||
|
}
|
||||||
|
UpdateTitleAndLabelText();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
if (m_UpdateLabelText || m_UpdateTitleText)
|
||||||
|
{
|
||||||
|
m_UpdateTitleText = false;
|
||||||
|
m_UpdateLabelText = false;
|
||||||
|
UpdateTitleAndLabelText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
protected override void Reset()
|
||||||
|
{
|
||||||
|
base.Reset();
|
||||||
|
RemoveData();
|
||||||
|
m_Title.text = "GuageChart";
|
||||||
|
var serie = AddSerie(SerieType.Gauge, "serie1");
|
||||||
|
serie.min = 0;
|
||||||
|
serie.max = 100;
|
||||||
|
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.updateAnimation = true;
|
||||||
|
serie.titleStyle.show = true;
|
||||||
|
serie.titleStyle.textStyle.offset = new Vector2(0, 20);
|
||||||
|
serie.label.show = true;
|
||||||
|
serie.label.offset = new Vector3(0, -30);
|
||||||
|
serie.itemStyle.show = true;
|
||||||
|
serie.gaugeAxis.axisLabel.show = true;
|
||||||
|
serie.gaugeAxis.axisLabel.margin = 18;
|
||||||
|
AddData(0, UnityEngine.Random.Range(10, 90), "title");
|
||||||
|
InitAxisLabel();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private void InitAxisLabel()
|
||||||
|
{
|
||||||
|
var labelObject = ChartHelper.AddObject(s_AxisLabelObjectName, transform, Vector2.zero,
|
||||||
|
Vector2.zero, Vector2.zero, new Vector2(chartWidth, chartHeight));
|
||||||
|
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||||
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
|
{
|
||||||
|
var serie = m_Series.list[i];
|
||||||
|
|
||||||
|
var serieLabel = serie.gaugeAxis.axisLabel;
|
||||||
|
serie.gaugeAxis.ClearLabelObject();
|
||||||
|
var count = serie.splitNumber > 36 ? 36 : (serie.splitNumber + 1);
|
||||||
|
var startAngle = serie.startAngle;
|
||||||
|
for (int j = 0; j < count; j++)
|
||||||
|
{
|
||||||
|
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
||||||
|
var color = Color.grey;
|
||||||
|
var labelObj = SerieLabelPool.Get(textName, labelObject.transform, serieLabel, m_ThemeInfo.font, color, 100, 100);
|
||||||
|
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||||
|
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||||
|
var item = new LabelObject();
|
||||||
|
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||||
|
item.SetIcon(iconImage);
|
||||||
|
item.SetIconActive(false);
|
||||||
|
serie.gaugeAxis.AddLabelObject(item);
|
||||||
|
}
|
||||||
|
UpdateAxisLabel(serie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawChart(VertexHelper vh)
|
||||||
|
{
|
||||||
|
base.DrawChart(vh);
|
||||||
|
DrawData(vh);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnThemeChanged()
|
||||||
|
{
|
||||||
|
base.OnThemeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawData(VertexHelper vh)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
|
{
|
||||||
|
var serie = m_Series.list[i];
|
||||||
|
if (serie.type != SerieType.Gauge) continue;
|
||||||
|
DrawGauge(vh, serie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawGauge(VertexHelper vh, Serie serie)
|
||||||
|
{
|
||||||
|
serie.UpdateCenter(chartWidth, chartHeight);
|
||||||
|
var destAngle = GetCurrAngle(serie, true);
|
||||||
|
serie.animation.InitProgress(0, serie.startAngle, destAngle);
|
||||||
|
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||||
|
|
||||||
|
DrawProgressBar(vh, serie, currAngle);
|
||||||
|
DrawStageColor(vh, serie);
|
||||||
|
DrawSplitLine(vh, serie);
|
||||||
|
DrawAxisTick(vh, serie);
|
||||||
|
DrawPointer(vh, serie, currAngle);
|
||||||
|
UpdateTitle(serie);
|
||||||
|
// UpdateAxisLabel(serie);
|
||||||
|
UpdateLabel(serie);
|
||||||
|
|
||||||
|
CheckAnimation(serie);
|
||||||
|
if (!serie.animation.IsFinish())
|
||||||
|
{
|
||||||
|
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
||||||
|
float speed = (destAngle - serie.startAngle) / duration;
|
||||||
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
else if (NeedRefresh(serie))
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawProgressBar(VertexHelper vh, Serie serie, float currAngle)
|
||||||
|
{
|
||||||
|
if (serie.gaugeType != GaugeType.ProgressBar) return;
|
||||||
|
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||||
|
var color = serie.gaugeAxis.GetAxisLineColor(m_ThemeInfo, serie.index);
|
||||||
|
var backgroundColor = serie.gaugeAxis.GetAxisLineBackgroundColor(m_ThemeInfo, serie.index);
|
||||||
|
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||||
|
ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||||
|
backgroundColor, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, serie.startAngle, serie.endAngle);
|
||||||
|
if (serie.arcShaped)
|
||||||
|
{
|
||||||
|
DrawArcShape(vh, serie, serie.startAngle, backgroundColor, true);
|
||||||
|
DrawArcShape(vh, serie, serie.endAngle, backgroundColor);
|
||||||
|
}
|
||||||
|
ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||||
|
color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, serie.startAngle, currAngle);
|
||||||
|
if (serie.arcShaped && currAngle != serie.startAngle)
|
||||||
|
{
|
||||||
|
DrawArcShape(vh, serie, currAngle, color);
|
||||||
|
DrawArcShape(vh, serie, serie.startAngle, color, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawStageColor(VertexHelper vh, Serie serie)
|
||||||
|
{
|
||||||
|
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||||
|
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||||
|
var totalAngle = serie.endAngle - serie.startAngle;
|
||||||
|
var tempStartAngle = serie.startAngle;
|
||||||
|
var tempEndAngle = serie.startAngle;
|
||||||
|
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||||
|
serie.gaugeAxis.runtimeStageAngle.Clear();
|
||||||
|
for (int i = 0; i < serie.gaugeAxis.axisLine.stageColor.Count; i++)
|
||||||
|
{
|
||||||
|
var stageColor = serie.gaugeAxis.axisLine.stageColor[i];
|
||||||
|
tempEndAngle = serie.startAngle + totalAngle * stageColor.percent;
|
||||||
|
serie.gaugeAxis.runtimeStageAngle.Add(tempEndAngle);
|
||||||
|
ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||||
|
stageColor.color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, tempStartAngle, tempEndAngle);
|
||||||
|
tempStartAngle = tempEndAngle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawPointer(VertexHelper vh, Serie serie, float currAngle)
|
||||||
|
{
|
||||||
|
if (!serie.gaugePointer.show) return;
|
||||||
|
var pointerColor = serie.gaugeAxis.GetPointerColor(m_ThemeInfo, serie.index, currAngle, serie.itemStyle);
|
||||||
|
var len = serie.gaugePointer.length < 1 && serie.gaugePointer.length > -1 ?
|
||||||
|
serie.runtimeInsideRadius * serie.gaugePointer.length :
|
||||||
|
serie.gaugePointer.length;
|
||||||
|
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle, len);
|
||||||
|
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 180, serie.gaugePointer.width);
|
||||||
|
var p3 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle - 90, serie.gaugePointer.width / 2);
|
||||||
|
var p4 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 90, serie.gaugePointer.width / 2);
|
||||||
|
ChartDrawer.DrawPolygon(vh, p1, p3, p2, p4, pointerColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawSplitLine(VertexHelper vh, Serie serie)
|
||||||
|
{
|
||||||
|
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||||
|
if (!serie.gaugeAxis.show || !serie.gaugeAxis.splitLine.show) return;
|
||||||
|
if (serie.splitNumber <= 0) return;
|
||||||
|
var splitLine = serie.gaugeAxis.splitLine;
|
||||||
|
var totalAngle = serie.endAngle - serie.startAngle;
|
||||||
|
var diffAngle = totalAngle / serie.splitNumber;
|
||||||
|
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||||
|
var insideRadius = outsideRadius - splitLine.length;
|
||||||
|
var lineWidth = splitLine.lineStyle.width;
|
||||||
|
for (int i = 0; i < serie.splitNumber + 1; i++)
|
||||||
|
{
|
||||||
|
var angle = serie.startAngle + i * diffAngle;
|
||||||
|
var lineColor = serie.gaugeAxis.GetSplitLineColor(m_ThemeInfo, serie.index, angle);
|
||||||
|
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, insideRadius);
|
||||||
|
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, outsideRadius);
|
||||||
|
ChartDrawer.DrawLine(vh, p1, p2, lineWidth, lineColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawAxisTick(VertexHelper vh, Serie serie)
|
||||||
|
{
|
||||||
|
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||||
|
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisTick.show) return;
|
||||||
|
if (serie.splitNumber <= 0) return;
|
||||||
|
var axisTick = serie.gaugeAxis.axisTick;
|
||||||
|
var totalAngle = serie.endAngle - serie.startAngle;
|
||||||
|
var diffAngle = totalAngle / serie.splitNumber;
|
||||||
|
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||||
|
var insideRadius = outsideRadius - (axisTick.length < 1 ? serie.gaugeAxis.axisLine.width * axisTick.length : axisTick.length);
|
||||||
|
var lineWidth = axisTick.lineStyle.width;
|
||||||
|
for (int i = 0; i < serie.splitNumber; i++)
|
||||||
|
{
|
||||||
|
for (int j = 1; j < axisTick.splitNumber; j++)
|
||||||
|
{
|
||||||
|
var angle = serie.startAngle + i * diffAngle + j * (diffAngle / axisTick.splitNumber);
|
||||||
|
var lineColor = serie.gaugeAxis.GetSplitLineColor(m_ThemeInfo, serie.index, angle);
|
||||||
|
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, insideRadius);
|
||||||
|
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, outsideRadius);
|
||||||
|
ChartDrawer.DrawLine(vh, p1, p2, lineWidth, lineColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool NeedRefresh(Serie serie)
|
||||||
|
{
|
||||||
|
if (serie.type == SerieType.Gauge)
|
||||||
|
{
|
||||||
|
var serieData = serie.GetSerieData(0);
|
||||||
|
if (serieData != null)
|
||||||
|
{
|
||||||
|
var destValue = serieData.GetData(1);
|
||||||
|
var currValue = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||||
|
return destValue != currValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawArcShape(VertexHelper vh, Serie serie, float angle, Color color, bool invert = false)
|
||||||
|
{
|
||||||
|
var radius = serie.gaugeAxis.axisLine.width / 2;
|
||||||
|
var len = serie.runtimeInsideRadius + radius;
|
||||||
|
var pos = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, len);
|
||||||
|
var startAngle = invert ? angle + 180 : angle;
|
||||||
|
var endAngle = invert ? angle + 360 : angle + 180;
|
||||||
|
ChartDrawer.DrawSector(vh, pos, radius, color, startAngle, endAngle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckAnimation(Serie serie)
|
||||||
|
{
|
||||||
|
var serieData = serie.GetSerieData(0);
|
||||||
|
if (serieData != null)
|
||||||
|
{
|
||||||
|
var value = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||||
|
var data = serieData.GetData(1);
|
||||||
|
if (value != data) m_RefreshChart = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateTitle(Serie serie)
|
||||||
|
{
|
||||||
|
if (serie.titleStyle.show)
|
||||||
|
{
|
||||||
|
if (serie.titleStyle.IsInited())
|
||||||
|
{
|
||||||
|
serie.titleStyle.SetActive(true);
|
||||||
|
serie.titleStyle.UpdatePosition(serie.runtimeCenterPos);
|
||||||
|
m_UpdateTitleText = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ReinitTitle = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serie.titleStyle.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateAxisLabel(Serie serie)
|
||||||
|
{
|
||||||
|
var show = serie.gaugeAxis.show && serie.gaugeAxis.axisLabel.show;
|
||||||
|
serie.gaugeAxis.SetLabelObjectActive(show);
|
||||||
|
if (!show)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var count = serie.splitNumber > 36 ? 36 : serie.splitNumber;
|
||||||
|
var startAngle = serie.startAngle;
|
||||||
|
var totalAngle = serie.endAngle - serie.startAngle;
|
||||||
|
var totalValue = serie.max - serie.min;
|
||||||
|
var diffAngle = totalAngle / count;
|
||||||
|
var diffValue = totalValue / count;
|
||||||
|
var radius = serie.runtimeInsideRadius - serie.gaugeAxis.axisLabel.margin;
|
||||||
|
var serieData = serie.GetSerieData(0);
|
||||||
|
var dataName = serieData != null ? serieData.name : null;
|
||||||
|
var customLabelText = serie.gaugeAxis.axisLabelText;
|
||||||
|
for (int j = 0; j <= count; j++)
|
||||||
|
{
|
||||||
|
var angle = serie.startAngle + j * diffAngle;
|
||||||
|
var value = serie.min + j * diffValue;
|
||||||
|
var pos = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, radius);
|
||||||
|
var text = customLabelText != null && j < customLabelText.Count ? customLabelText[j] :
|
||||||
|
serie.gaugeAxis.axisLabel.GetFormatterContent(serie.name, dataName, value, totalValue);
|
||||||
|
serie.gaugeAxis.SetLabelObjectText(j, text);
|
||||||
|
serie.gaugeAxis.SetLabelObjectPosition(j, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLabel(Serie serie)
|
||||||
|
{
|
||||||
|
var serieData = serie.GetSerieData(0);
|
||||||
|
if (serieData != null)
|
||||||
|
{
|
||||||
|
if (serie.label.show)
|
||||||
|
{
|
||||||
|
if (serieData.IsInitLabel())
|
||||||
|
{
|
||||||
|
serieData.SetLabelActive(true);
|
||||||
|
serieData.SetLabelPosition(serie.runtimeCenterPos + serie.label.offset);
|
||||||
|
m_UpdateLabelText = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ReinitLabel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
serieData.SetLabelActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateTitleAndLabelText()
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series.list)
|
||||||
|
{
|
||||||
|
if (serie.type == SerieType.Gauge)
|
||||||
|
{
|
||||||
|
var serieData = serie.GetSerieData(0);
|
||||||
|
if (serieData != null)
|
||||||
|
{
|
||||||
|
if (serie.label.show && serieData.IsInitLabel())
|
||||||
|
{
|
||||||
|
var value = serieData.GetData(1);
|
||||||
|
var total = serie.max;
|
||||||
|
var content = serie.label.GetFormatterContent(serie.name, serieData.name, value, total);
|
||||||
|
serieData.SetLabelText(content);
|
||||||
|
if (serie.label.color != Color.clear)
|
||||||
|
{
|
||||||
|
serieData.SetLabelColor(serie.label.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (serie.titleStyle.show && serie.titleStyle.IsInited())
|
||||||
|
{
|
||||||
|
serie.titleStyle.SetText(serieData.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UpdateAxisLabel(serie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float GetCurrAngle(Serie serie, bool dest)
|
||||||
|
{
|
||||||
|
float rangeValue = serie.max - serie.min;
|
||||||
|
float rangeAngle = serie.endAngle - serie.startAngle;
|
||||||
|
float value = 0;
|
||||||
|
float angle = serie.startAngle;
|
||||||
|
if (serie.dataCount > 0)
|
||||||
|
{
|
||||||
|
var serieData = serie.data[0];
|
||||||
|
value = dest ? serieData.GetData(1) : serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||||
|
value = Mathf.Clamp(value, serie.min, serie.max);
|
||||||
|
}
|
||||||
|
if (rangeValue > 0)
|
||||||
|
{
|
||||||
|
angle += rangeAngle * value / rangeValue;
|
||||||
|
}
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnRefreshLabel()
|
||||||
|
{
|
||||||
|
//TODO:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/GaugeChart.cs.meta
Normal file
11
Assets/XCharts/Runtime/GaugeChart.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2c7cdc3b6d7f9473289a599c00a2569c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -87,8 +87,8 @@ namespace XCharts
|
|||||||
|
|
||||||
protected override void RefreshTooltip()
|
protected override void RefreshTooltip()
|
||||||
{
|
{
|
||||||
var xData = m_Tooltip.xValues[0];
|
var xData = m_Tooltip.runtimeXValues[0];
|
||||||
var yData = m_Tooltip.yValues[0];
|
var yData = m_Tooltip.runtimeYValues[0];
|
||||||
if (IsCategory() && (xData < 0 || yData < 0)) return;
|
if (IsCategory() && (xData < 0 || yData < 0)) return;
|
||||||
sb.Length = 0;
|
sb.Length = 0;
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
@@ -117,13 +117,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentText(sb.ToString().Trim());
|
m_Tooltip.UpdateContentText(sb.ToString().Trim());
|
||||||
var pos = m_Tooltip.GetContentPos();
|
var pos = m_Tooltip.GetContentPos();
|
||||||
if (pos.x + m_Tooltip.width > chartWidth)
|
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
||||||
{
|
{
|
||||||
pos.x = chartWidth - m_Tooltip.width;
|
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
||||||
}
|
}
|
||||||
if (pos.y - m_Tooltip.height < 0)
|
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
||||||
{
|
{
|
||||||
pos.y = m_Tooltip.height;
|
pos.y = m_Tooltip.runtimeHeight;
|
||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
m_Tooltip.UpdateContentPos(pos);
|
||||||
m_Tooltip.SetActive(true);
|
m_Tooltip.SetActive(true);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
public static class XAxisPool
|
internal static class XAxisPool
|
||||||
{
|
{
|
||||||
private static readonly ObjectPool<XAxis> s_ListPool = new ObjectPool<XAxis>(null, null);
|
private static readonly ObjectPool<XAxis> s_ListPool = new ObjectPool<XAxis>(null, null);
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class YAxisPool
|
internal static class YAxisPool
|
||||||
{
|
{
|
||||||
private static readonly ObjectPool<YAxis> s_ListPool = new ObjectPool<YAxis>(null, null);
|
private static readonly ObjectPool<YAxis> s_ListPool = new ObjectPool<YAxis>(null, null);
|
||||||
|
|
||||||
|
|||||||
@@ -30,13 +30,14 @@ namespace XCharts
|
|||||||
Vertical
|
Vertical
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class BaseChart : Graphic, IPointerDownHandler, IPointerUpHandler,
|
public partial class BaseChart : MaskableGraphic, IPointerDownHandler, IPointerUpHandler,
|
||||||
IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler,
|
IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler,
|
||||||
IDragHandler, IEndDragHandler, IScrollHandler
|
IDragHandler, IEndDragHandler, IScrollHandler
|
||||||
{
|
{
|
||||||
private static readonly string s_TitleObjectName = "title";
|
protected static readonly string s_TitleObjectName = "title";
|
||||||
private static readonly string s_LegendObjectName = "legend";
|
protected static readonly string s_LegendObjectName = "legend";
|
||||||
private static readonly string s_SerieLabelObjectName = "label";
|
protected static readonly string s_SerieLabelObjectName = "label";
|
||||||
|
protected static readonly string s_SerieTitleObjectName = "serie";
|
||||||
|
|
||||||
[SerializeField] protected float m_ChartWidth;
|
[SerializeField] protected float m_ChartWidth;
|
||||||
[SerializeField] protected float m_ChartHeight;
|
[SerializeField] protected float m_ChartHeight;
|
||||||
@@ -54,12 +55,17 @@ namespace XCharts
|
|||||||
[NonSerialized] private Legend m_CheckLegend = Legend.defaultLegend;
|
[NonSerialized] private Legend m_CheckLegend = Legend.defaultLegend;
|
||||||
[NonSerialized] private float m_CheckWidth = 0;
|
[NonSerialized] private float m_CheckWidth = 0;
|
||||||
[NonSerialized] private float m_CheckHeight = 0;
|
[NonSerialized] private float m_CheckHeight = 0;
|
||||||
|
[NonSerialized] private Vector2 m_CheckMinAnchor;
|
||||||
|
[NonSerialized] private Vector2 m_CheckMaxAnchor;
|
||||||
|
|
||||||
[NonSerialized] private float m_CheckSerieCount = 0;
|
[NonSerialized] private float m_CheckSerieCount = 0;
|
||||||
[NonSerialized] private List<string> m_CheckSerieName = new List<string>();
|
[NonSerialized] private List<string> m_CheckSerieName = new List<string>();
|
||||||
[NonSerialized] private bool m_RefreshChart = false;
|
[NonSerialized] protected bool m_RefreshChart = false;
|
||||||
[NonSerialized] private bool m_RefreshLabel = false;
|
[NonSerialized] protected bool m_RefreshLabel = false;
|
||||||
[NonSerialized] private bool m_ReinitLabel = false;
|
[NonSerialized] protected bool m_ReinitLabel = false;
|
||||||
[NonSerialized] private bool m_CheckAnimation = false;
|
[NonSerialized] protected bool m_ReinitTitle = false;
|
||||||
|
[NonSerialized] protected bool m_CheckAnimation = false;
|
||||||
|
[NonSerialized] protected bool m_IsPlayingStartAnimation = false;
|
||||||
[NonSerialized] protected List<string> m_LegendRealShowName = new List<string>();
|
[NonSerialized] protected List<string> m_LegendRealShowName = new List<string>();
|
||||||
|
|
||||||
protected Vector2 chartAnchorMax { get { return rectTransform.anchorMax; } }
|
protected Vector2 chartAnchorMax { get { return rectTransform.anchorMax; } }
|
||||||
@@ -84,6 +90,7 @@ namespace XCharts
|
|||||||
InitTitle();
|
InitTitle();
|
||||||
InitLegend();
|
InitLegend();
|
||||||
InitSerieLabel();
|
InitSerieLabel();
|
||||||
|
InitSerieTitle();
|
||||||
InitTooltip();
|
InitTooltip();
|
||||||
m_Series.AnimationStop();
|
m_Series.AnimationStop();
|
||||||
m_Series.AnimationStart();
|
m_Series.AnimationStart();
|
||||||
@@ -148,12 +155,12 @@ namespace XCharts
|
|||||||
private void InitTitle()
|
private void InitTitle()
|
||||||
{
|
{
|
||||||
m_Title.OnChanged();
|
m_Title.OnChanged();
|
||||||
TextAnchor anchor = m_Title.location.textAnchor;
|
TextAnchor anchor = m_Title.location.runtimeTextAnchor;
|
||||||
Vector2 anchorMin = m_Title.location.anchorMin;
|
Vector2 anchorMin = m_Title.location.runtimeAnchorMin;
|
||||||
Vector2 anchorMax = m_Title.location.anchorMax;
|
Vector2 anchorMax = m_Title.location.runtimeAnchorMax;
|
||||||
Vector2 pivot = m_Title.location.pivot;
|
Vector2 pivot = m_Title.location.runtimePivot;
|
||||||
Vector3 titlePosition = m_Title.location.GetPosition(chartWidth, chartHeight);
|
Vector3 titlePosition = m_Title.location.GetPosition(chartWidth, chartHeight);
|
||||||
Vector3 subTitlePosition = -new Vector3(0, m_Title.textFontSize + m_Title.itemGap, 0);
|
Vector3 subTitlePosition = -new Vector3(0, m_Title.textStyle.fontSize + m_Title.itemGap, 0);
|
||||||
float titleWid = chartWidth;
|
float titleWid = chartWidth;
|
||||||
|
|
||||||
var titleObject = ChartHelper.AddObject(s_TitleObjectName, transform, anchorMin, anchorMax,
|
var titleObject = ChartHelper.AddObject(s_TitleObjectName, transform, anchorMin, anchorMax,
|
||||||
@@ -163,30 +170,32 @@ namespace XCharts
|
|||||||
|
|
||||||
Text titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform,
|
Text titleText = ChartHelper.AddTextObject(s_TitleObjectName, titleObject.transform,
|
||||||
m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot,
|
m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot,
|
||||||
new Vector2(titleWid, m_Title.textFontSize), m_Title.textFontSize);
|
new Vector2(titleWid, m_Title.textStyle.fontSize), m_Title.textStyle.fontSize, m_Title.textStyle.rotate,
|
||||||
|
m_Title.textStyle.fontStyle);
|
||||||
|
|
||||||
titleText.alignment = anchor;
|
titleText.alignment = anchor;
|
||||||
titleText.gameObject.SetActive(m_Title.show);
|
titleText.gameObject.SetActive(m_Title.show);
|
||||||
titleText.transform.localPosition = Vector2.zero;
|
titleText.transform.localPosition = Vector3.zero + m_Title.textStyle.offsetv3;
|
||||||
titleText.text = m_Title.text.Replace("\\n", "\n");
|
titleText.text = m_Title.text.Replace("\\n", "\n");
|
||||||
|
|
||||||
Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform,
|
Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform,
|
||||||
m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot,
|
m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot,
|
||||||
new Vector2(titleWid, m_Title.subTextFontSize), m_Title.subTextFontSize);
|
new Vector2(titleWid, m_Title.subTextStyle.fontSize), m_Title.subTextStyle.fontSize,
|
||||||
|
m_Title.subTextStyle.rotate, m_Title.subTextStyle.fontStyle);
|
||||||
|
|
||||||
subText.alignment = anchor;
|
subText.alignment = anchor;
|
||||||
subText.gameObject.SetActive(m_Title.show && !string.IsNullOrEmpty(m_Title.subText));
|
subText.gameObject.SetActive(m_Title.show && !string.IsNullOrEmpty(m_Title.subText));
|
||||||
subText.transform.localPosition = subTitlePosition;
|
subText.transform.localPosition = subTitlePosition + m_Title.subTextStyle.offsetv3;
|
||||||
subText.text = m_Title.subText.Replace("\\n", "\n");
|
subText.text = m_Title.subText.Replace("\\n", "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitLegend()
|
private void InitLegend()
|
||||||
{
|
{
|
||||||
m_Legend.OnChanged();
|
m_Legend.OnChanged();
|
||||||
TextAnchor anchor = m_Legend.location.textAnchor;
|
TextAnchor anchor = m_Legend.location.runtimeTextAnchor;
|
||||||
Vector2 anchorMin = m_Legend.location.anchorMin;
|
Vector2 anchorMin = m_Legend.location.runtimeAnchorMin;
|
||||||
Vector2 anchorMax = m_Legend.location.anchorMax;
|
Vector2 anchorMax = m_Legend.location.runtimeAnchorMax;
|
||||||
Vector2 pivot = m_Legend.location.pivot;
|
Vector2 pivot = m_Legend.location.runtimePivot;
|
||||||
|
|
||||||
var legendObject = ChartHelper.AddObject(s_LegendObjectName, transform, anchorMin, anchorMax,
|
var legendObject = ChartHelper.AddObject(s_LegendObjectName, transform, anchorMin, anchorMax,
|
||||||
pivot, new Vector2(chartWidth, chartHeight));
|
pivot, new Vector2(chartWidth, chartHeight));
|
||||||
@@ -213,7 +222,7 @@ namespace XCharts
|
|||||||
totalLegend++;
|
totalLegend++;
|
||||||
}
|
}
|
||||||
m_Legend.RemoveButton();
|
m_Legend.RemoveButton();
|
||||||
ChartHelper.DestoryAllChilds(legendObject.transform);
|
ChartHelper.DestroyAllChildren(legendObject.transform);
|
||||||
if (!m_Legend.show) return;
|
if (!m_Legend.show) return;
|
||||||
for (int i = 0; i < datas.Count; i++)
|
for (int i = 0; i < datas.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -287,9 +296,9 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitSerieLabel()
|
private void InitSerieLabel()
|
||||||
{
|
{
|
||||||
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, chartAnchorMin,
|
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, Vector2.zero,
|
||||||
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
Vector2.zero, Vector2.zero, new Vector2(chartWidth, chartHeight));
|
||||||
ChartHelper.DestoryAllChilds(labelObject.transform);
|
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < m_Series.Count; i++)
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -297,37 +306,65 @@ namespace XCharts
|
|||||||
for (int j = 0; j < serie.data.Count; j++)
|
for (int j = 0; j < serie.data.Count; j++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
if (!serie.label.show && j > 100) continue;
|
var serieLabel = serieData.GetSerieLabel(serie.label);
|
||||||
var textName = s_SerieLabelObjectName + "_" + i + "_" + j + "_" + serieData.name;
|
if (!serieLabel.show && j > 100) continue;
|
||||||
|
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
||||||
var color = Color.grey;
|
var color = Color.grey;
|
||||||
if (serie.type == SerieType.Pie)
|
if (serie.type == SerieType.Pie)
|
||||||
{
|
{
|
||||||
color = (serie.label.position == SerieLabel.Position.Inside) ? Color.white :
|
color = (serieLabel.position == SerieLabel.Position.Inside) ? Color.white :
|
||||||
(Color)m_ThemeInfo.GetColor(count);
|
(Color)m_ThemeInfo.GetColor(count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
color = serie.label.color != Color.clear ? serie.label.color :
|
color = serieLabel.color != Color.clear ? serieLabel.color :
|
||||||
(Color)m_ThemeInfo.GetColor(i);
|
(Color)m_ThemeInfo.GetColor(i);
|
||||||
}
|
}
|
||||||
var backgroundColor = serie.label.backgroundColor;
|
var labelObj = SerieLabelPool.Get(textName, labelObject.transform, serieLabel, m_ThemeInfo.font, color,
|
||||||
var labelObj = ChartHelper.AddSerieLabel(textName, labelObject.transform, m_ThemeInfo.font,
|
serieData.iconStyle.width, serieData.iconStyle.height);
|
||||||
color, backgroundColor, serie.label.fontSize, serie.label.fontStyle, serie.label.rotate,
|
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||||
serie.label.backgroundWidth, serie.label.backgroundHeight);
|
serieData.SetIconImage(iconImage);
|
||||||
|
|
||||||
var iconObj = ChartHelper.AddIcon("Icon", labelObj.transform, serieData.iconWidth, serieData.iconHeight);
|
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||||
serieData.SetIconObj(iconObj);
|
serieData.InitLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||||
|
|
||||||
var isAutoSize = serie.label.backgroundWidth == 0 || serie.label.backgroundHeight == 0;
|
|
||||||
serieData.InitLabel(labelObj, isAutoSize, serie.label.paddingLeftRight, serie.label.paddingTopBottom);
|
|
||||||
serieData.SetLabelActive(false);
|
serieData.SetLabelActive(false);
|
||||||
serieData.SetLabelText(serieData.name);
|
//serieData.SetLabelText(serieData.name);
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitSerieTitle()
|
||||||
|
{
|
||||||
|
var titleObject = ChartHelper.AddObject(s_SerieTitleObjectName, transform, Vector2.zero,
|
||||||
|
Vector2.zero, Vector2.zero, new Vector2(chartWidth, chartHeight));
|
||||||
|
ChartHelper.HideAllObject(titleObject);
|
||||||
|
for (int i = 0; i < m_Series.Count; i++)
|
||||||
|
{
|
||||||
|
var serie = m_Series.list[i];
|
||||||
|
var textStyle = serie.titleStyle.textStyle;
|
||||||
|
var color = textStyle.color == Color.clear ? m_ThemeInfo.GetColor(i) : (Color32)textStyle.color;
|
||||||
|
var anchorMin = new Vector2(0.5f, 0.5f);
|
||||||
|
var anchorMax = new Vector2(0.5f, 0.5f);
|
||||||
|
var pivot = new Vector2(0.5f, 0.5f);
|
||||||
|
var fontSize = 10;
|
||||||
|
var sizeDelta = new Vector2(50, fontSize + 2);
|
||||||
|
var txt = ChartHelper.AddTextObject("title_" + i, titleObject.transform, m_ThemeInfo.font, color, TextAnchor.MiddleCenter,
|
||||||
|
anchorMin, anchorMax, pivot, sizeDelta, textStyle.fontSize, textStyle.rotate, textStyle.fontStyle);
|
||||||
|
txt.text = "";
|
||||||
|
txt.transform.localPosition = new Vector2(0, 0);
|
||||||
|
txt.transform.localEulerAngles = Vector2.zero;
|
||||||
|
ChartHelper.SetActive(txt, false);
|
||||||
|
serie.titleStyle.runtimeText = txt;
|
||||||
|
var serieData = serie.GetSerieData(0);
|
||||||
|
if (serieData != null)
|
||||||
|
{
|
||||||
|
txt.text = serieData.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void InitTooltip()
|
private void InitTooltip()
|
||||||
{
|
{
|
||||||
var tooltipObject = ChartHelper.AddObject("tooltip", transform, chartAnchorMin,
|
var tooltipObject = ChartHelper.AddObject("tooltip", transform, chartAnchorMin,
|
||||||
@@ -361,6 +398,13 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
SetSize(sizeDelta.x, sizeDelta.y);
|
SetSize(sizeDelta.x, sizeDelta.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_CheckMinAnchor != rectTransform.anchorMin || m_CheckMaxAnchor != rectTransform.anchorMax)
|
||||||
|
{
|
||||||
|
m_CheckMaxAnchor = rectTransform.anchorMax;
|
||||||
|
m_CheckMinAnchor = rectTransform.anchorMin;
|
||||||
|
m_ReinitLabel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckTheme()
|
private void CheckTheme()
|
||||||
@@ -409,14 +453,15 @@ namespace XCharts
|
|||||||
|
|
||||||
private void CheckPointerPos()
|
private void CheckPointerPos()
|
||||||
{
|
{
|
||||||
var needCheck = (m_Tooltip.show && m_Tooltip.inited)
|
var needCheck = (m_Tooltip.show && m_Tooltip.runtimeInited)
|
||||||
|| raycastTarget;
|
|| raycastTarget;
|
||||||
if (needCheck)
|
if (needCheck)
|
||||||
{
|
{
|
||||||
if (canvas == null) return;
|
if (canvas == null) return;
|
||||||
Vector2 local;
|
Vector2 local;
|
||||||
|
var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera;
|
||||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
|
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
|
||||||
Input.mousePosition, canvas.worldCamera, out local))
|
Input.mousePosition, cam, out local))
|
||||||
{
|
{
|
||||||
pointerPos = Vector2.zero;
|
pointerPos = Vector2.zero;
|
||||||
}
|
}
|
||||||
@@ -429,7 +474,7 @@ namespace XCharts
|
|||||||
|
|
||||||
private void CheckTooltip()
|
private void CheckTooltip()
|
||||||
{
|
{
|
||||||
if (!m_Tooltip.show || !m_Tooltip.inited)
|
if (!m_Tooltip.show || !m_Tooltip.runtimeInited)
|
||||||
{
|
{
|
||||||
if (m_Tooltip.IsActive())
|
if (m_Tooltip.IsActive())
|
||||||
{
|
{
|
||||||
@@ -439,9 +484,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < m_Tooltip.dataIndex.Count; i++)
|
for (int i = 0; i < m_Tooltip.runtimeDataIndex.Count; i++)
|
||||||
{
|
{
|
||||||
m_Tooltip.dataIndex[i] = -1;
|
m_Tooltip.runtimeDataIndex[i] = -1;
|
||||||
}
|
}
|
||||||
Vector2 local = pointerPos;
|
Vector2 local = pointerPos;
|
||||||
if (canvas == null) return;
|
if (canvas == null) return;
|
||||||
@@ -465,7 +510,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_Tooltip.pointerPos = local;
|
m_Tooltip.runtimePointerPos = local;
|
||||||
CheckTootipArea(local);
|
CheckTootipArea(local);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,12 +531,25 @@ namespace XCharts
|
|||||||
|
|
||||||
protected void CheckRefreshLabel()
|
protected void CheckRefreshLabel()
|
||||||
{
|
{
|
||||||
|
foreach (var serie in m_Series.list)
|
||||||
|
{
|
||||||
|
if (serie.label.show && serie.runtimeLastCheckDataCount != serie.dataCount)
|
||||||
|
{
|
||||||
|
m_ReinitLabel = true;
|
||||||
|
serie.runtimeLastCheckDataCount = serie.dataCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (m_ReinitLabel)
|
if (m_ReinitLabel)
|
||||||
{
|
{
|
||||||
m_ReinitLabel = false;
|
m_ReinitLabel = false;
|
||||||
m_LegendRealShowName = m_Series.GetSerieNameList();
|
m_LegendRealShowName = m_Series.GetSerieNameList();
|
||||||
InitSerieLabel();
|
InitSerieLabel();
|
||||||
}
|
}
|
||||||
|
if (m_ReinitTitle)
|
||||||
|
{
|
||||||
|
m_ReinitTitle = false;
|
||||||
|
InitSerieTitle();
|
||||||
|
}
|
||||||
if (m_RefreshLabel)
|
if (m_RefreshLabel)
|
||||||
{
|
{
|
||||||
m_RefreshLabel = false;
|
m_RefreshLabel = false;
|
||||||
@@ -518,6 +576,7 @@ namespace XCharts
|
|||||||
InitTitle();
|
InitTitle();
|
||||||
InitLegend();
|
InitLegend();
|
||||||
InitTooltip();
|
InitTooltip();
|
||||||
|
InitSerieLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnThemeChanged()
|
protected virtual void OnThemeChanged()
|
||||||
@@ -701,25 +760,26 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var labelHalfWid = serieData.GetLabelWidth() / 2;
|
var labelHalfWid = serieData.GetLabelWidth() / 2;
|
||||||
var labelHalfHig = serieData.GetLabelHeight() / 2;
|
var labelHalfHig = serieData.GetLabelHeight() / 2;
|
||||||
var centerPos = serieData.labelPosition + serie.label.offset;
|
var serieLabel = serieData.GetSerieLabel(serie.label);
|
||||||
|
var centerPos = serieData.labelPosition + serieLabel.offset;
|
||||||
var p1 = new Vector3(centerPos.x - labelHalfWid, centerPos.y + labelHalfHig);
|
var p1 = new Vector3(centerPos.x - labelHalfWid, centerPos.y + labelHalfHig);
|
||||||
var p2 = new Vector3(centerPos.x + labelHalfWid, centerPos.y + labelHalfHig);
|
var p2 = new Vector3(centerPos.x + labelHalfWid, centerPos.y + labelHalfHig);
|
||||||
var p3 = new Vector3(centerPos.x + labelHalfWid, centerPos.y - labelHalfHig);
|
var p3 = new Vector3(centerPos.x + labelHalfWid, centerPos.y - labelHalfHig);
|
||||||
var p4 = new Vector3(centerPos.x - labelHalfWid, centerPos.y - labelHalfHig);
|
var p4 = new Vector3(centerPos.x - labelHalfWid, centerPos.y - labelHalfHig);
|
||||||
|
|
||||||
if (serie.label.rotate > 0)
|
if (serieLabel.rotate > 0)
|
||||||
{
|
{
|
||||||
p1 = ChartHelper.RotateRound(p1, centerPos, Vector3.forward, serie.label.rotate);
|
p1 = ChartHelper.RotateRound(p1, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p2 = ChartHelper.RotateRound(p2, centerPos, Vector3.forward, serie.label.rotate);
|
p2 = ChartHelper.RotateRound(p2, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p3 = ChartHelper.RotateRound(p3, centerPos, Vector3.forward, serie.label.rotate);
|
p3 = ChartHelper.RotateRound(p3, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p4 = ChartHelper.RotateRound(p4, centerPos, Vector3.forward, serie.label.rotate);
|
p4 = ChartHelper.RotateRound(p4, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, serie.label.backgroundColor);
|
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, serieLabel.backgroundColor);
|
||||||
|
|
||||||
if (serie.label.border)
|
if (serieLabel.border)
|
||||||
{
|
{
|
||||||
var borderWid = serie.label.borderWidth;
|
var borderWid = serieLabel.borderWidth;
|
||||||
p1 = new Vector3(centerPos.x - labelHalfWid, centerPos.y + labelHalfHig + borderWid);
|
p1 = new Vector3(centerPos.x - labelHalfWid, centerPos.y + labelHalfHig + borderWid);
|
||||||
p2 = new Vector3(centerPos.x + labelHalfWid + 2 * borderWid, centerPos.y + labelHalfHig + borderWid);
|
p2 = new Vector3(centerPos.x + labelHalfWid + 2 * borderWid, centerPos.y + labelHalfHig + borderWid);
|
||||||
p3 = new Vector3(centerPos.x + labelHalfWid + borderWid, centerPos.y + labelHalfHig);
|
p3 = new Vector3(centerPos.x + labelHalfWid + borderWid, centerPos.y + labelHalfHig);
|
||||||
@@ -728,21 +788,21 @@ namespace XCharts
|
|||||||
var p6 = new Vector3(centerPos.x - labelHalfWid - 2 * borderWid, centerPos.y - labelHalfHig - borderWid);
|
var p6 = new Vector3(centerPos.x - labelHalfWid - 2 * borderWid, centerPos.y - labelHalfHig - borderWid);
|
||||||
var p7 = new Vector3(centerPos.x - labelHalfWid - borderWid, centerPos.y - labelHalfHig);
|
var p7 = new Vector3(centerPos.x - labelHalfWid - borderWid, centerPos.y - labelHalfHig);
|
||||||
var p8 = new Vector3(centerPos.x - labelHalfWid - borderWid, centerPos.y + labelHalfHig + 2 * borderWid);
|
var p8 = new Vector3(centerPos.x - labelHalfWid - borderWid, centerPos.y + labelHalfHig + 2 * borderWid);
|
||||||
if (serie.label.rotate > 0)
|
if (serieLabel.rotate > 0)
|
||||||
{
|
{
|
||||||
p1 = ChartHelper.RotateRound(p1, centerPos, Vector3.forward, serie.label.rotate);
|
p1 = ChartHelper.RotateRound(p1, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p2 = ChartHelper.RotateRound(p2, centerPos, Vector3.forward, serie.label.rotate);
|
p2 = ChartHelper.RotateRound(p2, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p3 = ChartHelper.RotateRound(p3, centerPos, Vector3.forward, serie.label.rotate);
|
p3 = ChartHelper.RotateRound(p3, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p4 = ChartHelper.RotateRound(p4, centerPos, Vector3.forward, serie.label.rotate);
|
p4 = ChartHelper.RotateRound(p4, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p5 = ChartHelper.RotateRound(p5, centerPos, Vector3.forward, serie.label.rotate);
|
p5 = ChartHelper.RotateRound(p5, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p6 = ChartHelper.RotateRound(p6, centerPos, Vector3.forward, serie.label.rotate);
|
p6 = ChartHelper.RotateRound(p6, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p7 = ChartHelper.RotateRound(p7, centerPos, Vector3.forward, serie.label.rotate);
|
p7 = ChartHelper.RotateRound(p7, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
p8 = ChartHelper.RotateRound(p8, centerPos, Vector3.forward, serie.label.rotate);
|
p8 = ChartHelper.RotateRound(p8, centerPos, Vector3.forward, serieLabel.rotate);
|
||||||
}
|
}
|
||||||
ChartDrawer.DrawLine(vh, p1, p2, borderWid, serie.label.borderColor);
|
ChartDrawer.DrawLine(vh, p1, p2, borderWid, serieLabel.borderColor);
|
||||||
ChartDrawer.DrawLine(vh, p3, p4, borderWid, serie.label.borderColor);
|
ChartDrawer.DrawLine(vh, p3, p4, borderWid, serieLabel.borderColor);
|
||||||
ChartDrawer.DrawLine(vh, p5, p6, borderWid, serie.label.borderColor);
|
ChartDrawer.DrawLine(vh, p5, p6, borderWid, serieLabel.borderColor);
|
||||||
ChartDrawer.DrawLine(vh, p7, p8, borderWid, serie.label.borderColor);
|
ChartDrawer.DrawLine(vh, p7, p8, borderWid, serieLabel.borderColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
base.DrawChart(vh);
|
base.DrawChart(vh);
|
||||||
if (!m_CheckMinMaxValue) return;
|
if (!m_CheckMinMaxValue) return;
|
||||||
|
m_IsPlayingStartAnimation = false;
|
||||||
bool yCategory = m_YAxises[0].IsCategory() || m_YAxises[1].IsCategory();
|
bool yCategory = m_YAxises[0].IsCategory() || m_YAxises[1].IsCategory();
|
||||||
m_Series.GetStackSeries(ref m_StackSeries);
|
m_Series.GetStackSeries(ref m_StackSeries);
|
||||||
int seriesCount = m_StackSeries.Count;
|
int seriesCount = m_StackSeries.Count;
|
||||||
@@ -146,6 +147,7 @@ namespace XCharts
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var isCartesian = IsValue();
|
var isCartesian = IsValue();
|
||||||
|
int dataCount = m_Series.list.Count > 0 ? m_Series.list[0].GetDataList(dataZoom).Count : 0;
|
||||||
for (int i = 0; i < m_XAxises.Count; i++)
|
for (int i = 0; i < m_XAxises.Count; i++)
|
||||||
{
|
{
|
||||||
var xAxis = m_XAxises[i];
|
var xAxis = m_XAxises[i];
|
||||||
@@ -153,14 +155,14 @@ namespace XCharts
|
|||||||
if (!xAxis.show && !yAxis.show) continue;
|
if (!xAxis.show && !yAxis.show) continue;
|
||||||
if (isCartesian && xAxis.show && yAxis.show)
|
if (isCartesian && xAxis.show && yAxis.show)
|
||||||
{
|
{
|
||||||
var yRate = (yAxis.maxValue - yAxis.minValue) / coordinateHeight;
|
var yRate = (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) / coordinateHeight;
|
||||||
var xRate = (xAxis.maxValue - xAxis.minValue) / coordinateWidth;
|
var xRate = (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) / coordinateWidth;
|
||||||
var yValue = yRate * (local.y - coordinateY - yAxis.zeroYOffset);
|
var yValue = yRate * (local.y - coordinateY - yAxis.runtimeZeroYOffset);
|
||||||
if (yAxis.minValue > 0) yValue += yAxis.minValue;
|
if (yAxis.runtimeMinValue > 0) yValue += yAxis.runtimeMinValue;
|
||||||
m_Tooltip.yValues[i] = yValue;
|
m_Tooltip.runtimeYValues[i] = yValue;
|
||||||
var xValue = xRate * (local.x - coordinateX - xAxis.zeroXOffset);
|
var xValue = xRate * (local.x - coordinateX - xAxis.runtimeZeroXOffset);
|
||||||
if (xAxis.minValue > 0) xValue += xAxis.minValue;
|
if (xAxis.runtimeMinValue > 0) xValue += xAxis.runtimeMinValue;
|
||||||
m_Tooltip.xValues[i] = xValue;
|
m_Tooltip.runtimeXValues[i] = xValue;
|
||||||
|
|
||||||
for (int j = 0; j < m_Series.Count; j++)
|
for (int j = 0; j < m_Series.Count; j++)
|
||||||
{
|
{
|
||||||
@@ -174,7 +176,7 @@ namespace XCharts
|
|||||||
if (Mathf.Abs(xValue - xdata) / xRate < symbolSize
|
if (Mathf.Abs(xValue - xdata) / xRate < symbolSize
|
||||||
&& Mathf.Abs(yValue - ydata) / yRate < symbolSize)
|
&& Mathf.Abs(yValue - ydata) / yRate < symbolSize)
|
||||||
{
|
{
|
||||||
m_Tooltip.dataIndex[i] = n;
|
m_Tooltip.runtimeDataIndex[i] = n;
|
||||||
serieData.highlighted = true;
|
serieData.highlighted = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -189,60 +191,60 @@ namespace XCharts
|
|||||||
|
|
||||||
for (int j = 0; j < xAxis.GetDataNumber(m_DataZoom); j++)
|
for (int j = 0; j < xAxis.GetDataNumber(m_DataZoom); j++)
|
||||||
{
|
{
|
||||||
float splitWid = xAxis.GetDataWidth(coordinateWidth, m_DataZoom);
|
float splitWid = xAxis.GetDataWidth(coordinateWidth, dataCount, m_DataZoom);
|
||||||
float pX = coordinateX + j * splitWid;
|
float pX = coordinateX + j * splitWid;
|
||||||
if ((xAxis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
|
if ((xAxis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
|
||||||
(!xAxis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
|
(!xAxis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
|
||||||
{
|
{
|
||||||
m_Tooltip.xValues[i] = j;
|
m_Tooltip.runtimeXValues[i] = j;
|
||||||
m_Tooltip.dataIndex[i] = j;
|
m_Tooltip.runtimeDataIndex[i] = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int j = 0; j < yAxis.GetDataNumber(m_DataZoom); j++)
|
for (int j = 0; j < yAxis.GetDataNumber(m_DataZoom); j++)
|
||||||
{
|
{
|
||||||
float splitWid = yAxis.GetDataWidth(coordinateHeight, m_DataZoom);
|
float splitWid = yAxis.GetDataWidth(coordinateHeight, dataCount, m_DataZoom);
|
||||||
float pY = coordinateY + j * splitWid;
|
float pY = coordinateY + j * splitWid;
|
||||||
if ((yAxis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
|
if ((yAxis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
|
||||||
(!yAxis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
|
(!yAxis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
|
||||||
{
|
{
|
||||||
m_Tooltip.yValues[i] = j;
|
m_Tooltip.runtimeYValues[i] = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (xAxis.IsCategory())
|
else if (xAxis.IsCategory())
|
||||||
{
|
{
|
||||||
var value = (yAxis.maxValue - yAxis.minValue) * (local.y - coordinateY - yAxis.zeroYOffset) / coordinateHeight;
|
var value = (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * (local.y - coordinateY - yAxis.runtimeZeroYOffset) / coordinateHeight;
|
||||||
if (yAxis.minValue > 0) value += yAxis.minValue;
|
if (yAxis.runtimeMinValue > 0) value += yAxis.runtimeMinValue;
|
||||||
m_Tooltip.yValues[i] = value;
|
m_Tooltip.runtimeYValues[i] = value;
|
||||||
for (int j = 0; j < xAxis.GetDataNumber(m_DataZoom); j++)
|
for (int j = 0; j < xAxis.GetDataNumber(m_DataZoom); j++)
|
||||||
{
|
{
|
||||||
float splitWid = xAxis.GetDataWidth(coordinateWidth, m_DataZoom);
|
float splitWid = xAxis.GetDataWidth(coordinateWidth, dataCount, m_DataZoom);
|
||||||
float pX = coordinateX + j * splitWid;
|
float pX = coordinateX + j * splitWid;
|
||||||
if ((xAxis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
|
if ((xAxis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
|
||||||
(!xAxis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
|
(!xAxis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
|
||||||
{
|
{
|
||||||
m_Tooltip.xValues[i] = j;
|
m_Tooltip.runtimeXValues[i] = j;
|
||||||
m_Tooltip.dataIndex[i] = j;
|
m_Tooltip.runtimeDataIndex[i] = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (yAxis.IsCategory())
|
else if (yAxis.IsCategory())
|
||||||
{
|
{
|
||||||
var value = (xAxis.maxValue - xAxis.minValue) * (local.x - coordinateX - xAxis.zeroXOffset) / coordinateWidth;
|
var value = (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * (local.x - coordinateX - xAxis.runtimeZeroXOffset) / coordinateWidth;
|
||||||
if (xAxis.minValue > 0) value += xAxis.minValue;
|
if (xAxis.runtimeMinValue > 0) value += xAxis.runtimeMinValue;
|
||||||
m_Tooltip.xValues[i] = value;
|
m_Tooltip.runtimeXValues[i] = value;
|
||||||
for (int j = 0; j < yAxis.GetDataNumber(m_DataZoom); j++)
|
for (int j = 0; j < yAxis.GetDataNumber(m_DataZoom); j++)
|
||||||
{
|
{
|
||||||
float splitWid = yAxis.GetDataWidth(coordinateHeight, m_DataZoom);
|
float splitWid = yAxis.GetDataWidth(coordinateHeight, dataCount, m_DataZoom);
|
||||||
float pY = coordinateY + j * splitWid;
|
float pY = coordinateY + j * splitWid;
|
||||||
if ((yAxis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
|
if ((yAxis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
|
||||||
(!yAxis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
|
(!yAxis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
|
||||||
{
|
{
|
||||||
m_Tooltip.yValues[i] = j;
|
m_Tooltip.runtimeYValues[i] = j;
|
||||||
m_Tooltip.dataIndex[i] = j;
|
m_Tooltip.runtimeDataIndex[i] = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -275,17 +277,17 @@ namespace XCharts
|
|||||||
bool isCartesian = IsValue();
|
bool isCartesian = IsValue();
|
||||||
if (isCartesian)
|
if (isCartesian)
|
||||||
{
|
{
|
||||||
index = m_Tooltip.dataIndex[0];
|
index = m_Tooltip.runtimeDataIndex[0];
|
||||||
tempAxis = m_XAxises[0];
|
tempAxis = m_XAxises[0];
|
||||||
}
|
}
|
||||||
else if (m_XAxises[0].type == Axis.AxisType.Value)
|
else if (m_XAxises[0].type == Axis.AxisType.Value)
|
||||||
{
|
{
|
||||||
index = (int)m_Tooltip.yValues[0];
|
index = (int)m_Tooltip.runtimeYValues[0];
|
||||||
tempAxis = m_YAxises[0];
|
tempAxis = m_YAxises[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
index = (int)m_Tooltip.xValues[0];
|
index = (int)m_Tooltip.runtimeXValues[0];
|
||||||
tempAxis = m_XAxises[0];
|
tempAxis = m_XAxises[0];
|
||||||
}
|
}
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
@@ -298,7 +300,7 @@ namespace XCharts
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(tooltip.formatter))
|
if (tooltip.IsNoFormatter())
|
||||||
{
|
{
|
||||||
sb.Length = 0;
|
sb.Length = 0;
|
||||||
if (!isCartesian)
|
if (!isCartesian)
|
||||||
@@ -319,8 +321,8 @@ namespace XCharts
|
|||||||
if (serieData != null && serieData.highlighted)
|
if (serieData != null && serieData.highlighted)
|
||||||
{
|
{
|
||||||
sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "");
|
sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "");
|
||||||
sb.Append("[").Append(ChartCached.FloatToStr(xValue)).Append(",")
|
sb.Append("[").Append(ChartCached.FloatToStr(xValue, 0, m_Tooltip.forceENotation)).Append(",")
|
||||||
.Append(ChartCached.FloatToStr(yValue)).Append("]\n");
|
.Append(ChartCached.FloatToStr(yValue, 0, m_Tooltip.forceENotation)).Append("]\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -328,7 +330,7 @@ namespace XCharts
|
|||||||
sb.Append("\n")
|
sb.Append("\n")
|
||||||
.Append("<color=#").Append(m_ThemeInfo.GetColorStr(i)).Append(">● </color>")
|
.Append("<color=#").Append(m_ThemeInfo.GetColorStr(i)).Append(">● </color>")
|
||||||
.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "")
|
.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "")
|
||||||
.Append(ChartCached.FloatToStr(yValue));
|
.Append(ChartCached.FloatToStr(yValue, 0, m_Tooltip.forceENotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,13 +342,13 @@ namespace XCharts
|
|||||||
m_Tooltip.UpdateContentText(m_Tooltip.GetFormatterContent(index, m_Series, category, m_DataZoom));
|
m_Tooltip.UpdateContentText(m_Tooltip.GetFormatterContent(index, m_Series, category, m_DataZoom));
|
||||||
}
|
}
|
||||||
var pos = m_Tooltip.GetContentPos();
|
var pos = m_Tooltip.GetContentPos();
|
||||||
if (pos.x + m_Tooltip.width > chartWidth)
|
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
||||||
{
|
{
|
||||||
pos.x = chartWidth - m_Tooltip.width;
|
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
||||||
}
|
}
|
||||||
if (pos.y - m_Tooltip.height < 0)
|
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
||||||
{
|
{
|
||||||
pos.y = m_Tooltip.height;
|
pos.y = m_Tooltip.runtimeHeight;
|
||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
m_Tooltip.UpdateContentPos(pos);
|
||||||
m_Tooltip.SetActive(true);
|
m_Tooltip.SetActive(true);
|
||||||
@@ -374,14 +376,14 @@ namespace XCharts
|
|||||||
var diff = axisIndex > 0 ? -axis.axisLabel.fontSize - axis.axisLabel.margin - 3.5f : axis.axisLabel.margin / 2 + 1;
|
var diff = axisIndex > 0 ? -axis.axisLabel.fontSize - axis.axisLabel.margin - 3.5f : axis.axisLabel.margin / 2 + 1;
|
||||||
if (axis.IsValue())
|
if (axis.IsValue())
|
||||||
{
|
{
|
||||||
labelText = ChartCached.FloatToStr(m_Tooltip.xValues[axisIndex], 2);
|
labelText = ChartCached.FloatToStr(m_Tooltip.runtimeXValues[axisIndex], 2);
|
||||||
labelPos = new Vector2(m_Tooltip.pointerPos.x, posY - diff);
|
labelPos = new Vector2(m_Tooltip.runtimePointerPos.x, posY - diff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labelText = axis.GetData((int)m_Tooltip.xValues[axisIndex], m_DataZoom);
|
labelText = axis.GetData((int)m_Tooltip.runtimeXValues[axisIndex], m_DataZoom);
|
||||||
float splitWidth = axis.GetSplitWidth(coordinateWidth, m_DataZoom);
|
float splitWidth = axis.GetSplitWidth(coordinateWidth, m_DataZoom);
|
||||||
int index = (int)m_Tooltip.xValues[axisIndex];
|
int index = (int)m_Tooltip.runtimeXValues[axisIndex];
|
||||||
float px = coordinateX + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0) + 0.5f;
|
float px = coordinateX + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0) + 0.5f;
|
||||||
labelPos = new Vector2(px, posY - diff);
|
labelPos = new Vector2(px, posY - diff);
|
||||||
}
|
}
|
||||||
@@ -392,14 +394,14 @@ namespace XCharts
|
|||||||
var diff = axisIndex > 0 ? -axis.axisLabel.margin + 3 : axis.axisLabel.margin - 3;
|
var diff = axisIndex > 0 ? -axis.axisLabel.margin + 3 : axis.axisLabel.margin - 3;
|
||||||
if (axis.IsValue())
|
if (axis.IsValue())
|
||||||
{
|
{
|
||||||
labelText = ChartCached.FloatToStr(m_Tooltip.yValues[axisIndex], 2);
|
labelText = ChartCached.FloatToStr(m_Tooltip.runtimeYValues[axisIndex], 2);
|
||||||
labelPos = new Vector2(posX - diff, m_Tooltip.pointerPos.y);
|
labelPos = new Vector2(posX - diff, m_Tooltip.runtimePointerPos.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labelText = axis.GetData((int)m_Tooltip.yValues[axisIndex], m_DataZoom);
|
labelText = axis.GetData((int)m_Tooltip.runtimeYValues[axisIndex], m_DataZoom);
|
||||||
float splitWidth = axis.GetSplitWidth(coordinateHeight, m_DataZoom);
|
float splitWidth = axis.GetSplitWidth(coordinateHeight, m_DataZoom);
|
||||||
int index = (int)m_Tooltip.yValues[axisIndex];
|
int index = (int)m_Tooltip.runtimeYValues[axisIndex];
|
||||||
float py = coordinateY + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0);
|
float py = coordinateY + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0);
|
||||||
labelPos = new Vector2(posX - diff, py);
|
labelPos = new Vector2(posX - diff, py);
|
||||||
}
|
}
|
||||||
@@ -438,8 +440,8 @@ namespace XCharts
|
|||||||
m_YAxises.Add(axis1);
|
m_YAxises.Add(axis1);
|
||||||
m_YAxises.Add(axis2);
|
m_YAxises.Add(axis2);
|
||||||
}
|
}
|
||||||
foreach (var axis in m_XAxises) axis.minValue = axis.maxValue = 0;
|
foreach (var axis in m_XAxises) axis.runtimeMinValue = axis.runtimeMaxValue = 0;
|
||||||
foreach (var axis in m_YAxises) axis.minValue = axis.maxValue = 0;
|
foreach (var axis in m_YAxises) axis.runtimeMinValue = axis.runtimeMaxValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitAxisY()
|
private void InitAxisY()
|
||||||
@@ -461,7 +463,7 @@ namespace XCharts
|
|||||||
axisObj.transform.localPosition = Vector3.zero;
|
axisObj.transform.localPosition = Vector3.zero;
|
||||||
axisObj.SetActive(yAxis.show && yAxis.axisLabel.show);
|
axisObj.SetActive(yAxis.show && yAxis.axisLabel.show);
|
||||||
ChartHelper.HideAllObject(axisObj);
|
ChartHelper.HideAllObject(axisObj);
|
||||||
if (yAxis.IsValue() && yAxis.minValue == 0 && yAxis.maxValue == 0) return;
|
if (yAxis.IsValue() && yAxis.runtimeMinValue == 0 && yAxis.runtimeMaxValue == 0) return;
|
||||||
var labelColor = yAxis.axisLabel.color == Color.clear ?
|
var labelColor = yAxis.axisLabel.color == Color.clear ?
|
||||||
(Color)m_ThemeInfo.axisTextColor :
|
(Color)m_ThemeInfo.axisTextColor :
|
||||||
yAxis.axisLabel.color;
|
yAxis.axisLabel.color;
|
||||||
@@ -490,7 +492,7 @@ namespace XCharts
|
|||||||
txt.transform.localPosition = GetLabelYPosition(totalWidth + (yAxis.boundaryGap ? labelWidth / 2 : 0), i, yAxisIndex, yAxis);
|
txt.transform.localPosition = GetLabelYPosition(totalWidth + (yAxis.boundaryGap ? labelWidth / 2 : 0), i, yAxisIndex, yAxis);
|
||||||
|
|
||||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||||
txt.text = yAxis.GetLabelName(coordinateHeight, i, yAxis.minValue, yAxis.maxValue, m_DataZoom, isPercentStack);
|
txt.text = yAxis.GetLabelName(coordinateHeight, i, yAxis.runtimeMinValue, yAxis.runtimeMaxValue, m_DataZoom, isPercentStack);
|
||||||
txt.gameObject.SetActive(yAxis.show &&
|
txt.gameObject.SetActive(yAxis.show &&
|
||||||
(yAxis.axisLabel.interval == 0 || i % (yAxis.axisLabel.interval + 1) == 0));
|
(yAxis.axisLabel.interval == 0 || i % (yAxis.axisLabel.interval + 1) == 0));
|
||||||
yAxis.axisLabelTextList.Add(txt);
|
yAxis.axisLabelTextList.Add(txt);
|
||||||
@@ -503,7 +505,7 @@ namespace XCharts
|
|||||||
var fontSize = yAxis.axisName.fontSize;
|
var fontSize = yAxis.axisName.fontSize;
|
||||||
var offset = yAxis.axisName.offset;
|
var offset = yAxis.axisName.offset;
|
||||||
Text axisName = null;
|
Text axisName = null;
|
||||||
var zeroPos = new Vector3(coordinateX + m_XAxises[yAxisIndex].zeroXOffset, coordinateY);
|
var zeroPos = new Vector3(coordinateX + m_XAxises[yAxisIndex].runtimeZeroXOffset, coordinateY);
|
||||||
switch (yAxis.axisName.location)
|
switch (yAxis.axisName.location)
|
||||||
{
|
{
|
||||||
case AxisName.Location.Start:
|
case AxisName.Location.Start:
|
||||||
@@ -537,10 +539,10 @@ namespace XCharts
|
|||||||
axisName.text = yAxis.axisName.name;
|
axisName.text = yAxis.axisName.name;
|
||||||
}
|
}
|
||||||
//init tooltip label
|
//init tooltip label
|
||||||
if (m_Tooltip.gameObject)
|
if (m_Tooltip.runtimeGameObject)
|
||||||
{
|
{
|
||||||
Vector2 privot = yAxisIndex > 0 ? new Vector2(0, 0.5f) : new Vector2(1, 0.5f);
|
Vector2 privot = yAxisIndex > 0 ? new Vector2(0, 0.5f) : new Vector2(1, 0.5f);
|
||||||
var labelParent = m_Tooltip.gameObject.transform;
|
var labelParent = m_Tooltip.runtimeGameObject.transform;
|
||||||
GameObject labelObj = ChartHelper.AddTooltipLabel(objName + "_label", labelParent, m_ThemeInfo.font, privot);
|
GameObject labelObj = ChartHelper.AddTooltipLabel(objName + "_label", labelParent, m_ThemeInfo.font, privot);
|
||||||
yAxis.SetTooltipLabel(labelObj);
|
yAxis.SetTooltipLabel(labelObj);
|
||||||
yAxis.SetTooltipLabelColor(m_ThemeInfo.tooltipBackgroundColor, m_ThemeInfo.tooltipTextColor);
|
yAxis.SetTooltipLabelColor(m_ThemeInfo.tooltipBackgroundColor, m_ThemeInfo.tooltipTextColor);
|
||||||
@@ -566,7 +568,7 @@ namespace XCharts
|
|||||||
axisObj.transform.localPosition = Vector3.zero;
|
axisObj.transform.localPosition = Vector3.zero;
|
||||||
axisObj.SetActive(xAxis.show && xAxis.axisLabel.show);
|
axisObj.SetActive(xAxis.show && xAxis.axisLabel.show);
|
||||||
ChartHelper.HideAllObject(axisObj);
|
ChartHelper.HideAllObject(axisObj);
|
||||||
if (xAxis.IsValue() && xAxis.minValue == 0 && xAxis.maxValue == 0) return;
|
if (xAxis.IsValue() && xAxis.runtimeMinValue == 0 && xAxis.runtimeMaxValue == 0) return;
|
||||||
var labelColor = xAxis.axisLabel.color == Color.clear ?
|
var labelColor = xAxis.axisLabel.color == Color.clear ?
|
||||||
(Color)m_ThemeInfo.axisTextColor :
|
(Color)m_ThemeInfo.axisTextColor :
|
||||||
xAxis.axisLabel.color;
|
xAxis.axisLabel.color;
|
||||||
@@ -585,7 +587,7 @@ namespace XCharts
|
|||||||
i, xAxisIndex, xAxis);
|
i, xAxisIndex, xAxis);
|
||||||
totalWidth += labelWidth;
|
totalWidth += labelWidth;
|
||||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||||
txt.text = xAxis.GetLabelName(coordinateWidth, i, xAxis.minValue, xAxis.maxValue, m_DataZoom, isPercentStack);
|
txt.text = xAxis.GetLabelName(coordinateWidth, i, xAxis.runtimeMinValue, xAxis.runtimeMaxValue, m_DataZoom, isPercentStack);
|
||||||
txt.gameObject.SetActive(xAxis.show &&
|
txt.gameObject.SetActive(xAxis.show &&
|
||||||
(xAxis.axisLabel.interval == 0 || i % (xAxis.axisLabel.interval + 1) == 0));
|
(xAxis.axisLabel.interval == 0 || i % (xAxis.axisLabel.interval + 1) == 0));
|
||||||
xAxis.axisLabelTextList.Add(txt);
|
xAxis.axisLabelTextList.Add(txt);
|
||||||
@@ -597,7 +599,7 @@ namespace XCharts
|
|||||||
var fontSize = xAxis.axisName.fontSize;
|
var fontSize = xAxis.axisName.fontSize;
|
||||||
var offset = xAxis.axisName.offset;
|
var offset = xAxis.axisName.offset;
|
||||||
Text axisName = null;
|
Text axisName = null;
|
||||||
var zeroPos = new Vector3(coordinateX, coordinateY + m_YAxises[xAxisIndex].zeroYOffset);
|
var zeroPos = new Vector3(coordinateX, coordinateY + m_YAxises[xAxisIndex].runtimeZeroYOffset);
|
||||||
switch (xAxis.axisName.location)
|
switch (xAxis.axisName.location)
|
||||||
{
|
{
|
||||||
case AxisName.Location.Start:
|
case AxisName.Location.Start:
|
||||||
@@ -630,10 +632,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
axisName.text = xAxis.axisName.name;
|
axisName.text = xAxis.axisName.name;
|
||||||
}
|
}
|
||||||
if (m_Tooltip.gameObject)
|
if (m_Tooltip.runtimeGameObject)
|
||||||
{
|
{
|
||||||
Vector2 privot = xAxisIndex > 0 ? new Vector2(0.5f, 1) : new Vector2(0.5f, 1);
|
Vector2 privot = xAxisIndex > 0 ? new Vector2(0.5f, 1) : new Vector2(0.5f, 1);
|
||||||
var labelParent = m_Tooltip.gameObject.transform;
|
var labelParent = m_Tooltip.runtimeGameObject.transform;
|
||||||
GameObject labelObj = ChartHelper.AddTooltipLabel(ChartHelper.Cancat(objName, "_label"), labelParent, m_ThemeInfo.font, privot);
|
GameObject labelObj = ChartHelper.AddTooltipLabel(ChartHelper.Cancat(objName, "_label"), labelParent, m_ThemeInfo.font, privot);
|
||||||
xAxis.SetTooltipLabel(labelObj);
|
xAxis.SetTooltipLabel(labelObj);
|
||||||
xAxis.SetTooltipLabelColor(m_ThemeInfo.tooltipBackgroundColor, m_ThemeInfo.tooltipTextColor);
|
xAxis.SetTooltipLabelColor(m_ThemeInfo.tooltipBackgroundColor, m_ThemeInfo.tooltipTextColor);
|
||||||
@@ -647,12 +649,14 @@ namespace XCharts
|
|||||||
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||||
dataZoomObject.transform.localPosition = Vector3.zero;
|
dataZoomObject.transform.localPosition = Vector3.zero;
|
||||||
ChartHelper.HideAllObject(dataZoomObject);
|
ChartHelper.HideAllObject(dataZoomObject);
|
||||||
m_DataZoom.startLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "start",
|
var startLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "start",
|
||||||
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.dataZoomTextColor, TextAnchor.MiddleRight,
|
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.dataZoomTextColor, TextAnchor.MiddleRight,
|
||||||
Vector2.zero, Vector2.zero, new Vector2(1, 0.5f), new Vector2(200, 20), m_DataZoom.fontSize, 0, m_DataZoom.fontStyle);
|
Vector2.zero, Vector2.zero, new Vector2(1, 0.5f), new Vector2(200, 20), m_DataZoom.fontSize, 0, m_DataZoom.fontStyle);
|
||||||
m_DataZoom.endLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "end",
|
var endLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "end",
|
||||||
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.dataZoomTextColor, TextAnchor.MiddleLeft,
|
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.dataZoomTextColor, TextAnchor.MiddleLeft,
|
||||||
Vector2.zero, Vector2.zero, new Vector2(0, 0.5f), new Vector2(200, 20), m_DataZoom.fontSize, 0, m_DataZoom.fontStyle);
|
Vector2.zero, Vector2.zero, new Vector2(0, 0.5f), new Vector2(200, 20), m_DataZoom.fontSize, 0, m_DataZoom.fontStyle);
|
||||||
|
m_DataZoom.SetStartLabel(startLabel);
|
||||||
|
m_DataZoom.SetEndLabel(endLabel);
|
||||||
m_DataZoom.SetLabelActive(false);
|
m_DataZoom.SetLabelActive(false);
|
||||||
CheckRaycastTarget();
|
CheckRaycastTarget();
|
||||||
var xAxis = m_XAxises[m_DataZoom.xAxisIndex];
|
var xAxis = m_XAxises[m_DataZoom.xAxisIndex];
|
||||||
@@ -766,8 +770,8 @@ namespace XCharts
|
|||||||
private void UpdateAxisMinMaxValue(int axisIndex, Axis axis, bool updateChart = true)
|
private void UpdateAxisMinMaxValue(int axisIndex, Axis axis, bool updateChart = true)
|
||||||
{
|
{
|
||||||
if (axis.IsCategory() || !axis.show) return;
|
if (axis.IsCategory() || !axis.show) return;
|
||||||
int tempMinValue = 0;
|
float tempMinValue = 0;
|
||||||
int tempMaxValue = 0;
|
float tempMaxValue = 0;
|
||||||
|
|
||||||
if (IsValue())
|
if (IsValue())
|
||||||
{
|
{
|
||||||
@@ -784,38 +788,44 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, false, out tempMinValue, out tempMaxValue);
|
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, false, out tempMinValue, out tempMaxValue);
|
||||||
}
|
}
|
||||||
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue);
|
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue, true);
|
||||||
if (tempMinValue != axis.minValue || tempMaxValue != axis.maxValue)
|
if (tempMinValue != axis.runtimeMinValue || tempMaxValue != axis.runtimeMaxValue)
|
||||||
{
|
{
|
||||||
m_CheckMinMaxValue = true;
|
m_CheckMinMaxValue = true;
|
||||||
|
axis.runtimeMinValue = tempMinValue;
|
||||||
axis.minValue = tempMinValue;
|
axis.runtimeMaxValue = tempMaxValue;
|
||||||
axis.maxValue = tempMaxValue;
|
axis.runtimeZeroXOffset = 0;
|
||||||
axis.zeroXOffset = 0;
|
axis.runtimeZeroYOffset = 0;
|
||||||
axis.zeroYOffset = 0;
|
|
||||||
if (tempMinValue != 0 || tempMaxValue != 0)
|
if (tempMinValue != 0 || tempMaxValue != 0)
|
||||||
{
|
{
|
||||||
if (axis is XAxis && axis.IsValue())
|
if (axis is XAxis && axis.IsValue())
|
||||||
{
|
{
|
||||||
axis.zeroXOffset = axis.minValue > 0 ? 0 :
|
axis.runtimeZeroXOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||||
axis.maxValue < 0 ? this.coordinateWidth :
|
axis.runtimeMaxValue < 0 ? this.coordinateWidth :
|
||||||
Mathf.Abs(axis.minValue) * (this.coordinateWidth / (Mathf.Abs(axis.minValue) + Mathf.Abs(axis.maxValue)));
|
Mathf.Abs(axis.runtimeMinValue) * (this.coordinateWidth / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||||
}
|
}
|
||||||
if (axis is YAxis && axis.IsValue())
|
if (axis is YAxis && axis.IsValue())
|
||||||
{
|
{
|
||||||
axis.zeroYOffset = axis.minValue > 0 ? 0 :
|
axis.runtimeZeroYOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||||
axis.maxValue < 0 ? coordinateHeight :
|
axis.runtimeMaxValue < 0 ? coordinateHeight :
|
||||||
Mathf.Abs(axis.minValue) * (coordinateHeight / (Mathf.Abs(axis.minValue) + Mathf.Abs(axis.maxValue)));
|
Mathf.Abs(axis.runtimeMinValue) * (coordinateHeight / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updateChart)
|
if (updateChart)
|
||||||
{
|
{
|
||||||
float coordinateWidth = axis is XAxis ? this.coordinateWidth : coordinateHeight;
|
float coordinateWidth = axis is XAxis ? this.coordinateWidth : coordinateHeight;
|
||||||
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||||
axis.UpdateLabelText(coordinateWidth, m_DataZoom, isPercentStack);
|
axis.UpdateLabelText(coordinateWidth, m_DataZoom, isPercentStack, 500);
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (axis.IsValueChanging(500) && !m_IsPlayingStartAnimation)
|
||||||
|
{
|
||||||
|
float coordinateWidth = axis is XAxis ? this.coordinateWidth : coordinateHeight;
|
||||||
|
var isPercentStack = m_Series.IsPercentStack(SerieType.Bar);
|
||||||
|
axis.UpdateLabelText(coordinateWidth, m_DataZoom, isPercentStack, 500);
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnCoordinateChanged()
|
protected virtual void OnCoordinateChanged()
|
||||||
@@ -876,12 +886,12 @@ namespace XCharts
|
|||||||
|
|
||||||
private void DrawYAxisTickAndSplit(VertexHelper vh, int yAxisIndex, YAxis yAxis)
|
private void DrawYAxisTickAndSplit(VertexHelper vh, int yAxisIndex, YAxis yAxis)
|
||||||
{
|
{
|
||||||
if (yAxis.show)
|
if (yAxis.NeedShowSplit())
|
||||||
{
|
{
|
||||||
var size = yAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
var size = yAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||||
var totalWidth = coordinateY;
|
var totalWidth = coordinateY;
|
||||||
var xAxis = m_XAxises[yAxisIndex];
|
var xAxis = m_XAxises[yAxisIndex];
|
||||||
var zeroPos = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY + yAxis.zeroYOffset);
|
var zeroPos = new Vector3(coordinateX + xAxis.runtimeZeroXOffset, coordinateY + yAxis.runtimeZeroYOffset);
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
var scaleWidth = yAxis.GetScaleWidth(coordinateHeight, i, m_DataZoom);
|
var scaleWidth = yAxis.GetScaleWidth(coordinateHeight, i, m_DataZoom);
|
||||||
@@ -899,9 +909,17 @@ namespace XCharts
|
|||||||
new Vector2(coordinateX, pY + scaleWidth),
|
new Vector2(coordinateX, pY + scaleWidth),
|
||||||
yAxis.splitArea.getColor(i));
|
yAxis.splitArea.getColor(i));
|
||||||
}
|
}
|
||||||
|
if (yAxis.showSplitLine)
|
||||||
|
{
|
||||||
|
if (!xAxis.axisLine.show || !xAxis.axisLine.onZero || zeroPos.y != pY)
|
||||||
|
{
|
||||||
|
DrawSplitLine(vh, yAxis, yAxis.splitLineType, new Vector3(coordinateX, pY),
|
||||||
|
new Vector3(coordinateX + coordinateWidth, pY), m_ThemeInfo.axisSplitLineColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (yAxis.axisTick.show)
|
if (yAxis.axisTick.show)
|
||||||
{
|
{
|
||||||
var startX = coordinateX + m_XAxises[yAxisIndex].zeroXOffset;
|
var startX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||||
if (yAxis.IsValue() && yAxisIndex > 0) startX += coordinateWidth;
|
if (yAxis.IsValue() && yAxisIndex > 0) startX += coordinateWidth;
|
||||||
bool inside = yAxis.axisTick.inside;
|
bool inside = yAxis.axisTick.inside;
|
||||||
if ((inside && yAxisIndex == 0) || (!inside && yAxisIndex == 1))
|
if ((inside && yAxisIndex == 0) || (!inside && yAxisIndex == 1))
|
||||||
@@ -915,14 +933,6 @@ namespace XCharts
|
|||||||
ChartDrawer.DrawLine(vh, new Vector3(startX, pY), new Vector3(pX, pY),
|
ChartDrawer.DrawLine(vh, new Vector3(startX, pY), new Vector3(pX, pY),
|
||||||
yAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
yAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||||
}
|
}
|
||||||
if (yAxis.showSplitLine)
|
|
||||||
{
|
|
||||||
if (!xAxis.axisLine.show || zeroPos.y != pY)
|
|
||||||
{
|
|
||||||
DrawSplitLine(vh, yAxis, yAxis.splitLineType, new Vector3(coordinateX, pY),
|
|
||||||
new Vector3(coordinateX + coordinateWidth, pY), m_ThemeInfo.axisSplitLineColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
totalWidth += scaleWidth;
|
totalWidth += scaleWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -930,12 +940,12 @@ namespace XCharts
|
|||||||
|
|
||||||
private void DrawXAxisTickAndSplit(VertexHelper vh, int xAxisIndex, XAxis xAxis)
|
private void DrawXAxisTickAndSplit(VertexHelper vh, int xAxisIndex, XAxis xAxis)
|
||||||
{
|
{
|
||||||
if (xAxis.show)
|
if (xAxis.NeedShowSplit())
|
||||||
{
|
{
|
||||||
var size = xAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
var size = xAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||||
var totalWidth = coordinateX;
|
var totalWidth = coordinateX;
|
||||||
var yAxis = m_YAxises[xAxisIndex];
|
var yAxis = m_YAxises[xAxisIndex];
|
||||||
var zeroPos = new Vector3(coordinateX, coordinateY + yAxis.zeroYOffset);
|
var zeroPos = new Vector3(coordinateX, coordinateY + yAxis.runtimeZeroYOffset);
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
var scaleWidth = xAxis.GetScaleWidth(coordinateWidth, i, m_DataZoom);
|
var scaleWidth = xAxis.GetScaleWidth(coordinateWidth, i, m_DataZoom);
|
||||||
@@ -953,9 +963,17 @@ namespace XCharts
|
|||||||
new Vector2(pX + scaleWidth, coordinateY),
|
new Vector2(pX + scaleWidth, coordinateY),
|
||||||
xAxis.splitArea.getColor(i));
|
xAxis.splitArea.getColor(i));
|
||||||
}
|
}
|
||||||
|
if (xAxis.showSplitLine)
|
||||||
|
{
|
||||||
|
if (!yAxis.axisLine.show || !yAxis.axisLine.onZero || zeroPos.x != pX)
|
||||||
|
{
|
||||||
|
DrawSplitLine(vh, xAxis, xAxis.splitLineType, new Vector3(pX, coordinateY),
|
||||||
|
new Vector3(pX, coordinateY + coordinateHeight), m_ThemeInfo.axisSplitLineColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (xAxis.axisTick.show)
|
if (xAxis.axisTick.show)
|
||||||
{
|
{
|
||||||
var startY = coordinateY + m_YAxises[xAxisIndex].zeroYOffset;
|
var startY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||||
if (xAxis.IsValue() && xAxisIndex > 0) startY += coordinateHeight;
|
if (xAxis.IsValue() && xAxisIndex > 0) startY += coordinateHeight;
|
||||||
bool inside = xAxis.axisTick.inside;
|
bool inside = xAxis.axisTick.inside;
|
||||||
if ((inside && xAxisIndex == 0) || (!inside && xAxisIndex == 1))
|
if ((inside && xAxisIndex == 0) || (!inside && xAxisIndex == 1))
|
||||||
@@ -969,14 +987,6 @@ namespace XCharts
|
|||||||
ChartDrawer.DrawLine(vh, new Vector3(pX, startY), new Vector3(pX, pY),
|
ChartDrawer.DrawLine(vh, new Vector3(pX, startY), new Vector3(pX, pY),
|
||||||
xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
|
||||||
}
|
}
|
||||||
if (xAxis.showSplitLine)
|
|
||||||
{
|
|
||||||
if (!yAxis.axisLine.show || zeroPos.x != pX)
|
|
||||||
{
|
|
||||||
DrawSplitLine(vh, xAxis, xAxis.splitLineType, new Vector3(pX, coordinateY),
|
|
||||||
new Vector3(pX, coordinateY + coordinateHeight), m_ThemeInfo.axisSplitLineColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
totalWidth += scaleWidth;
|
totalWidth += scaleWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -986,7 +996,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (xAxis.show && xAxis.axisLine.show)
|
if (xAxis.show && xAxis.axisLine.show)
|
||||||
{
|
{
|
||||||
var lineY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].zeroYOffset : 0);
|
var lineY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||||
if (xAxis.IsValue() && xAxisIndex > 0) lineY += coordinateHeight;
|
if (xAxis.IsValue() && xAxisIndex > 0) lineY += coordinateHeight;
|
||||||
var left = new Vector3(coordinateX - xAxis.axisLine.width, lineY);
|
var left = new Vector3(coordinateX - xAxis.axisLine.width, lineY);
|
||||||
var top = new Vector3(coordinateX + coordinateWidth + xAxis.axisLine.width, lineY);
|
var top = new Vector3(coordinateX + coordinateWidth + xAxis.axisLine.width, lineY);
|
||||||
@@ -1004,7 +1014,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (yAxis.show && yAxis.axisLine.show)
|
if (yAxis.show && yAxis.axisLine.show)
|
||||||
{
|
{
|
||||||
var lineX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].zeroXOffset : 0);
|
var lineX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||||
if (yAxis.IsValue() && yAxisIndex > 0) lineX += coordinateWidth;
|
if (yAxis.IsValue() && yAxisIndex > 0) lineX += coordinateWidth;
|
||||||
var top = new Vector3(lineX, coordinateY + coordinateHeight + yAxis.axisLine.width);
|
var top = new Vector3(lineX, coordinateY + coordinateHeight + yAxis.axisLine.width);
|
||||||
ChartDrawer.DrawLine(vh, new Vector3(lineX, coordinateY - yAxis.axisLine.width),
|
ChartDrawer.DrawLine(vh, new Vector3(lineX, coordinateY - yAxis.axisLine.width),
|
||||||
@@ -1039,10 +1049,10 @@ namespace XCharts
|
|||||||
float scaleWid = coordinateWidth / (showData.Count - 1);
|
float scaleWid = coordinateWidth / (showData.Count - 1);
|
||||||
Vector3 lp = Vector3.zero;
|
Vector3 lp = Vector3.zero;
|
||||||
Vector3 np = Vector3.zero;
|
Vector3 np = Vector3.zero;
|
||||||
int minValue = 0;
|
float minValue = 0;
|
||||||
int maxValue = 0;
|
float maxValue = 0;
|
||||||
m_Series.GetYMinMaxValue(null, 0, IsValue(), out minValue, out maxValue);
|
m_Series.GetYMinMaxValue(null, 0, IsValue(), out minValue, out maxValue);
|
||||||
axis.AdjustMinMaxValue(ref minValue, ref maxValue);
|
axis.AdjustMinMaxValue(ref minValue, ref maxValue, true);
|
||||||
|
|
||||||
int rate = 1;
|
int rate = 1;
|
||||||
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
|
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
|
||||||
@@ -1051,13 +1061,14 @@ namespace XCharts
|
|||||||
if (rate < 1) rate = 1;
|
if (rate < 1) rate = 1;
|
||||||
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
||||||
DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||||
|
var dataChanging = false;
|
||||||
for (int i = 0; i < maxCount; i += rate)
|
for (int i = 0; i < maxCount; i += rate)
|
||||||
{
|
{
|
||||||
float value = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i);
|
float value = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
||||||
|
serie.animation.GetUpdateAnimationDuration(), ref dataChanging);
|
||||||
float pX = coordinateX + i * scaleWid;
|
float pX = coordinateX + i * scaleWid;
|
||||||
float dataHig = (axis.maxValue - axis.minValue) == 0 ? 0 :
|
float dataHig = (axis.runtimeMaxValue - axis.runtimeMinValue) == 0 ? 0 :
|
||||||
(value - axis.minValue) / (axis.maxValue - axis.minValue) * hig;
|
(value - axis.runtimeMinValue) / (axis.runtimeMaxValue - axis.runtimeMinValue) * hig;
|
||||||
np = new Vector3(pX, m_DataZoom.bottom + dataHig);
|
np = new Vector3(pX, m_DataZoom.bottom + dataHig);
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
@@ -1072,6 +1083,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
lp = np;
|
lp = np;
|
||||||
}
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (m_DataZoom.rangeMode)
|
switch (m_DataZoom.rangeMode)
|
||||||
{
|
{
|
||||||
@@ -1116,35 +1131,35 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!m_Tooltip.show || !m_Tooltip.IsSelected()) return;
|
if (!m_Tooltip.show || !m_Tooltip.IsSelected()) return;
|
||||||
if (m_Tooltip.type == Tooltip.Type.None) return;
|
if (m_Tooltip.type == Tooltip.Type.None) return;
|
||||||
|
int dataCount = m_Series.list.Count > 0 ? m_Series.list[0].GetDataList(dataZoom).Count : 0;
|
||||||
for (int i = 0; i < m_XAxises.Count; i++)
|
for (int i = 0; i < m_XAxises.Count; i++)
|
||||||
{
|
{
|
||||||
var xAxis = m_XAxises[i];
|
var xAxis = m_XAxises[i];
|
||||||
var yAxis = m_YAxises[i];
|
var yAxis = m_YAxises[i];
|
||||||
if (!xAxis.show) continue;
|
if (!xAxis.show) continue;
|
||||||
float splitWidth = xAxis.GetDataWidth(coordinateWidth, m_DataZoom);
|
float splitWidth = xAxis.GetDataWidth(coordinateWidth, dataCount, m_DataZoom);
|
||||||
switch (m_Tooltip.type)
|
switch (m_Tooltip.type)
|
||||||
{
|
{
|
||||||
case Tooltip.Type.Corss:
|
case Tooltip.Type.Corss:
|
||||||
case Tooltip.Type.Line:
|
case Tooltip.Type.Line:
|
||||||
float pX = coordinateX + m_Tooltip.xValues[i] * splitWidth
|
float pX = coordinateX + m_Tooltip.runtimeXValues[i] * splitWidth
|
||||||
+ (xAxis.boundaryGap ? splitWidth / 2 : 0);
|
+ (xAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||||
if (xAxis.IsValue()) pX = m_Tooltip.pointerPos.x;
|
if (xAxis.IsValue()) pX = m_Tooltip.runtimePointerPos.x;
|
||||||
Vector2 sp = new Vector2(pX, coordinateY);
|
Vector2 sp = new Vector2(pX, coordinateY);
|
||||||
Vector2 ep = new Vector2(pX, coordinateY + coordinateHeight);
|
Vector2 ep = new Vector2(pX, coordinateY + coordinateHeight);
|
||||||
DrawSplitLine(vh, xAxis, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
DrawSplitLine(vh, xAxis, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||||
{
|
{
|
||||||
sp = new Vector2(coordinateX, m_Tooltip.pointerPos.y);
|
sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y);
|
||||||
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.pointerPos.y);
|
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||||
DrawSplitLine(vh, yAxis, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
DrawSplitLine(vh, yAxis, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Tooltip.Type.Shadow:
|
case Tooltip.Type.Shadow:
|
||||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||||
pX = coordinateX + splitWidth * m_Tooltip.xValues[i] -
|
pX = coordinateX + splitWidth * m_Tooltip.runtimeXValues[i] -
|
||||||
(xAxis.boundaryGap ? 0 : splitWidth / 2);
|
(xAxis.boundaryGap ? 0 : splitWidth / 2);
|
||||||
if (xAxis.IsValue()) pX = m_Tooltip.xValues[i];
|
if (xAxis.IsValue()) pX = m_Tooltip.runtimeXValues[i];
|
||||||
float pY = coordinateY + coordinateHeight;
|
float pY = coordinateY + coordinateHeight;
|
||||||
Vector3 p1 = new Vector3(pX, coordinateY);
|
Vector3 p1 = new Vector3(pX, coordinateY);
|
||||||
Vector3 p2 = new Vector3(pX, pY);
|
Vector3 p2 = new Vector3(pX, pY);
|
||||||
@@ -1160,33 +1175,33 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!m_Tooltip.show || !m_Tooltip.IsSelected()) return;
|
if (!m_Tooltip.show || !m_Tooltip.IsSelected()) return;
|
||||||
if (m_Tooltip.type == Tooltip.Type.None) return;
|
if (m_Tooltip.type == Tooltip.Type.None) return;
|
||||||
|
int dataCount = m_Series.list.Count > 0 ? m_Series.list[0].GetDataList(dataZoom).Count : 0;
|
||||||
for (int i = 0; i < m_YAxises.Count; i++)
|
for (int i = 0; i < m_YAxises.Count; i++)
|
||||||
{
|
{
|
||||||
var yAxis = m_YAxises[i];
|
var yAxis = m_YAxises[i];
|
||||||
var xAxis = m_XAxises[i];
|
var xAxis = m_XAxises[i];
|
||||||
if (!yAxis.show) continue;
|
if (!yAxis.show) continue;
|
||||||
float splitWidth = yAxis.GetDataWidth(coordinateHeight, m_DataZoom);
|
float splitWidth = yAxis.GetDataWidth(coordinateHeight, dataCount, m_DataZoom);
|
||||||
switch (m_Tooltip.type)
|
switch (m_Tooltip.type)
|
||||||
{
|
{
|
||||||
case Tooltip.Type.Corss:
|
case Tooltip.Type.Corss:
|
||||||
case Tooltip.Type.Line:
|
case Tooltip.Type.Line:
|
||||||
|
|
||||||
float pY = coordinateY + m_Tooltip.yValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0);
|
float pY = coordinateY + m_Tooltip.runtimeYValues[i] * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0);
|
||||||
Vector2 sp = new Vector2(coordinateX, pY);
|
Vector2 sp = new Vector2(coordinateX, pY);
|
||||||
Vector2 ep = new Vector2(coordinateX + coordinateWidth, pY);
|
Vector2 ep = new Vector2(coordinateX + coordinateWidth, pY);
|
||||||
DrawSplitLine(vh, xAxis, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
DrawSplitLine(vh, xAxis, Axis.SplitLineType.Solid, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||||
if (m_Tooltip.type == Tooltip.Type.Corss)
|
if (m_Tooltip.type == Tooltip.Type.Corss)
|
||||||
{
|
{
|
||||||
sp = new Vector2(coordinateX, m_Tooltip.pointerPos.y);
|
sp = new Vector2(coordinateX, m_Tooltip.runtimePointerPos.y);
|
||||||
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.pointerPos.y);
|
ep = new Vector2(coordinateX + coordinateWidth, m_Tooltip.runtimePointerPos.y);
|
||||||
DrawSplitLine(vh, yAxis, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
DrawSplitLine(vh, yAxis, Axis.SplitLineType.Dashed, sp, ep, m_ThemeInfo.tooltipLineColor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Tooltip.Type.Shadow:
|
case Tooltip.Type.Shadow:
|
||||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||||
float pX = coordinateX + coordinateWidth;
|
float pX = coordinateX + coordinateWidth;
|
||||||
pY = coordinateY + splitWidth * m_Tooltip.yValues[i] -
|
pY = coordinateY + splitWidth * m_Tooltip.runtimeYValues[i] -
|
||||||
(yAxis.boundaryGap ? 0 : splitWidth / 2);
|
(yAxis.boundaryGap ? 0 : splitWidth / 2);
|
||||||
Vector3 p1 = new Vector3(coordinateX, pY);
|
Vector3 p1 = new Vector3(coordinateX, pY);
|
||||||
Vector3 p2 = new Vector3(coordinateX, pY + tooltipSplitWid);
|
Vector3 p2 = new Vector3(coordinateX, pY + tooltipSplitWid);
|
||||||
@@ -1289,10 +1304,8 @@ namespace XCharts
|
|||||||
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
var start = coordinateX + coordinateWidth * m_DataZoom.start / 100;
|
||||||
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
var end = coordinateX + coordinateWidth * m_DataZoom.end / 100;
|
||||||
var hig = m_DataZoom.GetHeight(grid.bottom);
|
var hig = m_DataZoom.GetHeight(grid.bottom);
|
||||||
m_DataZoom.startLabel.transform.localPosition =
|
m_DataZoom.UpdateStartLabelPosition(new Vector3(start - 10, m_DataZoom.bottom + hig / 2));
|
||||||
new Vector3(start - 10, m_DataZoom.bottom + hig / 2);
|
m_DataZoom.UpdateEndLabelPosition(new Vector3(end + 10, m_DataZoom.bottom + hig / 2));
|
||||||
m_DataZoom.endLabel.transform.localPosition =
|
|
||||||
new Vector3(end + 10, m_DataZoom.bottom + hig / 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1313,19 +1326,19 @@ namespace XCharts
|
|||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
var xAxis = m_XAxises[serie.axisIndex];
|
var xAxis = m_XAxises[serie.axisIndex];
|
||||||
zeroPos = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY);
|
zeroPos = new Vector3(coordinateX + xAxis.runtimeZeroXOffset, coordinateY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var yAxis = m_YAxises[serie.axisIndex];
|
var yAxis = m_YAxises[serie.axisIndex];
|
||||||
zeroPos = new Vector3(coordinateX, coordinateY + yAxis.zeroYOffset);
|
zeroPos = new Vector3(coordinateX, coordinateY + yAxis.runtimeZeroYOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int j = 0; j < serie.data.Count; j++)
|
for (int j = 0; j < serie.data.Count; j++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
if (serie.label.show || serieData.showIcon)
|
if (serie.label.show || serieData.iconStyle.show)
|
||||||
{
|
{
|
||||||
var pos = serie.dataPoints[j];
|
var pos = serie.dataPoints[j];
|
||||||
var value = serieData.data[1];
|
var value = serieData.data[1];
|
||||||
@@ -1348,6 +1361,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
m_RefreshLabel = true;
|
||||||
serieData.labelPosition = pos;
|
serieData.labelPosition = pos;
|
||||||
if (serie.label.show) DrawLabelBackground(vh, serie, serieData);
|
if (serie.label.show) DrawLabelBackground(vh, serie, serieData);
|
||||||
}
|
}
|
||||||
@@ -1372,6 +1386,7 @@ namespace XCharts
|
|||||||
if (j >= serie.dataPoints.Count) break;
|
if (j >= serie.dataPoints.Count) break;
|
||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
var pos = serie.dataPoints[j];
|
var pos = serie.dataPoints[j];
|
||||||
|
|
||||||
serieData.SetGameObjectPosition(serieData.labelPosition);
|
serieData.SetGameObjectPosition(serieData.labelPosition);
|
||||||
serieData.UpdateIcon();
|
serieData.UpdateIcon();
|
||||||
if (serie.show && serie.label.show && serieData.canShowLabel)
|
if (serie.show && serie.label.show && serieData.canShowLabel)
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ namespace XCharts
|
|||||||
var yAxis = m_YAxises[serie.axisIndex];
|
var yAxis = m_YAxises[serie.axisIndex];
|
||||||
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
||||||
|
|
||||||
float categoryWidth = yAxis.GetDataWidth(coordinateHeight, m_DataZoom);
|
var showData = serie.GetDataList(m_DataZoom);
|
||||||
|
float categoryWidth = yAxis.GetDataWidth(coordinateHeight, showData.Count, m_DataZoom);
|
||||||
float barGap = GetBarGap();
|
float barGap = GetBarGap();
|
||||||
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
||||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||||
@@ -30,7 +31,7 @@ namespace XCharts
|
|||||||
float barGapWidth = barWidth + barWidth * barGap;
|
float barGapWidth = barWidth + barWidth * barGap;
|
||||||
float space = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
|
float space = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
|
||||||
|
|
||||||
var showData = serie.GetDataList(m_DataZoom);
|
|
||||||
int maxCount = serie.maxShow > 0 ?
|
int maxCount = serie.maxShow > 0 ?
|
||||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||||
: showData.Count;
|
: showData.Count;
|
||||||
@@ -42,14 +43,21 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var isPercentStack = m_Series.IsPercentStack(serie.stack, SerieType.Bar);
|
var isPercentStack = m_Series.IsPercentStack(serie.stack, SerieType.Bar);
|
||||||
|
bool dataChanging = false;
|
||||||
|
float updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
|
float xMinValue = xAxis.GetCurrMinValue(updateDuration);
|
||||||
|
float xMaxValue = xAxis.GetCurrMaxValue(updateDuration);
|
||||||
for (int i = serie.minShow; i < maxCount; i++)
|
for (int i = serie.minShow; i < maxCount; i++)
|
||||||
{
|
{
|
||||||
if (i >= seriesHig.Count)
|
if (i >= seriesHig.Count)
|
||||||
{
|
{
|
||||||
seriesHig.Add(0);
|
seriesHig.Add(0);
|
||||||
}
|
}
|
||||||
float value = showData[i].data[1];
|
var serieData = showData[i];
|
||||||
float pX = seriesHig[i] + coordinateX + xAxis.zeroXOffset + yAxis.axisLine.width;
|
serieData.canShowLabel = true;
|
||||||
|
float value = showData[i].GetCurrData(1, updateDuration);
|
||||||
|
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||||
|
float pX = seriesHig[i] + coordinateX + xAxis.runtimeZeroXOffset + yAxis.axisLine.width;
|
||||||
float pY = coordinateY + +i * categoryWidth;
|
float pY = coordinateY + +i * categoryWidth;
|
||||||
if (!yAxis.boundaryGap) pY -= categoryWidth / 2;
|
if (!yAxis.boundaryGap) pY -= categoryWidth / 2;
|
||||||
|
|
||||||
@@ -58,14 +66,15 @@ namespace XCharts
|
|||||||
if (isPercentStack)
|
if (isPercentStack)
|
||||||
{
|
{
|
||||||
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
||||||
barHig = value / valueTotal * coordinateWidth;
|
barHig = valueTotal != 0 ? (value / valueTotal * coordinateWidth) : 0;
|
||||||
seriesHig[i] += barHig;
|
seriesHig[i] += barHig;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valueTotal = xAxis.maxValue - xAxis.minValue;
|
valueTotal = xMaxValue - xMinValue;
|
||||||
barHig = (xAxis.minValue > 0 ? value - xAxis.minValue : value)
|
if (valueTotal != 0)
|
||||||
/ valueTotal * coordinateWidth;
|
barHig = (xMinValue > 0 ? value - xMinValue : value)
|
||||||
|
/ valueTotal * coordinateWidth;
|
||||||
seriesHig[i] += barHig;
|
seriesHig[i] += barHig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +108,10 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_BarLastOffset += barGapWidth;
|
m_BarLastOffset += barGapWidth;
|
||||||
}
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float CheckAnimation(Serie serie, int dataIndex, float barHig)
|
private float CheckAnimation(Serie serie, int dataIndex, float barHig)
|
||||||
@@ -119,6 +132,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
|
m_IsPlayingStartAnimation = true;
|
||||||
}
|
}
|
||||||
return currHig;
|
return currHig;
|
||||||
}
|
}
|
||||||
@@ -131,7 +145,7 @@ namespace XCharts
|
|||||||
var xAxis = m_XAxises[serie.axisIndex];
|
var xAxis = m_XAxises[serie.axisIndex];
|
||||||
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
||||||
|
|
||||||
float categoryWidth = xAxis.GetDataWidth(coordinateWidth, m_DataZoom);
|
float categoryWidth = xAxis.GetDataWidth(coordinateWidth, showData.Count, m_DataZoom);
|
||||||
float barGap = GetBarGap();
|
float barGap = GetBarGap();
|
||||||
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
||||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||||
@@ -151,15 +165,20 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isPercentStack = m_Series.IsPercentStack(serie.stack, SerieType.Bar);
|
var isPercentStack = m_Series.IsPercentStack(serie.stack, SerieType.Bar);
|
||||||
|
bool dataChanging = false;
|
||||||
|
float updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
|
float yMinValue = yAxis.GetCurrMinValue(updateDuration);
|
||||||
|
float yMaxValue = yAxis.GetCurrMaxValue(updateDuration);
|
||||||
for (int i = serie.minShow; i < maxCount; i++)
|
for (int i = serie.minShow; i < maxCount; i++)
|
||||||
{
|
{
|
||||||
if (i >= seriesHig.Count)
|
if (i >= seriesHig.Count)
|
||||||
{
|
{
|
||||||
seriesHig.Add(0);
|
seriesHig.Add(0);
|
||||||
}
|
}
|
||||||
float value = showData[i].data[1];
|
float value = showData[i].GetCurrData(1, updateDuration);
|
||||||
|
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||||
float pX = coordinateX + i * categoryWidth;
|
float pX = coordinateX + i * categoryWidth;
|
||||||
float zeroY = coordinateY + yAxis.zeroYOffset;
|
float zeroY = coordinateY + yAxis.runtimeZeroYOffset;
|
||||||
if (!xAxis.boundaryGap) pX -= categoryWidth / 2;
|
if (!xAxis.boundaryGap) pX -= categoryWidth / 2;
|
||||||
float pY = seriesHig[i] + zeroY + xAxis.axisLine.width;
|
float pY = seriesHig[i] + zeroY + xAxis.axisLine.width;
|
||||||
|
|
||||||
@@ -168,14 +187,15 @@ namespace XCharts
|
|||||||
if (isPercentStack)
|
if (isPercentStack)
|
||||||
{
|
{
|
||||||
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
||||||
barHig = value / valueTotal * coordinateHeight;
|
barHig = valueTotal != 0 ? (value / valueTotal * coordinateHeight) : 0;
|
||||||
seriesHig[i] += barHig;
|
seriesHig[i] += barHig;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valueTotal = yAxis.maxValue - yAxis.minValue;
|
valueTotal = yMaxValue - yMinValue;
|
||||||
barHig = (yAxis.minValue > 0 ? value - yAxis.minValue : value)
|
if (valueTotal != 0)
|
||||||
/ valueTotal * coordinateHeight;
|
barHig = (yMinValue > 0 ? value - yMinValue : value)
|
||||||
|
/ valueTotal * coordinateHeight;
|
||||||
seriesHig[i] += barHig;
|
seriesHig[i] += barHig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +226,10 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
if (!m_Series.IsStack(serie.stack, SerieType.Bar))
|
if (!m_Series.IsStack(serie.stack, SerieType.Bar))
|
||||||
{
|
{
|
||||||
m_BarLastOffset += barGapWidth;
|
m_BarLastOffset += barGapWidth;
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ namespace XCharts
|
|||||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
|
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
|
||||||
Input.mousePosition, canvas.worldCamera, out local))
|
Input.mousePosition, canvas.worldCamera, out local))
|
||||||
{
|
{
|
||||||
if (m_VisualMap.rtSelectedIndex >= 0)
|
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
||||||
{
|
{
|
||||||
m_VisualMap.rtSelectedIndex = -1;
|
m_VisualMap.runtimeSelectedIndex = -1;
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -35,9 +35,9 @@ namespace XCharts
|
|||||||
local.y < 0 || local.y > chartHeight ||
|
local.y < 0 || local.y > chartHeight ||
|
||||||
!m_VisualMap.IsInRangeRect(local, chartWidth, chartHeight))
|
!m_VisualMap.IsInRangeRect(local, chartWidth, chartHeight))
|
||||||
{
|
{
|
||||||
if (m_VisualMap.rtSelectedIndex >= 0)
|
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
||||||
{
|
{
|
||||||
m_VisualMap.rtSelectedIndex = -1;
|
m_VisualMap.runtimeSelectedIndex = -1;
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -63,8 +63,8 @@ namespace XCharts
|
|||||||
selectedIndex = m_VisualMap.GetIndex(value);
|
selectedIndex = m_VisualMap.GetIndex(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_VisualMap.rtSelectedValue = value;
|
m_VisualMap.runtimeSelectedValue = value;
|
||||||
m_VisualMap.rtSelectedIndex = selectedIndex;
|
m_VisualMap.runtimeSelectedIndex = selectedIndex;
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +135,8 @@ namespace XCharts
|
|||||||
serie.dataPoints.Clear();
|
serie.dataPoints.Clear();
|
||||||
serie.animation.InitProgress(1, 0, xCount);
|
serie.animation.InitProgress(1, 0, xCount);
|
||||||
var animationIndex = serie.animation.GetCurrIndex();
|
var animationIndex = serie.animation.GetCurrIndex();
|
||||||
|
var updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
|
var dataChanging = false;
|
||||||
for (int i = 0; i < xCount; i++)
|
for (int i = 0; i < xCount; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < yCount; j++)
|
for (int j = 0; j < yCount; j++)
|
||||||
@@ -144,7 +146,8 @@ namespace XCharts
|
|||||||
var serieData = dataList[dataIndex];
|
var serieData = dataList[dataIndex];
|
||||||
var dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 :
|
var dimension = m_VisualMap.enable && m_VisualMap.dimension > 0 ? m_VisualMap.dimension - 1 :
|
||||||
serieData.data.Count - 1;
|
serieData.data.Count - 1;
|
||||||
var value = serieData.data[dimension];
|
var value = serieData.GetCurrData(dimension, updateDuration);
|
||||||
|
if (serieData.IsDataChanged()) dataChanging = true;
|
||||||
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth, zeroY + (j + 0.5f) * yWidth);
|
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth, zeroY + (j + 0.5f) * yWidth);
|
||||||
serie.dataPoints.Add(pos);
|
serie.dataPoints.Add(pos);
|
||||||
serieData.canShowLabel = false;
|
serieData.canShowLabel = false;
|
||||||
@@ -159,10 +162,10 @@ namespace XCharts
|
|||||||
if (!m_VisualMap.IsInSelectedValue(value)) continue;
|
if (!m_VisualMap.IsInSelectedValue(value)) continue;
|
||||||
color = m_VisualMap.GetColor(value);
|
color = m_VisualMap.GetColor(value);
|
||||||
}
|
}
|
||||||
if(animationIndex>= 0 && i> animationIndex) continue;
|
if (animationIndex >= 0 && i > animationIndex) continue;
|
||||||
serieData.canShowLabel = true;
|
serieData.canShowLabel = true;
|
||||||
var emphasis = (m_Tooltip.show && i == (int)m_Tooltip.xValues[0] && j == (int)m_Tooltip.yValues[0])
|
var emphasis = (m_Tooltip.show && i == (int)m_Tooltip.runtimeXValues[0] && j == (int)m_Tooltip.runtimeYValues[0])
|
||||||
|| m_VisualMap.rtSelectedIndex > 0;
|
|| m_VisualMap.runtimeSelectedIndex > 0;
|
||||||
var rectWid = xWidth - 2 * borderWidth;
|
var rectWid = xWidth - 2 * borderWidth;
|
||||||
var rectHig = yWidth - 2 * borderWidth;
|
var rectHig = yWidth - 2 * borderWidth;
|
||||||
ChartDrawer.DrawPolygon(vh, pos, rectWid / 2, rectHig / 2, color);
|
ChartDrawer.DrawPolygon(vh, pos, rectWid / 2, rectHig / 2, color);
|
||||||
@@ -183,6 +186,11 @@ namespace XCharts
|
|||||||
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
||||||
float speed = xCount / duration;
|
float speed = xCount / duration;
|
||||||
serie.animation.CheckProgress(Time.deltaTime * speed);
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
|
m_IsPlayingStartAnimation = true;
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,10 +207,10 @@ namespace XCharts
|
|||||||
var halfHig = m_VisualMap.itemHeight / 2;
|
var halfHig = m_VisualMap.itemHeight / 2;
|
||||||
var xRadius = 0f;
|
var xRadius = 0f;
|
||||||
var yRadius = 0f;
|
var yRadius = 0f;
|
||||||
var splitNum = m_VisualMap.rtInRange.Count;
|
var splitNum = m_VisualMap.runtimeInRange.Count;
|
||||||
var splitWid = m_VisualMap.itemHeight / (splitNum - 1);
|
var splitWid = m_VisualMap.itemHeight / (splitNum - 1);
|
||||||
var isVertical = false;
|
var isVertical = false;
|
||||||
var colors = m_VisualMap.rtInRange;
|
var colors = m_VisualMap.runtimeInRange;
|
||||||
var triangeLen = m_Settings.visualMapTriangeLen;
|
var triangeLen = m_Settings.visualMapTriangeLen;
|
||||||
switch (m_VisualMap.orient)
|
switch (m_VisualMap.orient)
|
||||||
{
|
{
|
||||||
@@ -215,13 +223,13 @@ namespace XCharts
|
|||||||
isVertical = false;
|
isVertical = false;
|
||||||
if (m_VisualMap.calculable)
|
if (m_VisualMap.calculable)
|
||||||
{
|
{
|
||||||
var p0 = pos1 + Vector3.right * m_VisualMap.rangeMinHeight;
|
var p0 = pos1 + Vector3.right * m_VisualMap.runtimeRangeMinHeight;
|
||||||
var p1 = p0 + Vector3.up * halfWid;
|
var p1 = p0 + Vector3.up * halfWid;
|
||||||
var p2 = p0 + Vector3.up * (halfWid + triangeLen);
|
var p2 = p0 + Vector3.up * (halfWid + triangeLen);
|
||||||
var p3 = p2 + Vector3.left * triangeLen;
|
var p3 = p2 + Vector3.left * triangeLen;
|
||||||
var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||||
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
||||||
p0 = pos1 + Vector3.right * m_VisualMap.rangeMaxHeight;
|
p0 = pos1 + Vector3.right * m_VisualMap.runtimeRangeMaxHeight;
|
||||||
p1 = p0 + Vector3.up * halfWid;
|
p1 = p0 + Vector3.up * halfWid;
|
||||||
p2 = p0 + Vector3.up * (halfWid + triangeLen);
|
p2 = p0 + Vector3.up * (halfWid + triangeLen);
|
||||||
p3 = p2 + Vector3.right * triangeLen;
|
p3 = p2 + Vector3.right * triangeLen;
|
||||||
@@ -238,13 +246,13 @@ namespace XCharts
|
|||||||
isVertical = true;
|
isVertical = true;
|
||||||
if (m_VisualMap.calculable)
|
if (m_VisualMap.calculable)
|
||||||
{
|
{
|
||||||
var p0 = pos1 + Vector3.up * m_VisualMap.rangeMinHeight;
|
var p0 = pos1 + Vector3.up * m_VisualMap.runtimeRangeMinHeight;
|
||||||
var p1 = p0 + Vector3.right * halfWid;
|
var p1 = p0 + Vector3.right * halfWid;
|
||||||
var p2 = p0 + Vector3.right * (halfWid + triangeLen);
|
var p2 = p0 + Vector3.right * (halfWid + triangeLen);
|
||||||
var p3 = p2 + Vector3.down * triangeLen;
|
var p3 = p2 + Vector3.down * triangeLen;
|
||||||
var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||||
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
||||||
p0 = pos1 + Vector3.up * m_VisualMap.rangeMaxHeight;
|
p0 = pos1 + Vector3.up * m_VisualMap.runtimeRangeMaxHeight;
|
||||||
p1 = p0 + Vector3.right * halfWid;
|
p1 = p0 + Vector3.right * halfWid;
|
||||||
p2 = p0 + Vector3.right * (halfWid + triangeLen);
|
p2 = p0 + Vector3.right * (halfWid + triangeLen);
|
||||||
p3 = p2 + Vector3.up * triangeLen;
|
p3 = p2 + Vector3.up * triangeLen;
|
||||||
@@ -276,7 +284,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else if (rangeMin > splitMin && rangeMax >= splitMax)
|
else if (rangeMin > splitMin && rangeMax >= splitMax)
|
||||||
{
|
{
|
||||||
var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
|
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||||
var splitMaxPos = pos1 + dir * i * splitWid;
|
var splitMaxPos = pos1 + dir * i * splitWid;
|
||||||
var splitPos = p0 + (splitMaxPos - p0) / 2;
|
var splitPos = p0 + (splitMaxPos - p0) / 2;
|
||||||
var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||||
@@ -289,7 +297,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else if (rangeMax < splitMax && rangeMin <= splitMin)
|
else if (rangeMax < splitMax && rangeMin <= splitMin)
|
||||||
{
|
{
|
||||||
var p0 = pos1 + dir * m_VisualMap.rangeMaxHeight;
|
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||||
var splitMinPos = pos1 + dir * (i - 1) * splitWid;
|
var splitMinPos = pos1 + dir * (i - 1) * splitWid;
|
||||||
var splitPos = splitMinPos + (p0 - splitMinPos) / 2;
|
var splitPos = splitMinPos + (p0 - splitMinPos) / 2;
|
||||||
var startColor = colors[i - 1];
|
var startColor = colors[i - 1];
|
||||||
@@ -302,8 +310,8 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
|
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||||
var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
|
var p1 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||||
var splitPos = (p0 + p1) / 2;
|
var splitPos = (p0 + p1) / 2;
|
||||||
var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||||
var toColor = m_VisualMap.GetColor(m_VisualMap.rangeMax);
|
var toColor = m_VisualMap.GetColor(m_VisualMap.rangeMax);
|
||||||
@@ -328,38 +336,38 @@ namespace XCharts
|
|||||||
|
|
||||||
if (m_VisualMap.rangeMin > m_VisualMap.min)
|
if (m_VisualMap.rangeMin > m_VisualMap.min)
|
||||||
{
|
{
|
||||||
var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
|
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||||
ChartDrawer.DrawPolygon(vh, pos1, p0, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
|
ChartDrawer.DrawPolygon(vh, pos1, p0, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
|
||||||
}
|
}
|
||||||
if (m_VisualMap.rangeMax < m_VisualMap.max)
|
if (m_VisualMap.rangeMax < m_VisualMap.max)
|
||||||
{
|
{
|
||||||
var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
|
var p1 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||||
ChartDrawer.DrawPolygon(vh, p1, pos2, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
|
ChartDrawer.DrawPolygon(vh, p1, pos2, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_VisualMap.hoverLink)
|
if (m_VisualMap.hoverLink)
|
||||||
{
|
{
|
||||||
if (m_VisualMap.rtSelectedIndex >= 0)
|
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
||||||
{
|
{
|
||||||
var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
|
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||||
var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
|
var p1 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||||
|
|
||||||
if (m_VisualMap.orient == Orient.Vertical)
|
if (m_VisualMap.orient == Orient.Vertical)
|
||||||
{
|
{
|
||||||
var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
|
var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
|
||||||
var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
|
var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
|
||||||
var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
|
var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
|
||||||
ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
|
ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.runtimeSelectedIndex]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
||||||
var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
||||||
var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
|
var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
|
||||||
ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
|
ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.runtimeSelectedIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_Tooltip.show && m_Tooltip.xValues[0] >= 0 && m_Tooltip.yValues[0] >= 0)
|
else if (m_Tooltip.show && m_Tooltip.runtimeXValues[0] >= 0 && m_Tooltip.runtimeYValues[0] >= 0)
|
||||||
{
|
{
|
||||||
// var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
|
// var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
|
||||||
// var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
|
// var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
|
||||||
|
|||||||
@@ -88,10 +88,10 @@ namespace XCharts
|
|||||||
Vector3 lp = Vector3.zero, np = Vector3.zero, llp = Vector3.zero, nnp = Vector3.zero;
|
Vector3 lp = Vector3.zero, np = Vector3.zero, llp = Vector3.zero, nnp = Vector3.zero;
|
||||||
var yAxis = m_YAxises[serie.axisIndex];
|
var yAxis = m_YAxises[serie.axisIndex];
|
||||||
var xAxis = m_XAxises[serie.axisIndex];
|
var xAxis = m_XAxises[serie.axisIndex];
|
||||||
var zeroPos = new Vector3(coordinateX, coordinateY + yAxis.zeroYOffset);
|
var zeroPos = new Vector3(coordinateX, coordinateY + yAxis.runtimeZeroYOffset);
|
||||||
var isStack = m_Series.IsStack(serie.stack, SerieType.Line);
|
var isStack = m_Series.IsStack(serie.stack, SerieType.Line);
|
||||||
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
||||||
float scaleWid = xAxis.GetDataWidth(coordinateWidth, m_DataZoom);
|
float scaleWid = xAxis.GetDataWidth(coordinateWidth, showData.Count, m_DataZoom);
|
||||||
float startX = coordinateX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
|
float startX = coordinateX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||||
int maxCount = serie.maxShow > 0 ?
|
int maxCount = serie.maxShow > 0 ?
|
||||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||||
@@ -111,6 +111,8 @@ namespace XCharts
|
|||||||
var includeLastData = false;
|
var includeLastData = false;
|
||||||
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
||||||
DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||||
|
var dataChanging = false;
|
||||||
|
var updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
for (i = serie.minShow; i < maxCount; i += rate)
|
for (i = serie.minShow; i < maxCount; i += rate)
|
||||||
{
|
{
|
||||||
if (i == maxCount - 1) includeLastData = true;
|
if (i == maxCount - 1) includeLastData = true;
|
||||||
@@ -118,16 +120,23 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
for (int j = 0; j < rate; j++) seriesHig.Add(0);
|
for (int j = 0; j < rate; j++) seriesHig.Add(0);
|
||||||
}
|
}
|
||||||
float yValue = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i);
|
float yValue = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage,
|
||||||
seriesHig[i] += GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, seriesHig[i], ref np);
|
i, updateDuration, ref dataChanging);
|
||||||
|
seriesHig[i] += GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, seriesHig[i], ref np,
|
||||||
|
updateDuration);
|
||||||
serie.dataPoints.Add(np);
|
serie.dataPoints.Add(np);
|
||||||
}
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
if (!includeLastData)
|
if (!includeLastData)
|
||||||
{
|
{
|
||||||
i = maxCount - 1;
|
i = maxCount - 1;
|
||||||
seriesHig.Add(0);
|
seriesHig.Add(0);
|
||||||
float yValue = showData[i].data[1];
|
float yValue = showData[i].GetCurrData(1, updateDuration);
|
||||||
seriesHig[i] += GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, seriesHig[i], ref np);
|
seriesHig[i] += GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, seriesHig[i], ref np,
|
||||||
|
updateDuration);
|
||||||
serie.dataPoints.Add(np);
|
serie.dataPoints.Add(np);
|
||||||
}
|
}
|
||||||
if (serie.dataPoints.Count <= 0)
|
if (serie.dataPoints.Count <= 0)
|
||||||
@@ -144,8 +153,8 @@ namespace XCharts
|
|||||||
if (serie.minShow > 0 && serie.minShow < showData.Count)
|
if (serie.minShow > 0 && serie.minShow < showData.Count)
|
||||||
{
|
{
|
||||||
i = serie.minShow - 1;
|
i = serie.minShow - 1;
|
||||||
float yValue = showData[i].data[1];
|
float yValue = showData[i].GetCurrData(1, updateDuration);
|
||||||
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref firstLastPos);
|
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref firstLastPos, updateDuration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -154,21 +163,20 @@ namespace XCharts
|
|||||||
if (serie.maxShow > 0 && serie.maxShow < showData.Count)
|
if (serie.maxShow > 0 && serie.maxShow < showData.Count)
|
||||||
{
|
{
|
||||||
i = serie.maxShow;
|
i = serie.maxShow;
|
||||||
float yValue = showData[i].data[1];
|
float yValue = showData[i].GetCurrData(1, updateDuration);
|
||||||
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref lastNextPos);
|
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref lastNextPos, updateDuration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lastNextPos = serie.dataPoints[serie.dataPoints.Count - 1];
|
lastNextPos = serie.dataPoints[serie.dataPoints.Count - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < serie.dataPoints.Count; i++)
|
for (i = 1; i < serie.dataPoints.Count; i++)
|
||||||
{
|
{
|
||||||
np = serie.dataPoints[i];
|
np = serie.dataPoints[i];
|
||||||
serie.ClearSmoothList(i);
|
serie.ClearSmoothList(i);
|
||||||
if (!serie.animation.NeedAnimation(i)) break;
|
if (!serie.animation.NeedAnimation(i)) break;
|
||||||
bool isFinish = true;
|
bool isFinish = true;
|
||||||
if (serie.areaStyle.tooltipHighlight && m_Tooltip.show && i <= m_Tooltip.dataIndex[0])
|
if (serie.areaStyle.tooltipHighlight && m_Tooltip.show && i <= m_Tooltip.runtimeDataIndex[0])
|
||||||
{
|
{
|
||||||
areaColor = highlightAreaColor;
|
areaColor = highlightAreaColor;
|
||||||
areaToColor = highlightAreaToColor;
|
areaToColor = highlightAreaToColor;
|
||||||
@@ -216,6 +224,7 @@ namespace XCharts
|
|||||||
float symbolSpeed = serie.symbol.size / duration;
|
float symbolSpeed = serie.symbol.size / duration;
|
||||||
serie.animation.CheckProgress(Time.deltaTime * speed);
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
serie.animation.CheckSymbol(Time.deltaTime * symbolSpeed, serie.symbol.size);
|
serie.animation.CheckSymbol(Time.deltaTime * symbolSpeed, serie.symbol.size);
|
||||||
|
m_IsPlayingStartAnimation = true;
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,9 +245,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
private float SampleValue(ref List<SerieData> showData, SampleType sampleType, int rate,
|
private float SampleValue(ref List<SerieData> showData, SampleType sampleType, int rate,
|
||||||
int minCount, int maxCount, float totalAverage, int index)
|
int minCount, int maxCount, float totalAverage, int index, float updateDuration, ref bool dataChanging)
|
||||||
{
|
{
|
||||||
if (rate <= 1 || index == minCount) return showData[index].data[1];
|
if (rate <= 1 || index == minCount)
|
||||||
|
{
|
||||||
|
if (showData[index].IsDataChanged()) dataChanging = true;
|
||||||
|
return showData[index].GetCurrData(1, updateDuration);
|
||||||
|
}
|
||||||
switch (sampleType)
|
switch (sampleType)
|
||||||
{
|
{
|
||||||
case SampleType.Sum:
|
case SampleType.Sum:
|
||||||
@@ -246,7 +259,8 @@ namespace XCharts
|
|||||||
float total = 0;
|
float total = 0;
|
||||||
for (int i = index; i > index - rate; i--)
|
for (int i = index; i > index - rate; i--)
|
||||||
{
|
{
|
||||||
total += showData[i].data[1];
|
total += showData[i].GetCurrData(1, updateDuration);
|
||||||
|
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||||
}
|
}
|
||||||
if (sampleType == SampleType.Average) return total / rate;
|
if (sampleType == SampleType.Average) return total / rate;
|
||||||
else return total;
|
else return total;
|
||||||
@@ -254,16 +268,18 @@ namespace XCharts
|
|||||||
float max = float.MinValue;
|
float max = float.MinValue;
|
||||||
for (int i = index; i > index - rate; i--)
|
for (int i = index; i > index - rate; i--)
|
||||||
{
|
{
|
||||||
var value = showData[i].data[1];
|
var value = showData[i].GetCurrData(1, updateDuration);
|
||||||
if (value > max) max = value;
|
if (value > max) max = value;
|
||||||
|
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
case SampleType.Min:
|
case SampleType.Min:
|
||||||
float min = float.MaxValue;
|
float min = float.MaxValue;
|
||||||
for (int i = index; i > index - rate; i--)
|
for (int i = index; i > index - rate; i--)
|
||||||
{
|
{
|
||||||
var value = showData[i].data[1];
|
var value = showData[i].GetCurrData(1, updateDuration);
|
||||||
if (value < min) min = value;
|
if (value < min) min = value;
|
||||||
|
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||||
}
|
}
|
||||||
return min;
|
return min;
|
||||||
case SampleType.Peak:
|
case SampleType.Peak:
|
||||||
@@ -272,41 +288,74 @@ namespace XCharts
|
|||||||
total = 0;
|
total = 0;
|
||||||
for (int i = index; i > index - rate; i--)
|
for (int i = index; i > index - rate; i--)
|
||||||
{
|
{
|
||||||
var value = showData[i].data[1];
|
var value = showData[i].GetCurrData(1, updateDuration);
|
||||||
total += value;
|
total += value;
|
||||||
if (value < min) min = value;
|
if (value < min) min = value;
|
||||||
if (value > max) max = value;
|
if (value > max) max = value;
|
||||||
|
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||||
}
|
}
|
||||||
var average = total / rate;
|
var average = total / rate;
|
||||||
if (average >= totalAverage) return max;
|
if (average >= totalAverage) return max;
|
||||||
else return min;
|
else return min;
|
||||||
|
|
||||||
}
|
}
|
||||||
return showData[index].data[1];
|
if (showData[index].IsDataChanged()) dataChanging = true;
|
||||||
|
return showData[index].GetCurrData(1, updateDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetDataPoint(Axis xAxis, Axis yAxis, List<SerieData> showData, float yValue, float startX, int i,
|
private float GetDataPoint(Axis xAxis, Axis yAxis, List<SerieData> showData, float yValue, float startX, int i,
|
||||||
float scaleWid, float serieHig, ref Vector3 np)
|
float scaleWid, float serieHig, ref Vector3 np, float duration)
|
||||||
{
|
{
|
||||||
float xDataHig, yDataHig;
|
float xDataHig, yDataHig;
|
||||||
if (xAxis.IsValue())
|
float xMinValue = xAxis.GetCurrMinValue(duration);
|
||||||
|
float xMaxValue = xAxis.GetCurrMaxValue(duration);
|
||||||
|
float yMinValue = yAxis.GetCurrMinValue(duration);
|
||||||
|
float yMaxValue = yAxis.GetCurrMaxValue(duration);
|
||||||
|
if (xAxis.IsValue() || xAxis.IsLog())
|
||||||
{
|
{
|
||||||
float xValue = i > showData.Count - 1 ? 0 : showData[i].data[0];
|
float xValue = i > showData.Count - 1 ? 0 : showData[i].data[0];
|
||||||
float pX = coordinateX + xAxis.axisLine.width;
|
float pX = coordinateX + xAxis.axisLine.width;
|
||||||
float pY = serieHig + coordinateY + xAxis.axisLine.width;
|
float pY = serieHig + coordinateY + xAxis.axisLine.width;
|
||||||
if ((xAxis.maxValue - xAxis.minValue) <= 0) xDataHig = 0;
|
if (xAxis.IsLog())
|
||||||
else xDataHig = (xValue - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWidth;
|
{
|
||||||
if ((yAxis.maxValue - yAxis.minValue) <= 0) yDataHig = 0;
|
int minIndex = xAxis.runtimeMinLogIndex;
|
||||||
else yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHeight;
|
float nowIndex = xAxis.GetLogValue(xValue);
|
||||||
|
xDataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * coordinateWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((xMaxValue - xMinValue) <= 0) xDataHig = 0;
|
||||||
|
else xDataHig = (xValue - xMinValue) / (xMaxValue - xMinValue) * coordinateWidth;
|
||||||
|
}
|
||||||
|
if (yAxis.IsLog())
|
||||||
|
{
|
||||||
|
int minIndex = yAxis.runtimeMinLogIndex;
|
||||||
|
float nowIndex = yAxis.GetLogValue(yValue);
|
||||||
|
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * coordinateHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
||||||
|
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * coordinateHeight;
|
||||||
|
}
|
||||||
np = new Vector3(pX + xDataHig, pY + yDataHig);
|
np = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float pX = startX + i * scaleWid;
|
float pX = startX + i * scaleWid;
|
||||||
float pY = serieHig + coordinateY + yAxis.axisLine.width;
|
float pY = serieHig + coordinateY + yAxis.axisLine.width;
|
||||||
if ((yAxis.maxValue - yAxis.minValue) <= 0) yDataHig = 0;
|
if (yAxis.IsLog())
|
||||||
else yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHeight;
|
{
|
||||||
|
int minIndex = yAxis.runtimeMinLogIndex;
|
||||||
|
float nowIndex = yAxis.GetLogValue(yValue);
|
||||||
|
yDataHig = (nowIndex - minIndex) / (yAxis.splitNumber - 1) * coordinateHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
||||||
|
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * coordinateHeight;
|
||||||
|
}
|
||||||
np = new Vector3(pX, pY + yDataHig);
|
np = new Vector3(pX, pY + yDataHig);
|
||||||
|
|
||||||
}
|
}
|
||||||
return yDataHig;
|
return yDataHig;
|
||||||
}
|
}
|
||||||
@@ -327,10 +376,10 @@ namespace XCharts
|
|||||||
Color areaColor, areaToColor;
|
Color areaColor, areaToColor;
|
||||||
var xAxis = m_XAxises[serie.axisIndex];
|
var xAxis = m_XAxises[serie.axisIndex];
|
||||||
var yAxis = m_YAxises[serie.axisIndex];
|
var yAxis = m_YAxises[serie.axisIndex];
|
||||||
var zeroPos = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY);
|
var zeroPos = new Vector3(coordinateX + xAxis.runtimeZeroXOffset, coordinateY);
|
||||||
var isStack = m_Series.IsStack(serie.stack, SerieType.Line);
|
var isStack = m_Series.IsStack(serie.stack, SerieType.Line);
|
||||||
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
||||||
float scaleWid = yAxis.GetDataWidth(coordinateHeight, m_DataZoom);
|
float scaleWid = yAxis.GetDataWidth(coordinateHeight, showData.Count, m_DataZoom);
|
||||||
float startY = coordinateY + (yAxis.boundaryGap ? scaleWid / 2 : 0);
|
float startY = coordinateY + (yAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||||
int maxCount = serie.maxShow > 0 ?
|
int maxCount = serie.maxShow > 0 ?
|
||||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||||
@@ -347,28 +396,57 @@ namespace XCharts
|
|||||||
var sampleDist = serie.sampleDist;
|
var sampleDist = serie.sampleDist;
|
||||||
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (coordinateWidth / sampleDist));
|
if (sampleDist > 0) rate = (int)((maxCount - serie.minShow) / (coordinateWidth / sampleDist));
|
||||||
if (rate < 1) rate = 1;
|
if (rate < 1) rate = 1;
|
||||||
|
var dataChanging = false;
|
||||||
|
float updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
|
float xMinValue = xAxis.GetCurrMinValue(updateDuration);
|
||||||
|
float xMaxValue = xAxis.GetCurrMaxValue(updateDuration);
|
||||||
for (i = serie.minShow; i < maxCount; i += rate)
|
for (i = serie.minShow; i < maxCount; i += rate)
|
||||||
{
|
{
|
||||||
if (i >= seriesHig.Count)
|
if (i >= seriesHig.Count)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < rate; j++) seriesHig.Add(0);
|
for (int j = 0; j < rate; j++) seriesHig.Add(0);
|
||||||
}
|
}
|
||||||
float value = showData[i].data[1];
|
float value = showData[i].GetCurrData(1, updateDuration);
|
||||||
float pY = startY + i * scaleWid;
|
float pY = startY + i * scaleWid;
|
||||||
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
||||||
float dataHig = (value - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWidth;
|
float dataHig = 0;
|
||||||
|
if (xAxis.IsLog())
|
||||||
|
{
|
||||||
|
int minIndex = xAxis.runtimeMinLogIndex;
|
||||||
|
float nowIndex = xAxis.GetLogValue(value);
|
||||||
|
dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * coordinateWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * coordinateWidth;
|
||||||
|
}
|
||||||
np = new Vector3(pX + dataHig, pY);
|
np = new Vector3(pX + dataHig, pY);
|
||||||
serie.dataPoints.Add(np);
|
serie.dataPoints.Add(np);
|
||||||
seriesHig[i] += dataHig;
|
seriesHig[i] += dataHig;
|
||||||
|
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||||
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
}
|
}
|
||||||
if (maxCount % rate != 0)
|
if (maxCount % rate != 0)
|
||||||
{
|
{
|
||||||
i = maxCount - 1;
|
i = maxCount - 1;
|
||||||
seriesHig.Add(0);
|
seriesHig.Add(0);
|
||||||
float value = showData[i].data[1];
|
float value = showData[i].GetCurrData(1, updateDuration);
|
||||||
float pY = startY + i * scaleWid;
|
float pY = startY + i * scaleWid;
|
||||||
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
||||||
float dataHig = (value - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWidth;
|
float dataHig = 0;
|
||||||
|
if (xAxis.IsLog())
|
||||||
|
{
|
||||||
|
int minIndex = xAxis.runtimeMinLogIndex;
|
||||||
|
float nowIndex = xAxis.GetLogValue(value);
|
||||||
|
dataHig = (nowIndex - minIndex) / (xAxis.splitNumber - 1) * coordinateWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dataHig = (value - xMinValue) / (xMaxValue - xMinValue) * coordinateWidth;
|
||||||
|
}
|
||||||
np = new Vector3(pX + dataHig, pY);
|
np = new Vector3(pX + dataHig, pY);
|
||||||
serie.dataPoints.Add(np);
|
serie.dataPoints.Add(np);
|
||||||
seriesHig[i] += dataHig;
|
seriesHig[i] += dataHig;
|
||||||
@@ -384,7 +462,7 @@ namespace XCharts
|
|||||||
serie.ClearSmoothList(i);
|
serie.ClearSmoothList(i);
|
||||||
if (!serie.animation.NeedAnimation(i)) break;
|
if (!serie.animation.NeedAnimation(i)) break;
|
||||||
bool isFinish = true;
|
bool isFinish = true;
|
||||||
if (serie.areaStyle.tooltipHighlight && m_Tooltip.show && i < m_Tooltip.dataIndex[0])
|
if (serie.areaStyle.tooltipHighlight && m_Tooltip.show && i < m_Tooltip.runtimeDataIndex[0])
|
||||||
{
|
{
|
||||||
areaColor = highlightAreaColor;
|
areaColor = highlightAreaColor;
|
||||||
areaToColor = highlightAreaToColor;
|
areaToColor = highlightAreaToColor;
|
||||||
@@ -442,6 +520,7 @@ namespace XCharts
|
|||||||
float symbolSpeed = serie.symbol.size / duration;
|
float symbolSpeed = serie.symbol.size / duration;
|
||||||
serie.animation.CheckProgress(Time.deltaTime * speed);
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
serie.animation.CheckSymbol(Time.deltaTime * symbolSpeed, serie.symbol.size);
|
serie.animation.CheckSymbol(Time.deltaTime * symbolSpeed, serie.symbol.size);
|
||||||
|
m_IsPlayingStartAnimation = true;
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,15 +23,18 @@ namespace XCharts
|
|||||||
: serie.dataCount;
|
: serie.dataCount;
|
||||||
serie.animation.InitProgress(1, 0, 1);
|
serie.animation.InitProgress(1, 0, 1);
|
||||||
var rate = serie.animation.GetCurrRate();
|
var rate = serie.animation.GetCurrRate();
|
||||||
|
var updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
|
var dataChanging = false;
|
||||||
for (int n = serie.minShow; n < maxCount; n++)
|
for (int n = serie.minShow; n < maxCount; n++)
|
||||||
{
|
{
|
||||||
var serieData = serie.GetDataList(m_DataZoom)[n];
|
var serieData = serie.GetDataList(m_DataZoom)[n];
|
||||||
float xValue = serieData.data[0];
|
float xValue = serieData.GetCurrData(0, updateDuration);
|
||||||
float yValue = serieData.data[1];
|
float yValue = serieData.GetCurrData(1, updateDuration);
|
||||||
|
if (serieData.IsDataChanged()) dataChanging = true;
|
||||||
float pX = coordinateX + xAxis.axisLine.width;
|
float pX = coordinateX + xAxis.axisLine.width;
|
||||||
float pY = coordinateY + yAxis.axisLine.width;
|
float pY = coordinateY + yAxis.axisLine.width;
|
||||||
float xDataHig = (xValue - xAxis.minValue) / (xAxis.maxValue - xAxis.minValue) * coordinateWidth;
|
float xDataHig = (xValue - xAxis.runtimeMinValue) / (xAxis.runtimeMaxValue - xAxis.runtimeMinValue) * coordinateWidth;
|
||||||
float yDataHig = (yValue - yAxis.minValue) / (yAxis.maxValue - yAxis.minValue) * coordinateHeight;
|
float yDataHig = (yValue - yAxis.runtimeMinValue) / (yAxis.runtimeMaxValue - yAxis.runtimeMinValue) * coordinateHeight;
|
||||||
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
|
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||||
|
|
||||||
var datas = serie.data[n].data;
|
var datas = serie.data[n].data;
|
||||||
@@ -66,6 +69,11 @@ namespace XCharts
|
|||||||
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
float duration = serie.animation.duration > 0 ? (float)serie.animation.duration / 1000 : 1;
|
||||||
float speed = 1 / duration;
|
float speed = 1 / duration;
|
||||||
serie.animation.CheckProgress(Time.deltaTime * speed);
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
|
m_IsPlayingStartAnimation = true;
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
/******************************************/
|
|
||||||
/* */
|
|
||||||
/* Copyright (c) 2018 monitor1394 */
|
|
||||||
/* https://github.com/monitor1394 */
|
|
||||||
/* */
|
|
||||||
/******************************************/
|
|
||||||
|
|
||||||
using UnityEngine;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace XCharts
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 支持从json格式的字符串中导入数据
|
|
||||||
/// </summary>
|
|
||||||
public class JsonDataSupport : IJsonData, ISerializationCallbackReceiver
|
|
||||||
{
|
|
||||||
[SerializeField] protected string m_JsonData;
|
|
||||||
[SerializeField] protected bool m_DataFromJson;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// json格式的字符串数据
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
|
|
||||||
|
|
||||||
public void OnAfterDeserialize()
|
|
||||||
{
|
|
||||||
if (m_DataFromJson)
|
|
||||||
{
|
|
||||||
ParseJsonData(m_JsonData);
|
|
||||||
m_DataFromJson = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnBeforeSerialize()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ParseJsonData(string json)
|
|
||||||
{
|
|
||||||
throw new Exception("no support yet");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
96
Assets/XCharts/Runtime/Internal/LabelObject.cs
Normal file
96
Assets/XCharts/Runtime/Internal/LabelObject.cs
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
public class LabelObject
|
||||||
|
{
|
||||||
|
private GameObject m_GameObject;
|
||||||
|
private bool m_LabelAutoSize = true;
|
||||||
|
private float m_LabelPaddingLeftRight = 3f;
|
||||||
|
private float m_LabelPaddingTopBottom = 3f;
|
||||||
|
private Text m_LabelText;
|
||||||
|
private RectTransform m_LabelRect;
|
||||||
|
private Image m_IconImage;
|
||||||
|
// private RectTransform m_IconRect;
|
||||||
|
|
||||||
|
public Image icon { get { return m_IconImage; } }
|
||||||
|
public Text label { get { return m_LabelText; } }
|
||||||
|
|
||||||
|
public LabelObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLabel(GameObject labelObj, bool autoSize, float paddingLeftRight, float paddingTopBottom)
|
||||||
|
{
|
||||||
|
m_GameObject = labelObj;
|
||||||
|
m_LabelAutoSize = autoSize;
|
||||||
|
m_LabelPaddingLeftRight = paddingLeftRight;
|
||||||
|
m_LabelPaddingTopBottom = paddingTopBottom;
|
||||||
|
m_LabelText = labelObj.GetComponentInChildren<Text>();
|
||||||
|
m_LabelRect = m_LabelText.GetComponent<RectTransform>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIcon(Image image)
|
||||||
|
{
|
||||||
|
m_IconImage = image;
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
// m_IconRect = m_IconImage.GetComponent<RectTransform>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIconSprite(Sprite sprite)
|
||||||
|
{
|
||||||
|
if (m_IconImage != null) m_IconImage.sprite = sprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIconSize(float width, float height)
|
||||||
|
{
|
||||||
|
if (m_LabelRect != null) m_LabelRect.sizeDelta = new Vector3(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIconActive(bool flag)
|
||||||
|
{
|
||||||
|
ChartHelper.SetActive(m_IconImage, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPosition(Vector3 position)
|
||||||
|
{
|
||||||
|
if (m_GameObject != null)
|
||||||
|
{
|
||||||
|
m_GameObject.transform.localPosition = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetActive(bool flag)
|
||||||
|
{
|
||||||
|
ChartHelper.SetActive(m_GameObject, flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetText(string text)
|
||||||
|
{
|
||||||
|
if (m_LabelText && !m_LabelText.text.Equals(text))
|
||||||
|
{
|
||||||
|
m_LabelText.text = text;
|
||||||
|
if (m_LabelAutoSize)
|
||||||
|
{
|
||||||
|
var newSize = string.IsNullOrEmpty(text) ? Vector2.zero :
|
||||||
|
new Vector2(m_LabelText.preferredWidth + m_LabelPaddingLeftRight * 2,
|
||||||
|
m_LabelText.preferredHeight + m_LabelPaddingTopBottom * 2);
|
||||||
|
var sizeChange = newSize.x != m_LabelRect.sizeDelta.x || newSize.y != m_LabelRect.sizeDelta.y;
|
||||||
|
if (sizeChange) m_LabelRect.sizeDelta = newSize;
|
||||||
|
return sizeChange;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Internal/LabelObject.cs.meta
Normal file
11
Assets/XCharts/Runtime/Internal/LabelObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f4e7ef04b9a0e4526b49bf63967cfef4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -11,7 +11,7 @@ using UnityEngine.Events;
|
|||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
public class ObjectPool<T> where T : new()
|
internal class ObjectPool<T> where T : new()
|
||||||
{
|
{
|
||||||
private readonly Stack<T> m_Stack = new Stack<T>();
|
private readonly Stack<T> m_Stack = new Stack<T>();
|
||||||
private readonly UnityAction<T> m_ActionOnGet;
|
private readonly UnityAction<T> m_ActionOnGet;
|
||||||
|
|||||||
67
Assets/XCharts/Runtime/Internal/SerieLabelPool.cs
Normal file
67
Assets/XCharts/Runtime/Internal/SerieLabelPool.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace XCharts
|
||||||
|
{
|
||||||
|
internal static class SerieLabelPool
|
||||||
|
{
|
||||||
|
private static readonly Stack<GameObject> m_Stack = new Stack<GameObject>(200);
|
||||||
|
|
||||||
|
public static GameObject Get(string name, Transform parent, SerieLabel label, Font font, Color color, float iconWidth, float iconHeight)
|
||||||
|
{
|
||||||
|
GameObject element;
|
||||||
|
if (m_Stack.Count == 0 || !Application.isPlaying)
|
||||||
|
{
|
||||||
|
element = ChartHelper.AddSerieLabel(name, parent, font,
|
||||||
|
color, label.backgroundColor, label.fontSize, label.fontStyle, label.rotate,
|
||||||
|
label.backgroundWidth, label.backgroundHeight);
|
||||||
|
ChartHelper.AddIcon("Icon", element.transform, iconWidth, iconHeight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
element = m_Stack.Pop();
|
||||||
|
element.name = name;
|
||||||
|
element.transform.SetParent(parent);
|
||||||
|
element.transform.localEulerAngles = new Vector3(0, 0, label.rotate);
|
||||||
|
var text = element.GetComponentInChildren<Text>();
|
||||||
|
text.color = color;
|
||||||
|
text.font = font;
|
||||||
|
text.fontSize = label.fontSize;
|
||||||
|
text.fontStyle = label.fontStyle;
|
||||||
|
ChartHelper.SetActive(element, true);
|
||||||
|
}
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Release(GameObject element)
|
||||||
|
{
|
||||||
|
ChartHelper.SetActive(element, false);
|
||||||
|
//if (m_Stack.Count > 0 && ReferenceEquals(m_Stack.Peek(), element))
|
||||||
|
// Debug.LogError("Internal error. Trying to destroy object that is already released to pool." + element.name);
|
||||||
|
if (Application.isPlaying)
|
||||||
|
m_Stack.Push(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ReleaseAll(Transform parent)
|
||||||
|
{
|
||||||
|
int count = parent.childCount;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
Release(parent.GetChild(i).gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ClearAll()
|
||||||
|
{
|
||||||
|
m_Stack.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Runtime/Internal/SerieLabelPool.cs.meta
Normal file
11
Assets/XCharts/Runtime/Internal/SerieLabelPool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 340f267fa46e74d0bbbb0b75a20bd708
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -20,7 +20,6 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
private bool isDrawPie;
|
private bool isDrawPie;
|
||||||
private bool m_IsEnterLegendButtom;
|
private bool m_IsEnterLegendButtom;
|
||||||
private bool m_RefreshLabel;
|
|
||||||
|
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
@@ -65,9 +64,9 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
bool isFinish = true;
|
bool isFinish = true;
|
||||||
if (serie.pieClickOffset) isClickOffset = true;
|
if (serie.pieClickOffset) isClickOffset = true;
|
||||||
serie.pieDataMax = serie.yMax;
|
serie.runtimePieDataMax = serie.yMax;
|
||||||
serie.pieDataTotal = serie.yTotal;
|
serie.runtimePieDataTotal = serie.yTotal;
|
||||||
UpdatePieCenter(serie);
|
serie.UpdateCenter(chartWidth, chartHeight);
|
||||||
|
|
||||||
float totalDegree = 360;
|
float totalDegree = 360;
|
||||||
float startDegree = 0;
|
float startDegree = 0;
|
||||||
@@ -77,81 +76,89 @@ namespace XCharts
|
|||||||
if (sd.show && serie.pieRoseType == RoseType.Area) showdataCount++;
|
if (sd.show && serie.pieRoseType == RoseType.Area) showdataCount++;
|
||||||
sd.canShowLabel = false;
|
sd.canShowLabel = false;
|
||||||
}
|
}
|
||||||
|
bool dataChanging = false;
|
||||||
|
float updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
for (int n = 0; n < data.Count; n++)
|
for (int n = 0; n < data.Count; n++)
|
||||||
{
|
{
|
||||||
if (!serie.animation.NeedAnimation(n)) break;
|
if (!serie.animation.NeedAnimation(n)) break;
|
||||||
var serieData = data[n];
|
var serieData = data[n];
|
||||||
serieData.index = n;
|
serieData.index = n;
|
||||||
float value = serieData.data[1];
|
float value = serieData.GetCurrData(1, updateDuration);
|
||||||
|
if (serieData.IsDataChanged()) dataChanging = true;
|
||||||
serieNameCount = m_LegendRealShowName.IndexOf(serieData.legendName);
|
serieNameCount = m_LegendRealShowName.IndexOf(serieData.legendName);
|
||||||
Color color = m_ThemeInfo.GetColor(serieNameCount);
|
Color color = m_ThemeInfo.GetColor(serieNameCount);
|
||||||
serieData.pieStartAngle = startDegree;
|
serieData.runtimePieStartAngle = startDegree;
|
||||||
serieData.pieToAngle = startDegree;
|
serieData.runtimePieToAngle = startDegree;
|
||||||
serieData.pieHalfAngle = startDegree;
|
serieData.runtimePieHalfAngle = startDegree;
|
||||||
serieData.pieCurrAngle = startDegree;
|
serieData.runtimePieCurrAngle = startDegree;
|
||||||
if (!serieData.show)
|
if (!serieData.show)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
float degree = serie.pieRoseType == RoseType.Area ?
|
float degree = serie.pieRoseType == RoseType.Area ?
|
||||||
(totalDegree / showdataCount) : (totalDegree * value / serie.pieDataTotal);
|
(totalDegree / showdataCount) : (totalDegree * value / serie.runtimePieDataTotal);
|
||||||
serieData.pieToAngle = startDegree + degree;
|
serieData.runtimePieToAngle = startDegree + degree;
|
||||||
|
|
||||||
serieData.pieOutsideRadius = serie.pieRoseType > 0 ?
|
serieData.runtimePieOutsideRadius = serie.pieRoseType > 0 ?
|
||||||
serie.pieInsideRadius + (serie.pieOutsideRadius - serie.pieInsideRadius) * value / serie.pieDataMax :
|
serie.runtimeInsideRadius + (serie.runtimeOutsideRadius - serie.runtimeInsideRadius) * value / serie.runtimePieDataMax :
|
||||||
serie.pieOutsideRadius;
|
serie.runtimeOutsideRadius;
|
||||||
if (serieData.highlighted)
|
if (serieData.highlighted)
|
||||||
{
|
{
|
||||||
isDataHighlight = true;
|
isDataHighlight = true;
|
||||||
color *= 1.2f;
|
color *= 1.2f;
|
||||||
serieData.pieOutsideRadius += m_Settings.pieTooltipExtraRadius;
|
serieData.runtimePieOutsideRadius += m_Settings.pieTooltipExtraRadius;
|
||||||
}
|
}
|
||||||
var offset = serie.pieSpace;
|
var offset = serie.pieSpace;
|
||||||
if (serie.pieClickOffset && serieData.selected)
|
if (serie.pieClickOffset && serieData.selected)
|
||||||
{
|
{
|
||||||
offset += m_Settings.pieSelectedOffset;
|
offset += m_Settings.pieSelectedOffset;
|
||||||
}
|
}
|
||||||
var halfDegree = (serieData.pieToAngle - startDegree) / 2;
|
var halfDegree = (serieData.runtimePieToAngle - startDegree) / 2;
|
||||||
serieData.pieHalfAngle = startDegree + halfDegree;
|
serieData.runtimePieHalfAngle = startDegree + halfDegree;
|
||||||
float currRad = serieData.pieHalfAngle * Mathf.Deg2Rad;
|
float currRad = serieData.runtimePieHalfAngle * Mathf.Deg2Rad;
|
||||||
float currSin = Mathf.Sin(currRad);
|
float currSin = Mathf.Sin(currRad);
|
||||||
float currCos = Mathf.Cos(currRad);
|
float currCos = Mathf.Cos(currRad);
|
||||||
var center = serie.pieCenterPos;
|
var center = serie.runtimeCenterPos;
|
||||||
|
|
||||||
serieData.pieCurrAngle = serieData.pieToAngle;
|
serieData.runtimePieCurrAngle = serieData.runtimePieToAngle;
|
||||||
serieData.pieOffsetCenter = center;
|
serieData.runtiemPieOffsetCenter = center;
|
||||||
serieData.pieInsideRadius = serie.pieInsideRadius;
|
serieData.runtimePieInsideRadius = serie.runtimeInsideRadius;
|
||||||
if (serie.animation.CheckDetailBreak(n, serieData.pieToAngle))
|
if (serie.animation.CheckDetailBreak(n, serieData.runtimePieToAngle))
|
||||||
{
|
{
|
||||||
isFinish = false;
|
isFinish = false;
|
||||||
serieData.pieCurrAngle = serie.animation.GetCurrDetail();
|
serieData.runtimePieCurrAngle = serie.animation.GetCurrDetail();
|
||||||
}
|
}
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
serieData.pieOffsetRadius = serie.pieSpace / Mathf.Sin(halfDegree * Mathf.Deg2Rad);
|
serieData.runtimePieOffsetRadius = serie.pieSpace / Mathf.Sin(halfDegree * Mathf.Deg2Rad);
|
||||||
serieData.pieInsideRadius -= serieData.pieOffsetRadius;
|
serieData.runtimePieInsideRadius -= serieData.runtimePieOffsetRadius;
|
||||||
serieData.pieOutsideRadius -= serieData.pieOffsetRadius;
|
serieData.runtimePieOutsideRadius -= serieData.runtimePieOffsetRadius;
|
||||||
if (serie.pieClickOffset && serieData.selected)
|
if (serie.pieClickOffset && serieData.selected)
|
||||||
{
|
{
|
||||||
serieData.pieOffsetRadius += m_Settings.pieSelectedOffset;
|
serieData.runtimePieOffsetRadius += m_Settings.pieSelectedOffset;
|
||||||
if (serieData.pieInsideRadius > 0) serieData.pieInsideRadius += m_Settings.pieSelectedOffset;
|
if (serieData.runtimePieInsideRadius > 0) serieData.runtimePieInsideRadius += m_Settings.pieSelectedOffset;
|
||||||
serieData.pieOutsideRadius += m_Settings.pieSelectedOffset;
|
serieData.runtimePieOutsideRadius += m_Settings.pieSelectedOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
serieData.pieOffsetCenter = new Vector3(center.x + serieData.pieOffsetRadius * currSin,
|
serieData.runtiemPieOffsetCenter = new Vector3(center.x + serieData.runtimePieOffsetRadius * currSin,
|
||||||
center.y + serieData.pieOffsetRadius * currCos);
|
center.y + serieData.runtimePieOffsetRadius * currCos);
|
||||||
|
var drawStartDegree = startDegree + serie.pieSpace;
|
||||||
ChartDrawer.DrawDoughnut(vh, serieData.pieOffsetCenter, serieData.pieInsideRadius, serieData.pieOutsideRadius,
|
var drawEndDegree = serieData.runtimePieCurrAngle - serie.pieSpace;
|
||||||
color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, startDegree, serieData.pieCurrAngle);
|
DrawArcShape(vh, serie, serieData, serieData.runtiemPieOffsetCenter, color, ref drawStartDegree, ref drawEndDegree);
|
||||||
|
ChartDrawer.DrawDoughnut(vh, serieData.runtiemPieOffsetCenter, serieData.runtimePieInsideRadius, serieData.runtimePieOutsideRadius,
|
||||||
|
color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, drawStartDegree, drawEndDegree);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChartDrawer.DrawDoughnut(vh, center, serieData.pieInsideRadius, serieData.pieOutsideRadius,
|
var drawStartDegree = startDegree + serie.pieSpace;
|
||||||
color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, startDegree, serieData.pieCurrAngle);
|
var drawEndDegree = serieData.runtimePieCurrAngle - serie.pieSpace;
|
||||||
|
DrawArcShape(vh, serie, serieData, center, color, ref drawStartDegree, ref drawEndDegree);
|
||||||
|
ChartDrawer.DrawDoughnut(vh, center, serieData.runtimePieInsideRadius, serieData.runtimePieOutsideRadius,
|
||||||
|
color, m_ThemeInfo.backgroundColor, m_Settings.cicleSmoothness, drawStartDegree, drawEndDegree);
|
||||||
}
|
}
|
||||||
serieData.canShowLabel = serieData.pieCurrAngle >= serieData.pieHalfAngle;
|
serieData.canShowLabel = serieData.runtimePieCurrAngle >= serieData.runtimePieHalfAngle;
|
||||||
isDrawPie = true;
|
isDrawPie = true;
|
||||||
startDegree = serieData.pieToAngle;
|
startDegree = serieData.runtimePieToAngle;
|
||||||
if (isFinish) serie.animation.SetDataFinish(n);
|
if (isFinish) serie.animation.SetDataFinish(n);
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
@@ -164,21 +171,48 @@ namespace XCharts
|
|||||||
serie.animation.CheckSymbol(Time.deltaTime * symbolSpeed, serie.symbol.size);
|
serie.animation.CheckSymbol(Time.deltaTime * symbolSpeed, serie.symbol.size);
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DrawLabelLine(vh);
|
DrawLabelLine(vh);
|
||||||
DrawLabelBackground(vh);
|
DrawLabelBackground(vh);
|
||||||
raycastTarget = isClickOffset && isDataHighlight;
|
raycastTarget = isClickOffset && isDataHighlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawArcShape(VertexHelper vh, Serie serie, SerieData serieData, Vector3 centerPos,
|
||||||
|
Color color, ref float drawStartDegree, ref float drawEndDegree)
|
||||||
|
{
|
||||||
|
if (serie.arcShaped && serieData.runtimePieInsideRadius > 0)
|
||||||
|
{
|
||||||
|
var width = (serieData.runtimePieOutsideRadius - serieData.runtimePieInsideRadius) / 2;
|
||||||
|
var radius = serieData.runtimePieInsideRadius + width;
|
||||||
|
var diffDegree = Mathf.Asin(width / radius) * Mathf.Rad2Deg;
|
||||||
|
drawStartDegree += diffDegree;
|
||||||
|
drawEndDegree -= diffDegree;
|
||||||
|
|
||||||
|
var px = Mathf.Sin(drawStartDegree * Mathf.Deg2Rad) * radius;
|
||||||
|
var py = Mathf.Cos(drawStartDegree * Mathf.Deg2Rad) * radius;
|
||||||
|
var pos = new Vector3(px, py) + centerPos;
|
||||||
|
ChartDrawer.DrawSector(vh, pos, width, color, drawStartDegree + 180, drawStartDegree + 360);
|
||||||
|
px = Mathf.Sin(drawEndDegree * Mathf.Deg2Rad) * radius;
|
||||||
|
py = Mathf.Cos(drawEndDegree * Mathf.Deg2Rad) * radius;
|
||||||
|
pos = new Vector3(px, py) + centerPos;
|
||||||
|
ChartDrawer.DrawSector(vh, pos, width, color, drawEndDegree, drawEndDegree + 180);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawLabelLine(VertexHelper vh)
|
private void DrawLabelLine(VertexHelper vh)
|
||||||
{
|
{
|
||||||
foreach (var serie in m_Series.list)
|
foreach (var serie in m_Series.list)
|
||||||
{
|
{
|
||||||
if (serie.type == SerieType.Pie && serie.label.show)
|
if (serie.type == SerieType.Pie)
|
||||||
{
|
{
|
||||||
foreach (var serieData in serie.data)
|
foreach (var serieData in serie.data)
|
||||||
{
|
{
|
||||||
if (serieData.canShowLabel)
|
var serieLabel = serieData.GetSerieLabel(serie.label);
|
||||||
|
if (serieLabel.show && serieData.canShowLabel)
|
||||||
{
|
{
|
||||||
int colorIndex = m_LegendRealShowName.IndexOf(serieData.name);
|
int colorIndex = m_LegendRealShowName.IndexOf(serieData.name);
|
||||||
Color color = m_ThemeInfo.GetColor(colorIndex);
|
Color color = m_ThemeInfo.GetColor(colorIndex);
|
||||||
@@ -193,11 +227,12 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
foreach (var serie in m_Series.list)
|
foreach (var serie in m_Series.list)
|
||||||
{
|
{
|
||||||
if (serie.type == SerieType.Pie && serie.label.show)
|
if (serie.type == SerieType.Pie)
|
||||||
{
|
{
|
||||||
foreach (var serieData in serie.data)
|
foreach (var serieData in serie.data)
|
||||||
{
|
{
|
||||||
if (serieData.canShowLabel)
|
var serieLabel = serieData.GetSerieLabel(serie.label);
|
||||||
|
if (serieLabel.show && serieData.canShowLabel)
|
||||||
{
|
{
|
||||||
UpdateLabelPostion(serie, serieData);
|
UpdateLabelPostion(serie, serieData);
|
||||||
DrawLabelBackground(vh, serie, serieData);
|
DrawLabelBackground(vh, serie, serieData);
|
||||||
@@ -209,86 +244,89 @@ namespace XCharts
|
|||||||
|
|
||||||
private void DrawLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color)
|
private void DrawLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color)
|
||||||
{
|
{
|
||||||
if (serie.label.show
|
var serieLabel = serieData.GetSerieLabel(serie.label);
|
||||||
&& serie.label.position == SerieLabel.Position.Outside
|
if (serieLabel.show
|
||||||
&& serie.label.line)
|
&& serieLabel.position == SerieLabel.Position.Outside
|
||||||
|
&& serieLabel.line)
|
||||||
{
|
{
|
||||||
var insideRadius = serieData.pieInsideRadius;
|
var insideRadius = serieData.runtimePieInsideRadius;
|
||||||
var outSideRadius = serieData.pieOutsideRadius;
|
var outSideRadius = serieData.runtimePieOutsideRadius;
|
||||||
var center = serie.pieCenterPos;
|
var center = serie.runtimeCenterPos;
|
||||||
var currAngle = serieData.pieHalfAngle;
|
var currAngle = serieData.runtimePieHalfAngle;
|
||||||
if (serie.label.lineColor != Color.clear) color = serie.label.lineColor;
|
if (serieLabel.lineColor != Color.clear) color = serieLabel.lineColor;
|
||||||
else if (serie.label.lineType == SerieLabel.LineType.HorizontalLine) color *= color;
|
else if (serieLabel.lineType == SerieLabel.LineType.HorizontalLine) color *= color;
|
||||||
float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
|
float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
|
||||||
float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
|
float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
|
||||||
var radius1 = serie.label.lineType == SerieLabel.LineType.HorizontalLine ?
|
var radius1 = serieLabel.lineType == SerieLabel.LineType.HorizontalLine ?
|
||||||
serie.pieOutsideRadius : outSideRadius;
|
serie.runtimeOutsideRadius : outSideRadius;
|
||||||
var radius2 = serie.pieOutsideRadius + serie.label.lineLength1;
|
var radius2 = serie.runtimeOutsideRadius + serieLabel.lineLength1;
|
||||||
var radius3 = insideRadius + (outSideRadius - insideRadius) / 2;
|
var radius3 = insideRadius + (outSideRadius - insideRadius) / 2;
|
||||||
|
if (radius1 < serie.runtimeInsideRadius) radius1 = serie.runtimeInsideRadius;
|
||||||
|
radius1 -= 0.1f;
|
||||||
var pos0 = new Vector3(center.x + radius3 * currSin, center.y + radius3 * currCos);
|
var pos0 = new Vector3(center.x + radius3 * currSin, center.y + radius3 * currCos);
|
||||||
var pos1 = new Vector3(center.x + radius1 * currSin, center.y + radius1 * currCos);
|
var pos1 = new Vector3(center.x + radius1 * currSin, center.y + radius1 * currCos);
|
||||||
var pos2 = new Vector3(center.x + radius2 * currSin, center.y + radius2 * currCos);
|
var pos2 = new Vector3(center.x + radius2 * currSin, center.y + radius2 * currCos);
|
||||||
float tx, ty;
|
float tx, ty;
|
||||||
Vector3 pos3, pos4, pos6;
|
Vector3 pos3, pos4, pos6;
|
||||||
var horizontalLineCircleRadius = serie.label.lineWidth * 4f;
|
var horizontalLineCircleRadius = serieLabel.lineWidth * 4f;
|
||||||
var lineCircleDiff = horizontalLineCircleRadius - 0.3f;
|
var lineCircleDiff = horizontalLineCircleRadius - 0.3f;
|
||||||
if (currAngle < 90)
|
if (currAngle < 90)
|
||||||
{
|
{
|
||||||
ty = serie.label.lineWidth * Mathf.Cos((90 - currAngle) * Mathf.Deg2Rad);
|
ty = serieLabel.lineWidth * Mathf.Cos((90 - currAngle) * Mathf.Deg2Rad);
|
||||||
tx = serie.label.lineWidth * Mathf.Sin((90 - currAngle) * Mathf.Deg2Rad);
|
tx = serieLabel.lineWidth * Mathf.Sin((90 - currAngle) * Mathf.Deg2Rad);
|
||||||
pos3 = new Vector3(pos2.x - tx, pos2.y + ty - serie.label.lineWidth);
|
pos3 = new Vector3(pos2.x - tx, pos2.y + ty - serieLabel.lineWidth);
|
||||||
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
|
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
|
||||||
r4 += serie.label.lineLength1 - lineCircleDiff;
|
r4 += serieLabel.lineLength1 - lineCircleDiff;
|
||||||
pos6 = pos0 + Vector3.right * lineCircleDiff;
|
pos6 = pos0 + Vector3.right * lineCircleDiff;
|
||||||
pos4 = pos6 + Vector3.right * r4;
|
pos4 = pos6 + Vector3.right * r4;
|
||||||
}
|
}
|
||||||
else if (currAngle < 180)
|
else if (currAngle < 180)
|
||||||
{
|
{
|
||||||
ty = serie.label.lineWidth * Mathf.Sin((180 - currAngle) * Mathf.Deg2Rad);
|
ty = serieLabel.lineWidth * Mathf.Sin((180 - currAngle) * Mathf.Deg2Rad);
|
||||||
tx = serie.label.lineWidth * Mathf.Cos((180 - currAngle) * Mathf.Deg2Rad);
|
tx = serieLabel.lineWidth * Mathf.Cos((180 - currAngle) * Mathf.Deg2Rad);
|
||||||
pos3 = new Vector3(pos2.x - tx, pos2.y - ty + serie.label.lineWidth);
|
pos3 = new Vector3(pos2.x - tx, pos2.y - ty + serieLabel.lineWidth);
|
||||||
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
|
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
|
||||||
r4 += serie.label.lineLength1 - lineCircleDiff;
|
r4 += serieLabel.lineLength1 - lineCircleDiff;
|
||||||
pos6 = pos0 + Vector3.right * lineCircleDiff;
|
pos6 = pos0 + Vector3.right * lineCircleDiff;
|
||||||
pos4 = pos6 + Vector3.right * r4;
|
pos4 = pos6 + Vector3.right * r4;
|
||||||
}
|
}
|
||||||
else if (currAngle < 270)
|
else if (currAngle < 270)
|
||||||
{
|
{
|
||||||
ty = serie.label.lineWidth * Mathf.Sin((180 + currAngle) * Mathf.Deg2Rad);
|
ty = serieLabel.lineWidth * Mathf.Sin((180 + currAngle) * Mathf.Deg2Rad);
|
||||||
tx = serie.label.lineWidth * Mathf.Cos((180 + currAngle) * Mathf.Deg2Rad);
|
tx = serieLabel.lineWidth * Mathf.Cos((180 + currAngle) * Mathf.Deg2Rad);
|
||||||
var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
|
var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
|
||||||
var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
|
var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
|
||||||
pos3 = new Vector3(pos2.x + tx, pos2.y - ty + serie.label.lineWidth);
|
pos3 = new Vector3(pos2.x + tx, pos2.y - ty + serieLabel.lineWidth);
|
||||||
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3;
|
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3;
|
||||||
r4 += serie.label.lineLength1 - lineCircleDiff;
|
r4 += serieLabel.lineLength1 - lineCircleDiff;
|
||||||
pos6 = pos0 + Vector3.left * lineCircleDiff;
|
pos6 = pos0 + Vector3.left * lineCircleDiff;
|
||||||
pos4 = pos6 + Vector3.left * r4;
|
pos4 = pos6 + Vector3.left * r4;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ty = serie.label.lineWidth * Mathf.Cos((90 + currAngle) * Mathf.Deg2Rad);
|
ty = serieLabel.lineWidth * Mathf.Cos((90 + currAngle) * Mathf.Deg2Rad);
|
||||||
tx = serie.label.lineWidth * Mathf.Sin((90 + currAngle) * Mathf.Deg2Rad);
|
tx = serieLabel.lineWidth * Mathf.Sin((90 + currAngle) * Mathf.Deg2Rad);
|
||||||
pos3 = new Vector3(pos2.x + tx, pos2.y + ty - serie.label.lineWidth);
|
pos3 = new Vector3(pos2.x + tx, pos2.y + ty - serieLabel.lineWidth);
|
||||||
var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
|
var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
|
||||||
var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
|
var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
|
||||||
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3;
|
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3;
|
||||||
r4 += serie.label.lineLength1 - lineCircleDiff;
|
r4 += serieLabel.lineLength1 - lineCircleDiff;
|
||||||
pos6 = pos0 + Vector3.left * lineCircleDiff;
|
pos6 = pos0 + Vector3.left * lineCircleDiff;
|
||||||
pos4 = pos6 + Vector3.left * r4;
|
pos4 = pos6 + Vector3.left * r4;
|
||||||
}
|
}
|
||||||
var pos5 = new Vector3(currAngle > 180 ? pos3.x - serie.label.lineLength2 : pos3.x + serie.label.lineLength2, pos3.y);
|
var pos5 = new Vector3(currAngle > 180 ? pos3.x - serieLabel.lineLength2 : pos3.x + serieLabel.lineLength2, pos3.y);
|
||||||
switch (serie.label.lineType)
|
switch (serieLabel.lineType)
|
||||||
{
|
{
|
||||||
case SerieLabel.LineType.BrokenLine:
|
case SerieLabel.LineType.BrokenLine:
|
||||||
ChartDrawer.DrawLine(vh, pos1, pos2, serie.label.lineWidth, color);
|
ChartDrawer.DrawLine(vh, pos1, pos2, serieLabel.lineWidth, color);
|
||||||
ChartDrawer.DrawLine(vh, pos3, pos5, serie.label.lineWidth, color);
|
ChartDrawer.DrawLine(vh, pos3, pos5, serieLabel.lineWidth, color);
|
||||||
break;
|
break;
|
||||||
case SerieLabel.LineType.Curves:
|
case SerieLabel.LineType.Curves:
|
||||||
ChartDrawer.DrawCurves(vh, pos1, pos5, pos1, pos2, serie.label.lineWidth, color, m_Settings.lineSmoothness);
|
ChartDrawer.DrawCurves(vh, pos1, pos5, pos1, pos2, serieLabel.lineWidth, color, m_Settings.lineSmoothness);
|
||||||
break;
|
break;
|
||||||
case SerieLabel.LineType.HorizontalLine:
|
case SerieLabel.LineType.HorizontalLine:
|
||||||
ChartDrawer.DrawCricle(vh, pos0, horizontalLineCircleRadius, color);
|
ChartDrawer.DrawCricle(vh, pos0, horizontalLineCircleRadius, color);
|
||||||
ChartDrawer.DrawLine(vh, pos6, pos4, serie.label.lineWidth, color);
|
ChartDrawer.DrawLine(vh, pos6, pos4, serieLabel.lineWidth, color);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,15 +370,16 @@ namespace XCharts
|
|||||||
private void DrawLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
|
private void DrawLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
|
||||||
{
|
{
|
||||||
if (serieData.labelText == null) return;
|
if (serieData.labelText == null) return;
|
||||||
var currAngle = serieData.pieHalfAngle;
|
var currAngle = serieData.runtimePieHalfAngle;
|
||||||
var isHighlight = (serieData.highlighted && serie.emphasis.label.show);
|
var isHighlight = (serieData.highlighted && serie.emphasis.label.show);
|
||||||
var showLabel = ((serie.label.show || isHighlight) && serieData.canShowLabel);
|
var serieLabel = serieData.GetSerieLabel(serie.label);
|
||||||
if (showLabel || serieData.showIcon)
|
var showLabel = ((serieLabel.show || isHighlight) && serieData.canShowLabel);
|
||||||
|
if (showLabel || serieData.iconStyle.show)
|
||||||
{
|
{
|
||||||
serieData.SetLabelActive(showLabel);
|
serieData.SetLabelActive(showLabel);
|
||||||
float rotate = 0;
|
float rotate = 0;
|
||||||
bool isInsidePosition = serie.label.position == SerieLabel.Position.Inside;
|
bool isInsidePosition = serieLabel.position == SerieLabel.Position.Inside;
|
||||||
if (serie.label.rotate > 0 && isInsidePosition)
|
if (serieLabel.rotate > 0 && isInsidePosition)
|
||||||
{
|
{
|
||||||
if (currAngle > 180) rotate += 270 - currAngle;
|
if (currAngle > 180) rotate += 270 - currAngle;
|
||||||
else rotate += -(currAngle - 90);
|
else rotate += -(currAngle - 90);
|
||||||
@@ -350,16 +389,16 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (serie.emphasis.label.color != Color.clear) color = serie.emphasis.label.color;
|
if (serie.emphasis.label.color != Color.clear) color = serie.emphasis.label.color;
|
||||||
}
|
}
|
||||||
else if (serie.label.color != Color.clear)
|
else if (serieLabel.color != Color.clear)
|
||||||
{
|
{
|
||||||
color = serie.label.color;
|
color = serieLabel.color;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
color = isInsidePosition ? Color.white : serieColor;
|
color = isInsidePosition ? Color.white : serieColor;
|
||||||
}
|
}
|
||||||
var fontSize = isHighlight ? serie.emphasis.label.fontSize : serie.label.fontSize;
|
var fontSize = isHighlight ? serie.emphasis.label.fontSize : serieLabel.fontSize;
|
||||||
var fontStyle = isHighlight ? serie.emphasis.label.fontStyle : serie.label.fontStyle;
|
var fontStyle = isHighlight ? serie.emphasis.label.fontStyle : serieLabel.fontStyle;
|
||||||
|
|
||||||
serieData.labelText.color = color;
|
serieData.labelText.color = color;
|
||||||
serieData.labelText.fontSize = fontSize;
|
serieData.labelText.fontSize = fontSize;
|
||||||
@@ -368,15 +407,20 @@ namespace XCharts
|
|||||||
serieData.labelRect.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
serieData.labelRect.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
||||||
|
|
||||||
UpdateLabelPostion(serie, serieData);
|
UpdateLabelPostion(serie, serieData);
|
||||||
if (!string.IsNullOrEmpty(serie.label.formatter))
|
if (!string.IsNullOrEmpty(serieLabel.formatter))
|
||||||
{
|
{
|
||||||
var value = serieData.data[1];
|
var value = serieData.data[1];
|
||||||
var total = serie.yTotal;
|
var total = serie.yTotal;
|
||||||
var content = serie.label.GetFormatterContent(serie.name, serieData.name, value, total);
|
var content = serieLabel.GetFormatterContent(serie.name, serieData.name, value, total);
|
||||||
if (serieData.SetLabelText(content)) RefreshChart();
|
if (serieData.SetLabelText(content)) RefreshChart();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (serieData.SetLabelText(serieData.name)) RefreshChart();
|
||||||
|
}
|
||||||
serieData.SetGameObjectPosition(serieData.labelPosition);
|
serieData.SetGameObjectPosition(serieData.labelPosition);
|
||||||
if (showLabel) serieData.SetLabelPosition(serie.label.offset);
|
if (showLabel) serieData.SetLabelPosition(serieLabel.offset);
|
||||||
|
else serieData.SetLabelActive(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -387,53 +431,55 @@ namespace XCharts
|
|||||||
|
|
||||||
protected void UpdateLabelPostion(Serie serie, SerieData serieData)
|
protected void UpdateLabelPostion(Serie serie, SerieData serieData)
|
||||||
{
|
{
|
||||||
var currAngle = serieData.pieHalfAngle;
|
if (serieData.labelText == null) return;
|
||||||
|
var currAngle = serieData.runtimePieHalfAngle;
|
||||||
var currRad = currAngle * Mathf.Deg2Rad;
|
var currRad = currAngle * Mathf.Deg2Rad;
|
||||||
var offsetRadius = serieData.pieOffsetRadius;
|
var offsetRadius = serieData.runtimePieOffsetRadius;
|
||||||
var insideRadius = serieData.pieInsideRadius;
|
var insideRadius = serieData.runtimePieInsideRadius;
|
||||||
var outsideRadius = serieData.pieOutsideRadius;
|
var outsideRadius = serieData.runtimePieOutsideRadius;
|
||||||
switch (serie.label.position)
|
var serieLabel = serieData.GetSerieLabel(serie.label);
|
||||||
|
switch (serieLabel.position)
|
||||||
{
|
{
|
||||||
case SerieLabel.Position.Center:
|
case SerieLabel.Position.Center:
|
||||||
serieData.labelPosition = serie.pieCenterPos;
|
serieData.labelPosition = serie.runtimeCenterPos;
|
||||||
break;
|
break;
|
||||||
case SerieLabel.Position.Inside:
|
case SerieLabel.Position.Inside:
|
||||||
var labelRadius = offsetRadius + insideRadius + (outsideRadius - insideRadius) / 2;
|
var labelRadius = offsetRadius + insideRadius + (outsideRadius - insideRadius) / 2;
|
||||||
var labelCenter = new Vector2(serie.pieCenterPos.x + labelRadius * Mathf.Sin(currRad),
|
var labelCenter = new Vector2(serie.runtimeCenterPos.x + labelRadius * Mathf.Sin(currRad),
|
||||||
serie.pieCenterPos.y + labelRadius * Mathf.Cos(currRad));
|
serie.runtimeCenterPos.y + labelRadius * Mathf.Cos(currRad));
|
||||||
serieData.labelPosition = labelCenter;
|
serieData.labelPosition = labelCenter;
|
||||||
break;
|
break;
|
||||||
case SerieLabel.Position.Outside:
|
case SerieLabel.Position.Outside:
|
||||||
if (serie.label.lineType == SerieLabel.LineType.HorizontalLine)
|
if (serieLabel.lineType == SerieLabel.LineType.HorizontalLine)
|
||||||
{
|
{
|
||||||
var radius1 = serie.pieOutsideRadius;
|
var radius1 = serie.runtimeOutsideRadius;
|
||||||
var radius3 = insideRadius + (outsideRadius - insideRadius) / 2;
|
var radius3 = insideRadius + (outsideRadius - insideRadius) / 2;
|
||||||
var currSin = Mathf.Sin(currRad);
|
var currSin = Mathf.Sin(currRad);
|
||||||
var currCos = Mathf.Cos(currRad);
|
var currCos = Mathf.Cos(currRad);
|
||||||
var pos0 = new Vector3(serie.pieCenterPos.x + radius3 * currSin, serie.pieCenterPos.y + radius3 * currCos);
|
var pos0 = new Vector3(serie.runtimeCenterPos.x + radius3 * currSin, serie.runtimeCenterPos.y + radius3 * currCos);
|
||||||
if (currAngle > 180)
|
if (currAngle > 180)
|
||||||
{
|
{
|
||||||
currSin = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
|
currSin = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad);
|
||||||
currCos = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
|
currCos = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad);
|
||||||
}
|
}
|
||||||
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
|
var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3;
|
||||||
r4 += serie.label.lineLength1 + serie.label.lineWidth * 4;
|
r4 += serieLabel.lineLength1 + serieLabel.lineWidth * 4;
|
||||||
r4 += serieData.labelText.preferredWidth / 2;
|
r4 += serieData.labelText.preferredWidth / 2;
|
||||||
serieData.labelPosition = pos0 + (currAngle > 180 ? Vector3.left : Vector3.right) * r4;
|
serieData.labelPosition = pos0 + (currAngle > 180 ? Vector3.left : Vector3.right) * r4;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labelRadius = serie.pieOutsideRadius + serie.label.lineLength1;
|
labelRadius = serie.runtimeOutsideRadius + serieLabel.lineLength1;
|
||||||
labelCenter = new Vector2(serie.pieCenterPos.x + labelRadius * Mathf.Sin(currRad),
|
labelCenter = new Vector2(serie.runtimeCenterPos.x + labelRadius * Mathf.Sin(currRad),
|
||||||
serie.pieCenterPos.y + labelRadius * Mathf.Cos(currRad));
|
serie.runtimeCenterPos.y + labelRadius * Mathf.Cos(currRad));
|
||||||
float labelWidth = serieData.labelText.preferredWidth;
|
float labelWidth = serieData.labelText.preferredWidth;
|
||||||
if (currAngle > 180)
|
if (currAngle > 180)
|
||||||
{
|
{
|
||||||
serieData.labelPosition = new Vector2(labelCenter.x - serie.label.lineLength2 - 5 - labelWidth / 2, labelCenter.y);
|
serieData.labelPosition = new Vector2(labelCenter.x - serieLabel.lineLength2 - 5 - labelWidth / 2, labelCenter.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serieData.labelPosition = new Vector2(labelCenter.x + serie.label.lineLength2 + 5 + labelWidth / 2, labelCenter.y);
|
serieData.labelPosition = new Vector2(labelCenter.x + serieLabel.lineLength2 + 5 + labelWidth / 2, labelCenter.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -462,26 +508,15 @@ namespace XCharts
|
|||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdatePieCenter(Serie serie)
|
|
||||||
{
|
|
||||||
if (serie.pieCenter.Length < 2) return;
|
|
||||||
var centerX = serie.pieCenter[0] <= 1 ? chartWidth * serie.pieCenter[0] : serie.pieCenter[0];
|
|
||||||
var centerY = serie.pieCenter[1] <= 1 ? chartHeight * serie.pieCenter[1] : serie.pieCenter[1];
|
|
||||||
serie.pieCenterPos = new Vector2(centerX, centerY);
|
|
||||||
var minWidth = Mathf.Min(chartWidth, chartHeight);
|
|
||||||
serie.pieInsideRadius = serie.pieRadius[0] <= 1 ? minWidth * serie.pieRadius[0] : serie.pieRadius[0];
|
|
||||||
serie.pieOutsideRadius = serie.pieRadius[1] <= 1 ? minWidth * serie.pieRadius[1] : serie.pieRadius[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CheckTootipArea(Vector2 local)
|
protected override void CheckTootipArea(Vector2 local)
|
||||||
{
|
{
|
||||||
if (m_IsEnterLegendButtom) return;
|
if (m_IsEnterLegendButtom) return;
|
||||||
m_Tooltip.dataIndex.Clear();
|
m_Tooltip.runtimeDataIndex.Clear();
|
||||||
bool selected = false;
|
bool selected = false;
|
||||||
foreach (var serie in m_Series.list)
|
foreach (var serie in m_Series.list)
|
||||||
{
|
{
|
||||||
int index = GetPosPieIndex(serie, local);
|
int index = GetPosPieIndex(serie, local);
|
||||||
m_Tooltip.dataIndex.Add(index);
|
m_Tooltip.runtimeDataIndex.Add(index);
|
||||||
if (serie.type != SerieType.Pie) continue;
|
if (serie.type != SerieType.Pie) continue;
|
||||||
bool refresh = false;
|
bool refresh = false;
|
||||||
for (int j = 0; j < serie.data.Count; j++)
|
for (int j = 0; j < serie.data.Count; j++)
|
||||||
@@ -508,14 +543,14 @@ namespace XCharts
|
|||||||
private int GetPosPieIndex(Serie serie, Vector2 local)
|
private int GetPosPieIndex(Serie serie, Vector2 local)
|
||||||
{
|
{
|
||||||
if (serie.type != SerieType.Pie) return -1;
|
if (serie.type != SerieType.Pie) return -1;
|
||||||
var dist = Vector2.Distance(local, serie.pieCenterPos);
|
var dist = Vector2.Distance(local, serie.runtimeCenterPos);
|
||||||
if (dist < serie.pieInsideRadius || dist > serie.pieOutsideRadius) return -1;
|
if (dist < serie.runtimeInsideRadius || dist > serie.runtimeOutsideRadius) return -1;
|
||||||
Vector2 dir = local - new Vector2(serie.pieCenterPos.x, serie.pieCenterPos.y);
|
Vector2 dir = local - new Vector2(serie.runtimeCenterPos.x, serie.runtimeCenterPos.y);
|
||||||
float angle = VectorAngle(Vector2.up, dir);
|
float angle = VectorAngle(Vector2.up, dir);
|
||||||
for (int i = 0; i < serie.data.Count; i++)
|
for (int i = 0; i < serie.data.Count; i++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[i];
|
var serieData = serie.data[i];
|
||||||
if (angle >= serieData.pieStartAngle && angle <= serieData.pieToAngle)
|
if (angle >= serieData.runtimePieStartAngle && angle <= serieData.runtimePieToAngle)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -541,10 +576,10 @@ namespace XCharts
|
|||||||
bool showTooltip = false;
|
bool showTooltip = false;
|
||||||
foreach (var serie in m_Series.list)
|
foreach (var serie in m_Series.list)
|
||||||
{
|
{
|
||||||
int index = m_Tooltip.dataIndex[serie.index];
|
int index = m_Tooltip.runtimeDataIndex[serie.index];
|
||||||
if (index < 0) continue;
|
if (index < 0) continue;
|
||||||
showTooltip = true;
|
showTooltip = true;
|
||||||
if (string.IsNullOrEmpty(tooltip.formatter))
|
if (tooltip.IsNoFormatter())
|
||||||
{
|
{
|
||||||
string key = serie.data[index].name;
|
string key = serie.data[index].name;
|
||||||
if (string.IsNullOrEmpty(key)) key = m_Legend.GetData(index);
|
if (string.IsNullOrEmpty(key)) key = m_Legend.GetData(index);
|
||||||
@@ -556,7 +591,7 @@ namespace XCharts
|
|||||||
sb.Append(serie.name).Append("\n");
|
sb.Append(serie.name).Append("\n");
|
||||||
}
|
}
|
||||||
sb.Append("<color=#").Append(m_ThemeInfo.GetColorStr(index)).Append(">● </color>")
|
sb.Append("<color=#").Append(m_ThemeInfo.GetColorStr(index)).Append(">● </color>")
|
||||||
.Append(key).Append(": ").Append(ChartCached.FloatToStr(value));
|
.Append(key).Append(": ").Append(ChartCached.FloatToStr(value, 0, m_Tooltip.forceENotation));
|
||||||
m_Tooltip.UpdateContentText(sb.ToString());
|
m_Tooltip.UpdateContentText(sb.ToString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -565,13 +600,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pos = m_Tooltip.GetContentPos();
|
var pos = m_Tooltip.GetContentPos();
|
||||||
if (pos.x + m_Tooltip.width > chartWidth)
|
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
||||||
{
|
{
|
||||||
pos.x = chartWidth - m_Tooltip.width;
|
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
||||||
}
|
}
|
||||||
if (pos.y - m_Tooltip.height < 0)
|
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
||||||
{
|
{
|
||||||
pos.y = m_Tooltip.height;
|
pos.y = m_Tooltip.runtimeHeight;
|
||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
m_Tooltip.UpdateContentPos(pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,31 +16,14 @@ namespace XCharts
|
|||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
[RequireComponent(typeof(RectTransform))]
|
[RequireComponent(typeof(RectTransform))]
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
public class RadarChart : BaseChart
|
public partial class RadarChart : BaseChart
|
||||||
{
|
{
|
||||||
private const string INDICATOR_TEXT = "indicator";
|
private const string INDICATOR_TEXT = "indicator";
|
||||||
|
|
||||||
//[SerializeField] private Radar radar = Radar.defaultRadar;
|
|
||||||
[SerializeField] private List<Radar> m_Radars = new List<Radar>();
|
[SerializeField] private List<Radar> m_Radars = new List<Radar>();
|
||||||
private List<Radar> m_CheckRadars = new List<Radar>();
|
private List<Radar> m_CheckRadars = new List<Radar>();
|
||||||
private bool m_IsEnterLegendButtom;
|
private bool m_IsEnterLegendButtom;
|
||||||
|
|
||||||
//public Radar radar { get { return radar; } }
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
m_CheckRadars.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnLegendButtonClick(int index, string legendName, bool show)
|
protected override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||||
{
|
{
|
||||||
bool active = CheckDataShow(legendName, show);
|
bool active = CheckDataShow(legendName, show);
|
||||||
@@ -110,30 +93,31 @@ namespace XCharts
|
|||||||
var indicator = radar.indicatorList[i];
|
var indicator = radar.indicatorList[i];
|
||||||
var pos = radar.GetIndicatorPosition(i);
|
var pos = radar.GetIndicatorPosition(i);
|
||||||
TextAnchor anchor = TextAnchor.MiddleCenter;
|
TextAnchor anchor = TextAnchor.MiddleCenter;
|
||||||
var diff = pos.x - radar.centerPos.x;
|
var textStyle = indicator.textStyle;
|
||||||
if (diff < -1f)
|
var textColor = textStyle.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor : textStyle.color;
|
||||||
|
var txt = ChartHelper.AddTextObject(INDICATOR_TEXT + "_" + n + "_" + i, transform, m_ThemeInfo.font,
|
||||||
|
textColor, anchor, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
|
||||||
|
new Vector2(txtWid, txtHig), textStyle.fontSize, textStyle.rotate, textStyle.fontStyle);
|
||||||
|
txt.text = radar.indicatorList[i].name;
|
||||||
|
txt.gameObject.SetActive(radar.indicator);
|
||||||
|
var txtWidth = txt.preferredWidth;
|
||||||
|
var sizeDelta = new Vector2(txt.preferredWidth, txt.preferredHeight);
|
||||||
|
txt.GetComponent<RectTransform>().sizeDelta = sizeDelta;
|
||||||
|
var diff = pos.x - radar.runtimeCenterPos.x;
|
||||||
|
if (diff < -1f) //left
|
||||||
{
|
{
|
||||||
pos = new Vector3(pos.x - 5, pos.y);
|
pos = new Vector3(pos.x - txtWidth / 2, pos.y);
|
||||||
anchor = TextAnchor.MiddleRight;
|
|
||||||
}
|
}
|
||||||
else if (diff > 1f)
|
else if (diff > 1f) //right
|
||||||
{
|
{
|
||||||
anchor = TextAnchor.MiddleLeft;
|
pos = new Vector3(pos.x + txtWidth / 2, pos.y);
|
||||||
pos = new Vector3(pos.x + txtWid + 5, pos.y);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
anchor = TextAnchor.MiddleCenter;
|
float y = pos.y > radar.runtimeCenterPos.y ? pos.y + txtHig / 2 : pos.y - txtHig / 2;
|
||||||
float y = pos.y > radar.centerPos.y ? pos.y + txtHig / 2 : pos.y - txtHig / 2;
|
pos = new Vector3(pos.x, y);
|
||||||
pos = new Vector3(pos.x + txtWid / 2, y);
|
|
||||||
}
|
}
|
||||||
var textColor = indicator.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor : indicator.color;
|
txt.transform.localPosition = pos + new Vector3(textStyle.offset.x, textStyle.offset.y);
|
||||||
Text txt = ChartHelper.AddTextObject(INDICATOR_TEXT + "_" + n + "_" + i, transform, m_ThemeInfo.font,
|
|
||||||
textColor, anchor, Vector2.zero, Vector2.zero, new Vector2(1, 0.5f),
|
|
||||||
new Vector2(txtWid, txtHig));
|
|
||||||
txt.transform.localPosition = pos;
|
|
||||||
txt.text = radar.indicatorList[i].name;
|
|
||||||
txt.gameObject.SetActive(radar.indicator);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,24 +196,26 @@ namespace XCharts
|
|||||||
var radar = m_Radars[serie.radarIndex];
|
var radar = m_Radars[serie.radarIndex];
|
||||||
int indicatorNum = radar.indicatorList.Count;
|
int indicatorNum = radar.indicatorList.Count;
|
||||||
var angle = 2 * Mathf.PI / indicatorNum;
|
var angle = 2 * Mathf.PI / indicatorNum;
|
||||||
Vector3 p = radar.centerPos;
|
Vector3 p = radar.runtimeCenterPos;
|
||||||
serie.animation.InitProgress(1,0,1);
|
serie.animation.InitProgress(1, 0, 1);
|
||||||
if (!IsActive(i))
|
if (!IsActive(i))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var rate = serie.animation.GetCurrRate();
|
var rate = serie.animation.GetCurrRate();
|
||||||
|
var dataChanging = false;
|
||||||
|
var updateDuration = serie.animation.GetUpdateAnimationDuration();
|
||||||
for (int j = 0; j < serie.data.Count; j++)
|
for (int j = 0; j < serie.data.Count; j++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
int key = i * 100 + j;
|
int key = i * 100 + j;
|
||||||
if (!radar.dataPosList.ContainsKey(key))
|
if (!radar.runtimeDataPosList.ContainsKey(key))
|
||||||
{
|
{
|
||||||
radar.dataPosList.Add(i * 100 + j, new List<Vector3>(serieData.data.Count));
|
radar.runtimeDataPosList.Add(i * 100 + j, new List<Vector3>(serieData.data.Count));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
radar.dataPosList[key].Clear();
|
radar.runtimeDataPosList[key].Clear();
|
||||||
}
|
}
|
||||||
string dataName = serieData.name;
|
string dataName = serieData.name;
|
||||||
int serieIndex = 0;
|
int serieIndex = 0;
|
||||||
@@ -253,25 +239,26 @@ namespace XCharts
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var isHighlight = serie.highlighted || serieData.highlighted ||
|
var isHighlight = serie.highlighted || serieData.highlighted ||
|
||||||
(m_Tooltip.show && m_Tooltip.dataIndex[0] == i && m_Tooltip.dataIndex[1] == j);
|
(m_Tooltip.show && m_Tooltip.runtimeDataIndex[0] == i && m_Tooltip.runtimeDataIndex[1] == j);
|
||||||
var areaColor = serie.GetAreaColor(m_ThemeInfo, serieIndex, isHighlight);
|
var areaColor = serie.GetAreaColor(m_ThemeInfo, serieIndex, isHighlight);
|
||||||
var lineColor = serie.GetLineColor(m_ThemeInfo, serieIndex, isHighlight);
|
var lineColor = serie.GetLineColor(m_ThemeInfo, serieIndex, isHighlight);
|
||||||
int dataCount = radar.indicatorList.Count;
|
int dataCount = radar.indicatorList.Count;
|
||||||
List<Vector3> pointList = radar.dataPosList[key];
|
List<Vector3> pointList = radar.runtimeDataPosList[key];
|
||||||
for (int n = 0; n < dataCount; n++)
|
for (int n = 0; n < dataCount; n++)
|
||||||
{
|
{
|
||||||
if (n >= serieData.data.Count) break;
|
if (n >= serieData.data.Count) break;
|
||||||
float min = radar.GetIndicatorMin(n);
|
float min = radar.GetIndicatorMin(n);
|
||||||
float max = radar.GetIndicatorMax(n);
|
float max = radar.GetIndicatorMax(n);
|
||||||
float value = serieData.data[n];
|
float value = serieData.GetCurrData(n, updateDuration);
|
||||||
|
if (serieData.IsDataChanged()) dataChanging = true;
|
||||||
if (max == 0)
|
if (max == 0)
|
||||||
{
|
{
|
||||||
serie.GetMinMaxData(n, out min, out max);
|
serie.GetMinMaxData(n, out min, out max);
|
||||||
min = radar.GetIndicatorMin(n);
|
min = radar.GetIndicatorMin(n);
|
||||||
}
|
}
|
||||||
var radius = max < 0 ? radar.actualRadius - radar.actualRadius * value / max
|
var radius = max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
|
||||||
: radar.actualRadius * value / max;
|
: radar.runtimeDataRadius * value / max;
|
||||||
var currAngle = n * angle;
|
var currAngle = (n + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle;
|
||||||
radius *= rate;
|
radius *= rate;
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
@@ -321,6 +308,10 @@ namespace XCharts
|
|||||||
serie.animation.CheckProgress(Time.deltaTime * speed);
|
serie.animation.CheckProgress(Time.deltaTime * speed);
|
||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
if (dataChanging)
|
||||||
|
{
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,10 +322,10 @@ namespace XCharts
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float insideRadius = 0, outsideRadius = 0;
|
float insideRadius = 0, outsideRadius = 0;
|
||||||
float block = radar.actualRadius / radar.splitNumber;
|
float block = radar.runtimeRadius / radar.splitNumber;
|
||||||
int indicatorNum = radar.indicatorList.Count;
|
int indicatorNum = radar.indicatorList.Count;
|
||||||
Vector3 p1, p2, p3, p4;
|
Vector3 p1, p2, p3, p4;
|
||||||
Vector3 p = radar.centerPos;
|
Vector3 p = radar.runtimeCenterPos;
|
||||||
float angle = 2 * Mathf.PI / indicatorNum;
|
float angle = 2 * Mathf.PI / indicatorNum;
|
||||||
var lineColor = GetLineColor(radar);
|
var lineColor = GetLineColor(radar);
|
||||||
for (int i = 0; i < radar.splitNumber; i++)
|
for (int i = 0; i < radar.splitNumber; i++)
|
||||||
@@ -382,9 +373,9 @@ namespace XCharts
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float insideRadius = 0, outsideRadius = 0;
|
float insideRadius = 0, outsideRadius = 0;
|
||||||
float block = radar.actualRadius / radar.splitNumber;
|
float block = radar.runtimeRadius / radar.splitNumber;
|
||||||
int indicatorNum = radar.indicatorList.Count;
|
int indicatorNum = radar.indicatorList.Count;
|
||||||
Vector3 p = radar.centerPos;
|
Vector3 p = radar.runtimeCenterPos;
|
||||||
Vector3 p1;
|
Vector3 p1;
|
||||||
float angle = 2 * Mathf.PI / indicatorNum;
|
float angle = 2 * Mathf.PI / indicatorNum;
|
||||||
var lineColor = GetLineColor(radar);
|
var lineColor = GetLineColor(radar);
|
||||||
@@ -399,7 +390,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
if (radar.lineStyle.show)
|
if (radar.lineStyle.show)
|
||||||
{
|
{
|
||||||
ChartDrawer.DrawEmptyCricle(vh, p, outsideRadius, radar.lineStyle.width, lineColor,
|
ChartDrawer.DrawEmptyCricle(vh, p, outsideRadius, radar.lineStyle.width, lineColor,
|
||||||
Color.clear, m_Settings.cicleSmoothness);
|
Color.clear, m_Settings.cicleSmoothness);
|
||||||
}
|
}
|
||||||
insideRadius = outsideRadius;
|
insideRadius = outsideRadius;
|
||||||
@@ -443,23 +434,23 @@ namespace XCharts
|
|||||||
if (!IsActive(i)) continue;
|
if (!IsActive(i)) continue;
|
||||||
var serie = m_Series.GetSerie(i);
|
var serie = m_Series.GetSerie(i);
|
||||||
var radar = m_Radars[serie.radarIndex];
|
var radar = m_Radars[serie.radarIndex];
|
||||||
var dist = Vector2.Distance(radar.centerPos, local);
|
var dist = Vector2.Distance(radar.runtimeCenterPos, local);
|
||||||
if (dist > radar.actualRadius + serie.symbol.size)
|
if (dist > radar.runtimeRadius + serie.symbol.size)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int n = 0; n < serie.data.Count; n++)
|
for (int n = 0; n < serie.data.Count; n++)
|
||||||
{
|
{
|
||||||
var posKey = i * 100 + n;
|
var posKey = i * 100 + n;
|
||||||
if (radar.dataPosList.ContainsKey(posKey))
|
if (radar.runtimeDataPosList.ContainsKey(posKey))
|
||||||
{
|
{
|
||||||
var posList = radar.dataPosList[posKey];
|
var posList = radar.runtimeDataPosList[posKey];
|
||||||
foreach (var pos in posList)
|
foreach (var pos in posList)
|
||||||
{
|
{
|
||||||
if (Vector2.Distance(pos, local) <= serie.symbol.size * 1.2f)
|
if (Vector2.Distance(pos, local) <= serie.symbol.size * 1.2f)
|
||||||
{
|
{
|
||||||
m_Tooltip.dataIndex[0] = i;
|
m_Tooltip.runtimeDataIndex[0] = i;
|
||||||
m_Tooltip.dataIndex[1] = n;
|
m_Tooltip.runtimeDataIndex[1] = n;
|
||||||
highlight = true;
|
highlight = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -487,7 +478,7 @@ namespace XCharts
|
|||||||
protected override void RefreshTooltip()
|
protected override void RefreshTooltip()
|
||||||
{
|
{
|
||||||
base.RefreshTooltip();
|
base.RefreshTooltip();
|
||||||
int serieIndex = m_Tooltip.dataIndex[0];
|
int serieIndex = m_Tooltip.runtimeDataIndex[0];
|
||||||
if (serieIndex < 0)
|
if (serieIndex < 0)
|
||||||
{
|
{
|
||||||
if (m_Tooltip.IsActive())
|
if (m_Tooltip.IsActive())
|
||||||
@@ -500,24 +491,24 @@ namespace XCharts
|
|||||||
m_Tooltip.SetActive(true);
|
m_Tooltip.SetActive(true);
|
||||||
var serie = m_Series.GetSerie(serieIndex);
|
var serie = m_Series.GetSerie(serieIndex);
|
||||||
var radar = m_Radars[serie.radarIndex];
|
var radar = m_Radars[serie.radarIndex];
|
||||||
var serieData = serie.GetSerieData(m_Tooltip.dataIndex[1]);
|
var serieData = serie.GetSerieData(m_Tooltip.runtimeDataIndex[1]);
|
||||||
StringBuilder sb = new StringBuilder(serieData.name);
|
StringBuilder sb = new StringBuilder(serieData.name);
|
||||||
for (int i = 0; i < radar.indicatorList.Count; i++)
|
for (int i = 0; i < radar.indicatorList.Count; i++)
|
||||||
{
|
{
|
||||||
string key = radar.indicatorList[i].name;
|
string key = radar.indicatorList[i].name;
|
||||||
float value = serieData.GetData(i);
|
float value = serieData.GetData(i);
|
||||||
sb.Append("\n");
|
if ((i == 0 && !string.IsNullOrEmpty(serieData.name)) || i > 0) sb.Append("\n");
|
||||||
sb.AppendFormat("{0}: {1}", key, value);
|
sb.AppendFormat("{0}: {1}", key, ChartCached.FloatToStr(value, 0, m_Tooltip.forceENotation));
|
||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentText(sb.ToString());
|
m_Tooltip.UpdateContentText(sb.ToString());
|
||||||
var pos = m_Tooltip.GetContentPos();
|
var pos = m_Tooltip.GetContentPos();
|
||||||
if (pos.x + m_Tooltip.width > chartWidth)
|
if (pos.x + m_Tooltip.runtimeWidth > chartWidth)
|
||||||
{
|
{
|
||||||
pos.x = chartWidth - m_Tooltip.width;
|
pos.x = chartWidth - m_Tooltip.runtimeWidth;
|
||||||
}
|
}
|
||||||
if (pos.y - m_Tooltip.height < 0)
|
if (pos.y - m_Tooltip.runtimeHeight < 0)
|
||||||
{
|
{
|
||||||
pos.y = m_Tooltip.height;
|
pos.y = m_Tooltip.runtimeHeight;
|
||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentPos(pos);
|
m_Tooltip.UpdateContentPos(pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,31 +13,55 @@ namespace XCharts
|
|||||||
public static class ChartCached
|
public static class ChartCached
|
||||||
{
|
{
|
||||||
private static Dictionary<float, string> s_ValueToF1Str = new Dictionary<float, string>(1000);
|
private static Dictionary<float, string> s_ValueToF1Str = new Dictionary<float, string>(1000);
|
||||||
|
private static Dictionary<float, string> s_ValueToE1Str = new Dictionary<float, string>(1000);
|
||||||
private static Dictionary<float, string> s_ValueToF2Str = new Dictionary<float, string>(1000);
|
private static Dictionary<float, string> s_ValueToF2Str = new Dictionary<float, string>(1000);
|
||||||
private static Dictionary<float, string> s_ValueToStr = new Dictionary<float, string>(1000);
|
private static Dictionary<float, string> s_ValueToE2Str = new Dictionary<float, string>(1000);
|
||||||
|
private static Dictionary<float, string> s_ValueToFnStr = new Dictionary<float, string>(1000);
|
||||||
|
private static Dictionary<float, string> s_ValueToEnStr = new Dictionary<float, string>(1000);
|
||||||
|
private static Dictionary<float, string> s_ValueToFStr = new Dictionary<float, string>(1000);
|
||||||
|
private static Dictionary<float, string> s_ValueToEStr = new Dictionary<float, string>(1000);
|
||||||
private static Dictionary<int, string> s_IntToStr = new Dictionary<int, string>(1000);
|
private static Dictionary<int, string> s_IntToStr = new Dictionary<int, string>(1000);
|
||||||
|
private static Dictionary<int, string> s_IntToFn = new Dictionary<int, string>(20);
|
||||||
private static Dictionary<Color, string> s_ColorToStr = new Dictionary<Color, string>(1000);
|
private static Dictionary<Color, string> s_ColorToStr = new Dictionary<Color, string>(1000);
|
||||||
|
private static Dictionary<int, string> s_SerieLabelName = new Dictionary<int, string>(1000);
|
||||||
|
private static Dictionary<int, string> s_AxisLabelName = new Dictionary<int, string>(1000);
|
||||||
|
|
||||||
public static string FloatToStr(float value, int f = 0)
|
|
||||||
|
|
||||||
|
public static string FloatToStr(float value, int f = 0, bool forceE = false)
|
||||||
{
|
{
|
||||||
if (f > 2) f = 2;
|
|
||||||
Dictionary<float, string> valueDic;
|
Dictionary<float, string> valueDic;
|
||||||
if (f == 1) valueDic = s_ValueToF1Str;
|
if (f == 0) valueDic = forceE ? s_ValueToEStr : s_ValueToFStr;
|
||||||
else if (f == 2) valueDic = s_ValueToF2Str;
|
if (f == 1) valueDic = forceE ? s_ValueToE1Str : s_ValueToF1Str;
|
||||||
else valueDic = s_ValueToStr;
|
else if (f == 2) valueDic = forceE ? s_ValueToE2Str : s_ValueToF2Str;
|
||||||
|
else valueDic = forceE ? s_ValueToEnStr : s_ValueToFnStr;
|
||||||
if (valueDic.ContainsKey(value))
|
if (valueDic.ContainsKey(value))
|
||||||
{
|
{
|
||||||
return valueDic[value];
|
return valueDic[value];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (f == 1) valueDic[value] = value.ToString("f1");
|
if (f == 0) valueDic[value] = forceE ? value.ToString("E0") : value.ToString();
|
||||||
else if (f == 2) valueDic[value] = value.ToString("f2");
|
else if (f == 1) valueDic[value] = forceE ? value.ToString("E1") : value.ToString("f1");
|
||||||
else valueDic[value] = value.ToString();
|
else if (f == 2) valueDic[value] = forceE ? value.ToString("E2") : value.ToString("f2");
|
||||||
|
else valueDic[value] = (f > 3 || forceE) ? value.ToString("E0") : value.ToString(GetFn(f));
|
||||||
return valueDic[value];
|
return valueDic[value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetFn(int f)
|
||||||
|
{
|
||||||
|
if (s_IntToFn.ContainsKey(f))
|
||||||
|
{
|
||||||
|
return s_IntToFn[f];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s_IntToFn[f] = "f" + f;
|
||||||
|
return s_IntToFn[f];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string IntToStr(int value)
|
public static string IntToStr(int value)
|
||||||
{
|
{
|
||||||
if (s_IntToStr.ContainsKey(value))
|
if (s_IntToStr.ContainsKey(value))
|
||||||
@@ -63,5 +87,35 @@ namespace XCharts
|
|||||||
return s_ColorToStr[color];
|
return s_ColorToStr[color];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static string GetSerieLabelName(string prefix, int i, int j)
|
||||||
|
{
|
||||||
|
int key = i * 10000000 + j;
|
||||||
|
if (s_SerieLabelName.ContainsKey(key))
|
||||||
|
{
|
||||||
|
return s_SerieLabelName[key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string name = prefix + "_" + i + "_" + j;
|
||||||
|
s_SerieLabelName[key] = name;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string GetAxisLabelName(string prefix, bool isYAxis, int axisIndex, int i)
|
||||||
|
{
|
||||||
|
int key = (isYAxis ? 2 : 1) * 1000000 + (axisIndex + 1) * 100000 + i;
|
||||||
|
if (s_AxisLabelName.ContainsKey(key))
|
||||||
|
{
|
||||||
|
return s_AxisLabelName[key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string name = prefix + "_" + axisIndex + "_" + i;
|
||||||
|
s_AxisLabelName[key] = name;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,9 @@ using System.Text.RegularExpressions;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace XCharts
|
namespace XCharts
|
||||||
{
|
{
|
||||||
@@ -19,6 +22,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
private static StringBuilder s_Builder = new StringBuilder();
|
private static StringBuilder s_Builder = new StringBuilder();
|
||||||
|
|
||||||
|
public static StringBuilder sb { get { return s_Builder; } }
|
||||||
public static string Cancat(string str1, string str2)
|
public static string Cancat(string str1, string str2)
|
||||||
{
|
{
|
||||||
s_Builder.Length = 0;
|
s_Builder.Length = 0;
|
||||||
@@ -38,6 +42,18 @@ namespace XCharts
|
|||||||
SetActive(gameObject.transform, active);
|
SetActive(gameObject.transform, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetActive(Image image, bool active)
|
||||||
|
{
|
||||||
|
if (image == null) return;
|
||||||
|
SetActive(image.gameObject, active);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetActive(Text text, bool active)
|
||||||
|
{
|
||||||
|
if (text == null) return;
|
||||||
|
SetActive(text.gameObject, active);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过设置scale实现是否显示,优化性能,减少GC
|
/// 通过设置scale实现是否显示,优化性能,减少GC
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -72,13 +88,22 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DestoryAllChilds(Transform parent)
|
public static void DestroyAllChildren(Transform parent)
|
||||||
{
|
{
|
||||||
|
if (parent == null) return;
|
||||||
|
#if UNITY_EDITOR && UNITY_2018_3_OR_NEWER
|
||||||
|
if (PrefabUtility.IsPartOfAnyPrefab(parent.gameObject))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (parent.childCount > 0)
|
while (parent.childCount > 0)
|
||||||
{
|
{
|
||||||
var go = parent.GetChild(0);
|
var go = parent.GetChild(0);
|
||||||
if (go.childCount > 0) DestoryAllChilds(go);
|
if (go != null)
|
||||||
else GameObject.DestroyImmediate(go.gameObject);
|
{
|
||||||
|
GameObject.DestroyImmediate(go.gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,15 +169,13 @@ namespace XCharts
|
|||||||
Text txt = GetOrAddComponent<Text>(txtObj);
|
Text txt = GetOrAddComponent<Text>(txtObj);
|
||||||
txt.font = font;
|
txt.font = font;
|
||||||
txt.fontSize = fontSize;
|
txt.fontSize = fontSize;
|
||||||
|
txt.fontStyle = fontStyle;
|
||||||
txt.text = "Text";
|
txt.text = "Text";
|
||||||
txt.alignment = anchor;
|
txt.alignment = anchor;
|
||||||
txt.horizontalOverflow = HorizontalWrapMode.Overflow;
|
txt.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
txt.verticalOverflow = VerticalWrapMode.Overflow;
|
txt.verticalOverflow = VerticalWrapMode.Overflow;
|
||||||
txt.color = color;
|
txt.color = color;
|
||||||
if (rotate > 0)
|
txtObj.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
||||||
{
|
|
||||||
txtObj.transform.localEulerAngles = new Vector3(0, 0, rotate);
|
|
||||||
}
|
|
||||||
|
|
||||||
RectTransform rect = GetOrAddComponent<RectTransform>(txtObj);
|
RectTransform rect = GetOrAddComponent<RectTransform>(txtObj);
|
||||||
rect.localPosition = Vector3.zero;
|
rect.localPosition = Vector3.zero;
|
||||||
@@ -178,7 +201,7 @@ namespace XCharts
|
|||||||
return btnObj.GetComponent<Button>();
|
return btnObj.GetComponent<Button>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject AddTooltipContent(string name, Transform parent, Font font, int fontSize, FontStyle fontStyle)
|
internal static GameObject AddTooltipContent(string name, Transform parent, Font font, int fontSize, FontStyle fontStyle)
|
||||||
{
|
{
|
||||||
var anchorMax = new Vector2(0, 1);
|
var anchorMax = new Vector2(0, 1);
|
||||||
var anchorMin = new Vector2(0, 1);
|
var anchorMin = new Vector2(0, 1);
|
||||||
@@ -206,7 +229,7 @@ namespace XCharts
|
|||||||
return iconObj;
|
return iconObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject AddSerieLabel(string name, Transform parent, Font font, Color textColor, Color backgroundColor,
|
internal static GameObject AddSerieLabel(string name, Transform parent, Font font, Color textColor, Color backgroundColor,
|
||||||
int fontSize, FontStyle fontStyle, float rotate, float width, float height)
|
int fontSize, FontStyle fontStyle, float rotate, float width, float height)
|
||||||
{
|
{
|
||||||
var anchorMin = new Vector2(0.5f, 0.5f);
|
var anchorMin = new Vector2(0.5f, 0.5f);
|
||||||
@@ -226,7 +249,7 @@ namespace XCharts
|
|||||||
return labelObj;
|
return labelObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject AddTooltipLabel(string name, Transform parent, Font font, Vector2 pivot)
|
internal static GameObject AddTooltipLabel(string name, Transform parent, Font font, Vector2 pivot)
|
||||||
{
|
{
|
||||||
var anchorMax = new Vector2(0, 0);
|
var anchorMax = new Vector2(0, 0);
|
||||||
var anchorMin = new Vector2(0, 0);
|
var anchorMin = new Vector2(0, 0);
|
||||||
@@ -347,6 +370,16 @@ namespace XCharts
|
|||||||
color1.r == color2.r;
|
color1.r == color2.r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsValueEqualsVector2(Vector2 v1, Vector2 v2)
|
||||||
|
{
|
||||||
|
return v1.x == v2.x && v1.y == v2.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsValueEqualsVector3(Vector3 v1, Vector3 v2)
|
||||||
|
{
|
||||||
|
return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsValueEqualsList<T>(List<T> list1, List<T> list2)
|
public static bool IsValueEqualsList<T>(List<T> list1, List<T> list2)
|
||||||
{
|
{
|
||||||
if (list1 == null || list2 == null) return false;
|
if (list1 == null || list2 == null) return false;
|
||||||
@@ -383,7 +416,6 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> ParseStringFromString(string jsonData)
|
public static List<string> ParseStringFromString(string jsonData)
|
||||||
@@ -409,9 +441,21 @@ namespace XCharts
|
|||||||
return (Color32)color;
|
return (Color32)color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetMaxDivisibleValue(float max)
|
public static float GetMaxDivisibleValue(float max)
|
||||||
{
|
{
|
||||||
if (max == 0) return 0;
|
if (max == 0) return 0;
|
||||||
|
if (max > -1 && max < 1)
|
||||||
|
{
|
||||||
|
int count = 1;
|
||||||
|
int intvalue = (int)(max * Mathf.Pow(10, count));
|
||||||
|
while (intvalue == 0 && count < 12)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
intvalue = (int)(max * Mathf.Pow(10, count));
|
||||||
|
}
|
||||||
|
if (max > 0) return 1 / Mathf.Pow(10, count - 1);
|
||||||
|
else return -1 / Mathf.Pow(10, count);
|
||||||
|
}
|
||||||
int bigger = Mathf.CeilToInt(Mathf.Abs(max));
|
int bigger = Mathf.CeilToInt(Mathf.Abs(max));
|
||||||
int n = 1;
|
int n = 1;
|
||||||
while (bigger / (Mathf.Pow(10, n)) > 10)
|
while (bigger / (Mathf.Pow(10, n)) > 10)
|
||||||
@@ -428,9 +472,21 @@ namespace XCharts
|
|||||||
else return Mathf.CeilToInt(mm);
|
else return Mathf.CeilToInt(mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetMinDivisibleValue(float min)
|
public static float GetMinDivisibleValue(float min)
|
||||||
{
|
{
|
||||||
if (min == 0) return 0;
|
if (min == 0) return 0;
|
||||||
|
if (min > -1 && min < 1)
|
||||||
|
{
|
||||||
|
int count = 1;
|
||||||
|
int intvalue = (int)(min * Mathf.Pow(10, count));
|
||||||
|
while (intvalue == 0 && count < 12)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
intvalue = (int)(min * Mathf.Pow(10, count));
|
||||||
|
}
|
||||||
|
if (min > 0) return 1 / Mathf.Pow(10, count);
|
||||||
|
else return -1 / Mathf.Pow(10, count - 1);
|
||||||
|
}
|
||||||
int bigger = Mathf.FloorToInt(Mathf.Abs(min));
|
int bigger = Mathf.FloorToInt(Mathf.Abs(min));
|
||||||
int n = 1;
|
int n = 1;
|
||||||
while (bigger / (Mathf.Pow(10, n)) > 10)
|
while (bigger / (Mathf.Pow(10, n)) > 10)
|
||||||
@@ -447,6 +503,60 @@ namespace XCharts
|
|||||||
else return Mathf.FloorToInt(mm);
|
else return Mathf.FloorToInt(mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float GetMaxLogValue(float value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||||
|
{
|
||||||
|
splitNumber = 0;
|
||||||
|
if (value <= 0) return 0;
|
||||||
|
float max = 0;
|
||||||
|
while (max < value)
|
||||||
|
{
|
||||||
|
if (isLogBaseE)
|
||||||
|
{
|
||||||
|
max = Mathf.Exp(splitNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
max = Mathf.Pow(logBase, splitNumber);
|
||||||
|
}
|
||||||
|
splitNumber++;
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float GetMinLogValue(float value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||||
|
{
|
||||||
|
splitNumber = 0;
|
||||||
|
if (value > 1) return 1;
|
||||||
|
float min = 1;
|
||||||
|
while (splitNumber < 12 && min > value)
|
||||||
|
{
|
||||||
|
if (isLogBaseE)
|
||||||
|
{
|
||||||
|
min = Mathf.Exp(-splitNumber);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
min = Mathf.Pow(logBase, -splitNumber);
|
||||||
|
}
|
||||||
|
splitNumber++;
|
||||||
|
}
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetFloatAccuracy(float value)
|
||||||
|
{
|
||||||
|
if (value > 1 || value < -1) return 0;
|
||||||
|
int count = 1;
|
||||||
|
int intvalue = (int)(value * Mathf.Pow(10, count));
|
||||||
|
while (intvalue == 0 && count < 12)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
intvalue = (int)(value * Mathf.Pow(10, count));
|
||||||
|
}
|
||||||
|
if (count == 12 && (value == 0 || value == 1)) return 1;
|
||||||
|
else return count;
|
||||||
|
}
|
||||||
|
|
||||||
public static void AddEventListener(GameObject obj, EventTriggerType type,
|
public static void AddEventListener(GameObject obj, EventTriggerType type,
|
||||||
UnityEngine.Events.UnityAction<BaseEventData> call)
|
UnityEngine.Events.UnityAction<BaseEventData> call)
|
||||||
{
|
{
|
||||||
@@ -539,5 +649,13 @@ namespace XCharts
|
|||||||
Vector3 resultVec3 = center + point;
|
Vector3 resultVec3 = center + point;
|
||||||
return resultVec3;
|
return resultVec3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector3 GetPosition(Vector3 center, float angle, float radius)
|
||||||
|
{
|
||||||
|
var rad = angle * Mathf.Deg2Rad;
|
||||||
|
var px = Mathf.Sin(rad) * radius;
|
||||||
|
var py = Mathf.Cos(rad) * radius;
|
||||||
|
return center + new Vector3(px, py);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/******************************************/
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) 2018 monitor1394 */
|
||||||
|
/* https://github.com/monitor1394 */
|
||||||
|
/* */
|
||||||
|
/******************************************/
|
||||||
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@@ -17,8 +24,8 @@ namespace XCharts
|
|||||||
|
|
||||||
public class XChartsMgr : MonoBehaviour
|
public class XChartsMgr : MonoBehaviour
|
||||||
{
|
{
|
||||||
public const string version = "1.0.0";
|
public const string version = "1.2.0";
|
||||||
public const int date = 20191023;
|
public const int date = 20200115;
|
||||||
|
|
||||||
[SerializeField] private string m_NowVersion;
|
[SerializeField] private string m_NowVersion;
|
||||||
[SerializeField] private string m_NewVersion;
|
[SerializeField] private string m_NewVersion;
|
||||||
@@ -36,7 +43,10 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
go = new GameObject();
|
go = new GameObject();
|
||||||
go.name = "_xcharts_";
|
go.name = "_xcharts_";
|
||||||
DontDestroyOnLoad(go);
|
if (Application.isPlaying)
|
||||||
|
{
|
||||||
|
DontDestroyOnLoad(go);
|
||||||
|
}
|
||||||
m_XCharts = go.AddComponent<XChartsMgr>();
|
m_XCharts = go.AddComponent<XChartsMgr>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -55,6 +65,10 @@ namespace XCharts
|
|||||||
|
|
||||||
private XChartsMgr() { }
|
private XChartsMgr() { }
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
SerieLabelPool.ClearAll();
|
||||||
|
}
|
||||||
|
|
||||||
public string changeLog { get; private set; }
|
public string changeLog { get; private set; }
|
||||||
public string newVersion { get { return m_NewVersion; } }
|
public string newVersion { get { return m_NewVersion; } }
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user