mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 20:28:46 +00:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce11222784 | ||
|
|
87059b2e7f | ||
|
|
4e7bcceda3 | ||
|
|
c4f95d3c4f | ||
|
|
892b84829d | ||
|
|
519063e5e0 | ||
|
|
9dea742254 | ||
|
|
5b9652e48d | ||
|
|
02915db85b | ||
|
|
db36d68788 | ||
|
|
0dbc2e1c5c | ||
|
|
4c27359cc0 | ||
|
|
44ebca4a39 | ||
|
|
c7272f1817 | ||
|
|
4898b0060f | ||
|
|
3147eb156e | ||
|
|
6f8017f0bf | ||
|
|
7e6d7d72d7 |
@@ -1,7 +1,17 @@
|
|||||||
|
|
||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
* (2019.11.17) 发布`v1.1.0`版本
|
* (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.16) 修复`Overlay`模式下不显示`Tooltip`的问题
|
||||||
* (2019.12.15) 增加`Title`的`TextStyle`支持
|
* (2019.12.15) 增加`Title`的`TextStyle`支持
|
||||||
* (2019.12.11) 修复`Legend`都隐藏时`Value轴`还显示数值的问题
|
* (2019.12.11) 修复`Legend`都隐藏时`Value轴`还显示数值的问题
|
||||||
|
|||||||
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,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5420ab107823641e49c2df9e3556ea30
|
guid: cb56350d2a2b24960a7174a1d3f2ea56
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
## `BaseChart`
|
## `BaseChart`
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
* `BaseChart.themeInfo`:主题组件`ThemeInfo`。
|
* `BaseChart.themeInfo`:主题组件`ThemeInfo`。
|
||||||
* `BaseChart.title`:标题组件`Title`。
|
* `BaseChart.title`:标题组件`Title`。
|
||||||
* `BaseChart.legend`:图例组件`Legend`。
|
* `BaseChart.legend`:图例组件`Legend`。
|
||||||
@@ -51,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`。
|
||||||
@@ -74,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)
|
||||||
|
|
||||||
|
|||||||
@@ -175,11 +175,13 @@
|
|||||||
* `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` 优先级高。
|
||||||
@@ -219,6 +221,7 @@
|
|||||||
* `scrollSensitivity`:缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
* `scrollSensitivity`:缩放区域组件的敏感度。值越高每次缩放所代表的数据越多。
|
||||||
* `fontSize`:字体大小。
|
* `fontSize`:字体大小。
|
||||||
* `fontStyle`:字体样式。
|
* `fontStyle`:字体样式。
|
||||||
|
* `minShowNum`:最小显示数据个数。当DataZoom放大到最大时,最小显示的数据个数。
|
||||||
|
|
||||||
## `VisualMap`
|
## `VisualMap`
|
||||||
|
|
||||||
@@ -287,9 +290,12 @@
|
|||||||
相关参数:
|
相关参数:
|
||||||
|
|
||||||
* `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`:最小值-最大值。
|
||||||
@@ -624,7 +630,7 @@
|
|||||||
* `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时才采用科学计数法。
|
* `forceENotation`:是否强制使用科学计数法格式化显示数值。默认为false,当小数精度大于3时才采用科学计数法。
|
||||||
|
|
||||||
## `AxisLine`
|
## `AxisLine`
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ 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");
|
||||||
@@ -38,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);
|
||||||
@@ -58,7 +64,7 @@ namespace XCharts
|
|||||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||||
{
|
{
|
||||||
if (m_TooltipModuleToggle)
|
if (m_TooltipModuleToggle)
|
||||||
return 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
return 12 * EditorGUIUtility.singleLineHeight + 11 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
else
|
else
|
||||||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -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>
|
||||||
@@ -103,6 +108,8 @@ namespace XCharts
|
|||||||
[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;
|
||||||
@@ -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时超过指定值会移除旧数据再插入新数据。
|
||||||
@@ -264,9 +280,12 @@ namespace XCharts
|
|||||||
/// 坐标轴原点在Y轴的偏移。
|
/// 坐标轴原点在Y轴的偏移。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float runtimeZeroYOffset { get; internal 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;
|
||||||
@@ -311,7 +330,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前坐标轴是否时类目轴
|
/// 是否为类目轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsCategory()
|
public bool IsCategory()
|
||||||
@@ -320,7 +339,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前坐标轴是否时数值轴
|
/// 是否为数值轴。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool IsValue()
|
public bool IsValue()
|
||||||
@@ -328,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>
|
||||||
@@ -389,15 +417,27 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
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
|
||||||
{
|
{
|
||||||
@@ -434,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)
|
||||||
@@ -493,6 +537,7 @@ namespace XCharts
|
|||||||
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;
|
if (minValue == 0 && maxValue == 0) return string.Empty;
|
||||||
@@ -510,6 +555,12 @@ namespace XCharts
|
|||||||
if (forcePercent) return string.Format("{0}%", (int)value);
|
if (forcePercent) return string.Format("{0}%", (int)value);
|
||||||
else return m_AxisLabel.GetFormatterContent(value, minValue, maxValue);
|
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;
|
||||||
if (dataCount <= 0) return "";
|
if (dataCount <= 0) return "";
|
||||||
@@ -536,7 +587,7 @@ namespace XCharts
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal 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;
|
||||||
@@ -647,6 +698,15 @@ namespace XCharts
|
|||||||
/// <param name="maxValue"></param>
|
/// <param name="maxValue"></param>
|
||||||
internal void AdjustMinMaxValue(ref float minValue, ref float maxValue, bool needFormat)
|
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)
|
||||||
@@ -736,6 +796,12 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -417,5 +417,31 @@ namespace XCharts
|
|||||||
var y = runtimeCenterPos.y + (runtimeRadius + indicatorGap) * Mathf.Cos(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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,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>>();
|
||||||
@@ -731,7 +732,6 @@ namespace XCharts
|
|||||||
var serieData = new SerieData()
|
var serieData = new SerieData()
|
||||||
{
|
{
|
||||||
data = new List<float>() { xValue, value },
|
data = new List<float>() { xValue, value },
|
||||||
lastData = new List<float>() { xValue, value },
|
|
||||||
name = dataName
|
name = dataName
|
||||||
};
|
};
|
||||||
serieData.index = xValue;
|
serieData.index = xValue;
|
||||||
@@ -760,7 +760,6 @@ namespace XCharts
|
|||||||
var serieData = new SerieData()
|
var serieData = new SerieData()
|
||||||
{
|
{
|
||||||
data = new List<float>() { xValue, yValue },
|
data = new List<float>() { xValue, yValue },
|
||||||
lastData = new List<float>() { xValue, yValue },
|
|
||||||
name = dataName
|
name = dataName
|
||||||
};
|
};
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
@@ -804,7 +803,6 @@ namespace XCharts
|
|||||||
for (int i = 0; i < valueList.Count; i++)
|
for (int i = 0; i < valueList.Count; i++)
|
||||||
{
|
{
|
||||||
serieData.data.Add(valueList[i]);
|
serieData.data.Add(valueList[i]);
|
||||||
serieData.lastData.Add(valueList[i]);
|
|
||||||
}
|
}
|
||||||
m_Data.Add(serieData);
|
m_Data.Add(serieData);
|
||||||
return serieData;
|
return serieData;
|
||||||
@@ -968,15 +966,28 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
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
|
||||||
{
|
{
|
||||||
@@ -1041,9 +1052,9 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (index >= 0 && index < m_Data.Count && values != null)
|
if (index >= 0 && index < m_Data.Count && values != null)
|
||||||
{
|
{
|
||||||
var list = m_Data[index].data;
|
var serieData = m_Data[index];
|
||||||
list.Clear();
|
for (int i = 0; i < values.Count; i++)
|
||||||
foreach (var v in values) list.Add(v);
|
serieData.UpdateData(i, values[i]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -452,7 +452,8 @@ namespace XCharts
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateData(string serieName,int dataIndex,List<float> values){
|
public bool UpdateData(string serieName, int dataIndex, List<float> values)
|
||||||
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
@@ -460,7 +461,8 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public bool UpdateData(int serieIndex,int dataIndex,List<float> values){
|
public bool UpdateData(int serieIndex, int dataIndex, List<float> values)
|
||||||
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
@@ -746,16 +748,8 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (max > 1)
|
minVaule = min > 1 ? Mathf.FloorToInt(min) : min;
|
||||||
{
|
maxValue = max > 1 ? Mathf.CeilToInt(max) : max;
|
||||||
minVaule = Mathf.FloorToInt(min);
|
|
||||||
maxValue = Mathf.CeilToInt(max);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
minVaule = min;
|
|
||||||
maxValue = max;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ 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;
|
||||||
@@ -75,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">
|
||||||
@@ -84,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>
|
||||||
@@ -341,11 +368,68 @@ namespace XCharts
|
|||||||
return runtimeDataIndex[0] == index || runtimeDataIndex[1] == index;
|
return runtimeDataIndex[0] == index || runtimeDataIndex[1] == index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsNoFormatter()
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(m_Formatter) && string.IsNullOrEmpty(m_ItemFormatter);
|
||||||
|
}
|
||||||
|
|
||||||
internal string GetFormatterContent(int dataIndex, Series series, string category, DataZoom dataZoom = null)
|
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
|
||||||
{
|
{
|
||||||
@@ -357,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), 0, m_ForceENotation));
|
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), 0, m_ForceENotation));
|
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");
|
||||||
|
|||||||
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:
|
||||||
@@ -71,7 +71,7 @@ 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>
|
/// <summary>
|
||||||
@@ -146,10 +146,17 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatterContent(float value, float minValue, float maxValue)
|
public string GetFormatterContent(float value, float minValue, float maxValue, bool isLog = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(m_Formatter))
|
if (string.IsNullOrEmpty(m_Formatter))
|
||||||
{
|
{
|
||||||
|
if (isLog)
|
||||||
|
{
|
||||||
|
if (value - (int)value == 0)
|
||||||
|
return ChartCached.IntToStr((int)value);
|
||||||
|
else
|
||||||
|
return ChartCached.FloatToStr(value);
|
||||||
|
}
|
||||||
if (minValue >= -1 && minValue <= 1 && maxValue >= -1 && maxValue <= 1)
|
if (minValue >= -1 && minValue <= 1 && maxValue >= -1 && maxValue <= 1)
|
||||||
{
|
{
|
||||||
int minAcc = ChartHelper.GetFloatAccuracy(minValue);
|
int minAcc = ChartHelper.GetFloatAccuracy(minValue);
|
||||||
@@ -166,6 +173,8 @@ namespace XCharts
|
|||||||
else if (m_Formatter.Contains("{value"))
|
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}"))
|
||||||
@@ -173,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));
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ namespace XCharts
|
|||||||
private List<float> m_LastData = new List<float>();
|
private List<float> m_LastData = new List<float>();
|
||||||
private List<float> m_DataUpdateTime = new List<float>();
|
private List<float> m_DataUpdateTime = new List<float>();
|
||||||
private List<bool> m_DataUpdateFlag = new List<bool>();
|
private List<bool> m_DataUpdateFlag = new List<bool>();
|
||||||
public List<float> lastData { get { return m_LastData; } internal set { m_LastData = value; } }
|
|
||||||
|
|
||||||
public float GetData(int index)
|
public float GetData(int index)
|
||||||
{
|
{
|
||||||
@@ -169,7 +168,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public float GetLastData(int index)
|
public float GetLastData(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < lastData.Count)
|
if (index >= 0 && index < m_LastData.Count)
|
||||||
{
|
{
|
||||||
return m_LastData[index];
|
return m_LastData[index];
|
||||||
}
|
}
|
||||||
@@ -219,6 +218,8 @@ namespace XCharts
|
|||||||
if (m_LastData.Count != m_Data.Count)
|
if (m_LastData.Count != m_Data.Count)
|
||||||
{
|
{
|
||||||
m_LastData.Clear();
|
m_LastData.Clear();
|
||||||
|
m_DataUpdateTime.Clear();
|
||||||
|
m_DataUpdateFlag.Clear();
|
||||||
for (int i = 0; i < m_Data.Count; i++)
|
for (int i = 0; i < m_Data.Count; i++)
|
||||||
{
|
{
|
||||||
m_LastData.Add(m_Data[i]);
|
m_LastData.Add(m_Data[i]);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ 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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -300,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)
|
||||||
@@ -909,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].runtimeZeroXOffset;
|
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))
|
||||||
@@ -925,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -963,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].runtimeZeroYOffset;
|
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))
|
||||||
@@ -979,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,24 +310,52 @@ namespace XCharts
|
|||||||
float xMaxValue = xAxis.GetCurrMaxValue(duration);
|
float xMaxValue = xAxis.GetCurrMaxValue(duration);
|
||||||
float yMinValue = yAxis.GetCurrMinValue(duration);
|
float yMinValue = yAxis.GetCurrMinValue(duration);
|
||||||
float yMaxValue = yAxis.GetCurrMaxValue(duration);
|
float yMaxValue = yAxis.GetCurrMaxValue(duration);
|
||||||
if (xAxis.IsValue())
|
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 ((xMaxValue - xMinValue) <= 0) xDataHig = 0;
|
if (xAxis.IsLog())
|
||||||
else xDataHig = (xValue - xMinValue) / (xMaxValue - xMinValue) * coordinateWidth;
|
{
|
||||||
if ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
int minIndex = xAxis.runtimeMinLogIndex;
|
||||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * 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 ((yMaxValue - yMinValue) <= 0) yDataHig = 0;
|
if (yAxis.IsLog())
|
||||||
else yDataHig = (yValue - yMinValue) / (yMaxValue - yMinValue) * 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;
|
||||||
}
|
}
|
||||||
@@ -381,7 +409,17 @@ namespace XCharts
|
|||||||
float value = showData[i].GetCurrData(1, updateDuration);
|
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 - xMinValue) / (xMaxValue - xMinValue) * 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;
|
||||||
@@ -398,7 +436,17 @@ namespace XCharts
|
|||||||
float value = showData[i].GetCurrData(1, updateDuration);
|
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 - xMinValue) / (xMaxValue - xMinValue) * 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;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace XCharts
|
|||||||
private Text m_LabelText;
|
private Text m_LabelText;
|
||||||
private RectTransform m_LabelRect;
|
private RectTransform m_LabelRect;
|
||||||
private Image m_IconImage;
|
private Image m_IconImage;
|
||||||
private RectTransform m_IconRect;
|
// private RectTransform m_IconRect;
|
||||||
|
|
||||||
public Image icon { get { return m_IconImage; } }
|
public Image icon { get { return m_IconImage; } }
|
||||||
public Text label { get { return m_LabelText; } }
|
public Text label { get { return m_LabelText; } }
|
||||||
@@ -43,7 +43,7 @@ namespace XCharts
|
|||||||
m_IconImage = image;
|
m_IconImage = image;
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
m_IconRect = m_IconImage.GetComponent<RectTransform>();
|
// m_IconRect = m_IconImage.GetComponent<RectTransform>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ namespace XCharts
|
|||||||
int index = m_Tooltip.runtimeDataIndex[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);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ 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";
|
||||||
|
|
||||||
@@ -24,21 +24,6 @@ namespace XCharts
|
|||||||
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 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);
|
||||||
@@ -512,7 +497,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
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, ChartCached.FloatToStr(value, 0, m_Tooltip.forceENotation));
|
sb.AppendFormat("{0}: {1}", key, ChartCached.FloatToStr(value, 0, m_Tooltip.forceENotation));
|
||||||
}
|
}
|
||||||
m_Tooltip.UpdateContentText(sb.ToString());
|
m_Tooltip.UpdateContentText(sb.ToString());
|
||||||
|
|||||||
@@ -22,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;
|
||||||
@@ -415,7 +416,6 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> ParseStringFromString(string jsonData)
|
public static List<string> ParseStringFromString(string jsonData)
|
||||||
@@ -503,6 +503,46 @@ 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)
|
public static int GetFloatAccuracy(float value)
|
||||||
{
|
{
|
||||||
if (value > 1 || value < -1) return 0;
|
if (value > 1 || value < -1) return 0;
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ namespace XCharts
|
|||||||
|
|
||||||
public class XChartsMgr : MonoBehaviour
|
public class XChartsMgr : MonoBehaviour
|
||||||
{
|
{
|
||||||
public const string version = "1.1.0";
|
public const string version = "1.2.0";
|
||||||
public const int date = 20191217;
|
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;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.monitor1394.xcharts",
|
"name": "com.monitor1394.xcharts",
|
||||||
"displayName": "XCharts",
|
"displayName": "XCharts",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"description": "A charting and data visualization library for Unity.",
|
"description": "A charting and data visualization library for Unity.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"date": "20191217",
|
"date": "20200115",
|
||||||
"checkdate": "20191217",
|
"checkdate": "20200115",
|
||||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||||
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
|
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
BIN
Doc/newfeature/(2019.12.21) 增加`Tooltip`的单个数据项和标题的字符串模版格式器.png
Normal file
BIN
Doc/newfeature/(2019.12.21) 增加`Tooltip`的单个数据项和标题的字符串模版格式器.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
BIN
Doc/newfeature/(2020.01.15) 增加`AxisLabel`格式化为整数的支持.png
Normal file
BIN
Doc/newfeature/(2020.01.15) 增加`AxisLabel`格式化为整数的支持.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
BIN
Doc/newfeature/(2020.01.15) 增加折线图对数轴`Log`的支持.png
Normal file
BIN
Doc/newfeature/(2020.01.15) 增加折线图对数轴`Log`的支持.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Reference in New Issue
Block a user