mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 11:40:13 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2e790561e | ||
|
|
f0e94d35b6 | ||
|
|
76f640f64d | ||
|
|
9d8dc80494 | ||
|
|
bc1d2ac095 | ||
|
|
913c8e1fb2 | ||
|
|
634bb45dc4 | ||
|
|
e4827ac262 | ||
|
|
9ad8a86ffc | ||
|
|
23a8ce52d1 | ||
|
|
38584f618b | ||
|
|
84c47e0d84 | ||
|
|
7ff1405de5 | ||
|
|
acae09bf28 | ||
|
|
b304bd2033 | ||
|
|
72c29235d8 | ||
|
|
5f18f060e3 | ||
|
|
a281028a22 | ||
|
|
fe702f3447 | ||
|
|
6888ba96e3 | ||
|
|
b261ef0573 | ||
|
|
64d0b047b3 | ||
|
|
5c395ade25 |
@@ -1,7 +1,9 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
[master](#master)
|
||||
[branch-2.0](#branch-2.0)
|
||||
[v2.6.0](#v2.6.0)
|
||||
[v2.5.0](#v2.5.0)
|
||||
[v2.4.0](#v2.4.0)
|
||||
[v2.3.0](#v2.3.0)
|
||||
[v2.2.3](#v2.2.3)
|
||||
@@ -38,7 +40,30 @@
|
||||
[v0.5.0](#v0.5.0)
|
||||
[v0.1.0](#v0.1.0)
|
||||
|
||||
## master
|
||||
## branch-2.0
|
||||
|
||||
## v2.6.0
|
||||
|
||||
* (2021.12.30) Release `v2.6.0` version
|
||||
* (2021.12.21) Fixed `Emphasis` dont work
|
||||
* (2021.12.17) Fixed `MarkLine` does not auto refresh label active when serie hide #178
|
||||
* (2021.12.10) Improved `Radar`'s `AxisLine` and `SplitLine` to be controlled separately
|
||||
* (2021.12.08) Fixed y axis does not refresh when serie hidden
|
||||
* (2021.12.04) Added `Symbol` new types: `EmptyRect`, `EmptyTriangle`, `EmptyDiamond`
|
||||
* (2021.12.04) Added setting symbol empty area color by itemStyle's backgroundColor
|
||||
* (2021.12.03) Fixed formatter `{c}` not work #175
|
||||
* (2021.12.03) Fixed axis `boundaryGap` display error in some cases #174
|
||||
* (2021.11.30) Fixed serie `ignore` display error in some cases #173
|
||||
|
||||
## v2.5.0
|
||||
|
||||
* (2021.11.27) Release `v2.5.0` version
|
||||
* (2021.11.27) Added `Tooltip` delegate function `positionFunction`
|
||||
* (2021.10.29) Removed settings for `TextMeshPro` when package first imported
|
||||
* (2021.10.29) Added support for `{e}` in `Tooltip` #170
|
||||
* (2021.09.08) Improved `RadarChart`
|
||||
* (2021.09.07) Fixed bug where `label` does not disappear at the end of `PieChart` fade animation #168
|
||||
* (2021.09.06) Fixed bug where `GaugeChart` changing `splitNumber` with code does not refresh `label` #167
|
||||
|
||||
## v2.4.0
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
[master](#master)
|
||||
[branch-2.0](#branch-2.0)
|
||||
[v2.6.0](#v2.6.0)
|
||||
[v2.5.0](#v2.5.0)
|
||||
[v2.4.0](#v2.4.0)
|
||||
[v2.3.0](#v2.3.0)
|
||||
[v2.2.3](#v2.2.3)
|
||||
@@ -38,7 +40,30 @@
|
||||
[v0.5.0](#v0.5.0)
|
||||
[v0.1.0](#v0.1.0)
|
||||
|
||||
## master
|
||||
## branch-2.0
|
||||
|
||||
## v2.6.0
|
||||
|
||||
* (2021.12.30) 发布`v2.6.0`版本
|
||||
* (2021.12.21) 修复`Emphasis`不生效的问题
|
||||
* (2021.12.17) 修复`MarkLine`在运行时`Label`不自动刷新显示隐藏的问题 #178
|
||||
* (2021.12.10) 完善`Radar`的`AxisLine`和`SplitLine`可单独控制
|
||||
* (2021.12.08) 修复`Serie`隐藏后`Y`轴最大值不刷新的问题
|
||||
* (2021.12.04) 增加`Symbol`新类型:`EmptyRect`,`EmptyTriangle`,`EmptyDiamond`
|
||||
* (2021.12.04) 增加`Symbol`的`Empty`区域颜色可通过`ItemStyle`的`backgroundColor`设置的支持
|
||||
* (2021.12.03) 修复`Formatter`的`{c}`通配符不生效的问题 #175
|
||||
* (2021.12.03) 修复`Axis`的`boundaryGap`某些情况下显示的问题 #174
|
||||
* (2021.11.30) 修复`Serie`的`ignore`某些情况下绘制异常的问题 #173
|
||||
|
||||
## v2.5.0
|
||||
|
||||
* (2021.11.27) 发布`v2.5.0`版本
|
||||
* (2021.11.27) 增加`Tooltip`的`positionFunction`的坐标设置委托函数
|
||||
* (2021.10.29) 移除`XCharts`首次导入时`TextMeshPro`的相关设置
|
||||
* (2021.10.29) 增加`Tooltip`对通配符`{e}`的支持 #170
|
||||
* (2021.09.08) 完善`RadarChart`
|
||||
* (2021.09.07) 修复`PieChart`渐出动画结束时`label`没有消失的问题 #168
|
||||
* (2021.09.06) 修复`GaugeChart`用代码改变`splitNumber`不会刷新`label`的问题 #167
|
||||
|
||||
## v2.4.0
|
||||
|
||||
|
||||
@@ -176,6 +176,9 @@
|
||||
* `ceilRate`:最大最小值向上取整的倍率。默认为0时自动计算。
|
||||
* `splitNumber`:分割段数。默认为 `5`。
|
||||
* `isAxisTooltip`:是否Tooltip显示轴线上的所有数据。只对Mutiple类型的Radar有效。
|
||||
* `outRangeColor`:数值超出范围时显示的颜色。
|
||||
* `connectCenter`:数值是否连线到中心点。
|
||||
* `lineGradient`:数值线段是否渐变。
|
||||
* `splitLine`:分割线条 [AxisSplitLine](#AxisSplitLine)。
|
||||
* `splitArea`:分割区域 [AxisSplitArea](#AxisSplitArea)。
|
||||
* `indicator`:是否显示指示器。
|
||||
@@ -187,6 +190,7 @@
|
||||
* `name`:指示器名称。
|
||||
* `max`:指示器的最大值,默认为 0 无限制。
|
||||
* `min`:指示器的最小值,默认为 0 无限制。
|
||||
* `range`:指示器的正常值范围,当数值超出这个范围时显示`Radar`的`outRangeColor`颜色。
|
||||
* `textStyle`:文本样式 [TextStyle](#TextStyle)。
|
||||
|
||||
## `TextLimit`
|
||||
@@ -229,6 +233,7 @@
|
||||
* `{b}`为当前所指示或`index`为`0`的`serie`的数据项`serieData`的`name`,或者类目值(如折线图的`X`轴)。
|
||||
* `{c}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)的数值。
|
||||
* `{d}`为当前所指示或`index`为`0`的`serie`的`y`维(`dimesion`为`1`)百分比值,注意不带`%`号。
|
||||
* `{e}`为当前所指示或`index`为`0`的`serie`的数据项`serieData`的`name`。
|
||||
* `{.1}`表示指定`index`为`1`的`serie`对应颜色的圆点。
|
||||
* `{a1}`、`{b1}`、`{c1}`中的`1`表示指定`index`为`1`的`serie`。
|
||||
* `{c1:2}`表示索引为`1`的`serie`的当前指示数据项的第`3`个数据(一个数据项有多个数据,index为`2`表示第`3`个数据)。
|
||||
|
||||
@@ -176,7 +176,10 @@ Radar coordinate conponnet for radar charts.
|
||||
* `center`: the center of radar chart. The `center[0]` is the x-coordinate, and the `center[1]` is the y-coordinate. When value between 0 and 1 represents a percentage relative to the chart.[default:[0.5f,0.4f]].
|
||||
* `ceilRate`: The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.[default:0].
|
||||
* `splitNumber`: Segments of indicator axis.[default:5].
|
||||
* `splitNumber`: Tooltip displays all the data on the axis.[default:false].
|
||||
* `isAxisTooltip`: Tooltip displays all the data on the axis.[default:false].
|
||||
* `outRangeColor`: The color displayed when data out of range.[default:red]
|
||||
* `connectCenter`: Whether serie data connect to radar center with line.[default:false]
|
||||
* `lineGradient`: Whether need gradient for data line..[default:true]
|
||||
* `splitLine`: The split line style of radar [AxisSplitLine](#AxisSplitLine).
|
||||
* `splitArea`: The split area style of radar [AxisSplitArea](#AxisSplitArea).
|
||||
* `indicator`: Whether to show indicator.
|
||||
@@ -190,6 +193,7 @@ Indicator of radar chart, which is used to assign multiple variables(dimensions)
|
||||
* `name`: The name of indicator.
|
||||
* `max`: The maximum value of indicator, with default value of 0, but we recommend to set it manually.
|
||||
* `min`: The minimum value of indicator, with default value of 0.
|
||||
* `min`: Normal range. When the value is outside this range, the display color is automatically changed.
|
||||
* `textStyle`: The text style of indicator [TextStyle](#TextStyle).
|
||||
|
||||
## `TextLimit`
|
||||
@@ -233,6 +237,7 @@ Tooltip component.
|
||||
* `{b}` is the `name` of the `serieData` that is currently indicated or whose `index` is `0`, or a `category` value (such as the X-axis of a line chart).
|
||||
* `{c}` is the value of a Y-dimension (`dimesion` is 1) from the `serie` that is currently indicated or whose `index` is `0`.
|
||||
* `{d}` is the percentage value of Y-dimensions (`dimesion` is 1) from the `serie` that is currently indicated or whose `index` is `0`, with no `%` sign.
|
||||
* `{e}` is the `name` of the `serieData` that is currently indicated or whose `index` is `0`.
|
||||
* `{.1}` represents a dot from serie corresponding color that specifies `index` as `1`.
|
||||
* `1` in `{a1}`, `{b1}`, `{c1}` represents a `serie` that specifies an `index` of `1`.
|
||||
* `{c1:2}` represents the third data from `serie`'s current indication data item indexed to `1` (a data item has multiple data, `index` 2 represents the third data).
|
||||
|
||||
@@ -29,6 +29,12 @@ namespace XCharts
|
||||
EditorGUI.indentLevel++;
|
||||
PropertyField(prop, isPolar ? "m_PolarIndex" : "m_GridIndex");
|
||||
PropertyField(prop, "m_Type");
|
||||
if (type == Axis.AxisType.Time)
|
||||
{
|
||||
var chartTypeName = prop.serializedObject.targetObject.GetType().Name;
|
||||
if (!chartTypeName.Equals("GanttChart"))
|
||||
EditorGUILayout.HelpBox("The Time axis is currently only supported in GanttChart.", MessageType.Warning);
|
||||
}
|
||||
PropertyField(prop, "m_Position");
|
||||
PropertyField(prop, "m_Offset");
|
||||
if (type == Axis.AxisType.Log)
|
||||
|
||||
@@ -28,6 +28,9 @@ namespace XCharts
|
||||
PropertyField(prop, "m_SplitNumber");
|
||||
PropertyField(prop, "m_CeilRate");
|
||||
PropertyField(prop, "m_IsAxisTooltip");
|
||||
PropertyField(prop, "m_OutRangeColor");
|
||||
PropertyField(prop, "m_ConnectCenter");
|
||||
PropertyField(prop, "m_LineGradient");
|
||||
PropertyField(prop, "m_AxisLine");
|
||||
PropertyField(prop, "m_SplitLine");
|
||||
PropertyField(prop, "m_SplitArea");
|
||||
@@ -50,6 +53,7 @@ namespace XCharts
|
||||
PropertyField(prop, "m_Name");
|
||||
PropertyField(prop, "m_Min");
|
||||
PropertyField(prop, "m_Max");
|
||||
PropertyTwoFiled(prop, "m_Range");
|
||||
PropertyField(prop, "m_TextStyle");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
@@ -402,6 +402,8 @@ namespace XCharts
|
||||
{
|
||||
EditorGUI.indentLevel += 2;
|
||||
var m_Ignore = serieData.FindPropertyRelative("m_Ignore");
|
||||
var m_Selected = serieData.FindPropertyRelative("m_Selected");
|
||||
var m_Id = serieData.FindPropertyRelative("m_Id");
|
||||
var m_EnableIcon = serieData.FindPropertyRelative("m_EnableIconStyle");
|
||||
var m_Icon = serieData.FindPropertyRelative("m_IconStyle");
|
||||
var m_EnableLabel = serieData.FindPropertyRelative("m_EnableLabel");
|
||||
@@ -414,6 +416,10 @@ namespace XCharts
|
||||
var m_Symbol = serieData.FindPropertyRelative("m_Symbol");
|
||||
EditorGUI.PropertyField(drawRect, m_Ignore);
|
||||
AddHeight(EditorGUI.GetPropertyHeight(m_Ignore));
|
||||
EditorGUI.PropertyField(drawRect, m_Selected);
|
||||
AddHeight(EditorGUI.GetPropertyHeight(m_Selected));
|
||||
EditorGUI.PropertyField(drawRect, m_Id);
|
||||
AddHeight(EditorGUI.GetPropertyHeight(m_Id));
|
||||
EditorGUI.PropertyField(drawRect, m_Icon);
|
||||
ChartEditorHelper.MakeBool(drawRect, m_EnableIcon, 1, "(enable)");
|
||||
AddHeight(EditorGUI.GetPropertyHeight(m_Icon));
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace XCharts
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private double m_Max;
|
||||
[SerializeField] private double m_Min;
|
||||
[SerializeField] private double[] m_Range = new double[2] { 0, 0 };
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
|
||||
/// <summary>
|
||||
@@ -83,6 +84,24 @@ namespace XCharts
|
||||
/// 指示器的文本组件。
|
||||
/// </summary>
|
||||
public Text text { get; set; }
|
||||
/// <summary>
|
||||
/// Normal range. When the value is outside this range, the display color is automatically changed.
|
||||
/// 正常值范围。当数值不在这个范围时,会自动变更显示颜色。
|
||||
/// </summary>
|
||||
public double[] range
|
||||
{
|
||||
get { return m_Range; }
|
||||
set { if (value != null && value.Length == 2) { m_Range = value; } }
|
||||
}
|
||||
|
||||
public bool IsInRange(double value)
|
||||
{
|
||||
if (m_Range == null || m_Range.Length < 2) return true;
|
||||
if (m_Range[0] != 0 || m_Range[1] != 0)
|
||||
return value >= m_Range[0] && value <= m_Range[1];
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Shape m_Shape;
|
||||
@@ -97,6 +116,9 @@ namespace XCharts
|
||||
[SerializeField] private float m_IndicatorGap = 10;
|
||||
[SerializeField] private int m_CeilRate = 0;
|
||||
[SerializeField] private bool m_IsAxisTooltip;
|
||||
[SerializeField] private Color32 m_OutRangeColor = Color.red;
|
||||
[SerializeField] private bool m_ConnectCenter = false;
|
||||
[SerializeField] private bool m_LineGradient = true;
|
||||
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
||||
/// <summary>
|
||||
/// [default:true]
|
||||
@@ -214,6 +236,33 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The color displayed when data out of range.
|
||||
/// 数值超出范围时显示的颜色。
|
||||
/// </summary>
|
||||
public Color32 outRangeColor
|
||||
{
|
||||
get { return m_OutRangeColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_OutRangeColor, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether serie data connect to radar center with line.
|
||||
/// 数值是否连线到中心点。
|
||||
/// </summary>
|
||||
public bool connectCenter
|
||||
{
|
||||
get { return m_ConnectCenter; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ConnectCenter, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether need gradient for data line.
|
||||
/// 数值线段是否需要渐变。
|
||||
/// </summary>
|
||||
public bool lineGradient
|
||||
{
|
||||
get { return m_LineGradient; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineGradient, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the indicator list.
|
||||
/// 指示器列表。
|
||||
/// </summary>
|
||||
@@ -276,6 +325,12 @@ namespace XCharts
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsInIndicatorRange(int index, double value)
|
||||
{
|
||||
var indicator = GetIndicator(index);
|
||||
return indicator == null ? true : indicator.IsInRange(value);
|
||||
}
|
||||
|
||||
public double GetIndicatorMin(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_IndicatorList.Count)
|
||||
|
||||
@@ -363,6 +363,7 @@ namespace XCharts
|
||||
[NonSerialized] internal bool m_NeedUpdateFilterData;
|
||||
[NonSerialized] internal List<SerieData> m_FilterData = new List<SerieData>();
|
||||
[NonSerialized] internal List<SerieData> m_SortedData = new List<SerieData>();
|
||||
[NonSerialized] internal List<SerieData> m_RootData = new List<SerieData>();
|
||||
[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 List<Vector3> m_DataPoints = new List<Vector3>();
|
||||
@@ -1188,7 +1189,9 @@ namespace XCharts
|
||||
public float runtimeY { get; internal set; }
|
||||
public float runtimeWidth { get; internal set; }
|
||||
public float runtimeHeight { get; internal set; }
|
||||
public Rect runtimeRect { get; internal set; }
|
||||
public List<SerieData> runtimeSortedData { get { return m_SortedData; } }
|
||||
public List<SerieData> rootData { get { return m_RootData; } }
|
||||
public bool nameDirty { get { return m_NameDirty; } }
|
||||
|
||||
private void SetNameDirty()
|
||||
@@ -1529,6 +1532,32 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public SerieData AddChildData(SerieData parent, double value, string name = null)
|
||||
{
|
||||
var serieData = new SerieData();
|
||||
serieData.name = name;
|
||||
serieData.index = m_Data.Count;
|
||||
serieData.data = new List<double>() { parent.children.Count, value };
|
||||
serieData.parentIndex = parent.index;
|
||||
serieData.runtimeParent = parent;
|
||||
AddSerieDataHeadOrTail(serieData);
|
||||
parent.children.Add(serieData.index);
|
||||
parent.runtimeChildren.Add(serieData);
|
||||
return serieData;
|
||||
}
|
||||
public SerieData AddChildData(SerieData parent, List<double> value, string name = null)
|
||||
{
|
||||
var serieData = new SerieData();
|
||||
serieData.name = name;
|
||||
serieData.index = m_Data.Count;
|
||||
serieData.data = new List<double>(value);
|
||||
serieData.parentIndex = parent.index;
|
||||
serieData.runtimeParent = parent;
|
||||
AddSerieDataHeadOrTail(serieData);
|
||||
parent.children.Add(serieData.index);
|
||||
parent.runtimeChildren.Add(serieData);
|
||||
return serieData;
|
||||
}
|
||||
|
||||
private void CheckMaxCache()
|
||||
{
|
||||
@@ -1645,6 +1674,31 @@ namespace XCharts
|
||||
return null;
|
||||
}
|
||||
|
||||
public SerieData GetSerieData(string id, DataZoom dataZoom = null)
|
||||
{
|
||||
var data = GetDataList(dataZoom);
|
||||
foreach (var serieData in data)
|
||||
{
|
||||
var target = GetSerieData(serieData, id);
|
||||
if (target != null) return target;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SerieData GetSerieData(SerieData parent, string id)
|
||||
{
|
||||
if (id.Equals(parent.id)) return parent;
|
||||
foreach (var child in parent.children)
|
||||
{
|
||||
var data = GetSerieData(GetSerieData(child), id);
|
||||
if (data != null)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定索引的维度X和维度Y的数据
|
||||
/// </summary>
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace XCharts
|
||||
[SerializeField] private Sprite m_BackgroundImage;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
|
||||
private DelegateTooltipPosition m_PositionFunction;
|
||||
|
||||
private GameObject m_GameObject;
|
||||
private GameObject m_Content;
|
||||
@@ -101,6 +102,7 @@ namespace XCharts
|
||||
/// {b} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart).
|
||||
/// {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.
|
||||
/// {d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.
|
||||
/// {e} is the name of the data item serieData that is currently indicated or whose index is 0.
|
||||
/// {.1} represents a dot from serie corresponding color that specifies index as 1.
|
||||
/// 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.
|
||||
/// {c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).
|
||||
@@ -115,6 +117,7 @@ namespace XCharts
|
||||
/// {b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。
|
||||
/// {c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。
|
||||
/// {d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。
|
||||
/// {e}为当前所指示或index为0的serie的数据项serieData的name。
|
||||
/// {.1}表示指定index为1的serie对应颜色的圆点。
|
||||
/// {a1}、{b1}、{c1}中的1表示指定index为1的serie。
|
||||
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。
|
||||
@@ -298,6 +301,12 @@ namespace XCharts
|
||||
public int runtimeGridIndex { get; internal set; }
|
||||
public int runtimePolarIndex { get; internal set; }
|
||||
|
||||
public DelegateTooltipPosition positionFunction
|
||||
{
|
||||
get { return m_PositionFunction; }
|
||||
set { m_PositionFunction = value; }
|
||||
}
|
||||
|
||||
public static Tooltip defaultTooltip
|
||||
{
|
||||
get
|
||||
@@ -447,7 +456,12 @@ namespace XCharts
|
||||
public void UpdateContentPos(Vector2 pos)
|
||||
{
|
||||
if (m_Content)
|
||||
m_Content.transform.localPosition = pos;
|
||||
{
|
||||
if (m_PositionFunction != null)
|
||||
m_Content.transform.localPosition = m_PositionFunction(pos);
|
||||
else
|
||||
m_Content.transform.localPosition = pos;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -262,7 +262,6 @@ namespace XCharts
|
||||
{
|
||||
public CoordinateChart chart;
|
||||
private GameObject m_MarkLineLabelRoot;
|
||||
private bool m_RefreshLabel = false;
|
||||
|
||||
public MarkLineHandler(CoordinateChart chart)
|
||||
{
|
||||
@@ -309,15 +308,16 @@ namespace XCharts
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (m_RefreshLabel)
|
||||
foreach (var serie in chart.series.list)
|
||||
{
|
||||
m_RefreshLabel = false;
|
||||
foreach (var serie in chart.series.list)
|
||||
var show = serie.show && serie.markLine.show;
|
||||
foreach (var data in serie.markLine.data)
|
||||
{
|
||||
if (!serie.show || !serie.markLine.show) continue;
|
||||
foreach (var data in serie.markLine.data)
|
||||
if (data.runtimeLabel != null)
|
||||
{
|
||||
if (data.runtimeLabel != null)
|
||||
if (data.runtimeLabel.gameObject.activeSelf != show)
|
||||
data.runtimeLabel.gameObject.SetActive(show);
|
||||
if (show)
|
||||
{
|
||||
data.runtimeLabel.SetPosition(MarkLineHelper.GetLabelPosition(data));
|
||||
data.runtimeLabel.SetText(MarkLineHelper.GetFormatterContent(serie, data));
|
||||
@@ -514,13 +514,12 @@ namespace XCharts
|
||||
data.runtimeCurrentEndPosition = ep;
|
||||
if (sp != Vector3.zero || ep != Vector3.zero)
|
||||
{
|
||||
m_RefreshLabel = true;
|
||||
chart.ClampInChart(ref sp);
|
||||
chart.ClampInChart(ref ep);
|
||||
var theme = chart.theme.axis;
|
||||
var lineColor = ChartHelper.IsClearColor(data.lineStyle.color) ? serieColor : data.lineStyle.color;
|
||||
var lineWidth = data.lineStyle.width == 0 ? theme.lineWidth : data.lineStyle.width;
|
||||
ChartDrawer.DrawLineStyle(vh, data.lineStyle, sp, ep, lineColor, lineWidth, LineStyle.Type.Dashed);
|
||||
ChartDrawer.DrawLineStyle(vh, data.lineStyle, sp, ep, lineWidth, LineStyle.Type.Dashed, lineColor, lineColor);
|
||||
if (data.startSymbol != null && data.startSymbol.show)
|
||||
{
|
||||
DrawMarkLineSymbol(vh, data.startSymbol, serie, grid, chart.theme, sp, sp, lineColor);
|
||||
@@ -539,7 +538,7 @@ namespace XCharts
|
||||
var tickness = SerieHelper.GetSymbolBorder(serie, null, theme, false);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false);
|
||||
chart.Internal_CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, tickness, pos, lineColor, lineColor,
|
||||
symbol.gap, true, cornerRadius, grid, startPos);
|
||||
ColorUtil.clearColor32, symbol.gap, true, cornerRadius, grid, startPos);
|
||||
}
|
||||
|
||||
private void GetStartEndPos(Axis xAxis, Axis yAxis, Grid grid, double value, ref Vector3 sp, ref Vector3 ep)
|
||||
|
||||
@@ -18,7 +18,10 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
public class SerieData : SubComponent
|
||||
{
|
||||
[SerializeField] private int m_Index;
|
||||
[SerializeField] private int m_ParentIndex = -1;
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private string m_Id;
|
||||
[SerializeField] private bool m_Selected;
|
||||
[SerializeField] private bool m_Ignore = false;
|
||||
[SerializeField] private float m_Radius;
|
||||
@@ -33,19 +36,25 @@ namespace XCharts
|
||||
[SerializeField] private bool m_EnableSymbol = false;
|
||||
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
|
||||
[SerializeField] private List<double> m_Data = new List<double>();
|
||||
[SerializeField] private List<int> m_Children = new List<int>();
|
||||
|
||||
public ChartLabel labelObject { get; set; }
|
||||
|
||||
private bool m_Show = true;
|
||||
private float m_RtPieOutsideRadius;
|
||||
|
||||
public int index { get; set; }
|
||||
public int index { get { return m_Index; } set { m_Index = value; } }
|
||||
public int parentIndex { get { return m_ParentIndex; } set { m_ParentIndex = value; } }
|
||||
/// <summary>
|
||||
/// the name of data item.
|
||||
/// 数据项名称。
|
||||
/// </summary>
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
/// <summary>
|
||||
/// 数据项的唯一id。唯一id不是必须设置的。
|
||||
/// </summary>
|
||||
public string id { get { return m_Id; } set { m_Id = value; } }
|
||||
/// <summary>
|
||||
/// 数据项图例名称。当数据项名称不为空时,图例名称即为系列名称;反之则为索引index。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
@@ -113,6 +122,7 @@ namespace XCharts
|
||||
/// 可指定任意维数的数值列表。
|
||||
/// </summary>
|
||||
public List<double> data { get { return m_Data; } set { m_Data = value; } }
|
||||
public List<int> children { get { return m_Children; } set { m_Children = value; } }
|
||||
/// <summary>
|
||||
/// [default:true] Whether the data item is showed.
|
||||
/// 该数据项是否要显示。
|
||||
@@ -174,18 +184,28 @@ namespace XCharts
|
||||
/// 绘制区域。
|
||||
/// </summary>
|
||||
public Rect runtimeRect { get; set; }
|
||||
public Rect runtimeSubRect { get; set; }
|
||||
public int runtimeLevel { get; set; }
|
||||
public SerieData runtimeParent { get; set; }
|
||||
public Color32 runtimeColor { get; set; }
|
||||
public double runtimeArea { get; set; }
|
||||
public float runtimeAngle { get; set; }
|
||||
public Vector3 runtiemPieOffsetCenter { get; set; }
|
||||
public float runtimeStackHig { get; set; }
|
||||
public Image runtimeSymbol { get; set; }
|
||||
public List<SerieData> runtimeChildren { get { return m_RuntimeChildren; } }
|
||||
|
||||
private List<double> m_PreviousData = new List<double>();
|
||||
private List<float> m_DataUpdateTime = new List<float>();
|
||||
private List<bool> m_DataUpdateFlag = new List<bool>();
|
||||
private List<Vector2> m_PolygonPoints = new List<Vector2>();
|
||||
[System.NonSerialized]
|
||||
private List<SerieData> m_RuntimeChildren = new List<SerieData>();
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
index = 0;
|
||||
m_ParentIndex = -1;
|
||||
labelObject = null;
|
||||
highlighted = false;
|
||||
m_Name = string.Empty;
|
||||
@@ -200,6 +220,8 @@ namespace XCharts
|
||||
m_Radius = 0;
|
||||
m_Data.Clear();
|
||||
m_PreviousData.Clear();
|
||||
m_PolygonPoints.Clear();
|
||||
m_RuntimeChildren.Clear();
|
||||
m_DataUpdateTime.Clear();
|
||||
m_DataUpdateFlag.Clear();
|
||||
m_IconStyle.Reset();
|
||||
@@ -350,6 +372,16 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool UpdateData(int dimension, double value)
|
||||
{
|
||||
if (dimension >= 0 && dimension < data.Count)
|
||||
{
|
||||
data[dimension] = value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CheckLastData()
|
||||
{
|
||||
if (m_PreviousData.Count != m_Data.Count)
|
||||
|
||||
@@ -48,7 +48,10 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 自定义标记。
|
||||
/// </summary>
|
||||
Custom
|
||||
Custom,
|
||||
EmptyRect,
|
||||
EmptyTriangle,
|
||||
EmptyDiamond
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -227,6 +227,19 @@ namespace XCharts
|
||||
else return Color.clear;
|
||||
}
|
||||
|
||||
public void SetColorPalette(List<Color32> colorList)
|
||||
{
|
||||
m_ColorPalette = colorList;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
public void SetColorPalette(List<string> hexColorStringList)
|
||||
{
|
||||
m_ColorPalette.Clear();
|
||||
foreach (var hexColor in hexColorStringList)
|
||||
m_ColorPalette.Add(ColorUtil.GetColor(hexColor));
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
public void CheckWarning(StringBuilder sb)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
|
||||
@@ -214,17 +214,21 @@ namespace XCharts
|
||||
if (splitNum == 0) return 0;
|
||||
if (axis.IsCategory())
|
||||
{
|
||||
var data = axis.GetDataList(dataZoom);
|
||||
var dataCount = axis.GetDataList(dataZoom).Count;
|
||||
var scaleNum = 0;
|
||||
|
||||
if (axis.boundaryGap)
|
||||
{
|
||||
scaleNum = data.Count % splitNum == 0 ? splitNum + 1 : splitNum + 2;
|
||||
scaleNum = dataCount > 2 && dataCount % splitNum == 0
|
||||
? splitNum + 1
|
||||
: splitNum + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.Count < splitNum) scaleNum = splitNum;
|
||||
else scaleNum = data.Count % splitNum == 0 ? splitNum : splitNum + 1;
|
||||
if (dataCount < splitNum) scaleNum = splitNum;
|
||||
else scaleNum = dataCount > 2 && dataCount % splitNum == 0
|
||||
? splitNum
|
||||
: splitNum + 1;
|
||||
}
|
||||
return scaleNum;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace XCharts
|
||||
public static class FormatterHelper
|
||||
{
|
||||
public const string PH_NN = "\n";
|
||||
private static Regex s_Regex = new Regex(@"{([a-d|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase);
|
||||
private static Regex s_Regex = new Regex(@"{([a-e|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexSub = new Regex(@"(0\.#*)|(\d+-\d+)|(\w+)|(\.)", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexN = new Regex(@"^\d+", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexN_N = new Regex(@"\d+-\d+", RegexOptions.IgnoreCase);
|
||||
@@ -23,11 +23,11 @@ namespace XCharts
|
||||
private static Regex s_RegexNewLine = new Regex(@"[\\|/]+n|</br>|<br>|<br/>", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexForAxisLabel = new Regex(@"{value(:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexSubForAxisLabel = new Regex(@"(value)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexForSerieLabel = new Regex(@"{[a-d|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-d])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexForSerieLabel = new Regex(@"{[a-e|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-e])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}。
|
||||
/// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}、{e}。
|
||||
/// </summary>
|
||||
/// <param name="content">要替换的字符串</param>
|
||||
/// <param name="dataIndex">选中的数据项serieData索引</param>
|
||||
@@ -84,15 +84,16 @@ namespace XCharts
|
||||
content = content.Replace(old, serie.name);
|
||||
}
|
||||
}
|
||||
else if (p == 'b' || p == 'B')
|
||||
else if (p == 'b' || p == 'B' || p == 'e' || p == 'E')
|
||||
{
|
||||
var bIndex = dataIndex;
|
||||
if (argsCount >= 2)
|
||||
{
|
||||
var args1Str = args[1].ToString();
|
||||
if (s_RegexN.IsMatch(args1Str)) bIndex = int.Parse(args1Str);
|
||||
if (s_RegexN.IsMatch(args1Str))
|
||||
bIndex = int.Parse(args1Str);
|
||||
}
|
||||
var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar;
|
||||
var needCategory = (p != 'e' && p != 'E') && (serie.type == SerieType.Line || serie.type == SerieType.Bar);
|
||||
if (needCategory)
|
||||
{
|
||||
var category = (chart as CoordinateChart).GetTooltipCategory(dataIndex, serie, dataZoom);
|
||||
@@ -236,7 +237,7 @@ namespace XCharts
|
||||
{
|
||||
content = content.Replace(old, serieName);
|
||||
}
|
||||
else if (p == 'b' || p == 'B')
|
||||
else if (p == 'b' || p == 'B' || p == 'e' || p == 'E')
|
||||
{
|
||||
content = content.Replace(old, dataName);
|
||||
}
|
||||
|
||||
@@ -235,6 +235,7 @@ namespace XCharts
|
||||
serie.runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
|
||||
serie.runtimeCenterPos = new Vector3(serie.runtimeX + serie.runtimeWidth / 2,
|
||||
serie.runtimeY + serie.runtimeHeight / 2);
|
||||
serie.runtimeRect = new Rect(serie.runtimeX, serie.runtimeY, serie.runtimeWidth, serie.runtimeHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -243,6 +244,7 @@ namespace XCharts
|
||||
serie.runtimeWidth = chartWidth;
|
||||
serie.runtimeHeight = chartHeight;
|
||||
serie.runtimeCenterPos = chartPosition + new Vector3(chartWidth / 2, chartHeight / 2);
|
||||
serie.runtimeRect = new Rect(serie.runtimeX, serie.runtimeY, serie.runtimeWidth, serie.runtimeHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,6 +431,14 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public static SerieLabel GetSerieEmphasisLabel(Serie serie, SerieData serieData)
|
||||
{
|
||||
if (!serie.IsPerformanceMode() && serieData.enableEmphasis && serieData.emphasis.show)
|
||||
return serieData.emphasis.label;
|
||||
else if (serie.emphasis.show) return serie.emphasis.label;
|
||||
else return null;
|
||||
}
|
||||
|
||||
public static IconStyle GetIconStyle(Serie serie, SerieData serieData)
|
||||
{
|
||||
if (serieData.enableIconStyle) return serieData.iconStyle;
|
||||
|
||||
@@ -443,7 +443,8 @@ namespace XCharts
|
||||
{
|
||||
var serie = series.GetSerie(i);
|
||||
if ((isPolar && serie.polarIndex != axisIndex)
|
||||
|| (!isPolar && serie.yAxisIndex != axisIndex)) continue;
|
||||
|| (!isPolar && serie.yAxisIndex != axisIndex)
|
||||
|| !series.IsActive(i)) continue;
|
||||
if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.name, SerieType.Bar))
|
||||
{
|
||||
if (100 > max) max = 100;
|
||||
@@ -485,7 +486,8 @@ namespace XCharts
|
||||
{
|
||||
var serie = ss.Value[i];
|
||||
if ((isPolar && serie.polarIndex != axisIndex)
|
||||
|| (!isPolar && serie.yAxisIndex != axisIndex)) continue;
|
||||
|| (!isPolar && serie.yAxisIndex != axisIndex)
|
||||
|| !series.IsActive(i)) continue;
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
if (SeriesHelper.IsPercentStack(series, serie.stack, SerieType.Bar))
|
||||
{
|
||||
@@ -510,7 +512,7 @@ namespace XCharts
|
||||
currData = yValue ? showData[j].GetData(1) : showData[j].GetData(0);
|
||||
}
|
||||
if (inverse) currData = -currData;
|
||||
if(!serie.IsIgnoreValue(currData))
|
||||
if (!serie.IsIgnoreValue(currData))
|
||||
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ namespace XCharts
|
||||
var active = IsActiveByLegend(datas[i]);
|
||||
var bgColor = LegendHelper.GetIconColor(this, readIndex, datas[i], active);
|
||||
var item = LegendHelper.AddLegendItem(legend, i, datas[i], legendObject.transform, m_Theme,
|
||||
legendName, bgColor, active,readIndex);
|
||||
legendName, bgColor, active, readIndex);
|
||||
legend.SetButton(legendName, item, totalLegend);
|
||||
ChartHelper.ClearEventListener(item.button.gameObject);
|
||||
ChartHelper.AddEventListener(item.button.gameObject, EventTriggerType.PointerDown, (data) =>
|
||||
@@ -529,23 +529,26 @@ namespace XCharts
|
||||
for (int j = 0; j < serie.data.Count; j++)
|
||||
{
|
||||
var serieData = serie.data[j];
|
||||
serieData.index = j;
|
||||
serieData.index = count;
|
||||
serieData.labelObject = null;
|
||||
AddSerieLabel(serie, serieData, count);
|
||||
AddSerieLabel(serie, serieData, ref count);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
SerieLabelHelper.UpdateLabelText(m_Series, m_Theme, m_LegendRealShowName);
|
||||
}
|
||||
|
||||
protected void AddSerieLabel(Serie serie, SerieData serieData, int count = -1)
|
||||
|
||||
protected void AddSerieLabel(Serie serie, SerieData serieData, ref int count)
|
||||
{
|
||||
if (m_SerieLabelRoot == null) return;
|
||||
if (count == -1) count = serie.dataCount;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var serieEmphasisLable = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
if (serie.IsPerformanceMode()) return;
|
||||
if (!serieLabel.show && !iconStyle.show) return;
|
||||
if (!serieLabel.show && (serieEmphasisLable == null || !serieEmphasisLable.show) && !iconStyle.show) return;
|
||||
if (serie.animation.enable && serie.animation.HasFadeOut()) return;
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
|
||||
var color = Color.grey;
|
||||
if (serie.type == SerieType.Pie)
|
||||
@@ -567,6 +570,12 @@ namespace XCharts
|
||||
item.SetIcon(iconImage);
|
||||
item.SetIconActive(iconStyle.show);
|
||||
serieData.labelObject = item;
|
||||
|
||||
foreach (var dataIndex in serieData.children)
|
||||
{
|
||||
AddSerieLabel(serie, serie.GetSerieData(dataIndex), ref count);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitSerieTitle()
|
||||
@@ -1014,17 +1023,20 @@ namespace XCharts
|
||||
}
|
||||
|
||||
public void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
|
||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius)
|
||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 fillColor, float gap, float[] cornerRadius)
|
||||
{
|
||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius, Vector3.zero);
|
||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, fillColor, gap, cornerRadius, Vector3.zero);
|
||||
}
|
||||
|
||||
public void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
|
||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius, Vector3 startPos)
|
||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 fillColor, float gap, float[] cornerRadius, Vector3 startPos)
|
||||
{
|
||||
var backgroundColor = ThemeHelper.GetBackgroundColor(m_Theme, m_Background);
|
||||
if (ChartHelper.IsClearColor(fillColor))
|
||||
fillColor = backgroundColor;
|
||||
var smoothness = settings.cicleSmoothness;
|
||||
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
|
||||
cornerRadius, backgroundColor, smoothness, startPos);
|
||||
cornerRadius, fillColor, backgroundColor, smoothness, startPos);
|
||||
}
|
||||
|
||||
public void DrawLabelBackground(VertexHelper vh, Serie serie, SerieData serieData)
|
||||
|
||||
@@ -1687,11 +1687,12 @@ namespace XCharts
|
||||
}
|
||||
|
||||
public void Internal_CheckClipAndDrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize, float tickness,
|
||||
Vector3 pos, Color32 color, Color32 toColor, float gap, bool clip, float[] cornerRadius, Grid grid, Vector3 startPos)
|
||||
Vector3 pos, Color32 color, Color32 toColor, Color32 backgroundColor, float gap, bool clip, float[] cornerRadius,
|
||||
Grid grid, Vector3 startPos)
|
||||
{
|
||||
if (!IsInChart(pos)) return;
|
||||
if (!clip || (clip && (IsInGrid(grid, pos))))
|
||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius, startPos);
|
||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, backgroundColor, gap, cornerRadius, startPos);
|
||||
}
|
||||
|
||||
public void Internal_CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
|
||||
|
||||
@@ -40,13 +40,14 @@ namespace XCharts
|
||||
? symbol.GetSelectedSize(serie.data[i].data, m_Theme.serie.lineSymbolSelectedSize)
|
||||
: symbol.GetSize(serie.data[i].data, m_Theme.serie.lineSymbolSize);
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, serie.index, highlight);
|
||||
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, serie.index, highlight);
|
||||
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, serie.index, highlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
||||
Internal_CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serie.dataPoints[i], symbolColor,
|
||||
symbolToColor, symbol.gap, clip, cornerRadius, grid, i > 0 ? serie.dataPoints[i - 1] : grid.runtimePosition);
|
||||
symbolToColor, backgroundColor, symbol.gap, clip, cornerRadius, grid,
|
||||
i > 0 ? serie.dataPoints[i - 1] : grid.runtimePosition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -832,7 +833,8 @@ namespace XCharts
|
||||
(!lastIsDown && IsInRightOrUp(isYAxis, lastDnPos, tp1)))
|
||||
{
|
||||
isStart = true;
|
||||
Internal_CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid);
|
||||
if (stPos1 != Vector3.zero && stPos2 != Vector3.zero)
|
||||
Internal_CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace XCharts
|
||||
var highlight = serie.highlighted || serieData.highlighted;
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, colorIndex, highlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||
@@ -67,13 +68,13 @@ namespace XCharts
|
||||
{
|
||||
var nowSize = symbol.animationSize[count];
|
||||
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
||||
DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
|
||||
DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, backgroundColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
|
||||
DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, backgroundColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
if (!serie.animation.IsFinish())
|
||||
|
||||
@@ -9,6 +9,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using XUGL;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -20,6 +21,7 @@ namespace XCharts
|
||||
private static readonly string s_AxisLabelObjectName = "axis_label";
|
||||
private bool m_UpdateTitleText = false;
|
||||
private bool m_UpdateLabelText = false;
|
||||
private Dictionary<int, int> m_LastSplitNumber = new Dictionary<int, int>();
|
||||
|
||||
public DrawSerieGauge(BaseChart chart)
|
||||
{
|
||||
@@ -61,6 +63,21 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var serie in chart.series.list)
|
||||
{
|
||||
if (serie.type == SerieType.Gauge)
|
||||
{
|
||||
if (!m_LastSplitNumber.TryGetValue(serie.index, out var lastSplitNumber))
|
||||
{
|
||||
m_LastSplitNumber[serie.index] = lastSplitNumber;
|
||||
}
|
||||
else if (serie.splitNumber != lastSplitNumber)
|
||||
{
|
||||
m_LastSplitNumber[serie.index] = serie.splitNumber;
|
||||
InitAxisLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawBase(VertexHelper vh)
|
||||
|
||||
@@ -413,6 +413,7 @@ namespace XCharts
|
||||
|
||||
private void DrawPieLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color)
|
||||
{
|
||||
if (serie.animation.enable && serie.animation.HasFadeOut()) return;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
if (serieLabel.show
|
||||
&& serieLabel.position == SerieLabel.Position.Outside
|
||||
@@ -496,6 +497,7 @@ namespace XCharts
|
||||
private void DrawPieLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
|
||||
{
|
||||
if (serieData.labelObject == null) return;
|
||||
if (serie.animation.enable && serie.animation.HasFadeOut()) return;
|
||||
var currAngle = serieData.runtimePieHalfAngle;
|
||||
var isHighlight = (serieData.highlighted && serie.emphasis.label.show);
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
|
||||
@@ -387,10 +387,11 @@ namespace XCharts
|
||||
: serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize);
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||
symbolToColor, serie.symbol.gap, cornerRadius);
|
||||
symbolToColor, backgroundColor, serie.symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,6 +440,8 @@ namespace XCharts
|
||||
var startPoint = Vector3.zero;
|
||||
var toPoint = Vector3.zero;
|
||||
var firstPoint = Vector3.zero;
|
||||
var lastColor = ColorUtil.clearColor32;
|
||||
var firstColor = ColorUtil.clearColor32;
|
||||
|
||||
var radar = chart.radars[serie.radarIndex];
|
||||
var indicatorNum = radar.indicatorList.Count;
|
||||
@@ -503,8 +506,10 @@ namespace XCharts
|
||||
var value = serieData.GetCurrData(1, dataChangeDuration);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
if (max == 0)
|
||||
{
|
||||
max = serie.runtimeDataMax;
|
||||
if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
|
||||
{
|
||||
lineColor = radar.outRangeColor;
|
||||
}
|
||||
var radius = (float)(max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max
|
||||
: radar.runtimeDataRadius * value / max);
|
||||
@@ -515,6 +520,8 @@ namespace XCharts
|
||||
startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle),
|
||||
p.y + radius * Mathf.Cos(currAngle));
|
||||
firstPoint = startPoint;
|
||||
lastColor = lineColor;
|
||||
firstColor = lineColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -526,22 +533,28 @@ namespace XCharts
|
||||
}
|
||||
if (serie.lineStyle.show)
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor,
|
||||
chart.theme.serie.lineWidth, LineStyle.Type.Solid);
|
||||
if (radar.connectCenter)
|
||||
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, centerPos,
|
||||
chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
|
||||
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, chart.theme.serie.lineWidth,
|
||||
LineStyle.Type.Solid, radar.lineGradient ? lastColor : lineColor, lineColor);
|
||||
}
|
||||
startPoint = toPoint;
|
||||
lastColor = lineColor;
|
||||
}
|
||||
serieData.labelPosition = startPoint;
|
||||
pointList.Add(startPoint);
|
||||
|
||||
if (serie.areaStyle.show && j == endIndex)
|
||||
{
|
||||
UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor);
|
||||
}
|
||||
if (serie.lineStyle.show && j == endIndex)
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor,
|
||||
chart.theme.serie.lineWidth, LineStyle.Type.Solid);
|
||||
if (radar.connectCenter)
|
||||
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, centerPos,
|
||||
chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
|
||||
ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, chart.theme.serie.lineWidth,
|
||||
LineStyle.Type.Solid, lineColor, radar.lineGradient ? firstColor : lineColor);
|
||||
}
|
||||
}
|
||||
if (serie.symbol.show && serie.symbol.type != SerieSymbolType.None)
|
||||
@@ -558,10 +571,16 @@ namespace XCharts
|
||||
: serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||
if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
|
||||
{
|
||||
symbolColor = radar.outRangeColor;
|
||||
symbolToColor = radar.outRangeColor;
|
||||
}
|
||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.labelPosition, symbolColor,
|
||||
symbolToColor, serie.symbol.gap, cornerRadius);
|
||||
symbolToColor, backgroundColor, serie.symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
if (!serie.animation.IsFinish())
|
||||
@@ -602,22 +621,19 @@ namespace XCharts
|
||||
: serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||
foreach (var point in pointList)
|
||||
{
|
||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||
symbolToColor, serie.symbol.gap, cornerRadius);
|
||||
symbolToColor, backgroundColor, serie.symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawRadar(VertexHelper vh, Radar radar)
|
||||
{
|
||||
if (!radar.splitLine.show && !radar.splitArea.show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
float insideRadius = 0, outsideRadius = 0;
|
||||
float block = radar.runtimeRadius / radar.splitNumber;
|
||||
int indicatorNum = radar.indicatorList.Count;
|
||||
@@ -632,7 +648,6 @@ namespace XCharts
|
||||
var splitLineType = radar.splitLine.GetType(chart.theme.radar.splitLineType);
|
||||
for (int i = 0; i < radar.splitNumber; i++)
|
||||
{
|
||||
var isLast = i == radar.splitNumber - 1;
|
||||
var color = radar.splitArea.GetColor(i, chart.theme.radar);
|
||||
outsideRadius = insideRadius + block;
|
||||
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0));
|
||||
@@ -650,34 +665,27 @@ namespace XCharts
|
||||
}
|
||||
if (radar.splitLine.NeedShow(i))
|
||||
{
|
||||
if (isLast)
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p2, p3, lineColor);
|
||||
else
|
||||
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
|
||||
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
|
||||
}
|
||||
p1 = p4;
|
||||
p2 = p3;
|
||||
}
|
||||
insideRadius = outsideRadius;
|
||||
}
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
if (radar.axisLine.show)
|
||||
{
|
||||
float currAngle = j * angle;
|
||||
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
if (radar.splitLine.show)
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p, p3, splitLineColor);
|
||||
float currAngle = j * angle;
|
||||
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCricleRadar(VertexHelper vh, Radar radar)
|
||||
{
|
||||
if (!radar.splitLine.show && !radar.splitArea.show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
float insideRadius = 0, outsideRadius = 0;
|
||||
float block = radar.runtimeRadius / radar.splitNumber;
|
||||
int indicatorNum = radar.indicatorList.Count;
|
||||
@@ -685,7 +693,10 @@ namespace XCharts
|
||||
Vector3 p1;
|
||||
float angle = 2 * Mathf.PI / indicatorNum;
|
||||
var lineColor = radar.axisLine.GetColor(chart.theme.radar.lineColor);
|
||||
var lineWidth = radar.splitLine.GetWidth(chart.theme.radar.splitLineWidth);
|
||||
var lineWidth = radar.axisLine.GetWidth(chart.theme.radar.lineWidth);
|
||||
var lineType = radar.axisLine.GetType(chart.theme.radar.lineType);
|
||||
var splitLineColor = radar.splitLine.GetColor(chart.theme.radar.splitLineColor);
|
||||
var splitLineWidth = radar.splitLine.GetWidth(chart.theme.radar.splitLineWidth);
|
||||
for (int i = 0; i < radar.splitNumber; i++)
|
||||
{
|
||||
var color = radar.splitArea.GetColor(i, chart.theme.radiusAxis);
|
||||
@@ -697,19 +708,19 @@ namespace XCharts
|
||||
}
|
||||
if (radar.splitLine.show)
|
||||
{
|
||||
UGL.DrawEmptyCricle(vh, p, outsideRadius, lineWidth, lineColor,
|
||||
UGL.DrawEmptyCricle(vh, p, outsideRadius, splitLineWidth, splitLineColor,
|
||||
Color.clear, chart.settings.cicleSmoothness);
|
||||
}
|
||||
insideRadius = outsideRadius;
|
||||
}
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
if (radar.axisLine.show)
|
||||
{
|
||||
float currAngle = j * angle;
|
||||
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
if (radar.splitLine.show)
|
||||
for (int j = 0; j <= indicatorNum; j++)
|
||||
{
|
||||
UGL.DrawLine(vh, p, p1, lineWidth / 2, lineColor);
|
||||
float currAngle = j * angle;
|
||||
p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
|
||||
p.y + outsideRadius * Mathf.Cos(currAngle));
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p1, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// The delegate function for AxisLabel's formatter. |
|
||||
/// AxisLabel的formatter自定义委托。
|
||||
/// AxisLabel的formatter自定义委托函数。
|
||||
/// </summary>
|
||||
/// <param name="labelIndex">label索引</param>
|
||||
/// <param name="value">当前label对应的数值数据,Value轴或Time轴有效</param>
|
||||
@@ -19,10 +21,16 @@ namespace XCharts
|
||||
public delegate string DelegateAxisLabelFormatter(int labelIndex, double value, string category);
|
||||
/// <summary>
|
||||
/// The delegate function for SerieLabel‘s formatter.
|
||||
/// SerieLabel的formatter自定义委托。
|
||||
/// SerieLabel的formatter自定义委托函数。
|
||||
/// </summary>
|
||||
/// <param name="dataIndex">数据索引</param>
|
||||
/// <param name="value">数值</param>
|
||||
/// <returns>最终显示的文本内容</returns>
|
||||
public delegate string DelegateSerieLabelFormatter(int dataIndex, double value);
|
||||
/// <summary>
|
||||
/// Tooltip的position自定义委托函数。
|
||||
/// </summary>
|
||||
/// <param name="pos">Tooltip的当前坐标</param>
|
||||
/// <returns>Tooltip的最终坐标</returns>
|
||||
public delegate Vector3 DelegateTooltipPosition(Vector3 pos);
|
||||
}
|
||||
@@ -246,7 +246,12 @@ namespace XCharts
|
||||
#if dUI_TextMeshPro
|
||||
if (m_TMPText != null) return 0; // TODO:
|
||||
#else
|
||||
if (m_Text != null) return m_Text.cachedTextGenerator.GetPreferredWidth(content, m_RelatedTextSettings);
|
||||
if (m_Text != null)
|
||||
{
|
||||
var tg = m_Text.cachedTextGeneratorForLayout;
|
||||
var setting = m_Text.GetGenerationSettings(Vector2.zero);
|
||||
return tg.GetPreferredWidth(content, setting) / m_Text.pixelsPerUnit;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -270,6 +275,30 @@ namespace XCharts
|
||||
return 0;
|
||||
}
|
||||
|
||||
public string GetPreferredText(string content, string suffix, float maxWidth)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
if (m_TMPText != null) return content; // TODO:
|
||||
#else
|
||||
if (m_Text != null)
|
||||
{
|
||||
var sourWid = GetPreferredWidth(content);
|
||||
if (sourWid < maxWidth) return content;
|
||||
var suffixWid = GetPreferredWidth(suffix);
|
||||
var textWid = maxWidth - 1.3f * suffixWid;
|
||||
for (int i = content.Length; i > 0; i--)
|
||||
{
|
||||
var temp = content.Substring(0, i);
|
||||
if (GetPreferredWidth(temp) < textWid)
|
||||
{
|
||||
return temp + suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
|
||||
public void SetFont(TMP_FontAsset font)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace XCharts
|
||||
|
||||
public static void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
|
||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
|
||||
Color32 backgroundColor, float smoothness, Vector3 startPos)
|
||||
Color32 centerFillColor, Color32 backgroundColor, float smoothness, Vector3 startPos)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -38,11 +38,11 @@ namespace XCharts
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
|
||||
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
|
||||
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, centerFillColor, smoothness);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
|
||||
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, centerFillColor, smoothness);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.Rect:
|
||||
@@ -56,6 +56,17 @@ namespace XCharts
|
||||
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.EmptyRect:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
||||
UGL.DrawBorder(vh, pos, symbolSize / 2, symbolSize / 2, tickness, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawBorder(vh, pos, symbolSize / 2, symbolSize / 2, tickness, color);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.Triangle:
|
||||
if (gap > 0)
|
||||
{
|
||||
@@ -67,6 +78,19 @@ namespace XCharts
|
||||
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.EmptyTriangle:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
|
||||
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
|
||||
UGL.DrawTriangle(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
|
||||
UGL.DrawTriangle(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.Diamond:
|
||||
if (gap > 0)
|
||||
{
|
||||
@@ -78,6 +102,19 @@ namespace XCharts
|
||||
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.EmptyDiamond:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
|
||||
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
|
||||
UGL.DrawDiamond(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
|
||||
UGL.DrawDiamond(vh, pos, symbolSize - tickness, centerFillColor, centerFillColor);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.Arrow:
|
||||
var arrowWidth = symbolSize * 2;
|
||||
var arrowHeight = arrowWidth * 1.5f;
|
||||
@@ -89,28 +126,44 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle,
|
||||
Vector3 startPos, Vector3 endPos, Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, Vector3 startPos, Vector3 endPos,
|
||||
Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
|
||||
{
|
||||
var type = lineStyle.GetType(themeType);
|
||||
var width = lineStyle.GetWidth(themeWidth);
|
||||
var color = lineStyle.GetColor(defaultColor);
|
||||
DrawLineStyle(vh, type, width, startPos, endPos, color);
|
||||
DrawLineStyle(vh, type, width, startPos, endPos, color, color);
|
||||
}
|
||||
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, Vector3 startPos, Vector3 endPos,
|
||||
float themeWidth, LineStyle.Type themeType, Color32 defaultColor, Color32 defaultToColor)
|
||||
{
|
||||
var type = lineStyle.GetType(themeType);
|
||||
var width = lineStyle.GetWidth(themeWidth);
|
||||
var color = lineStyle.GetColor(defaultColor);
|
||||
var toColor = ChartHelper.IsClearColor(defaultToColor) ? color : defaultToColor;
|
||||
DrawLineStyle(vh, type, width, startPos, endPos, color, toColor);
|
||||
}
|
||||
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle.Type lineType, float lineWidth,
|
||||
Vector3 startPos, Vector3 endPos, Color32 color)
|
||||
{
|
||||
DrawLineStyle(vh, lineType, lineWidth, startPos, endPos, color, color);
|
||||
}
|
||||
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle.Type lineType, float lineWidth,
|
||||
Vector3 startPos, Vector3 endPos, Color32 color, Color32 toColor)
|
||||
{
|
||||
switch (lineType)
|
||||
{
|
||||
case LineStyle.Type.Dashed:
|
||||
UGL.DrawDashLine(vh, startPos, endPos, lineWidth, color, color);
|
||||
UGL.DrawDashLine(vh, startPos, endPos, lineWidth, color, toColor);
|
||||
break;
|
||||
case LineStyle.Type.Dotted:
|
||||
UGL.DrawDotLine(vh, startPos, endPos, lineWidth, color, color);
|
||||
UGL.DrawDotLine(vh, startPos, endPos, lineWidth, color, toColor);
|
||||
break;
|
||||
case LineStyle.Type.Solid:
|
||||
UGL.DrawLine(vh, startPos, endPos, lineWidth, color);
|
||||
UGL.DrawLine(vh, startPos, endPos, lineWidth, color, toColor);
|
||||
break;
|
||||
case LineStyle.Type.DashDot:
|
||||
UGL.DrawDashDotLine(vh, startPos, endPos, lineWidth, color);
|
||||
|
||||
@@ -510,11 +510,12 @@ namespace XCharts
|
||||
: symbol.GetSize(serieData.data, m_Theme.serie.lineSymbolSize);
|
||||
var symbolColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, n, highlight);
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, n, highlight);
|
||||
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, n, highlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
||||
DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.runtimePosition, symbolColor,
|
||||
symbolToColor, symbol.gap, cornerRadius);
|
||||
symbolToColor, backgroundColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace XCharts
|
||||
[ExecuteInEditMode]
|
||||
public class XChartsMgr : MonoBehaviour
|
||||
{
|
||||
internal static string _version = "2.4.0";
|
||||
internal static int _versionDate = 20210831;
|
||||
internal static string _version = "2.6.0";
|
||||
internal static int _versionDate = 20211230;
|
||||
public static string version { get { return _version; } }
|
||||
public static int versionDate { get { return _versionDate; } }
|
||||
public static string fullVersion { get { return version + "-" + versionDate; } }
|
||||
|
||||
@@ -34,10 +34,14 @@ namespace XCharts
|
||||
GUI.enabled = !m_EssentialResourcesImported;
|
||||
if (GUILayout.Button("Import XCharts Essentials"))
|
||||
{
|
||||
AssetDatabase.importPackageCompleted += ImportCallback;
|
||||
|
||||
string packageFullPath = GetPackageFullPath();
|
||||
AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/XCharts Essential Resources.unitypackage", false);
|
||||
var sourPath = Path.Combine(packageFullPath, "Resources");
|
||||
var destPath = Path.Combine(Application.dataPath, "XCharts/Resources");
|
||||
if (CopyFolder(sourPath, destPath))
|
||||
{
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
GUILayout.Space(5f);
|
||||
GUI.enabled = true;
|
||||
@@ -45,35 +49,40 @@ namespace XCharts
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
{
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
{
|
||||
GUILayout.Label("TextMeshPro", EditorStyles.boldLabel);
|
||||
#if dUI_TextMeshPro
|
||||
GUILayout.Label("TextMeshPro is now enabled. You can turn it off by clicking the button below.", new GUIStyle(EditorStyles.label) { wordWrap = true });
|
||||
GUILayout.Space(5f);
|
||||
if (GUILayout.Button("Disable TextMeshPro"))
|
||||
{
|
||||
XChartsMgr.DisableTextMeshPro();
|
||||
}
|
||||
#else
|
||||
GUILayout.Label("TextMeshPro is not active. You can activate it by clicking the button below. Make sure TextMeshPro is already in your project before activating it.", new GUIStyle(EditorStyles.label) { wordWrap = true });
|
||||
GUILayout.Space(5f);
|
||||
if (GUILayout.Button("Enable TextMeshPro"))
|
||||
{
|
||||
XChartsMgr.EnableTextMeshPro();
|
||||
}
|
||||
#endif
|
||||
GUILayout.Space(5f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.Space(5f);
|
||||
}
|
||||
|
||||
private static bool CopyFolder(string sourPath, string destPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(destPath))
|
||||
{
|
||||
Directory.CreateDirectory(destPath);
|
||||
}
|
||||
var files = Directory.GetFiles(sourPath);
|
||||
foreach (var file in files)
|
||||
{
|
||||
var name = Path.GetFileName(file);
|
||||
var path = Path.Combine(destPath, name);
|
||||
File.Copy(file, path);
|
||||
}
|
||||
var folders = Directory.GetDirectories(sourPath);
|
||||
foreach (var folder in folders)
|
||||
{
|
||||
var name = Path.GetFileName(folder);
|
||||
var path = Path.Combine(destPath, name);
|
||||
CopyFolder(folder, path);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError("CopyFolder:" + e.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal void RegisterResourceImportCallback()
|
||||
{
|
||||
AssetDatabase.importPackageCompleted += ImportCallback;
|
||||
|
||||
@@ -55,6 +55,20 @@ namespace XUGL
|
||||
/// <param name="width">线宽</param>
|
||||
/// <param name="color">颜色</param>
|
||||
public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color)
|
||||
{
|
||||
DrawLine(vh, startPoint, endPoint, width, color, color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw a line. 画直线
|
||||
/// </summary>
|
||||
/// <param name="vh"></param>
|
||||
/// <param name="startPoint">起点</param>
|
||||
/// <param name="endPoint">终点</param>
|
||||
/// <param name="width">线宽</param>
|
||||
/// <param name="color">颜色</param>
|
||||
/// <param name="toColor">渐变颜色</param>
|
||||
public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color, Color32 toColor)
|
||||
{
|
||||
if (startPoint == endPoint) return;
|
||||
Vector3 v = Vector3.Cross(endPoint - startPoint, Vector3.forward).normalized * width;
|
||||
@@ -65,7 +79,7 @@ namespace XUGL
|
||||
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
s_Vertex[j].color = color;
|
||||
s_Vertex[j].color = j == 0 || j == 3 ? color : toColor;
|
||||
s_Vertex[j].uv0 = s_ZeroVector2;
|
||||
}
|
||||
vh.AddUIVertexQuad(s_Vertex);
|
||||
@@ -442,6 +456,20 @@ namespace XUGL
|
||||
DrawQuadrilateral(vh, p1, p2, p3, p4, color, toColor);
|
||||
}
|
||||
|
||||
public static void DrawRectangle(VertexHelper vh, Rect rect, Color32 color)
|
||||
{
|
||||
DrawRectangle(vh, rect, 0, color);
|
||||
}
|
||||
public static void DrawRectangle(VertexHelper vh, Rect rect, float border, Color32 color)
|
||||
{
|
||||
DrawRectangle(vh, rect, border, color, color);
|
||||
}
|
||||
|
||||
public static void DrawRectangle(VertexHelper vh, Rect rect, float border, Color32 color, Color32 toColor)
|
||||
{
|
||||
DrawRectangle(vh, rect.center, rect.width / 2 - border, rect.height / 2 - border, color, toColor, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw a quadrilateral. 画任意的四边形
|
||||
/// </summary>
|
||||
@@ -845,6 +873,26 @@ namespace XUGL
|
||||
cornerRadius, horizontal, smoothness, invertCorner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绘制(圆角)边框
|
||||
/// </summary>
|
||||
/// <param name="vh"></param>
|
||||
/// <param name="rect"></param>
|
||||
/// <param name="borderWidth"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <param name="rotate"></param>
|
||||
/// <param name="cornerRadius"></param>
|
||||
/// <param name="horizontal"></param>
|
||||
/// <param name="smoothness"></param>
|
||||
/// <param name="invertCorner"></param>
|
||||
public static void DrawBorder(VertexHelper vh, Rect rect,
|
||||
float borderWidth, Color32 color, float rotate = 0, float[] cornerRadius = null,
|
||||
bool horizontal = false, float smoothness = 1f, bool invertCorner = false)
|
||||
{
|
||||
DrawBorder(vh, rect.center, rect.width, rect.height, borderWidth, color, s_ClearColor32, rotate,
|
||||
cornerRadius, horizontal, smoothness, invertCorner);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绘制(圆角)边框
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "com.monitor1394.xcharts",
|
||||
"displayName": "XCharts",
|
||||
"version": "2.4.0",
|
||||
"date": "20210831",
|
||||
"checkdate": "20210831",
|
||||
"version": "2.6.0",
|
||||
"date": "20211230",
|
||||
"checkdate": "20211230",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"unity": "2018.3",
|
||||
"description": "A charting and data visualization library for Unity.",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": "2.4.0",
|
||||
"date": "20210831",
|
||||
"checkdate": "20210831",
|
||||
"version": "2.6.0",
|
||||
"date": "20211230",
|
||||
"checkdate": "20211230",
|
||||
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
|
||||
"homepage": "https://github.com/monitor1394/unity-ugui-XCharts"
|
||||
}
|
||||
Reference in New Issue
Block a user