3.0 - optimize code

This commit is contained in:
monitor1394
2022-03-04 22:17:32 +08:00
parent 1ee0df09eb
commit 5745fea9a1
59 changed files with 482 additions and 435 deletions

View File

@@ -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) 修复`RadarChart``Circle`时不绘制`SplitArea`的问题
* (2020.05.30) 优化`RadarChart`在设置`max``0`时可自动刷新最大值
* (2020.05.29) 修复`PieChart`设置`space`时只有一个数据时绘制异常的问题
* (2020.05.29) 修复`PieChart`设置`gap`时只有一个数据时绘制异常的问题
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题
* (2020.05.27) 优化`柱状图`的渐变色效果
* (2020.05.24) 修复`Axis`同时设置`boundaryGap``alignWithLabel``Tick`绘制异常的问题

View File

@@ -267,7 +267,7 @@
* (2020.05.30) 优化`PieChart`支持设置`ignoreValue`不显示指定数据
* (2020.05.30) 修复`RadarChart``Circle`时不绘制`SplitArea`的问题
* (2020.05.30) 优化`RadarChart`在设置`max``0`时可自动刷新最大值
* (2020.05.29) 修复`PieChart`设置`space`时只有一个数据时绘制异常的问题
* (2020.05.29) 修复`PieChart`设置`gap`时只有一个数据时绘制异常的问题
* (2020.05.27) 修复调用`UpdateDataName()`接口时不会自动刷新的问题
* (2020.05.27) 优化`柱状图`的渐变色效果
* (2020.05.24) 修复`Axis`同时设置`boundaryGap``alignWithLabel``Tick`绘制异常的问题

View File

@@ -638,7 +638,7 @@
* `None`:不展示成南丁格尔玫瑰图。
* `Radius`:扇区圆心角展现数据的百分比,半径展现数据的大小。
* `Area`:所有扇区圆心角相同,仅通过半径展现数据大小。
* `space`:扇区间隙。
* `gap`:扇区间隙。
* `center`:中心点坐标。当值为`0-1`的浮点数时表示百分比。
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
* `minAngle`最小的扇区角度0-360。用于防止某个值过小导致扇区太小影响交互。

View File

