mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-31 13:58:48 +00:00
3.0 - optimize code
This commit is contained in:
@@ -263,7 +263,7 @@ Since the data type is upgraded to `double`, the implicit conversion of `float`
|
|||||||
* (2020.05.30) 优化`PieChart`支持设置`ignoreValue`不显示指定数据
|
* (2020.05.30) 优化`PieChart`支持设置`ignoreValue`不显示指定数据
|
||||||
* (2020.05.30) 修复`RadarChart`为`Circle`时不绘制`SplitArea`的问题
|
* (2020.05.30) 修复`RadarChart`为`Circle`时不绘制`SplitArea`的问题
|
||||||
* (2020.05.30) 优化`RadarChart`在设置`max`为`0`时可自动刷新最大值
|
* (2020.05.30) 优化`RadarChart`在设置`max`为`0`时可自动刷新最大值
|
||||||
* (2020.05.29) 修复`PieChart`设置`space`时只有一个数据时绘制异常的问题
|
* (2020.05.29) 修复`PieChart`设置`gap`时只有一个数据时绘制异常的问题
|
||||||
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题
|
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题
|
||||||
* (2020.05.27) 优化`柱状图`的渐变色效果
|
* (2020.05.27) 优化`柱状图`的渐变色效果
|
||||||
* (2020.05.24) 修复`Axis`同时设置`boundaryGap`和`alignWithLabel`时`Tick`绘制异常的问题
|
* (2020.05.24) 修复`Axis`同时设置`boundaryGap`和`alignWithLabel`时`Tick`绘制异常的问题
|
||||||
|
|||||||
@@ -267,7 +267,7 @@
|
|||||||
* (2020.05.30) 优化`PieChart`支持设置`ignoreValue`不显示指定数据
|
* (2020.05.30) 优化`PieChart`支持设置`ignoreValue`不显示指定数据
|
||||||
* (2020.05.30) 修复`RadarChart`为`Circle`时不绘制`SplitArea`的问题
|
* (2020.05.30) 修复`RadarChart`为`Circle`时不绘制`SplitArea`的问题
|
||||||
* (2020.05.30) 优化`RadarChart`在设置`max`为`0`时可自动刷新最大值
|
* (2020.05.30) 优化`RadarChart`在设置`max`为`0`时可自动刷新最大值
|
||||||
* (2020.05.29) 修复`PieChart`设置`space`时只有一个数据时绘制异常的问题
|
* (2020.05.29) 修复`PieChart`设置`gap`时只有一个数据时绘制异常的问题
|
||||||
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题
|
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题
|
||||||
* (2020.05.27) 优化`柱状图`的渐变色效果
|
* (2020.05.27) 优化`柱状图`的渐变色效果
|
||||||
* (2020.05.24) 修复`Axis`同时设置`boundaryGap`和`alignWithLabel`时`Tick`绘制异常的问题
|
* (2020.05.24) 修复`Axis`同时设置`boundaryGap`和`alignWithLabel`时`Tick`绘制异常的问题
|
||||||
|
|||||||
@@ -638,7 +638,7 @@
|
|||||||
* `None`:不展示成南丁格尔玫瑰图。
|
* `None`:不展示成南丁格尔玫瑰图。
|
||||||
* `Radius`:扇区圆心角展现数据的百分比,半径展现数据的大小。
|
* `Radius`:扇区圆心角展现数据的百分比,半径展现数据的大小。
|
||||||
* `Area`:所有扇区圆心角相同,仅通过半径展现数据大小。
|
* `Area`:所有扇区圆心角相同,仅通过半径展现数据大小。
|
||||||
* `space`:扇区间隙。
|
* `gap`:扇区间隙。
|
||||||
* `center`:中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
* `center`:中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
||||||
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
||||||
* `minAngle`:最小的扇区角度(0-360)。用于防止某个值过小导致扇区太小影响交互。
|
* `minAngle`:最小的扇区角度(0-360)。用于防止某个值过小导致扇区太小影响交互。
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ The component of settings related to text.
|
|||||||
* `font`: the font of text. When `null`, the theme's font is used by default. [default: `null`].
|
* `font`: the font of text. When `null`, the theme's font is used by default. [default: `null`].
|
||||||
* `fontSize`: the size of text. [default: `18`].
|
* `fontSize`: the size of text. [default: `18`].
|
||||||
* `fontStyle`: the font style of text. [default: `FontStyle.Normal`].
|
* `fontStyle`: the font style of text. [default: `FontStyle.Normal`].
|
||||||
* `lineSpacing`: the space of text line. [default: `1f`].
|
* `lineSpacing`: the gap of text line. [default: `1f`].
|
||||||
* `autoWrap`: Whether to wrap lines.
|
* `autoWrap`: Whether to wrap lines.
|
||||||
* `autoAlign`: Whether to let the system automatically set alignment. If true, the system automatically selects alignment, and if false, use alignment.
|
* `autoAlign`: Whether to let the system automatically set alignment. If true, the system automatically selects alignment, and if false, use alignment.
|
||||||
|
|
||||||
@@ -531,7 +531,7 @@ Line chart serie.
|
|||||||
* `None`: 不展示成南丁格尔玫瑰图。
|
* `None`: 不展示成南丁格尔玫瑰图。
|
||||||
* `Radius`: 扇区圆心角展现数据的百分比,半径展现数据的大小。
|
* `Radius`: 扇区圆心角展现数据的百分比,半径展现数据的大小。
|
||||||
* `Area`: 所有扇区圆心角相同,仅通过半径展现数据大小。
|
* `Area`: 所有扇区圆心角相同,仅通过半径展现数据大小。
|
||||||
* `space`: 扇区间隙。
|
* `gap`: 扇区间隙。
|
||||||
* `center`: 中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
* `center`: 中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
||||||
* `radius`: 半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
* `radius`: 半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
||||||
* `minAngle`: The minimum angle of sector(0-360). It prevents some sector from being too small when value is small.
|
* `minAngle`: The minimum angle of sector(0-360). It prevents some sector from being too small when value is small.
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
sb.Length = 0;
|
sb.Length = 0;
|
||||||
sb.AppendFormat("v{0}", XChartsMgr.fullVersion);
|
sb.AppendFormat("v{0}", XChartsMgr.fullVersion);
|
||||||
//if(m_EnableTextMeshPro.boolValue)
|
if(m_EnableTextMeshPro.boolValue)
|
||||||
sb.Append("-tmp");
|
sb.Append("-tmp");
|
||||||
EditorGUILayout.HelpBox(sb.ToString(), MessageType.None);
|
EditorGUILayout.HelpBox(sb.ToString(), MessageType.None);
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ namespace XCharts.Editor
|
|||||||
}
|
}
|
||||||
if (GUILayout.Button("Reinit Component"))
|
if (GUILayout.Button("Reinit Component"))
|
||||||
{
|
{
|
||||||
m_Chart.ReinitAllChartComponent();
|
m_Chart.RemoveAndReinitChartObject();
|
||||||
}
|
}
|
||||||
if (m_CheckWarning)
|
if (m_CheckWarning)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ namespace XCharts.Editor
|
|||||||
PropertyField(prop, "m_HighlightColor");
|
PropertyField(prop, "m_HighlightColor");
|
||||||
PropertyField(prop, "m_HighlightToColor");
|
PropertyField(prop, "m_HighlightToColor");
|
||||||
PropertyField(prop, "m_Opacity");
|
PropertyField(prop, "m_Opacity");
|
||||||
PropertyField(prop, "m_TooltipHighlight");
|
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace XCharts.Editor
|
|||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
PropertyField(prop, "m_FoldSeries");
|
PropertyField(prop, "m_FoldSeries");
|
||||||
PropertyField(prop, "m_ShowDebugInfo");
|
PropertyField(prop, "m_ShowDebugInfo");
|
||||||
PropertyField(prop, "m_ShowAllChildObject");
|
PropertyField(prop, "m_ShowAllChartObject");
|
||||||
PropertyField(prop, "m_DebugInfoTextStyle");
|
PropertyField(prop, "m_DebugInfoTextStyle");
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace XCharts.Editor
|
|||||||
PropertyField(prop, "m_BackgroundWidth");
|
PropertyField(prop, "m_BackgroundWidth");
|
||||||
PropertyField(prop, "m_CenterColor");
|
PropertyField(prop, "m_CenterColor");
|
||||||
PropertyField(prop, "m_CenterGap");
|
PropertyField(prop, "m_CenterGap");
|
||||||
PropertyField(prop, "m_BorderType");
|
|
||||||
PropertyField(prop, "m_BorderWidth");
|
PropertyField(prop, "m_BorderWidth");
|
||||||
PropertyField(prop, "m_BorderColor");
|
PropertyField(prop, "m_BorderColor");
|
||||||
PropertyField(prop, "m_BorderColor0");
|
PropertyField(prop, "m_BorderColor0");
|
||||||
|
|||||||
38
Editor/ChildComponents/LevelStyleDrawer.cs
Normal file
38
Editor/ChildComponents/LevelStyleDrawer.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using XCharts.Runtime;
|
||||||
|
|
||||||
|
namespace XCharts.Editor
|
||||||
|
{
|
||||||
|
[CustomPropertyDrawer(typeof(LevelStyle), true)]
|
||||||
|
public class LevelStyleDrawer : BasePropertyDrawer
|
||||||
|
{
|
||||||
|
public override string ClassName { get { return "LevelStyle"; } }
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
base.OnGUI(pos, prop, label);
|
||||||
|
if (MakeComponentFoldout(prop, "m_Show"))
|
||||||
|
{
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
PropertyListField(prop, "m_Levels");
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CustomPropertyDrawer(typeof(Level), true)]
|
||||||
|
public class LevelDrawer : BasePropertyDrawer
|
||||||
|
{
|
||||||
|
public override string ClassName { get { return "Level"; } }
|
||||||
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||||
|
{
|
||||||
|
base.OnGUI(pos, prop, label);
|
||||||
|
++EditorGUI.indentLevel;
|
||||||
|
PropertyField(prop, "m_Label");
|
||||||
|
PropertyField(prop, "m_UpperLabel");
|
||||||
|
PropertyField(prop, "m_ItemStyle");
|
||||||
|
--EditorGUI.indentLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Editor/ChildComponents/LevelStyleDrawer.cs.meta
Normal file
11
Editor/ChildComponents/LevelStyleDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7a1ff119a53a44e5abe2ef6f57816aa6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -39,7 +39,7 @@ namespace XCharts.Editor
|
|||||||
PropertyField(prop, "m_DataScale");
|
PropertyField(prop, "m_DataScale");
|
||||||
PropertyField(prop, "m_SelectedDataScale");
|
PropertyField(prop, "m_SelectedDataScale");
|
||||||
break;
|
break;
|
||||||
case SymbolSizeType.Callback:
|
case SymbolSizeType.Function:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PropertyField(prop, "m_StartIndex");
|
PropertyField(prop, "m_StartIndex");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace XCharts.Editor
|
|||||||
public override void OnCustomInspectorGUI()
|
public override void OnCustomInspectorGUI()
|
||||||
{
|
{
|
||||||
PropertyField("m_RoseType");
|
PropertyField("m_RoseType");
|
||||||
PropertyField("m_Space");
|
PropertyField("m_Gap");
|
||||||
PropertyTwoFiled("m_Center");
|
PropertyTwoFiled("m_Center");
|
||||||
PropertyTwoFiled("m_Radius");
|
PropertyTwoFiled("m_Radius");
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace XCharts.Editor
|
|||||||
PropertyTwoFiled("m_Center");
|
PropertyTwoFiled("m_Center");
|
||||||
PropertyTwoFiled("m_Radius");
|
PropertyTwoFiled("m_Radius");
|
||||||
PropertyField("m_StartAngle");
|
PropertyField("m_StartAngle");
|
||||||
PropertyField("m_RingGap");
|
PropertyField("m_Gap");
|
||||||
PropertyField("m_RoundCap");
|
PropertyField("m_RoundCap");
|
||||||
PropertyField("m_Clockwise");
|
PropertyField("m_Clockwise");
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace XCharts.Editor
|
|||||||
while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
|
while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
|
||||||
while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
|
while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
|
||||||
}
|
}
|
||||||
if (listSize > 30 && !XCSettings.editorShowAllListData)
|
if (listSize > 30)// && !XCSettings.editorShowAllListData)
|
||||||
{
|
{
|
||||||
int num = listSize > 10 ? 10 : listSize;
|
int num = listSize > 10 ? 10 : listSize;
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
@@ -191,10 +191,10 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
var serieData = m_Datas.GetArrayElementAtIndex(index);
|
var serieData = m_Datas.GetArrayElementAtIndex(index);
|
||||||
var sereName = serieData.FindPropertyRelative("m_Name");
|
var m_Name = serieData.FindPropertyRelative("m_Name");
|
||||||
var selected = serieData.FindPropertyRelative("m_Selected");
|
var m_Id = serieData.FindPropertyRelative("m_Id");
|
||||||
|
var m_ParentId = serieData.FindPropertyRelative("m_ParentId");
|
||||||
|
|
||||||
var m_Ignore = serieData.FindPropertyRelative("m_Ignore");
|
|
||||||
var m_IconStyle = serieData.FindPropertyRelative("m_IconStyles");
|
var m_IconStyle = serieData.FindPropertyRelative("m_IconStyles");
|
||||||
var m_Label = serieData.FindPropertyRelative("m_Labels");
|
var m_Label = serieData.FindPropertyRelative("m_Labels");
|
||||||
var m_ItemStyle = serieData.FindPropertyRelative("m_ItemStyles");
|
var m_ItemStyle = serieData.FindPropertyRelative("m_ItemStyles");
|
||||||
@@ -204,9 +204,9 @@ namespace XCharts.Editor
|
|||||||
var m_AreaStyle = serieData.FindPropertyRelative("m_AreaStyles");
|
var m_AreaStyle = serieData.FindPropertyRelative("m_AreaStyles");
|
||||||
var m_TitleStyle = serieData.FindPropertyRelative("m_TitleStyles");
|
var m_TitleStyle = serieData.FindPropertyRelative("m_TitleStyles");
|
||||||
|
|
||||||
PropertyField(sereName);
|
PropertyField(m_Name);
|
||||||
PropertyField(selected);
|
PropertyField(m_Id);
|
||||||
PropertyField(m_Ignore);
|
PropertyField(m_ParentId);
|
||||||
|
|
||||||
var componentNum = m_IconStyle.arraySize + m_Label.arraySize + m_ItemStyle.arraySize + m_Emphasis.arraySize
|
var componentNum = m_IconStyle.arraySize + m_Label.arraySize + m_ItemStyle.arraySize + m_Emphasis.arraySize
|
||||||
+ m_Symbol.arraySize + m_LineStyle.arraySize + m_AreaStyle.arraySize;
|
+ m_Symbol.arraySize + m_LineStyle.arraySize + m_AreaStyle.arraySize;
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ namespace XCharts.Example
|
|||||||
var serie = chart.GetSerie(0);
|
var serie = chart.GetSerie(0);
|
||||||
serie.animation.enable = true;
|
serie.animation.enable = true;
|
||||||
//自定义每个数据项的渐入延时
|
//自定义每个数据项的渐入延时
|
||||||
serie.animation.customFadeInDelay = CustomFadeInDelay;
|
serie.animation.fadeInDelayFunction = CustomFadeInDelay;
|
||||||
//自定义每个数据项的渐入时长
|
//自定义每个数据项的渐入时长
|
||||||
serie.animation.customFadeInDuration = CustomFadeInDuration;
|
serie.animation.fadeInDurationFunction = CustomFadeInDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CustomFadeInDelay(int dataIndex)
|
float CustomFadeInDelay(int dataIndex)
|
||||||
|
|||||||
@@ -17,15 +17,15 @@ namespace XCharts.Example
|
|||||||
chart = gameObject.GetComponent<LineChart>();
|
chart = gameObject.GetComponent<LineChart>();
|
||||||
if (chart == null) return;
|
if (chart == null) return;
|
||||||
|
|
||||||
chart.onCustomDraw = delegate (VertexHelper vh)
|
chart.onDraw = delegate (VertexHelper vh)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
// or
|
// or
|
||||||
chart.onCustomDrawBeforeSerie = delegate (VertexHelper vh, Serie serie)
|
chart.onDrawBeforeSerie = delegate (VertexHelper vh, Serie serie)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
// or
|
// or
|
||||||
chart.onCustomDrawAfterSerie = delegate (VertexHelper vh, Serie serie)
|
chart.onDrawAfterSerie = delegate (VertexHelper vh, Serie serie)
|
||||||
{
|
{
|
||||||
if (serie.index != 0) return;
|
if (serie.index != 0) return;
|
||||||
var dataPoints = serie.context.dataPoints;
|
var dataPoints = serie.context.dataPoints;
|
||||||
@@ -41,7 +41,7 @@ namespace XCharts.Example
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
// or
|
// or
|
||||||
chart.onCustomDrawTop = delegate (VertexHelper vh)
|
chart.onDrawTop = delegate (VertexHelper vh)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace XCharts.Example
|
|||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
serie.pieSpace = 1f;
|
serie.gap = 1f;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return new WaitForSeconds(1);
|
yield return new WaitForSeconds(1);
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ namespace XCharts.Example
|
|||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return new WaitForSeconds(1);
|
yield return new WaitForSeconds(1);
|
||||||
|
|
||||||
serie.pieSpace = 0f;
|
serie.gap = 0f;
|
||||||
serie.data[0].selected = false;
|
serie.data[0].selected = false;
|
||||||
chart.RefreshChart();
|
chart.RefreshChart();
|
||||||
yield return new WaitForSeconds(1);
|
yield return new WaitForSeconds(1);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ namespace XCharts.Example
|
|||||||
if (chart == null) return;
|
if (chart == null) return;
|
||||||
foreach (var serie in chart.series)
|
foreach (var serie in chart.series)
|
||||||
{
|
{
|
||||||
serie.symbol.sizeCallback = SymbolSize;
|
serie.symbol.sizeFunction = SymbolSize;
|
||||||
serie.symbol.selectedSizeCallback = SymbolSelectedSize;
|
serie.symbol.selectedSizeFunction = SymbolSelectedSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ using System;
|
|||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
{
|
{
|
||||||
public delegate float CustomAnimationDelay(int dataIndex);
|
|
||||||
public delegate float CustomAnimationDuration(int dataIndex);
|
|
||||||
|
|
||||||
public enum AnimationType
|
public enum AnimationType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -69,19 +66,19 @@ namespace XCharts.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义渐入动画延时函数。返回ms值。
|
/// 自定义渐入动画延时函数。返回ms值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CustomAnimationDelay customFadeInDelay;
|
public AnimationDelayFunction fadeInDelayFunction;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义渐入动画时长函数。返回ms值。
|
/// 自定义渐入动画时长函数。返回ms值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CustomAnimationDuration customFadeInDuration;
|
public AnimationDurationFunction fadeInDurationFunction;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义渐出动画延时函数。返回ms值。
|
/// 自定义渐出动画延时函数。返回ms值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CustomAnimationDelay customFadeOutDelay;
|
public AnimationDelayFunction fadeOutDelayFunction;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义渐出动画时长函数。返回ms值。
|
/// 自定义渐出动画时长函数。返回ms值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CustomAnimationDuration customFadeOutDuration;
|
public AnimationDurationFunction fadeOutDurationFunction;
|
||||||
public AnimationStyleContext context = new AnimationStyleContext();
|
public AnimationStyleContext context = new AnimationStyleContext();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -390,10 +387,10 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public float GetIndexDelay(int dataIndex)
|
public float GetIndexDelay(int dataIndex)
|
||||||
{
|
{
|
||||||
if (m_FadeOut && customFadeOutDelay != null)
|
if (m_FadeOut && fadeOutDelayFunction != null)
|
||||||
return customFadeOutDelay(dataIndex);
|
return fadeOutDelayFunction(dataIndex);
|
||||||
else if (m_FadeIn && customFadeInDelay != null)
|
else if (m_FadeIn && fadeInDelayFunction != null)
|
||||||
return customFadeInDelay(dataIndex);
|
return fadeInDelayFunction(dataIndex);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -492,10 +489,10 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
if (dataIndex >= 0)
|
if (dataIndex >= 0)
|
||||||
{
|
{
|
||||||
if (m_FadeOut && customFadeOutDuration != null)
|
if (m_FadeOut && fadeOutDurationFunction != null)
|
||||||
return customFadeOutDuration(dataIndex) / 1000f;
|
return fadeOutDurationFunction(dataIndex) / 1000f;
|
||||||
if (m_FadeIn && customFadeInDuration != null)
|
if (m_FadeIn && fadeInDurationFunction != null)
|
||||||
return customFadeInDuration(dataIndex) / 1000f;
|
return fadeInDurationFunction(dataIndex) / 1000f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_FadeOut)
|
if (m_FadeOut)
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ namespace XCharts
|
|||||||
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
|
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
|
||||||
if (j != lastPointerValue)
|
if (j != lastPointerValue)
|
||||||
{
|
{
|
||||||
if (chart.onUpdateAxisPointer != null)
|
if (chart.onAxisPointerValueChanged != null)
|
||||||
chart.onUpdateAxisPointer(axis, j);
|
chart.onAxisPointerValueChanged(axis, j);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -74,8 +74,8 @@ namespace XCharts
|
|||||||
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
|
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
|
||||||
if (j != lastPointerValue)
|
if (j != lastPointerValue)
|
||||||
{
|
{
|
||||||
if (chart.onUpdateAxisPointer != null)
|
if (chart.onAxisPointerValueChanged != null)
|
||||||
chart.onUpdateAxisPointer(axis, j);
|
chart.onAxisPointerValueChanged(axis, j);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -97,8 +97,8 @@ namespace XCharts
|
|||||||
axis.context.pointerLabelPosition = new Vector3(labelX, chart.pointerPos.y);
|
axis.context.pointerLabelPosition = new Vector3(labelX, chart.pointerPos.y);
|
||||||
if (yValue != lastPointerValue)
|
if (yValue != lastPointerValue)
|
||||||
{
|
{
|
||||||
if (chart.onUpdateAxisPointer != null)
|
if (chart.onAxisPointerValueChanged != null)
|
||||||
chart.onUpdateAxisPointer(axis, yValue);
|
chart.onAxisPointerValueChanged(axis, yValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -114,8 +114,8 @@ namespace XCharts
|
|||||||
axis.context.pointerLabelPosition = new Vector3(chart.pointerPos.x, labelY);
|
axis.context.pointerLabelPosition = new Vector3(chart.pointerPos.x, labelY);
|
||||||
if (xValue != lastPointerValue)
|
if (xValue != lastPointerValue)
|
||||||
{
|
{
|
||||||
if (chart.onUpdateAxisPointer != null)
|
if (chart.onAxisPointerValueChanged != null)
|
||||||
chart.onUpdateAxisPointer(axis, xValue);
|
chart.onAxisPointerValueChanged(axis, xValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -750,7 +750,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal static void DrawAxisSplit(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
|
internal static void DrawAxisSplit(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
|
||||||
Orient orient, float startX, float startY, float axisLength, float splitLength)
|
Orient orient, float startX, float startY, float axisLength, float splitLength, Axis relativedAxis = null)
|
||||||
{
|
{
|
||||||
var lineColor = axis.splitLine.GetColor(theme.splitLineColor);
|
var lineColor = axis.splitLine.GetColor(theme.splitLineColor);
|
||||||
var lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
|
var lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
|
||||||
@@ -803,6 +803,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (orient == Orient.Horizonal)
|
if (orient == Orient.Horizonal)
|
||||||
{
|
{
|
||||||
|
if (relativedAxis == null || MathUtil.Approximately(current, relativedAxis.context.x))
|
||||||
ChartDrawer.DrawLineStyle(vh,
|
ChartDrawer.DrawLineStyle(vh,
|
||||||
lineType,
|
lineType,
|
||||||
lineWidth,
|
lineWidth,
|
||||||
@@ -812,12 +813,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ChartDrawer.DrawLineStyle(vh,
|
if (relativedAxis == null || MathUtil.Approximately(current, relativedAxis.context.y))
|
||||||
lineType,
|
ChartDrawer.DrawLineStyle(vh,
|
||||||
lineWidth,
|
lineType,
|
||||||
new Vector3(startX, current),
|
lineWidth,
|
||||||
new Vector3(startX + splitLength, current),
|
new Vector3(startX, current),
|
||||||
lineColor);
|
new Vector3(startX + splitLength, current),
|
||||||
|
lineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
if (dataCount < 1)
|
if (dataCount < 1)
|
||||||
dataCount = 1;
|
dataCount = 1;
|
||||||
|
if (axis.IsValue())
|
||||||
|
return dataCount > 1 ? coordinateWidth / (dataCount - 1) : coordinateWidth;
|
||||||
var categoryCount = axis.GetDataCount(dataZoom);
|
var categoryCount = axis.GetDataCount(dataZoom);
|
||||||
int segment = (axis.boundaryGap ? categoryCount : categoryCount - 1);
|
int segment = (axis.boundaryGap ? categoryCount : categoryCount - 1);
|
||||||
segment = segment <= 0 ? dataCount : segment;
|
segment = segment <= 0 ? dataCount : segment;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private bool m_ShowEndLabel = true;
|
[SerializeField] private bool m_ShowEndLabel = true;
|
||||||
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||||
private DelegateAxisLabelFormatter m_FormatterFunction;
|
private AxisLabelFormatterFunction m_FormatterFunction;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this to false to prevent the axis label from appearing.
|
/// Set this to false to prevent the axis label from appearing.
|
||||||
@@ -158,7 +158,7 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateAxisLabelFormatter formatterFunction
|
public AxisLabelFormatterFunction formatterFunction
|
||||||
{
|
{
|
||||||
set { m_FormatterFunction = value; }
|
set { m_FormatterFunction = value; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ namespace XCharts.Runtime
|
|||||||
if (grid == null)
|
if (grid == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var relativedAxis = chart.GetChartComponent<YAxis>(xAxis.gridIndex);
|
||||||
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
|
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
|
||||||
|
|
||||||
DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
|
DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
|
||||||
@@ -99,7 +100,8 @@ namespace XCharts.Runtime
|
|||||||
grid.context.x,
|
grid.context.x,
|
||||||
grid.context.y,
|
grid.context.y,
|
||||||
grid.context.width,
|
grid.context.width,
|
||||||
grid.context.height);
|
grid.context.height,
|
||||||
|
relativedAxis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,14 +89,15 @@ namespace XCharts.Runtime
|
|||||||
var grid = chart.GetChartComponent<GridCoord>(yAxis.gridIndex);
|
var grid = chart.GetChartComponent<GridCoord>(yAxis.gridIndex);
|
||||||
if (grid == null)
|
if (grid == null)
|
||||||
return;
|
return;
|
||||||
|
var relativedAxis = chart.GetChartComponent<XAxis>(yAxis.gridIndex);
|
||||||
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
|
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
|
||||||
DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
|
||||||
Orient.Vertical,
|
Orient.Vertical,
|
||||||
grid.context.x,
|
grid.context.x,
|
||||||
grid.context.y,
|
grid.context.y,
|
||||||
grid.context.height,
|
grid.context.height,
|
||||||
grid.context.width);
|
grid.context.width,
|
||||||
|
relativedAxis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private Color32 m_Color;
|
[SerializeField] private Color32 m_Color;
|
||||||
[SerializeField] private Color32 m_ToColor;
|
[SerializeField] private Color32 m_ToColor;
|
||||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 0.6f;
|
[SerializeField] [Range(0, 1)] private float m_Opacity = 0.6f;
|
||||||
[SerializeField] private bool m_TooltipHighlight;
|
|
||||||
[SerializeField] private Color32 m_HighlightColor;
|
[SerializeField] private Color32 m_HighlightColor;
|
||||||
[SerializeField] private Color32 m_HighlightToColor;
|
[SerializeField] private Color32 m_HighlightToColor;
|
||||||
|
|
||||||
@@ -88,14 +87,6 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 鼠标悬浮时是否高亮之前的区域
|
|
||||||
/// </summary>
|
|
||||||
public bool tooltipHighlight
|
|
||||||
{
|
|
||||||
get { return m_TooltipHighlight; }
|
|
||||||
set { if (PropertyUtil.SetStruct(ref m_TooltipHighlight, value)) SetVerticesDirty(); }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// the color of area,default use serie color.
|
/// the color of area,default use serie color.
|
||||||
/// 高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。
|
/// 高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace XCharts.Runtime
|
|||||||
UnderLabel,
|
UnderLabel,
|
||||||
AboveLabel
|
AboveLabel
|
||||||
}
|
}
|
||||||
[SerializeField] private bool m_Show;
|
[SerializeField] private bool m_Show = false;
|
||||||
[SerializeField] private Layer m_Layer;
|
[SerializeField] private Layer m_Layer;
|
||||||
[SerializeField] private Align m_Align = Align.Left;
|
[SerializeField] private Align m_Align = Align.Left;
|
||||||
[SerializeField] private Sprite m_Sprite;
|
[SerializeField] private Sprite m_Sprite;
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
@@ -11,24 +8,6 @@ namespace XCharts.Runtime
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class ItemStyle : ChildComponent, ISerieDataComponent
|
public class ItemStyle : ChildComponent, ISerieDataComponent
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 线的类型。
|
|
||||||
/// </summary>
|
|
||||||
public enum Type
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 实线
|
|
||||||
/// </summary>
|
|
||||||
Solid,
|
|
||||||
/// <summary>
|
|
||||||
/// 虚线
|
|
||||||
/// </summary>
|
|
||||||
Dashed,
|
|
||||||
/// <summary>
|
|
||||||
/// 点线
|
|
||||||
/// </summary>
|
|
||||||
Dotted
|
|
||||||
}
|
|
||||||
[SerializeField] private bool m_Show = true;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private Color32 m_Color;
|
[SerializeField] private Color32 m_Color;
|
||||||
[SerializeField] private Color32 m_Color0;
|
[SerializeField] private Color32 m_Color0;
|
||||||
@@ -38,7 +17,6 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private float m_BackgroundWidth;
|
[SerializeField] private float m_BackgroundWidth;
|
||||||
[SerializeField] private Color32 m_CenterColor;
|
[SerializeField] private Color32 m_CenterColor;
|
||||||
[SerializeField] private float m_CenterGap;
|
[SerializeField] private float m_CenterGap;
|
||||||
[SerializeField] private Type m_BorderType = Type.Solid;
|
|
||||||
[SerializeField] private float m_BorderWidth = 0;
|
[SerializeField] private float m_BorderWidth = 0;
|
||||||
[SerializeField] private Color32 m_BorderColor;
|
[SerializeField] private Color32 m_BorderColor;
|
||||||
[SerializeField] private Color32 m_BorderColor0;
|
[SerializeField] private Color32 m_BorderColor0;
|
||||||
@@ -60,7 +38,6 @@ namespace XCharts.Runtime
|
|||||||
m_BackgroundWidth = 0;
|
m_BackgroundWidth = 0;
|
||||||
m_CenterColor = Color.clear;
|
m_CenterColor = Color.clear;
|
||||||
m_CenterGap = 0;
|
m_CenterGap = 0;
|
||||||
m_BorderType = Type.Solid;
|
|
||||||
m_BorderWidth = 0;
|
m_BorderWidth = 0;
|
||||||
m_BorderColor = Color.clear;
|
m_BorderColor = Color.clear;
|
||||||
m_BorderColor0 = Color.clear;
|
m_BorderColor0 = Color.clear;
|
||||||
@@ -155,14 +132,6 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 边框的类型。
|
|
||||||
/// </summary>
|
|
||||||
public Type borderType
|
|
||||||
{
|
|
||||||
get { return m_BorderType; }
|
|
||||||
set { if (PropertyUtil.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 边框的颜色。
|
/// 边框的颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Color32 borderColor
|
public Color32 borderColor
|
||||||
@@ -261,6 +230,7 @@ namespace XCharts.Runtime
|
|||||||
color.a = (byte)(color.a * m_Opacity);
|
color.a = (byte)(color.a * m_Opacity);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color32 GetColor0()
|
public Color32 GetColor0()
|
||||||
{
|
{
|
||||||
if (m_Opacity == 1 || m_Color0.a == 0)
|
if (m_Opacity == 1 || m_Color0.a == 0)
|
||||||
@@ -270,6 +240,7 @@ namespace XCharts.Runtime
|
|||||||
color.a = (byte)(color.a * m_Opacity);
|
color.a = (byte)(color.a * m_Opacity);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color32 GetColor(Color32 defaultColor)
|
public Color32 GetColor(Color32 defaultColor)
|
||||||
{
|
{
|
||||||
var color = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
var color = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||||
@@ -280,6 +251,7 @@ namespace XCharts.Runtime
|
|||||||
color.a = (byte)(color.a * m_Opacity);
|
color.a = (byte)(color.a * m_Opacity);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color32 GetColor0(Color32 defaultColor)
|
public Color32 GetColor0(Color32 defaultColor)
|
||||||
{
|
{
|
||||||
var color = ChartHelper.IsClearColor(m_Color0) ? defaultColor : m_Color0;
|
var color = ChartHelper.IsClearColor(m_Color0) ? defaultColor : m_Color0;
|
||||||
@@ -290,6 +262,7 @@ namespace XCharts.Runtime
|
|||||||
color.a = (byte)(color.a * m_Opacity);
|
color.a = (byte)(color.a * m_Opacity);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color32 GetBorderColor(Color32 defaultColor)
|
public Color32 GetBorderColor(Color32 defaultColor)
|
||||||
{
|
{
|
||||||
var color = ChartHelper.IsClearColor(m_BorderColor) ? defaultColor : m_BorderColor;
|
var color = ChartHelper.IsClearColor(m_BorderColor) ? defaultColor : m_BorderColor;
|
||||||
@@ -300,6 +273,7 @@ namespace XCharts.Runtime
|
|||||||
color.a = (byte)(color.a * m_Opacity);
|
color.a = (byte)(color.a * m_Opacity);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color32 GetBorderColor0(Color32 defaultColor)
|
public Color32 GetBorderColor0(Color32 defaultColor)
|
||||||
{
|
{
|
||||||
var color = ChartHelper.IsClearColor(m_BorderColor0) ? defaultColor : m_BorderColor0;
|
var color = ChartHelper.IsClearColor(m_BorderColor0) ? defaultColor : m_BorderColor0;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private bool m_AutoOffset = false;
|
[SerializeField] private bool m_AutoOffset = false;
|
||||||
[SerializeField] private bool m_AutoColor = false;
|
[SerializeField] private bool m_AutoColor = false;
|
||||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||||
private DelegateSerieLabelFormatter m_FormatterFunction;
|
private SerieLabelFormatterFunction m_FormatterFunction;
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
@@ -230,7 +230,7 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetAllDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetAllDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelegateSerieLabelFormatter formatterFunction
|
public SerieLabelFormatterFunction formatterFunction
|
||||||
{
|
{
|
||||||
get { return m_FormatterFunction; }
|
get { return m_FormatterFunction; }
|
||||||
set { m_FormatterFunction = value; }
|
set { m_FormatterFunction = value; }
|
||||||
|
|||||||
33
Runtime/Component/Child/LevelStyle.cs
Normal file
33
Runtime/Component/Child/LevelStyle.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace XCharts.Runtime
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class Level : ChildComponent
|
||||||
|
{
|
||||||
|
[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
||||||
|
[SerializeField] private LabelStyle m_UpperLabel = new LabelStyle();
|
||||||
|
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
||||||
|
|
||||||
|
public LabelStyle label { get { return m_Label; } }
|
||||||
|
public LabelStyle upperLabel { get { return m_UpperLabel; } }
|
||||||
|
public ItemStyle itemStyle { get { return m_ItemStyle; } }
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class LevelStyle : ChildComponent
|
||||||
|
{
|
||||||
|
[SerializeField] private bool m_Show = false;
|
||||||
|
[SerializeField] private List<Level> m_Levels = new List<Level>() { new Level() };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用LevelStyle
|
||||||
|
/// </summary>
|
||||||
|
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// 各层节点对应的配置。当enableLevels为true时生效,levels[0]对应的第一层的配置,levels[1]对应第二层,依次类推。当levels中没有对应层时用默认的设置。
|
||||||
|
/// </summary>
|
||||||
|
public List<Level> levels { get { return m_Levels; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Runtime/Component/Child/LevelStyle.cs.meta
Normal file
11
Runtime/Component/Child/LevelStyle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3760e89d324d7413d95a2ac1d434a546
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -78,19 +78,12 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
FromData,
|
FromData,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify callback function for symbol size.
|
/// Specify function for symbol size.
|
||||||
/// 通过回调函数获取。
|
/// 通过委托函数获取。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Callback,
|
Function,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取标记大小的回调。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public delegate float SymbolSizeCallback(List<double> data);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系列数据项的标记的图形
|
/// 系列数据项的标记的图形
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -105,8 +98,8 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private int m_DataIndex = 1;
|
[SerializeField] private int m_DataIndex = 1;
|
||||||
[SerializeField] private float m_DataScale = 1;
|
[SerializeField] private float m_DataScale = 1;
|
||||||
[SerializeField] private float m_SelectedDataScale = 1.5f;
|
[SerializeField] private float m_SelectedDataScale = 1.5f;
|
||||||
[SerializeField] private SymbolSizeCallback m_SizeCallback;
|
[SerializeField] private SymbolSizeFunction m_SizeFunction;
|
||||||
[SerializeField] private SymbolSizeCallback m_SelectedSizeCallback;
|
[SerializeField] private SymbolSizeFunction m_SelectedSizeFunction;
|
||||||
[SerializeField] private int m_StartIndex;
|
[SerializeField] private int m_StartIndex;
|
||||||
[SerializeField] private int m_Interval;
|
[SerializeField] private int m_Interval;
|
||||||
[SerializeField] private bool m_ForceShowLast = false;
|
[SerializeField] private bool m_ForceShowLast = false;
|
||||||
@@ -128,8 +121,8 @@ namespace XCharts.Runtime
|
|||||||
m_DataIndex = 1;
|
m_DataIndex = 1;
|
||||||
m_DataScale = 1;
|
m_DataScale = 1;
|
||||||
m_SelectedDataScale = 1.5f;
|
m_SelectedDataScale = 1.5f;
|
||||||
m_SizeCallback = null;
|
m_SizeFunction = null;
|
||||||
m_SelectedSizeCallback = null;
|
m_SelectedSizeFunction = null;
|
||||||
m_StartIndex = 0;
|
m_StartIndex = 0;
|
||||||
m_Interval = 0;
|
m_Interval = 0;
|
||||||
m_ForceShowLast = false;
|
m_ForceShowLast = false;
|
||||||
@@ -215,22 +208,22 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the callback of size when sizeType assined as Callback.
|
/// the function of size when sizeType assined as Function.
|
||||||
/// 当sizeType指定为Callback时,指定的回调函数。
|
/// 当sizeType指定为Function时,指定的委托函数。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SymbolSizeCallback sizeCallback
|
public SymbolSizeFunction sizeFunction
|
||||||
{
|
{
|
||||||
get { return m_SizeCallback; }
|
get { return m_SizeFunction; }
|
||||||
set { if (PropertyUtil.SetClass(ref m_SizeCallback, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_SizeFunction, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the callback of size when sizeType assined as Callback.
|
/// the function of size when sizeType assined as Function.
|
||||||
/// 当sizeType指定为Callback时,指定的高亮回调函数。
|
/// 当sizeType指定为Function时,指定的高亮委托函数。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SymbolSizeCallback selectedSizeCallback
|
public SymbolSizeFunction selectedSizeFunction
|
||||||
{
|
{
|
||||||
get { return m_SelectedSizeCallback; }
|
get { return m_SelectedSizeFunction; }
|
||||||
set { if (PropertyUtil.SetClass(ref m_SelectedSizeCallback, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_SelectedSizeFunction, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the index start to show symbol.
|
/// the index start to show symbol.
|
||||||
@@ -341,8 +334,8 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
return size == 0 ? themeSize : size;
|
return size == 0 ? themeSize : size;
|
||||||
}
|
}
|
||||||
case SymbolSizeType.Callback:
|
case SymbolSizeType.Function:
|
||||||
if (data != null && sizeCallback != null) return sizeCallback(data);
|
if (data != null && sizeFunction != null) return sizeFunction(data);
|
||||||
else return size == 0 ? themeSize : size;
|
else return size == 0 ? themeSize : size;
|
||||||
default: return size == 0 ? themeSize : size;
|
default: return size == 0 ? themeSize : size;
|
||||||
}
|
}
|
||||||
@@ -372,10 +365,10 @@ namespace XCharts.Runtime
|
|||||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SymbolSizeType.Callback:
|
case SymbolSizeType.Function:
|
||||||
|
|
||||||
if (data != null && selectedSizeCallback != null)
|
if (data != null && selectedSizeFunction != null)
|
||||||
return selectedSizeCallback(data);
|
return selectedSizeFunction(data);
|
||||||
else
|
else
|
||||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace XCharts.Runtime
|
|||||||
public class DebugInfo
|
public class DebugInfo
|
||||||
{
|
{
|
||||||
[SerializeField] private bool m_ShowDebugInfo = false;
|
[SerializeField] private bool m_ShowDebugInfo = false;
|
||||||
[SerializeField] protected bool m_ShowAllChildObject = false;
|
[SerializeField] protected bool m_ShowAllChartObject = false;
|
||||||
[SerializeField] protected bool m_FoldSeries = false;
|
[SerializeField] protected bool m_FoldSeries = false;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private TextStyle m_DebugInfoTextStyle = new TextStyle()
|
private TextStyle m_DebugInfoTextStyle = new TextStyle()
|
||||||
@@ -32,7 +32,7 @@ namespace XCharts.Runtime
|
|||||||
private ChartLabel m_Label;
|
private ChartLabel m_Label;
|
||||||
private List<float> m_FpsList = new List<float>();
|
private List<float> m_FpsList = new List<float>();
|
||||||
|
|
||||||
public bool showAllChildObject { get { return m_ShowAllChildObject; } }
|
public bool showAllChartObject { get { return m_ShowAllChartObject; } }
|
||||||
public bool foldSeries { get { return m_FoldSeries; } set { m_FoldSeries = value; } }
|
public bool foldSeries { get { return m_FoldSeries; } set { m_FoldSeries = value; } }
|
||||||
public float fps { get; private set; }
|
public float fps { get; private set; }
|
||||||
public float avgFps { get; private set; }
|
public float avgFps { get; private set; }
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
|
|||||||
@@ -412,6 +412,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)
|
public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)
|
||||||
{
|
{
|
||||||
|
if (serieData == null) return serie.label;
|
||||||
if (highlight)
|
if (highlight)
|
||||||
{
|
{
|
||||||
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
|
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
|
||||||
|
|||||||
@@ -72,23 +72,23 @@ namespace XCharts.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义绘制回调。在绘制Serie前调用。
|
/// 自定义绘制回调。在绘制Serie前调用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<VertexHelper> onCustomDraw { set { m_OnCustomDrawBaseCallback = value; } }
|
public Action<VertexHelper> onDraw { set { m_OnDrawBase = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义Serie绘制回调。在每个Serie绘制完前调用。
|
/// 自定义Serie绘制回调。在每个Serie绘制完前调用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<VertexHelper, Serie> onCustomDrawBeforeSerie { set { m_OnCustomDrawSerieBeforeCallback = value; } }
|
public Action<VertexHelper, Serie> onDrawBeforeSerie { set { m_OnDrawSerieBefore = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义Serie绘制回调。在每个Serie绘制完后调用。
|
/// 自定义Serie绘制回调。在每个Serie绘制完后调用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<VertexHelper, Serie> onCustomDrawAfterSerie { set { m_OnCustomDrawSerieAfterCallback = value; } }
|
public Action<VertexHelper, Serie> onDrawAfterSerie { set { m_OnDrawSerieAfter = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义Top绘制回调。在绘制Tooltip前调用。
|
/// 自定义Top绘制回调。在绘制Tooltip前调用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<VertexHelper> onCustomDrawTop { set { m_OnCustomDrawTopCallback = value; } }
|
public Action<VertexHelper> onDrawTop { set { m_OnDrawTop = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义仪表盘指针绘制回调。参数:SerieIndex,SerieDataIndex,currAngle
|
/// 自定义仪表盘指针绘制委托。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<VertexHelper, int, int, float> onCustomDrawGagugePointer { set { m_OnCustomDrawGagugePointerCallback = value; } get { return m_OnCustomDrawGagugePointerCallback; } }
|
public CustomDrawGaugePointerFunction customDrawGaugePointerFunction { set { m_CustomDrawGaugePointerFunction = value; } get { return m_CustomDrawGaugePointerFunction; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the callback function of click pie area.
|
/// the callback function of click pie area.
|
||||||
/// 点击饼图区域回调。参数:PointerEventData,SerieIndex,SerieDataIndex
|
/// 点击饼图区域回调。参数:PointerEventData,SerieIndex,SerieDataIndex
|
||||||
@@ -102,7 +102,7 @@ namespace XCharts.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 坐标轴变更数据索引时回调。参数:axis, dataIndex/dataValue
|
/// 坐标轴变更数据索引时回调。参数:axis, dataIndex/dataValue
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<Axis, double> onUpdateAxisPointer { set { m_OnUpdateAxisPointer = value; } get { return m_OnUpdateAxisPointer; } }
|
public Action<Axis, double> onAxisPointerValueChanged { set { m_OnAxisPointerValueChanged = value; } get { return m_OnAxisPointerValueChanged; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Redraw chart in next frame.
|
/// Redraw chart in next frame.
|
||||||
/// 在下一帧刷新图表。
|
/// 在下一帧刷新图表。
|
||||||
|
|||||||
@@ -190,7 +190,6 @@ namespace XCharts.Runtime
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a data to serie.
|
/// Add a data to serie.
|
||||||
/// If serieName doesn't exist in legend,will be add to legend.
|
/// If serieName doesn't exist in legend,will be add to legend.
|
||||||
@@ -199,13 +198,14 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="serieName">the name of serie</param>
|
/// <param name="serieName">the name of serie</param>
|
||||||
/// <param name="data">the data to add</param>
|
/// <param name="data">the data to add</param>
|
||||||
/// <param name="dataName">the name of data</param>
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <param name="dataId">the unique id of data</param>
|
||||||
/// <returns>Returns True on success</returns>
|
/// <returns>Returns True on success</returns>
|
||||||
public SerieData AddData(string serieName, double data, string dataName = null)
|
public SerieData AddData(string serieName, double data, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddYData(data, dataName);
|
var serieData = serie.AddYData(data, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
@@ -219,13 +219,14 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="serieIndex">the index of serie</param>
|
/// <param name="serieIndex">the index of serie</param>
|
||||||
/// <param name="data">the data to add</param>
|
/// <param name="data">the data to add</param>
|
||||||
/// <param name="dataName">the name of data</param>
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <param name="dataId">the unique id of data</param>
|
||||||
/// <returns>Returns True on success</returns>
|
/// <returns>Returns True on success</returns>
|
||||||
public SerieData AddData(int serieIndex, double data, string dataName = null)
|
public SerieData AddData(int serieIndex, double data, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddYData(data, dataName);
|
var serieData = serie.AddYData(data, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
@@ -239,13 +240,14 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="serieName">the name of serie</param>
|
/// <param name="serieName">the name of serie</param>
|
||||||
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
|
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
|
||||||
/// <param name="dataName">the name of data</param>
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <param name="dataId">the unique id of data</param>
|
||||||
/// <returns>Returns True on success</returns>
|
/// <returns>Returns True on success</returns>
|
||||||
public SerieData AddData(string serieName, List<double> multidimensionalData, string dataName = null)
|
public SerieData AddData(string serieName, List<double> multidimensionalData, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddData(multidimensionalData, dataName);
|
var serieData = serie.AddData(multidimensionalData, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
@@ -259,13 +261,14 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="serieIndex">the index of serie,index starts at 0</param>
|
/// <param name="serieIndex">the index of serie,index starts at 0</param>
|
||||||
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
|
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
|
||||||
/// <param name="dataName">the name of data</param>
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <param name="dataId">the unique id of data</param>
|
||||||
/// <returns>Returns True on success</returns>
|
/// <returns>Returns True on success</returns>
|
||||||
public SerieData AddData(int serieIndex, List<double> multidimensionalData, string dataName = null)
|
public SerieData AddData(int serieIndex, List<double> multidimensionalData, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddData(multidimensionalData, dataName);
|
var serieData = serie.AddData(multidimensionalData, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
@@ -280,13 +283,14 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="xValue">x data</param>
|
/// <param name="xValue">x data</param>
|
||||||
/// <param name="yValue">y data</param>
|
/// <param name="yValue">y data</param>
|
||||||
/// <param name="dataName">the name of data</param>
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <param name="dataId">the unique id of data</param>
|
||||||
/// <returns>Returns True on success</returns>
|
/// <returns>Returns True on success</returns>
|
||||||
public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null)
|
public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddXYData(xValue, yValue, dataName);
|
var serieData = serie.AddXYData(xValue, yValue, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
@@ -301,35 +305,36 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="xValue">x data</param>
|
/// <param name="xValue">x data</param>
|
||||||
/// <param name="yValue">y data</param>
|
/// <param name="yValue">y data</param>
|
||||||
/// <param name="dataName">the name of data</param>
|
/// <param name="dataName">the name of data</param>
|
||||||
|
/// <param name="dataId">the unique id of data</param>
|
||||||
/// <returns>Returns True on success</returns>
|
/// <returns>Returns True on success</returns>
|
||||||
public SerieData AddData(int serieIndex, double xValue, double yValue, string dataName = null)
|
public SerieData AddData(int serieIndex, double xValue, double yValue, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddXYData(xValue, yValue, dataName);
|
var serieData = serie.AddXYData(xValue, yValue, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public SerieData AddData(int serieIndex, double open, double close, double lowest, double heighest, string dataName = null)
|
public SerieData AddData(int serieIndex, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieIndex);
|
var serie = GetSerie(serieIndex);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddData(open, close, lowest, heighest, dataName);
|
var serieData = serie.AddData(open, close, lowest, heighest, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public SerieData AddData(string serieName, double open, double close, double lowest, double heighest, string dataName = null)
|
public SerieData AddData(string serieName, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
var serie = GetSerie(serieName);
|
var serie = GetSerie(serieName);
|
||||||
if (serie != null)
|
if (serie != null)
|
||||||
{
|
{
|
||||||
var serieData = serie.AddData(open, close, lowest, heighest, dataName);
|
var serieData = serie.AddData(open, close, lowest, heighest, dataName, dataId);
|
||||||
RefreshPainter(serie.painter);
|
RefreshPainter(serie.painter);
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
@@ -853,8 +858,9 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InternalAddSerie(Serie serie)
|
private void AddSerieAfterDeserialize(Serie serie)
|
||||||
{
|
{
|
||||||
|
serie.OnAfterDeserialize();
|
||||||
m_Series.Add(serie);
|
m_Series.Add(serie);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,15 +77,17 @@ namespace XCharts.Runtime
|
|||||||
protected Vector2 m_ChartMaxAnchor;
|
protected Vector2 m_ChartMaxAnchor;
|
||||||
protected Vector2 m_ChartPivot;
|
protected Vector2 m_ChartPivot;
|
||||||
protected Vector2 m_ChartSizeDelta;
|
protected Vector2 m_ChartSizeDelta;
|
||||||
|
|
||||||
protected Rect m_ChartRect = new Rect(0, 0, 0, 0);
|
protected Rect m_ChartRect = new Rect(0, 0, 0, 0);
|
||||||
protected Action<VertexHelper> m_OnCustomDrawBaseCallback;
|
protected Action<VertexHelper> m_OnDrawBase;
|
||||||
protected Action<VertexHelper> m_OnCustomDrawTopCallback;
|
protected Action<VertexHelper> m_OnDrawTop;
|
||||||
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieBeforeCallback;
|
protected Action<VertexHelper, Serie> m_OnDrawSerieBefore;
|
||||||
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieAfterCallback;
|
protected Action<VertexHelper, Serie> m_OnDrawSerieAfter;
|
||||||
protected Action<VertexHelper, int, int, float> m_OnCustomDrawGagugePointerCallback;
|
|
||||||
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
|
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
|
||||||
protected Action<PointerEventData, int> m_OnPointerClickBar;
|
protected Action<PointerEventData, int> m_OnPointerClickBar;
|
||||||
protected Action<Axis, double> m_OnUpdateAxisPointer;
|
protected Action<Axis, double> m_OnAxisPointerValueChanged;
|
||||||
|
|
||||||
|
protected CustomDrawGaugePointerFunction m_CustomDrawGaugePointerFunction;
|
||||||
|
|
||||||
internal bool m_CheckAnimation = false;
|
internal bool m_CheckAnimation = false;
|
||||||
internal protected List<string> m_LegendRealShowName = new List<string>();
|
internal protected List<string> m_LegendRealShowName = new List<string>();
|
||||||
@@ -209,7 +211,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var painter = GetPainter(index);
|
var painter = GetPainter(index);
|
||||||
if (painter == null) return;
|
if (painter == null) return;
|
||||||
painter.SetActive(flag, m_DebugInfo.showAllChildObject);
|
painter.SetActive(flag, m_DebugInfo.showAllChartObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void CheckTheme()
|
protected virtual void CheckTheme()
|
||||||
@@ -306,7 +308,7 @@ namespace XCharts.Runtime
|
|||||||
painter.index = m_PainterList.Count;
|
painter.index = m_PainterList.Count;
|
||||||
painter.type = Painter.Type.Serie;
|
painter.type = Painter.Type.Serie;
|
||||||
painter.onPopulateMesh = OnDrawPainterSerie;
|
painter.onPopulateMesh = OnDrawPainterSerie;
|
||||||
painter.SetActive(false, m_DebugInfo.showAllChildObject);
|
painter.SetActive(false, m_DebugInfo.showAllChartObject);
|
||||||
painter.material = settings.seriePainterMaterial;
|
painter.material = settings.seriePainterMaterial;
|
||||||
painter.transform.SetSiblingIndex(index + 1);
|
painter.transform.SetSiblingIndex(index + 1);
|
||||||
m_PainterList.Add(painter);
|
m_PainterList.Add(painter);
|
||||||
@@ -315,7 +317,7 @@ namespace XCharts.Runtime
|
|||||||
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
|
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
|
||||||
m_PainterTop.type = Painter.Type.Top;
|
m_PainterTop.type = Painter.Type.Top;
|
||||||
m_PainterTop.onPopulateMesh = OnDrawPainterTop;
|
m_PainterTop.onPopulateMesh = OnDrawPainterTop;
|
||||||
m_PainterTop.SetActive(true, m_DebugInfo.showAllChildObject);
|
m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject);
|
||||||
m_PainterTop.material = settings.topPainterMaterial;
|
m_PainterTop.material = settings.topPainterMaterial;
|
||||||
m_PainterTop.transform.SetSiblingIndex(settings.maxPainter + 1);
|
m_PainterTop.transform.SetSiblingIndex(settings.maxPainter + 1);
|
||||||
}
|
}
|
||||||
@@ -513,9 +515,9 @@ namespace XCharts.Runtime
|
|||||||
DrawPainterBase(vh);
|
DrawPainterBase(vh);
|
||||||
foreach (var handler in m_ComponentHandlers) handler.DrawBase(vh);
|
foreach (var handler in m_ComponentHandlers) handler.DrawBase(vh);
|
||||||
foreach (var handler in m_SerieHandlers) handler.DrawBase(vh);
|
foreach (var handler in m_SerieHandlers) handler.DrawBase(vh);
|
||||||
if (m_OnCustomDrawBaseCallback != null)
|
if (m_OnDrawBase != null)
|
||||||
{
|
{
|
||||||
m_OnCustomDrawBaseCallback(vh);
|
m_OnDrawBase(vh);
|
||||||
}
|
}
|
||||||
m_BasePainterVertCount = vh.currentVertCount;
|
m_BasePainterVertCount = vh.currentVertCount;
|
||||||
}
|
}
|
||||||
@@ -535,9 +537,9 @@ namespace XCharts.Runtime
|
|||||||
serie.context.dataPoints.Clear();
|
serie.context.dataPoints.Clear();
|
||||||
serie.context.dataIgnores.Clear();
|
serie.context.dataIgnores.Clear();
|
||||||
AnimationStyleHelper.UpdateSerieAnimation(serie);
|
AnimationStyleHelper.UpdateSerieAnimation(serie);
|
||||||
if (m_OnCustomDrawSerieBeforeCallback != null)
|
if (m_OnDrawSerieBefore != null)
|
||||||
{
|
{
|
||||||
m_OnCustomDrawSerieBeforeCallback.Invoke(vh, serie);
|
m_OnDrawSerieBefore.Invoke(vh, serie);
|
||||||
}
|
}
|
||||||
DrawPainterSerie(vh, serie);
|
DrawPainterSerie(vh, serie);
|
||||||
if (i >= 0 && i < m_SerieHandlers.Count)
|
if (i >= 0 && i < m_SerieHandlers.Count)
|
||||||
@@ -546,9 +548,9 @@ namespace XCharts.Runtime
|
|||||||
handler.DrawSerie(vh);
|
handler.DrawSerie(vh);
|
||||||
handler.RefreshLabelNextFrame();
|
handler.RefreshLabelNextFrame();
|
||||||
}
|
}
|
||||||
if (m_OnCustomDrawSerieAfterCallback != null)
|
if (m_OnDrawSerieAfter != null)
|
||||||
{
|
{
|
||||||
m_OnCustomDrawSerieAfterCallback(vh, serie);
|
m_OnDrawSerieAfter(vh, serie);
|
||||||
}
|
}
|
||||||
serie.context.vertCount = vh.currentVertCount;
|
serie.context.vertCount = vh.currentVertCount;
|
||||||
}
|
}
|
||||||
@@ -559,9 +561,9 @@ namespace XCharts.Runtime
|
|||||||
vh.Clear();
|
vh.Clear();
|
||||||
DrawPainterTop(vh);
|
DrawPainterTop(vh);
|
||||||
foreach (var draw in m_ComponentHandlers) draw.DrawTop(vh);
|
foreach (var draw in m_ComponentHandlers) draw.DrawTop(vh);
|
||||||
if (m_OnCustomDrawTopCallback != null)
|
if (m_OnDrawTop != null)
|
||||||
{
|
{
|
||||||
m_OnCustomDrawTopCallback(vh);
|
m_OnDrawTop(vh);
|
||||||
}
|
}
|
||||||
m_TopPainterVertCount = vh.currentVertCount;
|
m_TopPainterVertCount = vh.currentVertCount;
|
||||||
}
|
}
|
||||||
@@ -648,6 +650,7 @@ namespace XCharts.Runtime
|
|||||||
foreach (var serie in m_Series)
|
foreach (var serie in m_Series)
|
||||||
{
|
{
|
||||||
FieldInfo field;
|
FieldInfo field;
|
||||||
|
serie.OnBeforeSerialize();
|
||||||
if (m_TypeListForSerie.TryGetValue(serie.GetType(), out field))
|
if (m_TypeListForSerie.TryGetValue(serie.GetType(), out field))
|
||||||
ReflectionUtil.InvokeListAdd(this, field, serie);
|
ReflectionUtil.InvokeListAdd(this, field, serie);
|
||||||
else
|
else
|
||||||
@@ -666,7 +669,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
foreach (var kv in m_TypeListForSerie)
|
foreach (var kv in m_TypeListForSerie)
|
||||||
{
|
{
|
||||||
ReflectionUtil.InvokeListAddTo<Serie>(this, kv.Value, InternalAddSerie);
|
ReflectionUtil.InvokeListAddTo<Serie>(this, kv.Value, AddSerieAfterDeserialize);
|
||||||
}
|
}
|
||||||
m_Series.Sort();
|
m_Series.Sort();
|
||||||
m_Components.Sort();
|
m_Components.Sort();
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ namespace XCharts.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除并重新初始化所有组件。
|
/// 移除并重新初始化所有组件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReinitAllChartComponent()
|
public void RemoveAndReinitChartObject()
|
||||||
{
|
{
|
||||||
ChartHelper.DestroyAllChildren(transform);
|
ChartHelper.DestroyAllChildren(transform);
|
||||||
SetAllComponentDirty();
|
SetAllComponentDirty();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace XCharts.Runtime
|
|||||||
protected Vector2 graphAnchorMax { get { return m_GraphMinAnchor; } }
|
protected Vector2 graphAnchorMax { get { return m_GraphMinAnchor; } }
|
||||||
protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } }
|
protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } }
|
||||||
protected Vector2 graphPivot { get { return m_GraphPivot; } }
|
protected Vector2 graphPivot { get { return m_GraphPivot; } }
|
||||||
public HideFlags chartHideFlags { get { return m_DebugInfo.showAllChildObject ? HideFlags.None : HideFlags.HideInHierarchy; } }
|
public HideFlags chartHideFlags { get { return m_DebugInfo.showAllChartObject ? HideFlags.None : HideFlags.HideInHierarchy; } }
|
||||||
public DebugInfo debug { get { return m_DebugInfo; } }
|
public DebugInfo debug { get { return m_DebugInfo; } }
|
||||||
private ScrollRect m_ScrollRect;
|
private ScrollRect m_ScrollRect;
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ namespace XCharts.Runtime
|
|||||||
if (m_EnableTextMeshPro != enableTextMeshPro)
|
if (m_EnableTextMeshPro != enableTextMeshPro)
|
||||||
{
|
{
|
||||||
m_EnableTextMeshPro = enableTextMeshPro;
|
m_EnableTextMeshPro = enableTextMeshPro;
|
||||||
ReinitAllChartComponent();
|
RemoveAndReinitChartObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace XCharts.Runtime
|
|||||||
[NonSerialized] public SerieContext context = new SerieContext();
|
[NonSerialized] public SerieContext context = new SerieContext();
|
||||||
[NonSerialized] public InteractData interact = new InteractData();
|
[NonSerialized] public InteractData interact = new InteractData();
|
||||||
|
|
||||||
internal SerieHandler handler { get; set; }
|
public SerieHandler handler { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public virtual void SetVerticesDirty()
|
public virtual void SetVerticesDirty()
|
||||||
@@ -68,6 +68,19 @@ namespace XCharts.Runtime
|
|||||||
handler.RemoveComponent();
|
handler.RemoveComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnDataUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnBeforeSerialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void OnAfterDeserialize()
|
||||||
|
{
|
||||||
|
OnDataUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
public void RefreshLabel()
|
public void RefreshLabel()
|
||||||
{
|
{
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace XCharts.Runtime
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class ChildComponent
|
public class ChildComponent
|
||||||
{
|
{
|
||||||
public int index { get; set; }
|
public virtual int index { get; set; }
|
||||||
[NonSerialized] protected bool m_VertsDirty;
|
[NonSerialized] protected bool m_VertsDirty;
|
||||||
[NonSerialized] protected bool m_ComponentDirty;
|
[NonSerialized] protected bool m_ComponentDirty;
|
||||||
[NonSerialized] protected Painter m_Painter;
|
[NonSerialized] protected Painter m_Painter;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -10,7 +13,7 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="value">当前label对应的数值数据,Value轴或Time轴有效</param>
|
/// <param name="value">当前label对应的数值数据,Value轴或Time轴有效</param>
|
||||||
/// <param name="category">当前label对应的类目数据,Category轴有效</param>
|
/// <param name="category">当前label对应的类目数据,Category轴有效</param>
|
||||||
/// <returns>最终显示的文本内容</returns>
|
/// <returns>最终显示的文本内容</returns>
|
||||||
public delegate string DelegateAxisLabelFormatter(int labelIndex, double value, string category);
|
public delegate string AxisLabelFormatterFunction(int labelIndex, double value, string category);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The delegate function for SerieLabel‘s formatter.
|
/// The delegate function for SerieLabel‘s formatter.
|
||||||
/// SerieLabel的formatter自定义委托。
|
/// SerieLabel的formatter自定义委托。
|
||||||
@@ -18,5 +21,14 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="dataIndex">数据索引</param>
|
/// <param name="dataIndex">数据索引</param>
|
||||||
/// <param name="value">数值</param>
|
/// <param name="value">数值</param>
|
||||||
/// <returns>最终显示的文本内容</returns>
|
/// <returns>最终显示的文本内容</returns>
|
||||||
public delegate string DelegateSerieLabelFormatter(int dataIndex, double value);
|
public delegate string SerieLabelFormatterFunction(int dataIndex, double value);
|
||||||
|
public delegate float AnimationDelayFunction(int dataIndex);
|
||||||
|
public delegate float AnimationDurationFunction(int dataIndex);
|
||||||
|
/// <summary>
|
||||||
|
/// 获取标记大小的回调。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public delegate float SymbolSizeFunction(List<double> data);
|
||||||
|
public delegate void CustomDrawGaugePointerFunction(VertexHelper vh, int serieIndex, int dataIndex, float currentAngle);
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ namespace XCharts.Runtime
|
|||||||
private static Dictionary<Color, string> s_ColorDotStr = new Dictionary<Color, string>(100);
|
private static Dictionary<Color, string> s_ColorDotStr = new Dictionary<Color, string>(100);
|
||||||
private static Dictionary<Type, Dictionary<int, string>> s_ComponentObjectName = new Dictionary<Type, Dictionary<int, string>>();
|
private static Dictionary<Type, Dictionary<int, string>> s_ComponentObjectName = new Dictionary<Type, Dictionary<int, string>>();
|
||||||
private static Dictionary<int, string> s_AxisLabelName = new Dictionary<int, string>();
|
private static Dictionary<int, string> s_AxisLabelName = new Dictionary<int, string>();
|
||||||
private static Dictionary<string, string> s_AxisLabel = new Dictionary<string, string>();
|
|
||||||
private static Dictionary<Type, string> s_TypeName = new Dictionary<Type, string>();
|
private static Dictionary<Type, string> s_TypeName = new Dictionary<Type, string>();
|
||||||
|
|
||||||
|
|
||||||
@@ -158,15 +157,6 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetAxisTooltipLabel(string axisName)
|
|
||||||
{
|
|
||||||
if (!s_AxisLabel.ContainsKey(axisName))
|
|
||||||
{
|
|
||||||
s_AxisLabel[axisName] = axisName + "_label";
|
|
||||||
}
|
|
||||||
return s_AxisLabel[axisName];
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string GetTypeName<T>()
|
internal static string GetTypeName<T>()
|
||||||
{
|
{
|
||||||
return GetTypeName(typeof(T));
|
return GetTypeName(typeof(T));
|
||||||
|
|||||||
@@ -794,9 +794,6 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
|
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
|
||||||
{
|
{
|
||||||
Vector3 point = Quaternion.AngleAxis(angle, axis) * (position - center);
|
Vector3 point = Quaternion.AngleAxis(angle, axis) * (position - center);
|
||||||
@@ -857,23 +854,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float GetRuntimeRelativeOrAbsoluteValue(float check, float total)
|
public static Vector3 GetLastValue(List<Vector3> list)
|
||||||
{
|
|
||||||
if (check <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (check <= 1)
|
|
||||||
{
|
|
||||||
return total * check;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return check;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3 GetLastPoint(List<Vector3> list)
|
|
||||||
{
|
{
|
||||||
if (list.Count <= 0) return Vector3.zero;
|
if (list.Count <= 0) return Vector3.zero;
|
||||||
else return list[list.Count - 1];
|
else return list[list.Count - 1];
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RadiusAxis GetRadiusAxis(List<MainComponent> components, int polarIndex)
|
public static RadiusAxis GetRadiusAxis(List<MainComponent> components, int polarIndex)
|
||||||
{
|
{
|
||||||
foreach (var component in components)
|
foreach (var component in components)
|
||||||
@@ -32,32 +33,6 @@ namespace XCharts.Runtime
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YAxis GetYAxisRelatedWitchXAxis(List<MainComponent> components, XAxis axis)
|
|
||||||
{
|
|
||||||
foreach (var component in components)
|
|
||||||
{
|
|
||||||
if (component is YAxis)
|
|
||||||
{
|
|
||||||
var yAxis = component as YAxis;
|
|
||||||
if (yAxis.gridIndex == axis.gridIndex) return yAxis;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static XAxis GetXAxisRelatedWithYAxis(List<MainComponent> components, YAxis axis)
|
|
||||||
{
|
|
||||||
foreach (var component in components)
|
|
||||||
{
|
|
||||||
if (component is XAxis)
|
|
||||||
{
|
|
||||||
var xAxis = component as XAxis;
|
|
||||||
if (xAxis.gridIndex == axis.gridIndex) return xAxis;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float GetXAxisOnZeroOffset(List<MainComponent> components, XAxis axis)
|
public static float GetXAxisOnZeroOffset(List<MainComponent> components, XAxis axis)
|
||||||
{
|
{
|
||||||
if (!axis.axisLine.onZero) return 0;
|
if (!axis.axisLine.onZero) return 0;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace XCharts.Runtime
|
|||||||
foreach (var chart in chartList)
|
foreach (var chart in chartList)
|
||||||
{
|
{
|
||||||
if (chart != null)
|
if (chart != null)
|
||||||
chart.ReinitAllChartComponent();
|
chart.RemoveAndReinitChartObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ namespace XCharts.Runtime
|
|||||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||||
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||||
float barGapWidth = barWidth + barWidth * barGap;
|
float barGapWidth = barWidth + barWidth * barGap;
|
||||||
float space = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth;
|
float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth;
|
||||||
int maxCount = serie.maxShow > 0
|
int maxCount = serie.maxShow > 0
|
||||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||||
: showData.Count;
|
: showData.Count;
|
||||||
@@ -209,7 +209,6 @@ namespace XCharts.Runtime
|
|||||||
var pX = 0f;
|
var pX = 0f;
|
||||||
var pY = 0f;
|
var pY = 0f;
|
||||||
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, isStack, value, ref pX, ref pY);
|
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, isStack, value, ref pX, ref pY);
|
||||||
|
|
||||||
var barHig = 0f;
|
var barHig = 0f;
|
||||||
if (isPercentStack)
|
if (isPercentStack)
|
||||||
{
|
{
|
||||||
@@ -223,7 +222,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||||
Vector3 plb, plt, prt, prb, top;
|
Vector3 plb, plt, prt, prb, top;
|
||||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
|
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, gap, borderWidth, barWidth, currHig,
|
||||||
out plb, out plt, out prt, out prb, out top);
|
out plb, out plt, out prt, out prb, out top);
|
||||||
serieData.context.stackHeight = barHig;
|
serieData.context.stackHeight = barHig;
|
||||||
serieData.context.position = top;
|
serieData.context.position = top;
|
||||||
@@ -237,15 +236,15 @@ namespace XCharts.Runtime
|
|||||||
switch (serie.barType)
|
switch (serie.barType)
|
||||||
{
|
{
|
||||||
case BarType.Normal:
|
case BarType.Normal:
|
||||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||||
break;
|
break;
|
||||||
case BarType.Zebra:
|
case BarType.Zebra:
|
||||||
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||||
break;
|
break;
|
||||||
case BarType.Capsule:
|
case BarType.Capsule:
|
||||||
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -278,7 +277,11 @@ namespace XCharts.Runtime
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
|
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
|
||||||
else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
|
else
|
||||||
|
{
|
||||||
|
var valueLen = (float)((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.height;
|
||||||
|
pY = grid.context.y + valueLen - categoryWidth * 0.5f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||||
if (isStack)
|
if (isStack)
|
||||||
@@ -296,7 +299,11 @@ namespace XCharts.Runtime
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
|
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
|
||||||
else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
|
else
|
||||||
|
{
|
||||||
|
var valueLen = (float)((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.width;
|
||||||
|
pX = grid.context.x + valueLen - categoryWidth * 0.5f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||||
if (isStack)
|
if (isStack)
|
||||||
@@ -307,7 +314,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float space, float borderWidth,
|
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float gap, float borderWidth,
|
||||||
float barWidth, float currHig,
|
float barWidth, float currHig,
|
||||||
out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top)
|
out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top)
|
||||||
{
|
{
|
||||||
@@ -315,37 +322,37 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
if (yValue < 0)
|
if (yValue < 0)
|
||||||
{
|
{
|
||||||
plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth);
|
plt = new Vector3(pX - borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth);
|
prt = new Vector3(pX + currHig + borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth);
|
prb = new Vector3(pX + currHig + borderWidth, pY + gap + borderWidth);
|
||||||
plb = new Vector3(pX - borderWidth, pY + space + borderWidth);
|
plb = new Vector3(pX - borderWidth, pY + gap + borderWidth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth);
|
plt = new Vector3(pX + borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
|
prt = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
|
prb = new Vector3(pX + currHig - borderWidth, pY + gap + borderWidth);
|
||||||
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
|
plb = new Vector3(pX + borderWidth, pY + gap + borderWidth);
|
||||||
}
|
}
|
||||||
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
|
top = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth / 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (yValue < 0)
|
if (yValue < 0)
|
||||||
{
|
{
|
||||||
plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
|
plb = new Vector3(pX + gap + borderWidth, pY - borderWidth);
|
||||||
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
|
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||||
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
|
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||||
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
|
prb = new Vector3(pX + gap + barWidth - borderWidth, pY - borderWidth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
|
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||||
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
|
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||||
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
|
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||||
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
|
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||||
}
|
}
|
||||||
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
|
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||||
}
|
}
|
||||||
if (serie.clip)
|
if (serie.clip)
|
||||||
{
|
{
|
||||||
@@ -358,10 +365,10 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||||
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
||||||
{
|
{
|
||||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, gap, barWidth, isYAxis, grid, axis);
|
||||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
@@ -423,10 +430,10 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||||
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 barColor, Color32 barToColor)
|
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 barColor, Color32 barToColor)
|
||||||
{
|
{
|
||||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, gap, barWidth, isYAxis, grid, axis);
|
||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
plt = (plb + plt) / 2;
|
plt = (plb + plt) / 2;
|
||||||
@@ -444,10 +451,10 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||||
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
||||||
{
|
{
|
||||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, gap, barWidth, isYAxis, grid, axis);
|
||||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||||
var radius = barWidth / 2 - borderWidth;
|
var radius = barWidth / 2 - borderWidth;
|
||||||
var isGradient = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
|
var isGradient = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
|
||||||
@@ -562,7 +569,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle,
|
private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle,
|
||||||
int colorIndex, bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis,
|
int colorIndex, bool highlight, float pX, float pY, float gap, float barWidth, bool isYAxis,
|
||||||
GridCoord grid, Axis axis)
|
GridCoord grid, Axis axis)
|
||||||
{
|
{
|
||||||
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
|
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
|
||||||
@@ -570,10 +577,10 @@ namespace XCharts.Runtime
|
|||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||||
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + space + barWidth);
|
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + gap + barWidth);
|
||||||
Vector3 prt = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space + barWidth);
|
Vector3 prt = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + gap + barWidth);
|
||||||
Vector3 prb = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space);
|
Vector3 prb = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + gap);
|
||||||
Vector3 plb = new Vector3(grid.context.x + axisWidth, pY + space);
|
Vector3 plb = new Vector3(grid.context.x + axisWidth, pY + gap);
|
||||||
if (serie.barType == BarType.Capsule)
|
if (serie.barType == BarType.Capsule)
|
||||||
{
|
{
|
||||||
var radius = barWidth / 2;
|
var radius = barWidth / 2;
|
||||||
@@ -610,10 +617,10 @@ namespace XCharts.Runtime
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||||
Vector3 plb = new Vector3(pX + space, grid.context.y + axisWidth);
|
Vector3 plb = new Vector3(pX + gap, grid.context.y + axisWidth);
|
||||||
Vector3 plt = new Vector3(pX + space, grid.context.y + grid.context.height + axisWidth);
|
Vector3 plt = new Vector3(pX + gap, grid.context.y + grid.context.height + axisWidth);
|
||||||
Vector3 prt = new Vector3(pX + space + barWidth, grid.context.y + grid.context.height + axisWidth);
|
Vector3 prt = new Vector3(pX + gap + barWidth, grid.context.y + grid.context.height + axisWidth);
|
||||||
Vector3 prb = new Vector3(pX + space + barWidth, grid.context.y + axisWidth);
|
Vector3 prb = new Vector3(pX + gap + barWidth, grid.context.y + axisWidth);
|
||||||
if (serie.barType == BarType.Capsule)
|
if (serie.barType == BarType.Capsule)
|
||||||
{
|
{
|
||||||
var radius = barWidth / 2;
|
var radius = barWidth / 2;
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ namespace XCharts.Runtime
|
|||||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||||
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||||
float barGapWidth = barWidth + barWidth * barGap;
|
float barGapWidth = barWidth + barWidth * barGap;
|
||||||
float space = serie.barGap == -1 ? offset : offset + serie.index * barGapWidth;
|
float gap = serie.barGap == -1 ? offset : offset + serie.index * barGapWidth;
|
||||||
int maxCount = serie.maxShow > 0
|
int maxCount = serie.maxShow > 0
|
||||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||||
: showData.Count;
|
: showData.Count;
|
||||||
@@ -194,13 +194,13 @@ namespace XCharts.Runtime
|
|||||||
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||||
|
|
||||||
Vector3 plb, plt, prt, prb, top;
|
Vector3 plb, plt, prt, prb, top;
|
||||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
|
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, gap, borderWidth, barWidth, currHig,
|
||||||
out plb, out plt, out prt, out prb, out top);
|
out plb, out plt, out prt, out prb, out top);
|
||||||
serieData.context.stackHeight = barHig;
|
serieData.context.stackHeight = barHig;
|
||||||
serieData.context.position = top;
|
serieData.context.position = top;
|
||||||
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
|
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
|
||||||
serie.context.dataPoints.Add(top);
|
serie.context.dataPoints.Add(top);
|
||||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, gap, barWidth,
|
||||||
pX, pY, plb, plt, prt, prb, false, m_SerieGrid, areaColor, areaToColor);
|
pX, pY, plb, plt, prt, prb, false, m_SerieGrid, areaColor, areaToColor);
|
||||||
|
|
||||||
if (serie.animation.CheckDetailBreak(top, isY))
|
if (serie.animation.CheckDetailBreak(top, isY))
|
||||||
@@ -250,7 +250,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float space, float borderWidth,
|
private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float gap, float borderWidth,
|
||||||
float barWidth, float currHig,
|
float barWidth, float currHig,
|
||||||
out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top)
|
out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top)
|
||||||
{
|
{
|
||||||
@@ -258,37 +258,37 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
if (yValue < 0)
|
if (yValue < 0)
|
||||||
{
|
{
|
||||||
plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth);
|
plt = new Vector3(pX - borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth);
|
prt = new Vector3(pX + currHig + borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth);
|
prb = new Vector3(pX + currHig + borderWidth, pY + gap + borderWidth);
|
||||||
plb = new Vector3(pX - borderWidth, pY + space + borderWidth);
|
plb = new Vector3(pX - borderWidth, pY + gap + borderWidth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth);
|
plt = new Vector3(pX + borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
|
prt = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth - borderWidth);
|
||||||
prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
|
prb = new Vector3(pX + currHig - borderWidth, pY + gap + borderWidth);
|
||||||
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
|
plb = new Vector3(pX + borderWidth, pY + gap + borderWidth);
|
||||||
}
|
}
|
||||||
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
|
top = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth / 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (yValue < 0)
|
if (yValue < 0)
|
||||||
{
|
{
|
||||||
plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
|
plb = new Vector3(pX + gap + borderWidth, pY - borderWidth);
|
||||||
plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth);
|
plt = new Vector3(pX + gap + borderWidth, pY + currHig + borderWidth);
|
||||||
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth);
|
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig + borderWidth);
|
||||||
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
|
prb = new Vector3(pX + gap + barWidth - borderWidth, pY - borderWidth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
|
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||||
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
|
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||||
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
|
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||||
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
|
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||||
}
|
}
|
||||||
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
|
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||||
}
|
}
|
||||||
if (serie.clip)
|
if (serie.clip)
|
||||||
{
|
{
|
||||||
@@ -301,7 +301,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
bool highlight, float gap, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||||
Vector3 prb, bool isYAxis, GridCoord grid, Color32 areaColor, Color32 areaToColor)
|
Vector3 prb, bool isYAxis, GridCoord grid, Color32 areaColor, Color32 areaToColor)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace XCharts.Runtime
|
|||||||
var showData = serie.GetDataList(dataZoom);
|
var showData = serie.GetDataList(dataZoom);
|
||||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
||||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||||
float space = (categoryWidth - barWidth) / 2;
|
float gap = (categoryWidth - barWidth) / 2;
|
||||||
int maxCount = serie.maxShow > 0
|
int maxCount = serie.maxShow > 0
|
||||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||||
: showData.Count;
|
: showData.Count;
|
||||||
@@ -140,11 +140,11 @@ namespace XCharts.Runtime
|
|||||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||||
Vector3 plb, plt, prt, prb, top;
|
Vector3 plb, plt, prt, prb, top;
|
||||||
|
|
||||||
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
|
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||||
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
|
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||||
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
|
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||||
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
|
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||||
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
|
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||||
if (serie.clip)
|
if (serie.clip)
|
||||||
{
|
{
|
||||||
plb = chart.ClampInGrid(grid, plb);
|
plb = chart.ClampInGrid(grid, plb);
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace XCharts.Runtime
|
|||||||
var showData = serie.GetDataList(dataZoom);
|
var showData = serie.GetDataList(dataZoom);
|
||||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
||||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||||
float space = (categoryWidth - barWidth) / 2;
|
float gap = (categoryWidth - barWidth) / 2;
|
||||||
int maxCount = serie.maxShow > 0
|
int maxCount = serie.maxShow > 0
|
||||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||||
: showData.Count;
|
: showData.Count;
|
||||||
@@ -140,11 +140,11 @@ namespace XCharts.Runtime
|
|||||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||||
Vector3 plb, plt, prt, prb, top;
|
Vector3 plb, plt, prt, prb, top;
|
||||||
|
|
||||||
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
|
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
|
||||||
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
|
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
|
||||||
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
|
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||||
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
|
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
|
||||||
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
|
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
|
||||||
// if (serie.clip)
|
// if (serie.clip)
|
||||||
// {
|
// {
|
||||||
// plb = chart.ClampInGrid(grid, plb);
|
// plb = chart.ClampInGrid(grid, plb);
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ namespace XCharts.Runtime
|
|||||||
var needRoundCap = serie.roundCap && insideRadius > 0;
|
var needRoundCap = serie.roundCap && insideRadius > 0;
|
||||||
UGL.DrawDoughnut(vh, serieData.context.offsetCenter, insideRadius,
|
UGL.DrawDoughnut(vh, serieData.context.offsetCenter, insideRadius,
|
||||||
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
|
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
|
||||||
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
|
drawEndDegree, borderWidth, borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
|
||||||
needRoundCap, true);
|
needRoundCap, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -339,7 +339,7 @@ namespace XCharts.Runtime
|
|||||||
var needRoundCap = serie.roundCap && insideRadius > 0;
|
var needRoundCap = serie.roundCap && insideRadius > 0;
|
||||||
UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
|
UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
|
||||||
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
|
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
|
||||||
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
|
drawEndDegree, borderWidth, borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
|
||||||
needRoundCap, true);
|
needRoundCap, true);
|
||||||
DrawPieCenter(vh, serie, itemStyle, insideRadius);
|
DrawPieCenter(vh, serie, itemStyle, insideRadius);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var serie = chart.AddSerie<Ring>(serieName);
|
var serie = chart.AddSerie<Ring>(serieName);
|
||||||
serie.roundCap = true;
|
serie.roundCap = true;
|
||||||
|
serie.gap = 10;
|
||||||
serie.radius = new float[] { 0.3f, 0.35f };
|
serie.radius = new float[] { 0.3f, 0.35f };
|
||||||
|
|
||||||
serie.AddExtraComponent<LabelStyle>();
|
serie.AddExtraComponent<LabelStyle>();
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace XCharts.Runtime
|
|||||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
|
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
|
||||||
var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlight);
|
var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlight);
|
||||||
var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlight);
|
var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlight);
|
||||||
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.ringGap);
|
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap);
|
||||||
var insideRadius = outsideRadius - ringWidth;
|
var insideRadius = outsideRadius - ringWidth;
|
||||||
var centerRadius = (outsideRadius + insideRadius) / 2;
|
var centerRadius = (outsideRadius + insideRadius) / 2;
|
||||||
var borderWidth = itemStyle.borderWidth;
|
var borderWidth = itemStyle.borderWidth;
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private bool m_BarPercentStack = false;
|
[SerializeField] private bool m_BarPercentStack = false;
|
||||||
[SerializeField] private float m_BarWidth = 0.6f;
|
[SerializeField] private float m_BarWidth = 0.6f;
|
||||||
[SerializeField] private float m_BarGap = 0.3f; // 30%
|
[SerializeField] private float m_BarGap = 0.3f; // 30%
|
||||||
[SerializeField] private float m_BarCategoryGap = 0.2f; // 20%
|
|
||||||
[SerializeField] private float m_BarZebraWidth = 4f;
|
[SerializeField] private float m_BarZebraWidth = 4f;
|
||||||
[SerializeField] private float m_BarZebraGap = 2f;
|
[SerializeField] private float m_BarZebraGap = 2f;
|
||||||
|
|
||||||
@@ -200,11 +199,10 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private float m_MinAngle;
|
[SerializeField] private float m_MinAngle;
|
||||||
[SerializeField] private bool m_Clockwise = true;
|
[SerializeField] private bool m_Clockwise = true;
|
||||||
[SerializeField] private bool m_RoundCap;
|
[SerializeField] private bool m_RoundCap;
|
||||||
[SerializeField] private float m_RingGap = 10f;
|
|
||||||
[SerializeField] private int m_SplitNumber;
|
[SerializeField] private int m_SplitNumber;
|
||||||
[SerializeField] private bool m_ClickOffset = true;
|
[SerializeField] private bool m_ClickOffset = true;
|
||||||
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
||||||
[SerializeField] private float m_Space;
|
[SerializeField] private float m_Gap;
|
||||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.48f };
|
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.48f };
|
||||||
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
|
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
|
||||||
|
|
||||||
@@ -488,19 +486,6 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bar gap of a single series, defaults to be 20% of the category gap, can be set as a fixed value.
|
|
||||||
/// In a single coodinate system, this attribute is shared by multiple 'bar' series.
|
|
||||||
/// This attribute should be set on the last 'bar' series in the coodinate system,
|
|
||||||
/// then it will be adopted by all 'bar' series in the coordinate system.
|
|
||||||
/// 同一系列的柱间距离,默认为类目间距的20%,可设固定值。
|
|
||||||
/// 在同一坐标系上,此属性会被多个 'bar' 系列共享。此属性应设置于此坐标系中最后一个 'bar' 系列上才会生效,并且是对此坐标系中所有 'bar' 系列生效。
|
|
||||||
/// </summary>
|
|
||||||
public float barCategoryGap
|
|
||||||
{
|
|
||||||
get { return m_BarCategoryGap; }
|
|
||||||
set { if (PropertyUtil.SetStruct(ref m_BarCategoryGap, value)) SetVerticesDirty(); }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 斑马线的粗细。
|
/// 斑马线的粗细。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float barZebraWidth
|
public float barZebraWidth
|
||||||
@@ -536,18 +521,13 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the space of pie chart item.
|
/// gap of item.
|
||||||
/// 饼图项间的空隙留白。
|
/// 间距。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieSpace
|
|
||||||
{
|
|
||||||
get { return m_Space; }
|
|
||||||
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
|
|
||||||
}
|
|
||||||
public float gap
|
public float gap
|
||||||
{
|
{
|
||||||
get { return m_Space; }
|
get { return m_Gap; }
|
||||||
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the center of chart.
|
/// the center of chart.
|
||||||
@@ -632,15 +612,6 @@ namespace XCharts.Runtime
|
|||||||
get { return m_Clockwise; }
|
get { return m_Clockwise; }
|
||||||
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 环形图的环间隙。
|
|
||||||
/// </summary>
|
|
||||||
public float ringGap
|
|
||||||
{
|
|
||||||
get { return m_RingGap; }
|
|
||||||
set { if (PropertyUtil.SetStruct(ref m_RingGap, value)) SetVerticesDirty(); }
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刻度分割段数。最大可设置36。
|
/// 刻度分割段数。最大可设置36。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -742,15 +713,7 @@ namespace XCharts.Runtime
|
|||||||
public bool large
|
public bool large
|
||||||
{
|
{
|
||||||
get { return m_Large; }
|
get { return m_Large; }
|
||||||
set
|
set { if (PropertyUtil.SetStruct(ref m_Large, value)) SetAllDirty(); }
|
||||||
{
|
|
||||||
if (PropertyUtil.SetStruct(ref m_Large, value))
|
|
||||||
{
|
|
||||||
SetAllDirty();
|
|
||||||
if (label != null)
|
|
||||||
label.SetComponentDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
|
/// 开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
|
||||||
@@ -758,15 +721,7 @@ namespace XCharts.Runtime
|
|||||||
public int largeThreshold
|
public int largeThreshold
|
||||||
{
|
{
|
||||||
get { return m_LargeThreshold; }
|
get { return m_LargeThreshold; }
|
||||||
set
|
set { if (PropertyUtil.SetStruct(ref m_LargeThreshold, value)) SetAllDirty(); }
|
||||||
{
|
|
||||||
if (PropertyUtil.SetStruct(ref m_LargeThreshold, value))
|
|
||||||
{
|
|
||||||
SetAllDirty();
|
|
||||||
if (label != null)
|
|
||||||
label.SetComponentDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。
|
/// 在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。
|
||||||
@@ -942,6 +897,7 @@ namespace XCharts.Runtime
|
|||||||
public bool nameDirty { get { return m_NameDirty; } }
|
public bool nameDirty { get { return m_NameDirty; } }
|
||||||
public bool labelDirty { get; set; }
|
public bool labelDirty { get; set; }
|
||||||
public bool titleDirty { get; set; }
|
public bool titleDirty { get; set; }
|
||||||
|
public bool dataDirty { get; set; }
|
||||||
|
|
||||||
private void SetSerieNameDirty()
|
private void SetSerieNameDirty()
|
||||||
{
|
{
|
||||||
@@ -1080,6 +1036,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
m_Data.Clear();
|
m_Data.Clear();
|
||||||
m_NeedUpdateFilterData = true;
|
m_NeedUpdateFilterData = true;
|
||||||
|
dataDirty = true;
|
||||||
SetVerticesDirty();
|
SetVerticesDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1105,6 +1062,7 @@ namespace XCharts.Runtime
|
|||||||
m_Data.RemoveAt(index);
|
m_Data.RemoveAt(index);
|
||||||
m_NeedUpdateFilterData = true;
|
m_NeedUpdateFilterData = true;
|
||||||
labelDirty = true;
|
labelDirty = true;
|
||||||
|
dataDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,7 +1071,8 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
public SerieData AddYData(double value, string dataName = null)
|
/// <param name="dataId">the unique id of data</param>
|
||||||
|
public SerieData AddYData(double value, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
CheckMaxCache();
|
CheckMaxCache();
|
||||||
int xValue = m_Data.Count;
|
int xValue = m_Data.Count;
|
||||||
@@ -1122,11 +1081,13 @@ namespace XCharts.Runtime
|
|||||||
serieData.data.Add(value);
|
serieData.data.Add(value);
|
||||||
serieData.name = dataName;
|
serieData.name = dataName;
|
||||||
serieData.index = xValue;
|
serieData.index = xValue;
|
||||||
|
serieData.id = dataId;
|
||||||
AddSerieData(serieData);
|
AddSerieData(serieData);
|
||||||
m_ShowDataDimension = 1;
|
m_ShowDataDimension = 1;
|
||||||
SetVerticesDirty();
|
SetVerticesDirty();
|
||||||
CheckDataName(dataName);
|
CheckDataName(dataName);
|
||||||
labelDirty = true;
|
labelDirty = true;
|
||||||
|
dataDirty = true;
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,6 +1097,8 @@ namespace XCharts.Runtime
|
|||||||
m_Data.Insert(0, serieData);
|
m_Data.Insert(0, serieData);
|
||||||
else
|
else
|
||||||
m_Data.Add(serieData);
|
m_Data.Add(serieData);
|
||||||
|
SetVerticesDirty();
|
||||||
|
dataDirty = true;
|
||||||
m_NeedUpdateFilterData = true;
|
m_NeedUpdateFilterData = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,8 +1116,8 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="xValue"></param>
|
/// <param name="xValue"></param>
|
||||||
/// <param name="yValue"></param>
|
/// <param name="yValue"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
/// <param name="maxDataNumber"></param>
|
/// <param name="dataId">the unique id of data</param>
|
||||||
public SerieData AddXYData(double xValue, double yValue, string dataName = null)
|
public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
CheckMaxCache();
|
CheckMaxCache();
|
||||||
var serieData = SerieDataPool.Get();
|
var serieData = SerieDataPool.Get();
|
||||||
@@ -1163,6 +1126,7 @@ namespace XCharts.Runtime
|
|||||||
serieData.data.Add(yValue);
|
serieData.data.Add(yValue);
|
||||||
serieData.name = dataName;
|
serieData.name = dataName;
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
|
serieData.id = dataId;
|
||||||
AddSerieData(serieData);
|
AddSerieData(serieData);
|
||||||
m_ShowDataDimension = 2;
|
m_ShowDataDimension = 2;
|
||||||
SetVerticesDirty();
|
SetVerticesDirty();
|
||||||
@@ -1179,8 +1143,9 @@ namespace XCharts.Runtime
|
|||||||
/// <param name="lowest"></param>
|
/// <param name="lowest"></param>
|
||||||
/// <param name="heighest"></param>
|
/// <param name="heighest"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
|
/// <param name="dataId">the unique id of data</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public SerieData AddData(double open, double close, double lowest, double heighest, string dataName = null)
|
public SerieData AddData(double open, double close, double lowest, double heighest, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
CheckMaxCache();
|
CheckMaxCache();
|
||||||
var serieData = SerieDataPool.Get();
|
var serieData = SerieDataPool.Get();
|
||||||
@@ -1191,6 +1156,7 @@ namespace XCharts.Runtime
|
|||||||
serieData.data.Add(heighest);
|
serieData.data.Add(heighest);
|
||||||
serieData.name = dataName;
|
serieData.name = dataName;
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
|
serieData.id = dataId;
|
||||||
AddSerieData(serieData);
|
AddSerieData(serieData);
|
||||||
m_ShowDataDimension = 4;
|
m_ShowDataDimension = 4;
|
||||||
SetVerticesDirty();
|
SetVerticesDirty();
|
||||||
@@ -1205,14 +1171,14 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="valueList"></param>
|
/// <param name="valueList"></param>
|
||||||
/// <param name="dataName"></param>
|
/// <param name="dataName"></param>
|
||||||
/// <param name="maxDataNumber"></param>
|
/// <param name="dataId">the unique id of data</param>
|
||||||
public SerieData AddData(List<double> valueList, string dataName = null)
|
public SerieData AddData(List<double> valueList, string dataName = null, string dataId = null)
|
||||||
{
|
{
|
||||||
if (valueList == null || valueList.Count == 0) return null;
|
if (valueList == null || valueList.Count == 0) return null;
|
||||||
if (valueList.Count == 1)
|
if (valueList.Count == 1)
|
||||||
return AddYData(valueList[0], dataName);
|
return AddYData(valueList[0], dataName, dataId);
|
||||||
else if (valueList.Count == 2)
|
else if (valueList.Count == 2)
|
||||||
return AddXYData(valueList[0], valueList[1], dataName);
|
return AddXYData(valueList[0], valueList[1], dataName, dataId);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CheckMaxCache();
|
CheckMaxCache();
|
||||||
@@ -1220,6 +1186,7 @@ namespace XCharts.Runtime
|
|||||||
var serieData = SerieDataPool.Get();
|
var serieData = SerieDataPool.Get();
|
||||||
serieData.name = dataName;
|
serieData.name = dataName;
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
|
serieData.id = dataId;
|
||||||
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]);
|
||||||
@@ -1232,29 +1199,42 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SerieData AddChildData(SerieData parent, double value, string name = null)
|
public SerieData AddChildData(SerieData parent, double value, string name, string id)
|
||||||
{
|
{
|
||||||
var serieData = new SerieData();
|
var serieData = new SerieData();
|
||||||
serieData.name = name;
|
serieData.name = name;
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
serieData.data = new List<double>() { parent.children.Count, value };
|
serieData.id = id;
|
||||||
serieData.context.parent = parent;
|
serieData.data = new List<double>() { m_Data.Count, value };
|
||||||
AddSerieData(serieData);
|
AddChildData(parent, serieData);
|
||||||
parent.children.Add(serieData.index);
|
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
public SerieData AddChildData(SerieData parent, List<double> value, string name = null)
|
|
||||||
|
public SerieData AddChildData(SerieData parent, List<double> value, string name, string id)
|
||||||
{
|
{
|
||||||
var serieData = new SerieData();
|
var serieData = new SerieData();
|
||||||
serieData.name = name;
|
serieData.name = name;
|
||||||
serieData.index = m_Data.Count;
|
serieData.index = m_Data.Count;
|
||||||
|
serieData.id = id;
|
||||||
serieData.data = new List<double>(value);
|
serieData.data = new List<double>(value);
|
||||||
serieData.context.parent = parent;
|
AddChildData(parent, serieData);
|
||||||
AddSerieData(serieData);
|
|
||||||
parent.children.Add(serieData.index);
|
|
||||||
return serieData;
|
return serieData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddChildData(SerieData parent, SerieData serieData)
|
||||||
|
{
|
||||||
|
serieData.parentId = parent.id;
|
||||||
|
serieData.context.parent = parent;
|
||||||
|
|
||||||
|
if (!m_Data.Contains(serieData))
|
||||||
|
AddSerieData(serieData);
|
||||||
|
|
||||||
|
if (!parent.context.children.Contains(serieData))
|
||||||
|
{
|
||||||
|
parent.context.children.Add(serieData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckMaxCache()
|
private void CheckMaxCache()
|
||||||
{
|
{
|
||||||
if (m_MaxCache <= 0) return;
|
if (m_MaxCache <= 0) return;
|
||||||
@@ -1360,23 +1340,23 @@ namespace XCharts.Runtime
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SerieData GetSerieData(string uuid, DataZoom dataZoom = null)
|
public SerieData GetSerieData(string id, DataZoom dataZoom = null)
|
||||||
{
|
{
|
||||||
var data = GetDataList(dataZoom);
|
var data = GetDataList(dataZoom);
|
||||||
foreach (var serieData in data)
|
foreach (var serieData in data)
|
||||||
{
|
{
|
||||||
var target = GetSerieData(serieData, uuid);
|
var target = GetSerieData(serieData, id);
|
||||||
if (target != null) return target;
|
if (target != null) return target;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SerieData GetSerieData(SerieData parent, string uuid)
|
public SerieData GetSerieData(SerieData parent, string id)
|
||||||
{
|
{
|
||||||
if (uuid.Equals(parent.uuid)) return parent;
|
if (id.Equals(parent.id)) return parent;
|
||||||
foreach (var child in parent.children)
|
foreach (var child in parent.context.children)
|
||||||
{
|
{
|
||||||
var data = GetSerieData(GetSerieData(child), uuid);
|
var data = GetSerieData(child, id);
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
return data;
|
return data;
|
||||||
@@ -1480,7 +1460,11 @@ namespace XCharts.Runtime
|
|||||||
var animationOpen = animation.enable;
|
var animationOpen = animation.enable;
|
||||||
var animationDuration = animation.GetUpdateAnimationDuration();
|
var animationDuration = animation.GetUpdateAnimationDuration();
|
||||||
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, animationDuration);
|
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, animationDuration);
|
||||||
if (flag) SetVerticesDirty();
|
if (flag)
|
||||||
|
{
|
||||||
|
SetVerticesDirty();
|
||||||
|
dataDirty = true;
|
||||||
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1504,6 +1488,7 @@ namespace XCharts.Runtime
|
|||||||
for (int i = 0; i < values.Count; i++)
|
for (int i = 0; i < values.Count; i++)
|
||||||
serieData.UpdateData(i, values[i], animationOpen, animationDuration);
|
serieData.UpdateData(i, values[i], animationOpen, animationDuration);
|
||||||
SetVerticesDirty();
|
SetVerticesDirty();
|
||||||
|
dataDirty = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ namespace XCharts.Runtime
|
|||||||
/// 排序后的数据
|
/// 排序后的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<SerieData> sortedData = new List<SerieData>();
|
public List<SerieData> sortedData = new List<SerieData>();
|
||||||
|
public List<SerieData> rootData = new List<SerieData>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// theme的颜色索引
|
/// theme的颜色索引
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ namespace XCharts.Runtime
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class SerieData : ChildComponent
|
public class SerieData : ChildComponent
|
||||||
{
|
{
|
||||||
|
[SerializeField] private int m_Index;
|
||||||
[SerializeField] private string m_Name;
|
[SerializeField] private string m_Name;
|
||||||
[SerializeField] private string m_Uuid;
|
[SerializeField] private string m_Id;
|
||||||
[SerializeField] private bool m_Selected;
|
[SerializeField] private string m_ParentId;
|
||||||
[SerializeField] private bool m_Ignore = false;
|
|
||||||
[SerializeField] private float m_Radius;
|
|
||||||
[SerializeField] private List<ItemStyle> m_ItemStyles = new List<ItemStyle>();
|
[SerializeField] private List<ItemStyle> m_ItemStyles = new List<ItemStyle>();
|
||||||
[SerializeField] private List<LabelStyle> m_Labels = new List<LabelStyle>();
|
[SerializeField] private List<LabelStyle> m_Labels = new List<LabelStyle>();
|
||||||
[SerializeField] private List<LabelLine> m_LabelLines = new List<LabelLine>();
|
[SerializeField] private List<LabelLine> m_LabelLines = new List<LabelLine>();
|
||||||
@@ -27,15 +26,18 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private List<AreaStyle> m_AreaStyles = new List<AreaStyle>();
|
[SerializeField] private List<AreaStyle> m_AreaStyles = new List<AreaStyle>();
|
||||||
[SerializeField] private List<TitleStyle> m_TitleStyles = new List<TitleStyle>();
|
[SerializeField] private List<TitleStyle> m_TitleStyles = new List<TitleStyle>();
|
||||||
[SerializeField] private List<double> m_Data = new List<double>();
|
[SerializeField] private List<double> m_Data = new List<double>();
|
||||||
[SerializeField] private List<int> m_Children = new List<int>();
|
|
||||||
|
|
||||||
[NonSerialized] public SerieDataContext context = new SerieDataContext();
|
[NonSerialized] public SerieDataContext context = new SerieDataContext();
|
||||||
[NonSerialized] public InteractData interact = new InteractData();
|
[NonSerialized] public InteractData interact = new InteractData();
|
||||||
|
[NonSerialized] private bool m_Ignore = false;
|
||||||
|
[NonSerialized] private bool m_Selected;
|
||||||
|
[NonSerialized] private float m_Radius;
|
||||||
public ChartLabel labelObject { get; set; }
|
public ChartLabel labelObject { get; set; }
|
||||||
public ChartLabel titleObject { get; set; }
|
public ChartLabel titleObject { get; set; }
|
||||||
|
|
||||||
private bool m_Show = true;
|
private bool m_Show = true;
|
||||||
|
|
||||||
|
public override int index { get { return m_Index; } set { m_Index = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the name of data item.
|
/// the name of data item.
|
||||||
/// 数据项名称。
|
/// 数据项名称。
|
||||||
@@ -44,7 +46,8 @@ namespace XCharts.Runtime
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据项的唯一id。唯一id不是必须设置的。
|
/// 数据项的唯一id。唯一id不是必须设置的。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string uuid { get { return m_Uuid; } set { m_Uuid = value; } }
|
public string id { get { return m_Id; } set { m_Id = value; } }
|
||||||
|
public string parentId { get { return m_ParentId; } set { m_ParentId = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据项图例名称。当数据项名称不为空时,图例名称即为系列名称;反之则为索引index。
|
/// 数据项图例名称。当数据项名称不为空时,图例名称即为系列名称;反之则为索引index。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -97,8 +100,6 @@ namespace XCharts.Runtime
|
|||||||
/// 可指定任意维数的数值列表。
|
/// 可指定任意维数的数值列表。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<double> data { get { return m_Data; } set { m_Data = value; } }
|
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>
|
/// <summary>
|
||||||
/// [default:true] Whether the data item is showed.
|
/// [default:true] Whether the data item is showed.
|
||||||
/// 该数据项是否要显示。
|
/// 该数据项是否要显示。
|
||||||
@@ -113,12 +114,16 @@ namespace XCharts.Runtime
|
|||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
index = 0;
|
index = 0;
|
||||||
|
m_Id = null;
|
||||||
|
m_ParentId = null;
|
||||||
labelObject = null;
|
labelObject = null;
|
||||||
m_Name = string.Empty;
|
m_Name = string.Empty;
|
||||||
m_Show = true;
|
m_Show = true;
|
||||||
m_Selected = false;
|
m_Selected = false;
|
||||||
context.canShowLabel = true;
|
context.canShowLabel = true;
|
||||||
context.highlight = false;
|
context.highlight = false;
|
||||||
|
context.children.Clear();
|
||||||
|
context.dataPoints.Clear();
|
||||||
m_Radius = 0;
|
m_Radius = 0;
|
||||||
interact.Reset();
|
interact.Reset();
|
||||||
m_Data.Clear();
|
m_Data.Clear();
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ namespace XCharts.Runtime
|
|||||||
public float outsideRadius { get; set; }
|
public float outsideRadius { get; set; }
|
||||||
public Vector3 position { get; set; }
|
public Vector3 position { get; set; }
|
||||||
public List<Vector3> dataPoints = new List<Vector3>();
|
public List<Vector3> dataPoints = new List<Vector3>();
|
||||||
|
public List<SerieData> children = new List<SerieData>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 绘制区域。
|
/// 绘制区域。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace XCharts.Runtime
|
|||||||
private static readonly string s_SerieTitleObjectName = "title";
|
private static readonly string s_SerieTitleObjectName = "title";
|
||||||
private static readonly string s_SerieRootObjectName = "serie";
|
private static readonly string s_SerieRootObjectName = "serie";
|
||||||
protected GameObject m_SerieRoot;
|
protected GameObject m_SerieRoot;
|
||||||
|
protected GameObject m_SerieLabelRoot;
|
||||||
protected bool m_InitedLabel;
|
protected bool m_InitedLabel;
|
||||||
protected bool m_NeedInitComponent;
|
protected bool m_NeedInitComponent;
|
||||||
protected bool m_RefreshLabel;
|
protected bool m_RefreshLabel;
|
||||||
@@ -56,6 +57,7 @@ namespace XCharts.Runtime
|
|||||||
protected int m_LegendEnterIndex;
|
protected int m_LegendEnterIndex;
|
||||||
|
|
||||||
public T serie { get; internal set; }
|
public T serie { get; internal set; }
|
||||||
|
public GameObject labelObject { get { return m_SerieLabelRoot; } }
|
||||||
|
|
||||||
internal override void SetSerie(Serie serie)
|
internal override void SetSerie(Serie serie)
|
||||||
{
|
{
|
||||||
@@ -77,6 +79,11 @@ namespace XCharts.Runtime
|
|||||||
if (m_InitedLabel)
|
if (m_InitedLabel)
|
||||||
RefreshLabelInternal();
|
RefreshLabelInternal();
|
||||||
}
|
}
|
||||||
|
if (serie.dataDirty)
|
||||||
|
{
|
||||||
|
serie.OnDataUpdate();
|
||||||
|
serie.dataDirty = false;
|
||||||
|
}
|
||||||
if (serie.label != null && (serie.labelDirty || serie.label.componentDirty))
|
if (serie.label != null && (serie.labelDirty || serie.label.componentDirty))
|
||||||
{
|
{
|
||||||
serie.labelDirty = false;
|
serie.labelDirty = false;
|
||||||
@@ -182,10 +189,11 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
if (m_SerieRoot == null)
|
if (m_SerieRoot == null)
|
||||||
InitRoot();
|
InitRoot();
|
||||||
var serieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, m_SerieRoot.transform,
|
m_SerieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, m_SerieRoot.transform,
|
||||||
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||||
serieLabelRoot.hideFlags = chart.chartHideFlags;
|
m_SerieLabelRoot.hideFlags = chart.chartHideFlags;
|
||||||
SerieLabelPool.ReleaseAll(serieLabelRoot.transform);
|
//SerieLabelPool.ReleaseAll(m_SerieLabelRoot.transform);
|
||||||
|
ChartHelper.DestroyAllChildren(m_SerieLabelRoot.transform);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||||
for (int j = 0; j < serie.data.Count; j++)
|
for (int j = 0; j < serie.data.Count; j++)
|
||||||
@@ -193,7 +201,7 @@ namespace XCharts.Runtime
|
|||||||
var serieData = serie.data[j];
|
var serieData = serie.data[j];
|
||||||
serieData.index = count;
|
serieData.index = count;
|
||||||
serieData.labelObject = null;
|
serieData.labelObject = null;
|
||||||
if (AddSerieLabel(serieLabelRoot, serie, serieData, ref count))
|
if (AddSerieLabel(m_SerieLabelRoot, serie, serieData, ref count))
|
||||||
{
|
{
|
||||||
m_InitedLabel = true;
|
m_InitedLabel = true;
|
||||||
count++;
|
count++;
|
||||||
@@ -204,6 +212,8 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
|
protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
|
||||||
{
|
{
|
||||||
|
if (serieData == null)
|
||||||
|
return false;
|
||||||
if (serieLabelRoot == null)
|
if (serieLabelRoot == null)
|
||||||
return false;
|
return false;
|
||||||
if (serie.IsPerformanceMode())
|
if (serie.IsPerformanceMode())
|
||||||
@@ -217,8 +227,9 @@ namespace XCharts.Runtime
|
|||||||
var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
|
var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
|
||||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||||
|
|
||||||
if (!serieLabel.show && (serieEmphasisLabel == null || !serieEmphasisLabel.show)
|
if (!serieLabel.show
|
||||||
&& (iconStyle != null && !iconStyle.show))
|
&& (serieEmphasisLabel == null || !serieEmphasisLabel.show)
|
||||||
|
&& (iconStyle == null || !iconStyle.show))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
|
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
|
||||||
@@ -239,12 +250,14 @@ namespace XCharts.Runtime
|
|||||||
item.color = serieLabel.textStyle.backgroundColor;
|
item.color = serieLabel.textStyle.backgroundColor;
|
||||||
serieData.labelObject = item;
|
serieData.labelObject = item;
|
||||||
|
|
||||||
foreach (var data in serieData.children)
|
if (serieData.context.children.Count > 0)
|
||||||
{
|
{
|
||||||
AddSerieLabel(serieLabelRoot, serie, serie.GetSerieData(data), ref count);
|
foreach (var childSerieData in serieData.context.children)
|
||||||
count++;
|
{
|
||||||
|
AddSerieLabel(serieLabelRoot, serie, childSerieData, ref count);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1266,16 +1266,16 @@ namespace XUGL
|
|||||||
/// <param name="toDegree">结束角度</param>
|
/// <param name="toDegree">结束角度</param>
|
||||||
/// <param name="borderWidth">边框宽度</param>
|
/// <param name="borderWidth">边框宽度</param>
|
||||||
/// <param name="borderColor">边框颜色</param>
|
/// <param name="borderColor">边框颜色</param>
|
||||||
/// <param name="space">边距</param>
|
/// <param name="gap">边距</param>
|
||||||
/// <param name="smoothness">光滑度</param>
|
/// <param name="smoothness">光滑度</param>
|
||||||
/// <param name="gradientType">渐变类型,0:向圆形渐变,1:水平或垂直渐变,2:开始角度向结束角度渐变</param>
|
/// <param name="gradientType">渐变类型,0:向圆形渐变,1:水平或垂直渐变,2:开始角度向结束角度渐变</param>
|
||||||
/// <param name="isYAxis">水平渐变还是垂直渐变,gradientType为1时生效</param>
|
/// <param name="isYAxis">水平渐变还是垂直渐变,gradientType为1时生效</param>
|
||||||
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, Color32 toColor,
|
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, Color32 toColor,
|
||||||
float startDegree, float toDegree, float borderWidth, Color32 borderColor, float space,
|
float startDegree, float toDegree, float borderWidth, Color32 borderColor, float gap,
|
||||||
float smoothness, int gradientType = 0, bool isYAxis = false)
|
float smoothness, int gradientType = 0, bool isYAxis = false)
|
||||||
{
|
{
|
||||||
if (radius == 0) return;
|
if (radius == 0) return;
|
||||||
if (space > 0 && Mathf.Abs(toDegree - startDegree) >= 360) space = 0;
|
if (gap > 0 && Mathf.Abs(toDegree - startDegree) >= 360) gap = 0;
|
||||||
radius -= borderWidth;
|
radius -= borderWidth;
|
||||||
smoothness = (smoothness < 0 ? 2f : smoothness);
|
smoothness = (smoothness < 0 ? 2f : smoothness);
|
||||||
int segments = (int)((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
|
int segments = (int)((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
|
||||||
@@ -1296,7 +1296,7 @@ namespace XUGL
|
|||||||
var lastP4 = center;
|
var lastP4 = center;
|
||||||
var lastColor = color;
|
var lastColor = color;
|
||||||
var needBorder = borderWidth != 0;
|
var needBorder = borderWidth != 0;
|
||||||
var needSpace = space != 0;
|
var needSpace = gap != 0;
|
||||||
var borderLineWidth = needSpace ? borderWidth : borderWidth / 2;
|
var borderLineWidth = needSpace ? borderWidth : borderWidth / 2;
|
||||||
var lastPos = Vector3.zero;
|
var lastPos = Vector3.zero;
|
||||||
var middleDire = UGLHelper.GetDire(startAngle + halfAngle);
|
var middleDire = UGLHelper.GetDire(startAngle + halfAngle);
|
||||||
@@ -1306,10 +1306,10 @@ namespace XUGL
|
|||||||
float borderDiff = 0f;
|
float borderDiff = 0f;
|
||||||
if (needSpace)
|
if (needSpace)
|
||||||
{
|
{
|
||||||
spaceDiff = space / Mathf.Sin(halfAngle);
|
spaceDiff = gap / Mathf.Sin(halfAngle);
|
||||||
spaceCenter = center + spaceDiff * middleDire;
|
spaceCenter = center + spaceDiff * middleDire;
|
||||||
realCenter = spaceCenter;
|
realCenter = spaceCenter;
|
||||||
spaceAngle = 2 * Mathf.Asin(space / (2 * radius));
|
spaceAngle = 2 * Mathf.Asin(gap / (2 * radius));
|
||||||
realStartAngle = startAngle + spaceAngle;
|
realStartAngle = startAngle + spaceAngle;
|
||||||
realToAngle = toAngle - spaceAngle;
|
realToAngle = toAngle - spaceAngle;
|
||||||
if (realToAngle < realStartAngle) realToAngle = realStartAngle;
|
if (realToAngle < realStartAngle) realToAngle = realStartAngle;
|
||||||
@@ -1452,14 +1452,14 @@ namespace XUGL
|
|||||||
|
|
||||||
public static void DrawDoughnut(VertexHelper vh, Vector3 center, float insideRadius, float outsideRadius,
|
public static void DrawDoughnut(VertexHelper vh, Vector3 center, float insideRadius, float outsideRadius,
|
||||||
Color32 color, Color32 toColor, Color32 emptyColor, float startDegree, float toDegree, float borderWidth,
|
Color32 color, Color32 toColor, Color32 emptyColor, float startDegree, float toDegree, float borderWidth,
|
||||||
Color32 borderColor, float space, float smoothness, bool roundCap = false, bool clockwise = true)
|
Color32 borderColor, float gap, float smoothness, bool roundCap = false, bool clockwise = true)
|
||||||
{
|
{
|
||||||
if (toDegree - startDegree == 0) return;
|
if (toDegree - startDegree == 0) return;
|
||||||
if (space > 0 && Mathf.Abs(toDegree - startDegree) >= 360) space = 0;
|
if (gap > 0 && Mathf.Abs(toDegree - startDegree) >= 360) gap = 0;
|
||||||
if (insideRadius <= 0)
|
if (insideRadius <= 0)
|
||||||
{
|
{
|
||||||
DrawSector(vh, center, outsideRadius, color, toColor, startDegree, toDegree, borderWidth, borderColor,
|
DrawSector(vh, center, outsideRadius, color, toColor, startDegree, toDegree, borderWidth, borderColor,
|
||||||
space, smoothness);
|
gap, smoothness);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
outsideRadius -= borderWidth;
|
outsideRadius -= borderWidth;
|
||||||
@@ -1467,7 +1467,7 @@ namespace XUGL
|
|||||||
smoothness = smoothness < 0 ? 2f : smoothness;
|
smoothness = smoothness < 0 ? 2f : smoothness;
|
||||||
Vector3 p1, p2, p3, p4, e1, e2;
|
Vector3 p1, p2, p3, p4, e1, e2;
|
||||||
var needBorder = borderWidth != 0;
|
var needBorder = borderWidth != 0;
|
||||||
var needSpace = space != 0;
|
var needSpace = gap != 0;
|
||||||
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
|
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
|
||||||
|
|
||||||
int segments = (int)((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
|
int segments = (int)((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
|
||||||
@@ -1506,12 +1506,12 @@ namespace XUGL
|
|||||||
{
|
{
|
||||||
if (needSpace)
|
if (needSpace)
|
||||||
{
|
{
|
||||||
var spaceDiff = space / Mathf.Sin(halfAngle);
|
var spaceDiff = gap / Mathf.Sin(halfAngle);
|
||||||
spaceCenter = center + Mathf.Abs(spaceDiff) * middleDire;
|
spaceCenter = center + Mathf.Abs(spaceDiff) * middleDire;
|
||||||
realCenter = spaceCenter;
|
realCenter = spaceCenter;
|
||||||
spaceAngle = 2 * Mathf.Asin(space / (2 * outsideRadius));
|
spaceAngle = 2 * Mathf.Asin(gap / (2 * outsideRadius));
|
||||||
spaceInAngle = 2 * Mathf.Asin(space / (2 * insideRadius));
|
spaceInAngle = 2 * Mathf.Asin(gap / (2 * insideRadius));
|
||||||
spaceHalfAngle = 2 * Mathf.Asin(space / (2 * (insideRadius + (outsideRadius - insideRadius) / 2)));
|
spaceHalfAngle = 2 * Mathf.Asin(gap / (2 * (insideRadius + (outsideRadius - insideRadius) / 2)));
|
||||||
if (clockwise)
|
if (clockwise)
|
||||||
{
|
{
|
||||||
p1 = UGLHelper.GetPos(center, insideRadius, startAngle + spaceInAngle, false);
|
p1 = UGLHelper.GetPos(center, insideRadius, startAngle + spaceInAngle, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user