@@ -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`].
* `fontSize`: the size of text. [default: `18`].
* `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.
* `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`: 不展示成南丁格尔玫瑰图。
* `Radius`: 扇区圆心角展现数据的百分比,半径展现数据的大小。
* `Area`: 所有扇区圆心角相同,仅通过半径展现数据大小。
* `space`: 扇区间隙。
* `gap`: 扇区间隙。
* `center`: 中心点坐标。当值为`0-1`的浮点数时表示百分比。
* `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.

View File

@@ -167,7 +167,7 @@ namespace XCharts.Editor
{
sb.Length = 0;
sb.AppendFormat("v{0}", XChartsMgr.fullVersion);
//if(m_EnableTextMeshPro.boolValue)
if(m_EnableTextMeshPro.boolValue)
sb.Append("-tmp");
EditorGUILayout.HelpBox(sb.ToString(), MessageType.None);
}
@@ -265,7 +265,7 @@ namespace XCharts.Editor
}
if (GUILayout.Button("Reinit Component"))
{
m_Chart.ReinitAllChartComponent();
m_Chart.RemoveAndReinitChartObject();
}
if (m_CheckWarning)
{

View File

@@ -21,7 +21,6 @@ namespace XCharts.Editor
PropertyField(prop, "m_HighlightColor");
PropertyField(prop, "m_HighlightToColor");
PropertyField(prop, "m_Opacity");
PropertyField(prop, "m_TooltipHighlight");
--EditorGUI.indentLevel;
}
}

View File

@@ -17,7 +17,7 @@ namespace XCharts.Editor
++EditorGUI.indentLevel;
PropertyField(prop, "m_FoldSeries");
PropertyField(prop, "m_ShowDebugInfo");
PropertyField(prop, "m_ShowAllChildObject");
PropertyField(prop, "m_ShowAllChartObject");
PropertyField(prop, "m_DebugInfoTextStyle");
--EditorGUI.indentLevel;
}

View File

@@ -23,7 +23,6 @@ namespace XCharts.Editor
PropertyField(prop, "m_BackgroundWidth");
PropertyField(prop, "m_CenterColor");
PropertyField(prop, "m_CenterGap");
PropertyField(prop, "m_BorderType");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_BorderColor");
PropertyField(prop, "m_BorderColor0");

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a1ff119a53a44e5abe2ef6f57816aa6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -39,7 +39,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_DataScale");
PropertyField(prop, "m_SelectedDataScale");
break;
case SymbolSizeType.Callback:
case SymbolSizeType.Function:
break;
}
PropertyField(prop, "m_StartIndex");

View File

@@ -8,7 +8,7 @@ namespace XCharts.Editor
public override void OnCustomInspectorGUI()
{
PropertyField("m_RoseType");
PropertyField("m_Space");
PropertyField("m_Gap");
PropertyTwoFiled("m_Center");
PropertyTwoFiled("m_Radius");

View File

@@ -10,7 +10,7 @@ namespace XCharts.Editor
PropertyTwoFiled("m_Center");
PropertyTwoFiled("m_Radius");
PropertyField("m_StartAngle");
PropertyField("m_RingGap");
PropertyField("m_Gap");
PropertyField("m_RoundCap");
PropertyField("m_Clockwise");

View File

@@ -75,7 +75,7 @@ namespace XCharts.Editor
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;
for (int i = 0; i < num; i++)
@@ -191,10 +191,10 @@ namespace XCharts.Editor
{
EditorGUI.indentLevel++;
var serieData = m_Datas.GetArrayElementAtIndex(index);
var sereName = serieData.FindPropertyRelative("m_Name");
var selected = serieData.FindPropertyRelative("m_Selected");
var m_Name = serieData.FindPropertyRelative("m_Name");
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_Label = serieData.FindPropertyRelative("m_Labels");
var m_ItemStyle = serieData.FindPropertyRelative("m_ItemStyles");
@@ -204,9 +204,9 @@ namespace XCharts.Editor
var m_AreaStyle = serieData.FindPropertyRelative("m_AreaStyles");
var m_TitleStyle = serieData.FindPropertyRelative("m_TitleStyles");
PropertyField(sereName);
PropertyField(selected);
PropertyField(m_Ignore);
PropertyField(m_Name);
PropertyField(m_Id);
PropertyField(m_ParentId);
var componentNum = m_IconStyle.arraySize + m_Label.arraySize + m_ItemStyle.arraySize + m_Emphasis.arraySize
+ m_Symbol.arraySize + m_LineStyle.arraySize + m_AreaStyle.arraySize;

View File

@@ -20,9 +20,9 @@ namespace XCharts.Example
var serie = chart.GetSerie(0);
serie.animation.enable = true;
//自定义每个数据项的渐入延时
serie.animation.customFadeInDelay = CustomFadeInDelay;
serie.animation.fadeInDelayFunction = CustomFadeInDelay;
//自定义每个数据项的渐入时长
serie.animation.customFadeInDuration = CustomFadeInDuration;
serie.animation.fadeInDurationFunction = CustomFadeInDuration;
}
float CustomFadeInDelay(int dataIndex)

View File

@@ -17,15 +17,15 @@ namespace XCharts.Example
chart = gameObject.GetComponent<LineChart>();
if (chart == null) return;
chart.onCustomDraw = delegate (VertexHelper vh)
chart.onDraw = delegate (VertexHelper vh)
{
};
// or
chart.onCustomDrawBeforeSerie = delegate (VertexHelper vh, Serie serie)
chart.onDrawBeforeSerie = delegate (VertexHelper vh, Serie serie)
{
};
// or
chart.onCustomDrawAfterSerie = delegate (VertexHelper vh, Serie serie)
chart.onDrawAfterSerie = delegate (VertexHelper vh, Serie serie)
{
if (serie.index != 0) return;
var dataPoints = serie.context.dataPoints;
@@ -41,7 +41,7 @@ namespace XCharts.Example
}
};
// or
chart.onCustomDrawTop = delegate (VertexHelper vh)
chart.onDrawTop = delegate (VertexHelper vh)
{
};
}

View File

@@ -114,7 +114,7 @@ namespace XCharts.Example
chart.RefreshChart();
yield return null;
}
serie.pieSpace = 1f;
serie.gap = 1f;
chart.RefreshChart();
yield return new WaitForSeconds(1);
@@ -122,7 +122,7 @@ namespace XCharts.Example
chart.RefreshChart();
yield return new WaitForSeconds(1);
serie.pieSpace = 0f;
serie.gap = 0f;
serie.data[0].selected = false;
chart.RefreshChart();
yield return new WaitForSeconds(1);

View File

@@ -18,8 +18,8 @@ namespace XCharts.Example
if (chart == null) return;
foreach (var serie in chart.series)
{
serie.symbol.sizeCallback = SymbolSize;
serie.symbol.selectedSizeCallback = SymbolSelectedSize;
serie.symbol.sizeFunction = SymbolSize;
serie.symbol.selectedSizeFunction = SymbolSelectedSize;
}
}

View File

@@ -5,9 +5,6 @@ using System;
namespace XCharts.Runtime
{
public delegate float CustomAnimationDelay(int dataIndex);
public delegate float CustomAnimationDuration(int dataIndex);
public enum AnimationType
{
/// <summary>
@@ -69,19 +66,19 @@ namespace XCharts.Runtime
/// <summary>
/// 自定义渐入动画延时函数。返回ms值。
/// </summary>
public CustomAnimationDelay customFadeInDelay;
public AnimationDelayFunction fadeInDelayFunction;
/// <summary>
/// 自定义渐入动画时长函数。返回ms值。
/// </summary>
public CustomAnimationDuration customFadeInDuration;
public AnimationDurationFunction fadeInDurationFunction;
/// <summary>
/// 自定义渐出动画延时函数。返回ms值。
/// </summary>
public CustomAnimationDelay customFadeOutDelay;
public AnimationDelayFunction fadeOutDelayFunction;
/// <summary>
/// 自定义渐出动画时长函数。返回ms值。
/// </summary>
public CustomAnimationDuration customFadeOutDuration;
public AnimationDurationFunction fadeOutDurationFunction;
public AnimationStyleContext context = new AnimationStyleContext();
/// <summary>
@@ -390,10 +387,10 @@ namespace XCharts.Runtime
public float GetIndexDelay(int dataIndex)
{
if (m_FadeOut && customFadeOutDelay != null)
return customFadeOutDelay(dataIndex);
else if (m_FadeIn && customFadeInDelay != null)
return customFadeInDelay(dataIndex);
if (m_FadeOut && fadeOutDelayFunction != null)
return fadeOutDelayFunction(dataIndex);
else if (m_FadeIn && fadeInDelayFunction != null)
return fadeInDelayFunction(dataIndex);
else
return 0;
}
@@ -492,10 +489,10 @@ namespace XCharts.Runtime
{
if (dataIndex >= 0)
{
if (m_FadeOut && customFadeOutDuration != null)
return customFadeOutDuration(dataIndex) / 1000f;
if (m_FadeIn && customFadeInDuration != null)
return customFadeInDuration(dataIndex) / 1000f;
if (m_FadeOut && fadeOutDurationFunction != null)
return fadeOutDurationFunction(dataIndex) / 1000f;
if (m_FadeIn && fadeInDurationFunction != null)
return fadeInDurationFunction(dataIndex) / 1000f;
}
if (m_FadeOut)

View File

@@ -57,8 +57,8 @@ namespace XCharts
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
if (j != lastPointerValue)
{
if (chart.onUpdateAxisPointer != null)
chart.onUpdateAxisPointer(axis, j);
if (chart.onAxisPointerValueChanged != null)
chart.onAxisPointerValueChanged(axis, j);
}
break;
}
@@ -74,8 +74,8 @@ namespace XCharts
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
if (j != lastPointerValue)
{
if (chart.onUpdateAxisPointer != null)
chart.onUpdateAxisPointer(axis, j);
if (chart.onAxisPointerValueChanged != null)
chart.onAxisPointerValueChanged(axis, j);
}
break;
}
@@ -97,8 +97,8 @@ namespace XCharts
axis.context.pointerLabelPosition = new Vector3(labelX, chart.pointerPos.y);
if (yValue != lastPointerValue)
{
if (chart.onUpdateAxisPointer != null)
chart.onUpdateAxisPointer(axis, yValue);
if (chart.onAxisPointerValueChanged != null)
chart.onAxisPointerValueChanged(axis, yValue);
}
}
else
@@ -114,8 +114,8 @@ namespace XCharts
axis.context.pointerLabelPosition = new Vector3(chart.pointerPos.x, labelY);
if (xValue != lastPointerValue)
{
if (chart.onUpdateAxisPointer != null)
chart.onUpdateAxisPointer(axis, xValue);
if (chart.onAxisPointerValueChanged != null)
chart.onAxisPointerValueChanged(axis, xValue);
}
}
}
@@ -750,7 +750,7 @@ namespace XCharts
}
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 lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
@@ -803,6 +803,7 @@ namespace XCharts
{
if (orient == Orient.Horizonal)
{
if (relativedAxis == null || MathUtil.Approximately(current, relativedAxis.context.x))
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
@@ -812,12 +813,13 @@ namespace XCharts
}
else
{
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
new Vector3(startX, current),
new Vector3(startX + splitLength, current),
lineColor);
if (relativedAxis == null || MathUtil.Approximately(current, relativedAxis.context.y))
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
new Vector3(startX, current),
new Vector3(startX + splitLength, current),
lineColor);
}
}

View File

@@ -81,6 +81,8 @@ namespace XCharts.Runtime
{
if (dataCount < 1)
dataCount = 1;
if (axis.IsValue())
return dataCount > 1 ? coordinateWidth / (dataCount - 1) : coordinateWidth;
var categoryCount = axis.GetDataCount(dataZoom);
int segment = (axis.boundaryGap ? categoryCount : categoryCount - 1);
segment = segment <= 0 ? dataCount : segment;

View File

@@ -26,7 +26,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_ShowEndLabel = true;
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
private DelegateAxisLabelFormatter m_FormatterFunction;
private AxisLabelFormatterFunction m_FormatterFunction;
/// <summary>
/// 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(); }
}
public DelegateAxisLabelFormatter formatterFunction
public AxisLabelFormatterFunction formatterFunction
{
set { m_FormatterFunction = value; }
}

View File

@@ -92,6 +92,7 @@ namespace XCharts.Runtime
if (grid == null)
return;
var relativedAxis = chart.GetChartComponent<YAxis>(xAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
@@ -99,7 +100,8 @@ namespace XCharts.Runtime
grid.context.x,
grid.context.y,
grid.context.width,
grid.context.height);
grid.context.height,
relativedAxis);
}
}

View File

@@ -89,14 +89,15 @@ namespace XCharts.Runtime
var grid = chart.GetChartComponent<GridCoord>(yAxis.gridIndex);
if (grid == null)
return;
var relativedAxis = chart.GetChartComponent<XAxis>(yAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
Orient.Vertical,
grid.context.x,
grid.context.y,
grid.context.height,
grid.context.width);
grid.context.width,
relativedAxis);
}
}

View File

@@ -38,7 +38,6 @@ namespace XCharts.Runtime
[SerializeField] private Color32 m_Color;
[SerializeField] private Color32 m_ToColor;
[SerializeField] [Range(0, 1)] private float m_Opacity = 0.6f;
[SerializeField] private bool m_TooltipHighlight;
[SerializeField] private Color32 m_HighlightColor;
[SerializeField] private Color32 m_HighlightToColor;
@@ -88,14 +87,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
}
/// <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.
/// 高亮时区域填充的颜色如果highlightToColor不是默认值则表示渐变色的起点颜色。
/// </summary>

View File

@@ -12,7 +12,7 @@ namespace XCharts.Runtime
UnderLabel,
AboveLabel
}
[SerializeField] private bool m_Show;
[SerializeField] private bool m_Show = false;
[SerializeField] private Layer m_Layer;
[SerializeField] private Align m_Align = Align.Left;
[SerializeField] private Sprite m_Sprite;

View File

@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts.Runtime
@@ -11,24 +8,6 @@ namespace XCharts.Runtime
[System.Serializable]
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 Color32 m_Color;
[SerializeField] private Color32 m_Color0;
@@ -38,7 +17,6 @@ namespace XCharts.Runtime
[SerializeField] private float m_BackgroundWidth;
[SerializeField] private Color32 m_CenterColor;
[SerializeField] private float m_CenterGap;
[SerializeField] private Type m_BorderType = Type.Solid;
[SerializeField] private float m_BorderWidth = 0;
[SerializeField] private Color32 m_BorderColor;
[SerializeField] private Color32 m_BorderColor0;
@@ -60,7 +38,6 @@ namespace XCharts.Runtime
m_BackgroundWidth = 0;
m_CenterColor = Color.clear;
m_CenterGap = 0;
m_BorderType = Type.Solid;
m_BorderWidth = 0;
m_BorderColor = Color.clear;
m_BorderColor0 = Color.clear;
@@ -155,14 +132,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框的类型。
/// </summary>
public Type borderType
{
get { return m_BorderType; }
set { if (PropertyUtil.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框的颜色。
/// </summary>
public Color32 borderColor
@@ -261,6 +230,7 @@ namespace XCharts.Runtime
color.a = (byte)(color.a * m_Opacity);
return color;
}
public Color32 GetColor0()
{
if (m_Opacity == 1 || m_Color0.a == 0)
@@ -270,6 +240,7 @@ namespace XCharts.Runtime
color.a = (byte)(color.a * m_Opacity);
return color;
}
public Color32 GetColor(Color32 defaultColor)
{
var color = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
@@ -280,6 +251,7 @@ namespace XCharts.Runtime
color.a = (byte)(color.a * m_Opacity);
return color;
}
public Color32 GetColor0(Color32 defaultColor)
{
var color = ChartHelper.IsClearColor(m_Color0) ? defaultColor : m_Color0;
@@ -290,6 +262,7 @@ namespace XCharts.Runtime
color.a = (byte)(color.a * m_Opacity);
return color;
}
public Color32 GetBorderColor(Color32 defaultColor)
{
var color = ChartHelper.IsClearColor(m_BorderColor) ? defaultColor : m_BorderColor;
@@ -300,6 +273,7 @@ namespace XCharts.Runtime
color.a = (byte)(color.a * m_Opacity);
return color;
}
public Color32 GetBorderColor0(Color32 defaultColor)
{
var color = ChartHelper.IsClearColor(m_BorderColor0) ? defaultColor : m_BorderColor0;

View File

@@ -83,7 +83,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_AutoOffset = false;
[SerializeField] private bool m_AutoColor = false;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
private DelegateSerieLabelFormatter m_FormatterFunction;
private SerieLabelFormatterFunction m_FormatterFunction;
public void Reset()
{
@@ -230,7 +230,7 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetAllDirty(); }
}
public DelegateSerieLabelFormatter formatterFunction
public SerieLabelFormatterFunction formatterFunction
{
get { return m_FormatterFunction; }
set { m_FormatterFunction = value; }

View 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; } }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3760e89d324d7413d95a2ac1d434a546
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -78,19 +78,12 @@ namespace XCharts.Runtime
/// </summary>
FromData,
/// <summary>
/// Specify callback function for symbol size.
/// 通过回调函数获取。
/// Specify function for symbol size.
/// 通过委托函数获取。
/// </summary>
Callback,
Function,
}
/// <summary>
/// 获取标记大小的回调。
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public delegate float SymbolSizeCallback(List<double> data);
/// <summary>
/// 系列数据项的标记的图形
/// </summary>
@@ -105,8 +98,8 @@ namespace XCharts.Runtime
[SerializeField] private int m_DataIndex = 1;
[SerializeField] private float m_DataScale = 1;
[SerializeField] private float m_SelectedDataScale = 1.5f;
[SerializeField] private SymbolSizeCallback m_SizeCallback;
[SerializeField] private SymbolSizeCallback m_SelectedSizeCallback;
[SerializeField] private SymbolSizeFunction m_SizeFunction;
[SerializeField] private SymbolSizeFunction m_SelectedSizeFunction;
[SerializeField] private int m_StartIndex;
[SerializeField] private int m_Interval;
[SerializeField] private bool m_ForceShowLast = false;
@@ -128,8 +121,8 @@ namespace XCharts.Runtime
m_DataIndex = 1;
m_DataScale = 1;
m_SelectedDataScale = 1.5f;
m_SizeCallback = null;
m_SelectedSizeCallback = null;
m_SizeFunction = null;
m_SelectedSizeFunction = null;
m_StartIndex = 0;
m_Interval = 0;
m_ForceShowLast = false;
@@ -215,22 +208,22 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
}
/// <summary>
/// the callback of size when sizeType assined as Callback.
/// 当sizeType指定为Callback时,指定的回调函数。
/// the function of size when sizeType assined as Function.
/// 当sizeType指定为Function时,指定的委托函数。
/// </summary>
public SymbolSizeCallback sizeCallback
public SymbolSizeFunction sizeFunction
{
get { return m_SizeCallback; }
set { if (PropertyUtil.SetClass(ref m_SizeCallback, value)) SetVerticesDirty(); }
get { return m_SizeFunction; }
set { if (PropertyUtil.SetClass(ref m_SizeFunction, value)) SetVerticesDirty(); }
}
/// <summary>
/// the callback of size when sizeType assined as Callback.
/// 当sizeType指定为Callback时,指定的高亮回调函数。
/// the function of size when sizeType assined as Function.
/// 当sizeType指定为Function时,指定的高亮委托函数。
/// </summary>
public SymbolSizeCallback selectedSizeCallback
public SymbolSizeFunction selectedSizeFunction
{
get { return m_SelectedSizeCallback; }
set { if (PropertyUtil.SetClass(ref m_SelectedSizeCallback, value)) SetVerticesDirty(); }
get { return m_SelectedSizeFunction; }
set { if (PropertyUtil.SetClass(ref m_SelectedSizeFunction, value)) SetVerticesDirty(); }
}
/// <summary>
/// the index start to show symbol.
@@ -341,8 +334,8 @@ namespace XCharts.Runtime
{
return size == 0 ? themeSize : size;
}
case SymbolSizeType.Callback:
if (data != null && sizeCallback != null) return sizeCallback(data);
case SymbolSizeType.Function:
if (data != null && sizeFunction != null) return sizeFunction(data);
else return size == 0 ? themeSize : size;
default: return size == 0 ? themeSize : size;
}
@@ -372,10 +365,10 @@ namespace XCharts.Runtime
return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
case SymbolSizeType.Callback:
case SymbolSizeType.Function:
if (data != null && selectedSizeCallback != null)
return selectedSizeCallback(data);
if (data != null && selectedSizeFunction != null)
return selectedSizeFunction(data);
else
return selectedSize == 0 ? themeSelectedSize : selectedSize;

View File

@@ -10,7 +10,7 @@ namespace XCharts.Runtime
public class DebugInfo
{
[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]
private TextStyle m_DebugInfoTextStyle = new TextStyle()
@@ -32,7 +32,7 @@ namespace XCharts.Runtime
private ChartLabel m_Label;
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 float fps { get; private set; }
public float avgFps { get; private set; }

View File

@@ -1,6 +1,5 @@
using System;
using System.Text;
using UnityEngine;
namespace XCharts.Runtime

View File

@@ -412,6 +412,7 @@ namespace XCharts.Runtime
public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)
{
if (serieData == null) return serie.label;
if (highlight)
{
if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)

View File

@@ -72,23 +72,23 @@ namespace XCharts.Runtime
/// <summary>
/// 自定义绘制回调。在绘制Serie前调用。
/// </summary>
public Action<VertexHelper> onCustomDraw { set { m_OnCustomDrawBaseCallback = value; } }
public Action<VertexHelper> onDraw { set { m_OnDrawBase = value; } }
/// <summary>
/// 自定义Serie绘制回调。在每个Serie绘制完前调用。
/// </summary>
public Action<VertexHelper, Serie> onCustomDrawBeforeSerie { set { m_OnCustomDrawSerieBeforeCallback = value; } }
public Action<VertexHelper, Serie> onDrawBeforeSerie { set { m_OnDrawSerieBefore = value; } }
/// <summary>
/// 自定义Serie绘制回调。在每个Serie绘制完后调用。
/// </summary>
public Action<VertexHelper, Serie> onCustomDrawAfterSerie { set { m_OnCustomDrawSerieAfterCallback = value; } }
public Action<VertexHelper, Serie> onDrawAfterSerie { set { m_OnDrawSerieAfter = value; } }
/// <summary>
/// 自定义Top绘制回调。在绘制Tooltip前调用。
/// </summary>
public Action<VertexHelper> onCustomDrawTop { set { m_OnCustomDrawTopCallback = value; } }
public Action<VertexHelper> onDrawTop { set { m_OnDrawTop = value; } }
/// <summary>
/// 自定义仪表盘指针绘制回调。参数SerieIndexSerieDataIndexcurrAngle
/// 自定义仪表盘指针绘制委托。
/// </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>
/// the callback function of click pie area.
/// 点击饼图区域回调。参数PointerEventDataSerieIndexSerieDataIndex
@@ -102,7 +102,7 @@ namespace XCharts.Runtime
/// <summary>
/// 坐标轴变更数据索引时回调。参数axis, dataIndex/dataValue
/// </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>
/// Redraw chart in next frame.
/// 在下一帧刷新图表。

View File

@@ -190,7 +190,6 @@ namespace XCharts.Runtime
return true;
}
/// <summary>
/// Add a data to serie.
/// 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="data">the data to add</param>
/// <param name="dataName">the name of data</param>
/// <param name="dataId">the unique id of data</param>
/// <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);
if (serie != null)
{
var serieData = serie.AddYData(data, dataName);
var serieData = serie.AddYData(data, dataName, dataId);
RefreshPainter(serie.painter);
return serieData;
}
@@ -219,13 +219,14 @@ namespace XCharts.Runtime
/// <param name="serieIndex">the index of serie</param>
/// <param name="data">the data to add</param>
/// <param name="dataName">the name of data</param>
/// <param name="dataId">the unique id of data</param>
/// <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);
if (serie != null)
{
var serieData = serie.AddYData(data, dataName);
var serieData = serie.AddYData(data, dataName, dataId);
RefreshPainter(serie.painter);
return serieData;
}
@@ -239,13 +240,14 @@ namespace XCharts.Runtime
/// <param name="serieName">the name of serie</param>
/// <param name="multidimensionalData">the (x,y,z,...) 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>
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);
if (serie != null)
{
var serieData = serie.AddData(multidimensionalData, dataName);
var serieData = serie.AddData(multidimensionalData, dataName, dataId);
RefreshPainter(serie.painter);
return serieData;
}
@@ -259,13 +261,14 @@ namespace XCharts.Runtime
/// <param name="serieIndex">the index of serie,index starts at 0</param>
/// <param name="multidimensionalData">the (x,y,z,...) 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>
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);
if (serie != null)
{
var serieData = serie.AddData(multidimensionalData, dataName);
var serieData = serie.AddData(multidimensionalData, dataName, dataId);
RefreshPainter(serie.painter);
return serieData;
}
@@ -280,13 +283,14 @@ namespace XCharts.Runtime
/// <param name="xValue">x data</param>
/// <param name="yValue">y 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>
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);
if (serie != null)
{
var serieData = serie.AddXYData(xValue, yValue, dataName);
var serieData = serie.AddXYData(xValue, yValue, dataName, dataId);
RefreshPainter(serie.painter);
return serieData;
}
@@ -301,35 +305,36 @@ namespace XCharts.Runtime
/// <param name="xValue">x data</param>
/// <param name="yValue">y 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>
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);
if (serie != null)
{
var serieData = serie.AddXYData(xValue, yValue, dataName);
var serieData = serie.AddXYData(xValue, yValue, dataName, dataId);
RefreshPainter(serie.painter);
return serieData;
}
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);
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);
return serieData;
}
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);
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);
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);
}

View File

@@ -77,15 +77,17 @@ namespace XCharts.Runtime
protected Vector2 m_ChartMaxAnchor;
protected Vector2 m_ChartPivot;
protected Vector2 m_ChartSizeDelta;
protected Rect m_ChartRect = new Rect(0, 0, 0, 0);
protected Action<VertexHelper> m_OnCustomDrawBaseCallback;
protected Action<VertexHelper> m_OnCustomDrawTopCallback;
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieBeforeCallback;
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieAfterCallback;
protected Action<VertexHelper, int, int, float> m_OnCustomDrawGagugePointerCallback;
protected Action<VertexHelper> m_OnDrawBase;
protected Action<VertexHelper> m_OnDrawTop;
protected Action<VertexHelper, Serie> m_OnDrawSerieBefore;
protected Action<VertexHelper, Serie> m_OnDrawSerieAfter;
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
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 protected List<string> m_LegendRealShowName = new List<string>();
@@ -209,7 +211,7 @@ namespace XCharts.Runtime
{
var painter = GetPainter(index);
if (painter == null) return;
painter.SetActive(flag, m_DebugInfo.showAllChildObject);
painter.SetActive(flag, m_DebugInfo.showAllChartObject);
}
protected virtual void CheckTheme()
@@ -306,7 +308,7 @@ namespace XCharts.Runtime
painter.index = m_PainterList.Count;
painter.type = Painter.Type.Serie;
painter.onPopulateMesh = OnDrawPainterSerie;
painter.SetActive(false, m_DebugInfo.showAllChildObject);
painter.SetActive(false, m_DebugInfo.showAllChartObject);
painter.material = settings.seriePainterMaterial;
painter.transform.SetSiblingIndex(index + 1);
m_PainterList.Add(painter);
@@ -315,7 +317,7 @@ namespace XCharts.Runtime
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
m_PainterTop.type = Painter.Type.Top;
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.transform.SetSiblingIndex(settings.maxPainter + 1);
}
@@ -513,9 +515,9 @@ namespace XCharts.Runtime
DrawPainterBase(vh);
foreach (var handler in m_ComponentHandlers) 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;
}
@@ -535,9 +537,9 @@ namespace XCharts.Runtime
serie.context.dataPoints.Clear();
serie.context.dataIgnores.Clear();
AnimationStyleHelper.UpdateSerieAnimation(serie);
if (m_OnCustomDrawSerieBeforeCallback != null)
if (m_OnDrawSerieBefore != null)
{
m_OnCustomDrawSerieBeforeCallback.Invoke(vh, serie);
m_OnDrawSerieBefore.Invoke(vh, serie);
}
DrawPainterSerie(vh, serie);
if (i >= 0 && i < m_SerieHandlers.Count)
@@ -546,9 +548,9 @@ namespace XCharts.Runtime
handler.DrawSerie(vh);
handler.RefreshLabelNextFrame();
}
if (m_OnCustomDrawSerieAfterCallback != null)
if (m_OnDrawSerieAfter != null)
{
m_OnCustomDrawSerieAfterCallback(vh, serie);
m_OnDrawSerieAfter(vh, serie);
}
serie.context.vertCount = vh.currentVertCount;
}
@@ -559,9 +561,9 @@ namespace XCharts.Runtime
vh.Clear();
DrawPainterTop(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;
}
@@ -648,6 +650,7 @@ namespace XCharts.Runtime
foreach (var serie in m_Series)
{
FieldInfo field;
serie.OnBeforeSerialize();
if (m_TypeListForSerie.TryGetValue(serie.GetType(), out field))
ReflectionUtil.InvokeListAdd(this, field, serie);
else
@@ -666,7 +669,7 @@ namespace XCharts.Runtime
}
foreach (var kv in m_TypeListForSerie)
{
ReflectionUtil.InvokeListAddTo<Serie>(this, kv.Value, InternalAddSerie);
ReflectionUtil.InvokeListAddTo<Serie>(this, kv.Value, AddSerieAfterDeserialize);
}
m_Series.Sort();
m_Components.Sort();

View File

@@ -145,7 +145,7 @@ namespace XCharts.Runtime
/// <summary>
/// 移除并重新初始化所有组件。
/// </summary>
public void ReinitAllChartComponent()
public void RemoveAndReinitChartObject()
{
ChartHelper.DestroyAllChildren(transform);
SetAllComponentDirty();

View File

@@ -49,7 +49,7 @@ namespace XCharts.Runtime
protected Vector2 graphAnchorMax { get { return m_GraphMinAnchor; } }
protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } }
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; } }
private ScrollRect m_ScrollRect;
@@ -125,7 +125,7 @@ namespace XCharts.Runtime
if (m_EnableTextMeshPro != enableTextMeshPro)
{
m_EnableTextMeshPro = enableTextMeshPro;
ReinitAllChartComponent();
RemoveAndReinitChartObject();
}
}

View File

@@ -23,7 +23,7 @@ namespace XCharts.Runtime
[NonSerialized] public SerieContext context = new SerieContext();
[NonSerialized] public InteractData interact = new InteractData();
internal SerieHandler handler { get; set; }
public SerieHandler handler { get; set; }
public virtual void SetVerticesDirty()
@@ -68,6 +68,19 @@ namespace XCharts.Runtime
handler.RemoveComponent();
}
public virtual void OnDataUpdate()
{
}
public virtual void OnBeforeSerialize()
{
}
public virtual void OnAfterDeserialize()
{
OnDataUpdate();
}
public void RefreshLabel()
{
if (handler != null)

View File

@@ -7,7 +7,7 @@ namespace XCharts.Runtime
[System.Serializable]
public class ChildComponent
{
public int index { get; set; }
public virtual int index { get; set; }
[NonSerialized] protected bool m_VertsDirty;
[NonSerialized] protected bool m_ComponentDirty;
[NonSerialized] protected Painter m_Painter;

View File

@@ -1,5 +1,8 @@
using System.Collections.Generic;
using UnityEngine.UI;
namespace XCharts.Runtime
{
/// <summary>
@@ -10,7 +13,7 @@ namespace XCharts.Runtime
/// <param name="value">当前label对应的数值数据Value轴或Time轴有效</param>
/// <param name="category">当前label对应的类目数据Category轴有效</param>
/// <returns>最终显示的文本内容</returns>
public delegate string DelegateAxisLabelFormatter(int labelIndex, double value, string category);
public delegate string AxisLabelFormatterFunction(int labelIndex, double value, string category);
/// <summary>
/// The delegate function for SerieLabels formatter.
/// SerieLabel的formatter自定义委托。
@@ -18,5 +21,14 @@ namespace XCharts.Runtime
/// <param name="dataIndex">数据索引</param>
/// <param name="value">数值</param>
/// <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);
}

View File

@@ -19,7 +19,6 @@ namespace XCharts.Runtime
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<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>();
@@ -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>()
{
return GetTypeName(typeof(T));

View File

@@ -794,9 +794,6 @@ namespace XCharts.Runtime
}
}
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
{
Vector3 point = Quaternion.AngleAxis(angle, axis) * (position - center);
@@ -857,23 +854,7 @@ namespace XCharts.Runtime
}
}
public static float GetRuntimeRelativeOrAbsoluteValue(float check, float total)
{
if (check <= 0)
{
return 0;
}
else if (check <= 1)
{
return total * check;
}
else
{
return check;
}
}
public static Vector3 GetLastPoint(List<Vector3> list)
public static Vector3 GetLastValue(List<Vector3> list)
{
if (list.Count <= 0) return Vector3.zero;
else return list[list.Count - 1];

View File

@@ -19,6 +19,7 @@ namespace XCharts.Runtime
}
return null;
}
public static RadiusAxis GetRadiusAxis(List<MainComponent> components, int polarIndex)
{
foreach (var component in components)
@@ -32,32 +33,6 @@ namespace XCharts.Runtime
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)
{
if (!axis.axisLine.onZero) return 0;

View File

@@ -122,7 +122,7 @@ namespace XCharts.Runtime
foreach (var chart in chartList)
{
if (chart != null)
chart.ReinitAllChartComponent();
chart.RemoveAndReinitChartObject();
}
}

View File

@@ -163,7 +163,7 @@ namespace XCharts.Runtime
float barWidth = serie.GetBarWidth(categoryWidth);
float offset = (categoryWidth - totalBarWidth) * 0.5f;
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
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
: showData.Count;
@@ -209,7 +209,6 @@ namespace XCharts.Runtime
var pX = 0f;
var pY = 0f;
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, isStack, value, ref pX, ref pY);
var barHig = 0f;
if (isPercentStack)
{
@@ -223,7 +222,7 @@ namespace XCharts.Runtime
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
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);
serieData.context.stackHeight = barHig;
serieData.context.position = top;
@@ -237,15 +236,15 @@ namespace XCharts.Runtime
switch (serie.barType)
{
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);
break;
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);
break;
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);
break;
}
@@ -278,7 +277,11 @@ namespace XCharts.Runtime
else
{
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);
if (isStack)
@@ -296,7 +299,11 @@ namespace XCharts.Runtime
else
{
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);
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,
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)
{
plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth);
plb = new Vector3(pX - borderWidth, pY + space + borderWidth);
plt = new Vector3(pX - borderWidth, pY + gap + barWidth - borderWidth);
prt = new Vector3(pX + currHig + borderWidth, pY + gap + barWidth - borderWidth);
prb = new Vector3(pX + currHig + borderWidth, pY + gap + borderWidth);
plb = new Vector3(pX - borderWidth, pY + gap + borderWidth);
}
else
{
plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
plt = new Vector3(pX + borderWidth, pY + gap + barWidth - borderWidth);
prt = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth - borderWidth);
prb = new Vector3(pX + currHig - borderWidth, pY + gap + 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
{
if (yValue < 0)
{
plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
plb = new Vector3(pX + gap + borderWidth, pY - borderWidth);
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + gap + barWidth - borderWidth, pY - borderWidth);
}
else
{
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - 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)
{
@@ -358,10 +365,10 @@ namespace XCharts.Runtime
}
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)
{
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;
if (isYAxis)
{
@@ -423,10 +430,10 @@ namespace XCharts.Runtime
}
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)
{
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)
{
plt = (plb + plt) / 2;
@@ -444,10 +451,10 @@ namespace XCharts.Runtime
}
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)
{
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 radius = barWidth / 2 - borderWidth;
var isGradient = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
@@ -562,7 +569,7 @@ namespace XCharts.Runtime
}
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)
{
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
@@ -570,10 +577,10 @@ namespace XCharts.Runtime
if (isYAxis)
{
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + space + barWidth);
Vector3 prt = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space + barWidth);
Vector3 prb = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space);
Vector3 plb = new Vector3(grid.context.x + axisWidth, pY + space);
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + gap + 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 + gap);
Vector3 plb = new Vector3(grid.context.x + axisWidth, pY + gap);
if (serie.barType == BarType.Capsule)
{
var radius = barWidth / 2;
@@ -610,10 +617,10 @@ namespace XCharts.Runtime
else
{
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
Vector3 plb = new Vector3(pX + space, grid.context.y + axisWidth);
Vector3 plt = new Vector3(pX + space, grid.context.y + grid.context.height + axisWidth);
Vector3 prt = new Vector3(pX + space + barWidth, grid.context.y + grid.context.height + axisWidth);
Vector3 prb = new Vector3(pX + space + barWidth, grid.context.y + axisWidth);
Vector3 plb = new Vector3(pX + gap, grid.context.y + axisWidth);
Vector3 plt = new Vector3(pX + gap, 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 + gap + barWidth, grid.context.y + axisWidth);
if (serie.barType == BarType.Capsule)
{
var radius = barWidth / 2;

View File

@@ -144,7 +144,7 @@ namespace XCharts.Runtime
float barWidth = serie.GetBarWidth(categoryWidth);
float offset = (categoryWidth - totalBarWidth) * 0.5f;
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
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
: showData.Count;
@@ -194,13 +194,13 @@ namespace XCharts.Runtime
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
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);
serieData.context.stackHeight = barHig;
serieData.context.position = top;
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
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);
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,
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)
{
plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth);
plb = new Vector3(pX - borderWidth, pY + space + borderWidth);
plt = new Vector3(pX - borderWidth, pY + gap + barWidth - borderWidth);
prt = new Vector3(pX + currHig + borderWidth, pY + gap + barWidth - borderWidth);
prb = new Vector3(pX + currHig + borderWidth, pY + gap + borderWidth);
plb = new Vector3(pX - borderWidth, pY + gap + borderWidth);
}
else
{
plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
plt = new Vector3(pX + borderWidth, pY + gap + barWidth - borderWidth);
prt = new Vector3(pX + currHig - borderWidth, pY + gap + barWidth - borderWidth);
prb = new Vector3(pX + currHig - borderWidth, pY + gap + 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
{
if (yValue < 0)
{
plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
plb = new Vector3(pX + gap + borderWidth, pY - borderWidth);
plt = new Vector3(pX + gap + borderWidth, pY + currHig + borderWidth);
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig + borderWidth);
prb = new Vector3(pX + gap + barWidth - borderWidth, pY - borderWidth);
}
else
{
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - 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)
{
@@ -301,7 +301,7 @@ namespace XCharts.Runtime
}
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)
{

View File

@@ -93,7 +93,7 @@ namespace XCharts.Runtime
var showData = serie.GetDataList(dataZoom);
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
float barWidth = serie.GetBarWidth(categoryWidth);
float space = (categoryWidth - barWidth) / 2;
float gap = (categoryWidth - barWidth) / 2;
int maxCount = serie.maxShow > 0
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
: showData.Count;
@@ -140,11 +140,11 @@ namespace XCharts.Runtime
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
Vector3 plb, plt, prt, prb, top;
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
if (serie.clip)
{
plb = chart.ClampInGrid(grid, plb);

View File

@@ -93,7 +93,7 @@ namespace XCharts.Runtime
var showData = serie.GetDataList(dataZoom);
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
float barWidth = serie.GetBarWidth(categoryWidth);
float space = (categoryWidth - barWidth) / 2;
float gap = (categoryWidth - barWidth) / 2;
int maxCount = serie.maxShow > 0
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
: showData.Count;
@@ -140,11 +140,11 @@ namespace XCharts.Runtime
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
Vector3 plb, plt, prt, prb, top;
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth);
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
plb = new Vector3(pX + gap + borderWidth, pY + borderWidth);
plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth);
prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth);
prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth);
top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth);
// if (serie.clip)
// {
// plb = chart.ClampInGrid(grid, plb);

View File

@@ -330,7 +330,7 @@ namespace XCharts.Runtime
var needRoundCap = serie.roundCap && insideRadius > 0;
UGL.DrawDoughnut(vh, serieData.context.offsetCenter, insideRadius,
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);
}
else
@@ -339,7 +339,7 @@ namespace XCharts.Runtime
var needRoundCap = serie.roundCap && insideRadius > 0;
UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
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);
DrawPieCenter(vh, serie, itemStyle, insideRadius);
}

View File

@@ -13,6 +13,7 @@ namespace XCharts.Runtime
{
var serie = chart.AddSerie<Ring>(serieName);
serie.roundCap = true;
serie.gap = 10;
serie.radius = new float[] { 0.3f, 0.35f };
serie.AddExtraComponent<LabelStyle>();

View File

@@ -132,7 +132,7 @@ namespace XCharts.Runtime
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, 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 outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.ringGap);
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap);
var insideRadius = outsideRadius - ringWidth;
var centerRadius = (outsideRadius + insideRadius) / 2;
var borderWidth = itemStyle.borderWidth;

View File

@@ -187,7 +187,6 @@ namespace XCharts.Runtime
[SerializeField] private bool m_BarPercentStack = false;
[SerializeField] private float m_BarWidth = 0.6f;
[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_BarZebraGap = 2f;
@@ -200,11 +199,10 @@ namespace XCharts.Runtime
[SerializeField] private float m_MinAngle;
[SerializeField] private bool m_Clockwise = true;
[SerializeField] private bool m_RoundCap;
[SerializeField] private float m_RingGap = 10f;
[SerializeField] private int m_SplitNumber;
[SerializeField] private bool m_ClickOffset = true;
[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_Radius = new float[2] { 0, 80 };
@@ -488,19 +486,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
}
/// <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>
public float barZebraWidth
@@ -536,18 +521,13 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the space of pie chart item.
/// 饼图项间的空隙留白
/// gap of item.
/// 间距
/// </summary>
public float pieSpace
{
get { return m_Space; }
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
}
public float gap
{
get { return m_Space; }
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
get { return m_Gap; }
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
}
/// <summary>
/// the center of chart.
@@ -632,15 +612,6 @@ namespace XCharts.Runtime
get { return m_Clockwise; }
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>
/// 刻度分割段数。最大可设置36。
/// </summary>
@@ -742,15 +713,7 @@ namespace XCharts.Runtime
public bool large
{
get { return m_Large; }
set
{
if (PropertyUtil.SetStruct(ref m_Large, value))
{
SetAllDirty();
if (label != null)
label.SetComponentDirty();
}
}
set { if (PropertyUtil.SetStruct(ref m_Large, value)) SetAllDirty(); }
}
/// <summary>
/// 开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。
@@ -758,15 +721,7 @@ namespace XCharts.Runtime
public int largeThreshold
{
get { return m_LargeThreshold; }
set
{
if (PropertyUtil.SetStruct(ref m_LargeThreshold, value))
{
SetAllDirty();
if (label != null)
label.SetComponentDirty();
}
}
set { if (PropertyUtil.SetStruct(ref m_LargeThreshold, value)) SetAllDirty(); }
}
/// <summary>
/// 在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。
@@ -942,6 +897,7 @@ namespace XCharts.Runtime
public bool nameDirty { get { return m_NameDirty; } }
public bool labelDirty { get; set; }
public bool titleDirty { get; set; }
public bool dataDirty { get; set; }
private void SetSerieNameDirty()
{
@@ -1080,6 +1036,7 @@ namespace XCharts.Runtime
}
m_Data.Clear();
m_NeedUpdateFilterData = true;
dataDirty = true;
SetVerticesDirty();
}
@@ -1105,6 +1062,7 @@ namespace XCharts.Runtime
m_Data.RemoveAt(index);
m_NeedUpdateFilterData = true;
labelDirty = true;
dataDirty = true;
}
}
@@ -1113,7 +1071,8 @@ namespace XCharts.Runtime
/// </summary>
/// <param name="value"></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();
int xValue = m_Data.Count;
@@ -1122,11 +1081,13 @@ namespace XCharts.Runtime
serieData.data.Add(value);
serieData.name = dataName;
serieData.index = xValue;
serieData.id = dataId;
AddSerieData(serieData);
m_ShowDataDimension = 1;
SetVerticesDirty();
CheckDataName(dataName);
labelDirty = true;
dataDirty = true;
return serieData;
}
@@ -1136,6 +1097,8 @@ namespace XCharts.Runtime
m_Data.Insert(0, serieData);
else
m_Data.Add(serieData);
SetVerticesDirty();
dataDirty = true;
m_NeedUpdateFilterData = true;
}
@@ -1153,8 +1116,8 @@ namespace XCharts.Runtime
/// <param name="xValue"></param>
/// <param name="yValue"></param>
/// <param name="dataName"></param>
/// <param name="maxDataNumber"></param>
public SerieData AddXYData(double xValue, double yValue, string dataName = null)
/// <param name="dataId">the unique id of data</param>
public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)
{
CheckMaxCache();
var serieData = SerieDataPool.Get();
@@ -1163,6 +1126,7 @@ namespace XCharts.Runtime
serieData.data.Add(yValue);
serieData.name = dataName;
serieData.index = m_Data.Count;
serieData.id = dataId;
AddSerieData(serieData);
m_ShowDataDimension = 2;
SetVerticesDirty();
@@ -1179,8 +1143,9 @@ namespace XCharts.Runtime
/// <param name="lowest"></param>
/// <param name="heighest"></param>
/// <param name="dataName"></param>
/// <param name="dataId">the unique id of data</param>
/// <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();
var serieData = SerieDataPool.Get();
@@ -1191,6 +1156,7 @@ namespace XCharts.Runtime
serieData.data.Add(heighest);
serieData.name = dataName;
serieData.index = m_Data.Count;
serieData.id = dataId;
AddSerieData(serieData);
m_ShowDataDimension = 4;
SetVerticesDirty();
@@ -1205,14 +1171,14 @@ namespace XCharts.Runtime
/// </summary>
/// <param name="valueList"></param>
/// <param name="dataName"></param>
/// <param name="maxDataNumber"></param>
public SerieData AddData(List<double> valueList, string dataName = null)
/// <param name="dataId">the unique id of data</param>
public SerieData AddData(List<double> valueList, string dataName = null, string dataId = null)
{
if (valueList == null || valueList.Count == 0) return null;
if (valueList.Count == 1)
return AddYData(valueList[0], dataName);
return AddYData(valueList[0], dataName, dataId);
else if (valueList.Count == 2)
return AddXYData(valueList[0], valueList[1], dataName);
return AddXYData(valueList[0], valueList[1], dataName, dataId);
else
{
CheckMaxCache();
@@ -1220,6 +1186,7 @@ namespace XCharts.Runtime
var serieData = SerieDataPool.Get();
serieData.name = dataName;
serieData.index = m_Data.Count;
serieData.id = dataId;
for (int i = 0; i < valueList.Count; 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();
serieData.name = name;
serieData.index = m_Data.Count;
serieData.data = new List<double>() { parent.children.Count, value };
serieData.context.parent = parent;
AddSerieData(serieData);
parent.children.Add(serieData.index);
serieData.id = id;
serieData.data = new List<double>() { m_Data.Count, value };
AddChildData(parent, 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();
serieData.name = name;
serieData.index = m_Data.Count;
serieData.id = id;
serieData.data = new List<double>(value);
serieData.context.parent = parent;
AddSerieData(serieData);
parent.children.Add(serieData.index);
AddChildData(parent, 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()
{
if (m_MaxCache <= 0) return;
@@ -1360,23 +1340,23 @@ namespace XCharts.Runtime
return null;
}
public SerieData GetSerieData(string uuid, DataZoom dataZoom = null)
public SerieData GetSerieData(string id, DataZoom dataZoom = null)
{
var data = GetDataList(dataZoom);
foreach (var serieData in data)
{
var target = GetSerieData(serieData, uuid);
var target = GetSerieData(serieData, id);
if (target != null) return target;
}
return null;
}
public SerieData GetSerieData(SerieData parent, string uuid)
public SerieData GetSerieData(SerieData parent, string id)
{
if (uuid.Equals(parent.uuid)) return parent;
foreach (var child in parent.children)
if (id.Equals(parent.id)) return parent;
foreach (var child in parent.context.children)
{
var data = GetSerieData(GetSerieData(child), uuid);
var data = GetSerieData(child, id);
if (data != null)
{
return data;
@@ -1480,7 +1460,11 @@ namespace XCharts.Runtime
var animationOpen = animation.enable;
var animationDuration = animation.GetUpdateAnimationDuration();
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, animationDuration);
if (flag) SetVerticesDirty();
if (flag)
{
SetVerticesDirty();
dataDirty = true;
}
return flag;
}
else
@@ -1504,6 +1488,7 @@ namespace XCharts.Runtime
for (int i = 0; i < values.Count; i++)
serieData.UpdateData(i, values[i], animationOpen, animationDuration);
SetVerticesDirty();
dataDirty = true;
return true;
}
return false;

View File

@@ -89,6 +89,7 @@ namespace XCharts.Runtime
/// 排序后的数据
/// </summary>
public List<SerieData> sortedData = new List<SerieData>();
public List<SerieData> rootData = new List<SerieData>();
/// <summary>
/// theme的颜色索引
/// </summary>

View File

@@ -12,11 +12,10 @@ namespace XCharts.Runtime
[System.Serializable]
public class SerieData : ChildComponent
{
[SerializeField] private int m_Index;
[SerializeField] private string m_Name;
[SerializeField] private string m_Uuid;
[SerializeField] private bool m_Selected;
[SerializeField] private bool m_Ignore = false;
[SerializeField] private float m_Radius;
[SerializeField] private string m_Id;
[SerializeField] private string m_ParentId;
[SerializeField] private List<ItemStyle> m_ItemStyles = new List<ItemStyle>();
[SerializeField] private List<LabelStyle> m_Labels = new List<LabelStyle>();
[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<TitleStyle> m_TitleStyles = new List<TitleStyle>();
[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 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 titleObject { get; set; }
private bool m_Show = true;
public override int index { get { return m_Index; } set { m_Index = value; } }
/// <summary>
/// the name of data item.
/// 数据项名称。
@@ -44,7 +46,8 @@ namespace XCharts.Runtime
/// <summary>
/// 数据项的唯一id。唯一id不是必须设置的。
/// </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>
/// 数据项图例名称。当数据项名称不为空时图例名称即为系列名称反之则为索引index。
/// </summary>
@@ -97,8 +100,6 @@ namespace XCharts.Runtime
/// 可指定任意维数的数值列表。
/// </summary>
public List<double> data { get { return m_Data; } set { m_Data = value; } }
public List<int> children { get { return m_Children; } set { m_Children = value; } }
/// <summary>
/// [default:true] Whether the data item is showed.
/// 该数据项是否要显示。
@@ -113,12 +114,16 @@ namespace XCharts.Runtime
public void Reset()
{
index = 0;
m_Id = null;
m_ParentId = null;
labelObject = null;
m_Name = string.Empty;
m_Show = true;
m_Selected = false;
context.canShowLabel = true;
context.highlight = false;
context.children.Clear();
context.dataPoints.Clear();
m_Radius = 0;
interact.Reset();
m_Data.Clear();

View File

@@ -35,6 +35,8 @@ namespace XCharts.Runtime
public float outsideRadius { get; set; }
public Vector3 position { get; set; }
public List<Vector3> dataPoints = new List<Vector3>();
public List<SerieData> children = new List<SerieData>();
/// <summary>
/// 绘制区域。
/// </summary>

View File

@@ -48,6 +48,7 @@ namespace XCharts.Runtime
private static readonly string s_SerieTitleObjectName = "title";
private static readonly string s_SerieRootObjectName = "serie";
protected GameObject m_SerieRoot;
protected GameObject m_SerieLabelRoot;
protected bool m_InitedLabel;
protected bool m_NeedInitComponent;
protected bool m_RefreshLabel;
@@ -56,6 +57,7 @@ namespace XCharts.Runtime
protected int m_LegendEnterIndex;
public T serie { get; internal set; }
public GameObject labelObject { get { return m_SerieLabelRoot; } }
internal override void SetSerie(Serie serie)
{
@@ -77,6 +79,11 @@ namespace XCharts.Runtime
if (m_InitedLabel)
RefreshLabelInternal();
}
if (serie.dataDirty)
{
serie.OnDataUpdate();
serie.dataDirty = false;
}
if (serie.label != null && (serie.labelDirty || serie.label.componentDirty))
{
serie.labelDirty = false;
@@ -182,10 +189,11 @@ namespace XCharts.Runtime
{
if (m_SerieRoot == null)
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);
serieLabelRoot.hideFlags = chart.chartHideFlags;
SerieLabelPool.ReleaseAll(serieLabelRoot.transform);
m_SerieLabelRoot.hideFlags = chart.chartHideFlags;
//SerieLabelPool.ReleaseAll(m_SerieLabelRoot.transform);
ChartHelper.DestroyAllChildren(m_SerieLabelRoot.transform);
int count = 0;
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
for (int j = 0; j < serie.data.Count; j++)
@@ -193,7 +201,7 @@ namespace XCharts.Runtime
var serieData = serie.data[j];
serieData.index = count;
serieData.labelObject = null;
if (AddSerieLabel(serieLabelRoot, serie, serieData, ref count))
if (AddSerieLabel(m_SerieLabelRoot, serie, serieData, ref count))
{
m_InitedLabel = true;
count++;
@@ -204,6 +212,8 @@ namespace XCharts.Runtime
protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
{
if (serieData == null)
return false;
if (serieLabelRoot == null)
return false;
if (serie.IsPerformanceMode())
@@ -217,8 +227,9 @@ namespace XCharts.Runtime
var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
if (!serieLabel.show && (serieEmphasisLabel == null || !serieEmphasisLabel.show)
&& (iconStyle != null && !iconStyle.show))
if (!serieLabel.show
&& (serieEmphasisLabel == null || !serieEmphasisLabel.show)
&& (iconStyle == null || !iconStyle.show))
return false;
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
@@ -239,12 +250,14 @@ namespace XCharts.Runtime
item.color = serieLabel.textStyle.backgroundColor;
serieData.labelObject = item;
foreach (var data in serieData.children)
if (serieData.context.children.Count > 0)
{
AddSerieLabel(serieLabelRoot, serie, serie.GetSerieData(data), ref count);
count++;
foreach (var childSerieData in serieData.context.children)
{
AddSerieLabel(serieLabelRoot, serie, childSerieData, ref count);
count++;
}
}
return true;
}

View File

@@ -1266,16 +1266,16 @@ namespace XUGL
/// <param name="toDegree">结束角度</param>
/// <param name="borderWidth">边框宽度</param>
/// <param name="borderColor">边框颜色</param>
/// <param name="space">边距</param>
/// <param name="gap">边距</param>
/// <param name="smoothness">光滑度</param>
/// <param name="gradientType">渐变类型0:向圆形渐变1:水平或垂直渐变2:开始角度向结束角度渐变</param>
/// <param name="isYAxis">水平渐变还是垂直渐变gradientType为1时生效</param>
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)
{
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;
smoothness = (smoothness < 0 ? 2f : smoothness);
int segments = (int)((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
@@ -1296,7 +1296,7 @@ namespace XUGL
var lastP4 = center;
var lastColor = color;
var needBorder = borderWidth != 0;
var needSpace = space != 0;
var needSpace = gap != 0;
var borderLineWidth = needSpace ? borderWidth : borderWidth / 2;
var lastPos = Vector3.zero;
var middleDire = UGLHelper.GetDire(startAngle + halfAngle);
@@ -1306,10 +1306,10 @@ namespace XUGL
float borderDiff = 0f;
if (needSpace)
{
spaceDiff = space / Mathf.Sin(halfAngle);
spaceDiff = gap / Mathf.Sin(halfAngle);
spaceCenter = center + spaceDiff * middleDire;
realCenter = spaceCenter;
spaceAngle = 2 * Mathf.Asin(space / (2 * radius));
spaceAngle = 2 * Mathf.Asin(gap / (2 * radius));
realStartAngle = startAngle + spaceAngle;
realToAngle = toAngle - spaceAngle;
if (realToAngle < realStartAngle) realToAngle = realStartAngle;
@@ -1452,14 +1452,14 @@ namespace XUGL
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 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 (space > 0 && Mathf.Abs(toDegree - startDegree) >= 360) space = 0;
if (gap > 0 && Mathf.Abs(toDegree - startDegree) >= 360) gap = 0;
if (insideRadius <= 0)
{
DrawSector(vh, center, outsideRadius, color, toColor, startDegree, toDegree, borderWidth, borderColor,
space, smoothness);
gap, smoothness);
return;
}
outsideRadius -= borderWidth;
@@ -1467,7 +1467,7 @@ namespace XUGL
smoothness = smoothness < 0 ? 2f : smoothness;
Vector3 p1, p2, p3, p4, e1, e2;
var needBorder = borderWidth != 0;
var needSpace = space != 0;
var needSpace = gap != 0;
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
int segments = (int)((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
@@ -1506,12 +1506,12 @@ namespace XUGL
{
if (needSpace)
{
var spaceDiff = space / Mathf.Sin(halfAngle);
var spaceDiff = gap / Mathf.Sin(halfAngle);
spaceCenter = center + Mathf.Abs(spaceDiff) * middleDire;
realCenter = spaceCenter;
spaceAngle = 2 * Mathf.Asin(space / (2 * outsideRadius));
spaceInAngle = 2 * Mathf.Asin(space / (2 * insideRadius));
spaceHalfAngle = 2 * Mathf.Asin(space / (2 * (insideRadius + (outsideRadius - insideRadius) / 2)));
spaceAngle = 2 * Mathf.Asin(gap / (2 * outsideRadius));
spaceInAngle = 2 * Mathf.Asin(gap / (2 * insideRadius));
spaceHalfAngle = 2 * Mathf.Asin(gap / (2 * (insideRadius + (outsideRadius - insideRadius) / 2)));
if (clockwise)
{
p1 = UGLHelper.GetPos(center, insideRadius, startAngle + spaceInAngle, false);