Merge branch 'master' into 3.0

This commit is contained in:
monitor1394
2025-01-01 23:13:07 +08:00
47 changed files with 452 additions and 123 deletions

View File

@@ -1362,6 +1362,11 @@ class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent)
Background component.
### Background.rect
public Rect rect
the rect of background.
### Background.SetDefaultValue
public override void SetDefaultValue()
@@ -2353,6 +2358,10 @@ class in XCharts.Runtime / Inherits from: [MaskableGraphic](https://docs.unity3d
public virtual HideFlags chartHideFlags
### BaseGraph.childrenNodeNames
public List<string> childrenNodeNames
### BaseGraph.clickPos
public Vector2 clickPos
@@ -2411,6 +2420,10 @@ The x of graph.
public float graphY
The y of graph.
### BaseGraph.isDragingClick
public bool isDragingClick
### BaseGraph.isPointerClick
public bool isPointerClick
@@ -2759,6 +2772,10 @@ public float GetRuntimeBorderWidth()
public float[] GetRuntimeCornerRadius()
### BorderStyle.IsCricle
public bool IsCricle()
## CalendarCoord
class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -2893,7 +2910,8 @@ public static void DestoryGameObject(GameObject go)
### ChartHelper.DestoryGameObjectByMatch
public static void DestoryGameObjectByMatch(Transform parent, string containString)
public static void DestoryGameObjectByMatch(Transform parent, List<string> children)
### ChartHelper.DestroyAllChildren
@@ -2940,7 +2958,8 @@ public static Vector3 GetLastValue(List<Vector3> list)
### ChartHelper.GetMaxCeilRate
public static double GetMaxCeilRate(double value, double ceilRate)
public static float GetMaxCeilRate(float value, float ceilRate)
### ChartHelper.GetMaxDivisibleValue
@@ -2952,7 +2971,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE
### ChartHelper.GetMinCeilRate
public static double GetMinCeilRate(double value, double ceilRate)
public static float GetMinCeilRate(float value, float ceilRate)
### ChartHelper.GetMinDivisibleValue
@@ -5317,6 +5337,10 @@ public float runtimeTop
public Vector3 GetPosition(float chartWidth, float chartHeight)
返回在坐标系中的具体位置
### Location.GetRect
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
### Location.IsBottom
public bool IsBottom()
@@ -9087,6 +9111,11 @@ class in XCharts.Runtime
UI帮助类。
### UIHelper.DrawBackground
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
## ViewControl
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)

View File

@@ -6,6 +6,7 @@ slug: /changelog
# Changelog
[master](#master)
[v3.13.0](#v3130)
[v3.12.1](#v3121)
[v3.12.0](#v3120)
[v3.11.2](#v3112)
@@ -77,6 +78,33 @@ slug: /changelog
## master
## v3.13.0
Key Features:
* Added the `UIText` extension component
* Added the `UIToggle` extension component
* Added the `UISlider` extension component
* Refactored the `UIProgress` extension component
* Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
* Added the `size2` parameter to `SymbolStyle` to support rectangular markers
* Other optimizations and bug fixes
Detailed Changelog:
* (2025.01.01) Released `v3.13.0`
* (2024.12.27) Added the `size2` parameter to `SymbolStyle` to support rectangular markers
* (2024.12.26) Optimized `Text` alignment in `TextMeshPro` for proper centering
* (2024.12.25) Added support for `{f0}` in the `Tooltip`'s `itemFormatter` setting
* (2024.12.25) Fixed an issue where some labels on the `YAxis` might not display during range refresh
* (2024.12.23) Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
* (2024.12.17) Added the `UISlider` extension component
* (2024.12.10) Added the `UIToggle` extension component
* (2024.12.09) Fixed an issue where the `UITable`'s `scrollbar` could not be dragged
* (2024.12.07) Fixed an issue where custom nodes could not be placed under the `Chart` node
* (2024.12.05) Added the `UIText` extension component
* (2024.12.04) Removed the unused `tmpAlignment` option from `TextStyle`
## v3.12.1
Version Highlights:

View File

@@ -4366,12 +4366,24 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) / Su
系列数据项的标记的图形
### SymbolStyle.borderWidth
`float` `0f` `v3.13.0`
the border width of symbol.
### SymbolStyle.color
`Color32`
图形的颜色。
### SymbolStyle.emptyColor
`Color32` `v3.13.0`
the color of empty symbol.
### SymbolStyle.gap
`float` `0`
@@ -4414,6 +4426,12 @@ Whether the symbol is showed.
the size of symbol.
### SymbolStyle.size2
`float` `0f` `v3.13.0`
the size of symbol.
### SymbolStyle.type
[SymbolType](#symboltype)
@@ -4551,10 +4569,6 @@ Rotation of text.
Settings related to text.
### TextStyle.tMPAlignment
`TextAlignmentOptions`
### TextStyle.tMPFont
`TMP_FontAsset`

View File

@@ -1362,6 +1362,11 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
背景组件。
### Background.rect
public Rect rect
背景的矩形区域。
### Background.SetDefaultValue
public override void SetDefaultValue()
@@ -2353,6 +2358,10 @@ class in XCharts.Runtime / 继承自: [MaskableGraphic](https://docs.unity3d.com
public virtual HideFlags chartHideFlags
### BaseGraph.childrenNodeNames
public List<string> childrenNodeNames
### BaseGraph.clickPos
public Vector2 clickPos
@@ -2411,6 +2420,10 @@ public float graphX
public float graphY
图形的Y
### BaseGraph.isDragingClick
public bool isDragingClick
### BaseGraph.isPointerClick
public bool isPointerClick
@@ -2759,6 +2772,10 @@ public float GetRuntimeBorderWidth()
public float[] GetRuntimeCornerRadius()
### BorderStyle.IsCricle
public bool IsCricle()
## CalendarCoord
class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -2893,7 +2910,8 @@ public static void DestoryGameObject(GameObject go)
### ChartHelper.DestoryGameObjectByMatch
public static void DestoryGameObjectByMatch(Transform parent, string containString)
public static void DestoryGameObjectByMatch(Transform parent, List<string> children)
### ChartHelper.DestroyAllChildren
@@ -2940,7 +2958,8 @@ public static Vector3 GetLastValue(List<Vector3> list)
### ChartHelper.GetMaxCeilRate
public static double GetMaxCeilRate(double value, double ceilRate)
public static float GetMaxCeilRate(float value, float ceilRate)
### ChartHelper.GetMaxDivisibleValue
@@ -2952,7 +2971,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE
### ChartHelper.GetMinCeilRate
public static double GetMinCeilRate(double value, double ceilRate)
public static float GetMinCeilRate(float value, float ceilRate)
### ChartHelper.GetMinDivisibleValue
@@ -5317,6 +5337,10 @@ public float runtimeTop
public Vector3 GetPosition(float chartWidth, float chartHeight)
返回在坐标系中的具体位置
### Location.GetRect
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
### Location.IsBottom
public bool IsBottom()
@@ -9087,6 +9111,11 @@ class in XCharts.Runtime
UI帮助类。
### UIHelper.DrawBackground
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
## ViewControl
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)

View File

@@ -6,6 +6,7 @@ slug: /changelog
# 更新日志
[master](#master)
[v3.13.0](#v3130)
[v3.12.1](#v3121)
[v3.12.0](#v3120)
[v3.11.2](#v3112)
@@ -78,6 +79,33 @@ slug: /changelog
## master
## v3.13.0
版本要点:
* 新增`UIText`扩展组件
* 新增`UIToggle`扩展组件
* 新增`UISlider`扩展组件
* 重构`UIProgress`扩展组件
* 增加`SymbolStyle``borderWidth``emptyColor`配置
* 增加`SymbolStyle``size2`参数支持长方形标记
* 其他优化和问题修复
日志详情:
* (2025.01.01) 发布`v3.13.0`版本
* (2024.12.27) 增加`SymbolStyle``size2`参数支持长方形标记
* (2024.12.26) 优化`Text``TextMeshPro`下的居中对齐方式
* (2024.12.25) 增加`Tooltip``itemFormatter`设置`{f0}`支持
* (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题
* (2024.12.23) 增加`SymbolStyle``borderWidth``emptyColor`配置
* (2024.12.17) 增加`UISlider`扩展组件
* (2024.12.10) 增加`UIToggle`扩展组件
* (2024.12.09) 修复`UITable``scrollbar`无法拖动的问题
* (2024.12.07) 修复`Chart`节点下不能放自定义节点的问题
* (2024.12.05) 增加`UIText`扩展组件
* (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment`
## v3.12.1
版本要点:
@@ -153,8 +181,6 @@ slug: /changelog
日志详情:
* (2024.06.16) 发布`v3.11.0`版本
* (2024.06.15) 增加`Editor``Data`的添加、删除、上下移动操作按钮
* (2024.06.11) 修复`Axis``IndicatorLabel`可能会遮挡住`Tooltip`的问题

View File

@@ -4366,12 +4366,24 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类
系列数据项的标记的图形
### SymbolStyle.borderWidth
`float` `0f` `v3.13.0`
图形的边框宽度。
### SymbolStyle.color
`Color32`
图形的颜色。
### SymbolStyle.emptyColor
`Color32` `v3.13.0`
空心图形的颜色。
### SymbolStyle.gap
`float` `0`
@@ -4414,6 +4426,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类
标记的大小。
### SymbolStyle.size2
`float` `0f` `v3.13.0`
标记的大小。当为Rect时size2表示高度。
### SymbolStyle.type
[SymbolType](#symboltype)
@@ -4551,10 +4569,6 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
文本的相关设置。
### TextStyle.tMPAlignment
`TextAlignmentOptions`
### TextStyle.tMPFont
`TMP_FontAsset`

View File

@@ -27,7 +27,10 @@ namespace XCharts.Editor
}
PropertyField(prop, "m_Color");
PropertyField(prop, "m_Size");
PropertyField(prop, "m_Size2");
PropertyField(prop, "m_Gap");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_EmptyColor");
PropertyField(prop, "m_Offset");
--EditorGUI.indentLevel;
}

View File

@@ -27,14 +27,13 @@ namespace XCharts.Editor
PropertyField(prop, "m_Color");
PropertyField(prop, "m_FontSize");
PropertyField(prop, "m_LineSpacing");
PropertyField(prop, "m_Alignment");
PropertyField(prop, "m_AutoAlign");
#if dUI_TextMeshPro
PropertyField(prop, "m_TMPFontStyle");
PropertyField(prop, "m_TMPSpriteAsset");
PropertyField(prop, "m_TMPAlignment");
#else
PropertyField(prop, "m_FontStyle");
PropertyField(prop, "m_Alignment");
PropertyField(prop, "m_AutoAlign");
PropertyField(prop, "m_AutoWrap");
#endif
--EditorGUI.indentLevel;

View File

@@ -108,11 +108,11 @@ namespace XCharts.Editor
{
EditorGUI.LabelField(drawRect, name);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var diff = 13 + EditorGUI.indentLevel * 14;
var diff = 12 + EditorGUI.indentLevel * 14;
var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset + 3.4f, drawRect.y, tempWidth - 1, drawRect.height - 1);
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -326,7 +326,13 @@ namespace XCharts.Editor
var foldoutRect = drawRect;
foldoutRect.xMax -= 10;
bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true);
ChartEditorHelper.DrawMenu(drawRect, menus);
if (!flag)
{
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var sizeRect = new Rect(startX, drawRect.y + 1f, (EditorGUI.indentLevel + 1) * 15, drawRect.height - 1);
EditorGUI.IntField(sizeRect, GUIContent.none, listProp.arraySize);
DrawMenu(drawRect, menus);
}
height += headerHeight;
drawRect.y += headerHeight;
drawRect.width = rawWidth;

View File

@@ -67,7 +67,7 @@ namespace XCharts.Runtime
string objName = component.GetType().Name + axis.index;
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.transform.localPosition = Vector3.zero;
axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags;

View File

@@ -372,6 +372,7 @@ namespace XCharts
var axisLength = (axis.context.end - axis.context.start).magnitude;
if (axisLength == 0) return;
chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName,
@@ -379,7 +380,7 @@ namespace XCharts
chart.chartMinAnchor,
chart.chartMaxAnchor,
chart.chartPivot,
chart.chartSizeDelta);
chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags;
@@ -473,7 +474,6 @@ namespace XCharts
break;
}
}
UpdateAxisMinMaxValue(axis.index, axis, true);
}
protected void InitAxis(Axis relativedAxis, Orient orient,
@@ -481,6 +481,7 @@ namespace XCharts
{
Axis axis = component;
chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName,
@@ -488,7 +489,7 @@ namespace XCharts
chart.chartMinAnchor,
chart.chartMaxAnchor,
chart.chartPivot,
chart.chartSizeDelta);
chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags;
@@ -637,7 +638,6 @@ namespace XCharts
}
}
}
UpdateAxisMinMaxValue(axis.index, axis, true);
}
internal static Vector3 GetLabelPosition(int i, Orient orient, Axis axis, Axis relativedAxis, AxisTheme theme,

View File

@@ -99,7 +99,7 @@ namespace XCharts.Runtime
var radius = polar.context.outsideRadius - polar.context.insideRadius;
var objName = component.GetType().Name + axis.index;
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.transform.localPosition = Vector3.zero;
axisObj.SetActive(axis.show && axis.axisLabel.show);
axisObj.hideFlags = chart.chartHideFlags;

View File

@@ -100,6 +100,12 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// the rect of background.
/// ||背景的矩形区域。
/// </summary>
public Rect rect { get; set; }
public override void SetDefaultValue()
{
m_Show = true;

View File

@@ -15,7 +15,7 @@ namespace XCharts.Runtime
component.refreshComponent = delegate ()
{
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
component.gameObject = backgroundObj;
backgroundObj.hideFlags = chart.chartHideFlags;

View File

@@ -82,5 +82,11 @@ namespace XCharts.Runtime
{
return m_Show && roundedCorner ? m_CornerRadius : null;
}
public bool IsCricle()
{
return roundedCorner && m_CornerRadius[0] == 1 && m_CornerRadius[1] == 1 &&
m_CornerRadius[2] == 1 && m_CornerRadius[3] == 1;
}
}
}

View File

@@ -349,6 +349,69 @@ namespace XCharts.Runtime
}
}
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
{
UpdateRuntimeData(graphWidth, graphWidth);
float x, y, width, height;
width = rectWidth == 0 ? graphWidth - runtimeLeft - runtimeRight : rectWidth;
height = rectHeight == 0 ? graphHeight - runtimeBottom - runtimeTop : rectHeight;
switch (align)
{
case Align.BottomCenter:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + runtimeBottom;
break;
case Align.BottomLeft:
x = graphX + runtimeLeft;
y = graphY + runtimeBottom;
break;
case Align.BottomRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + runtimeBottom;
break;
case Align.Center:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.CenterLeft:
x = graphX + runtimeLeft;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.CenterRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.TopCenter:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + graphHeight - runtimeTop - height;
break;
case Align.TopLeft:
x = graphX + runtimeLeft;
y = graphY + graphHeight - runtimeTop - height;
break;
case Align.TopRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + graphHeight - runtimeTop - height;
break;
default:
return new Rect(0, 0, 0, 0);
}
return new Rect(x, y, width, height);
}
/// <summary>
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
/// </summary>

View File

@@ -84,12 +84,16 @@ namespace XCharts.Runtime
[SerializeField] protected Sprite m_Image;
[SerializeField] protected Image.Type m_ImageType;
[SerializeField] protected Color32 m_Color;
[SerializeField][Since("v3.13.0")] protected float m_BorderWidth = 0f;
[SerializeField][Since("v3.13.0")] protected Color32 m_EmptyColor;
[SerializeField][Since("v3.13.0")] protected float m_Size2 = 0f;
public virtual void Reset()
{
m_Show = false;
m_Type = SymbolType.EmptyCircle;
m_Size = 0f;
m_Size2 = 0f;
m_Gap = 0;
m_Width = 0f;
m_Height = 0f;
@@ -126,6 +130,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
}
/// <summary>
/// the size of symbol.
/// ||标记的大小。当为Rect时size2表示高度。
/// </summary>
public float size2
{
get { return m_Size2; }
set { if (PropertyUtil.SetStruct(ref m_Size2, value)) SetVerticesDirty(); }
}
/// <summary>
/// the gap of symbol and line segment.
/// ||图形标记和线条的间隙距离。
/// </summary>
@@ -183,6 +196,24 @@ namespace XCharts.Runtime
get { return m_Color; }
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
}
/// <summary>
/// the border width of symbol.
/// ||图形的边框宽度。
/// </summary>
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); }
}
/// <summary>
/// the color of empty symbol.
/// ||空心图形的颜色。
/// </summary>
public Color32 emptyColor
{
get { return m_EmptyColor; }
set { if (PropertyUtil.SetStruct(ref m_EmptyColor, value)) SetAllDirty(); }
}
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
/// <summary>

View File

@@ -27,7 +27,6 @@ namespace XCharts.Runtime
#if dUI_TextMeshPro
[SerializeField] private TMP_FontAsset m_TMPFont;
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
[SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left;
[SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset;
#endif
public bool show
@@ -147,15 +146,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
}
/// <summary>
/// the text alignment of TextMeshPro.
/// ||TextMeshPro字体对齐方式。
/// </summary>
public TextAlignmentOptions tmpAlignment
{
get { return m_TMPAlignment; }
set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); }
}
/// <summary>
/// the sprite asset of TextMeshPro.
/// ||TextMeshPro的Sprite Asset。
/// </summary>
@@ -214,11 +204,7 @@ namespace XCharts.Runtime
public void UpdateAlignmentByLocation(Location location)
{
#if dUI_TextMeshPro
m_TMPAlignment = location.runtimeTMPTextAlignment;
#else
m_Alignment = location.runtimeTextAlignment;
#endif
}
public Color GetColor(Color defaultColor)

View File

@@ -22,7 +22,7 @@ namespace XCharts.Runtime
chart.chartMinAnchor,
chart.chartMaxAnchor,
chart.chartPivot,
chart.chartSizeDelta);
chart.chartSizeDelta, -1, chart.childrenNodeNames);
commentObj.SetActive(comment.show);
commentObj.hideFlags = chart.chartHideFlags;

View File

@@ -27,7 +27,7 @@ namespace XCharts.Runtime
dataZoom.refreshComponent = delegate ()
{
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
dataZoom.gameObject = dataZoomObject;
dataZoomObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(dataZoomObject);

View File

@@ -75,7 +75,7 @@ namespace XCharts.Runtime
public void Init(BaseChart chart)
{
m_Chart = chart;
m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme);
m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme, chart.childrenNodeNames);
}
public void Update()
@@ -155,14 +155,14 @@ namespace XCharts.Runtime
}
private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle,
ThemeStyle theme)
ThemeStyle theme, List<string> childrenNodeNames)
{
var anchorMax = new Vector2(0, 1);
var anchorMin = new Vector2(0, 1);
var pivot = new Vector2(0, 1);
var sizeDelta = new Vector2(100, 100);
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childrenNodeNames);
labelGameObject.transform.SetAsLastSibling();
labelGameObject.hideFlags = m_Chart.chartHideFlags;
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);

View File

@@ -45,7 +45,7 @@ namespace XCharts.Runtime
{
var content = serieLabel.formatter;
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
dataTotal, serieName, dataName, dataName, color, serieData, chart);
dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index);
if (serieLabel.formatterFunction == null)
return content;
else

View File

@@ -55,7 +55,7 @@ namespace XCharts.Runtime
{
legend.OnChanged();
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
legend.gameObject = legendObject;
legendObject.hideFlags = chart.chartHideFlags;
//ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_");

View File

@@ -48,7 +48,7 @@ namespace XCharts.Runtime
var objAnchorMin = new Vector2(0, 1);
var objAnchorMax = new Vector2(0, 1);
var objPivot = new Vector2(0, 1);
var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta);
var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta, -1, chart.childrenNodeNames);
var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta);
var img = ChartHelper.EnsureComponent<Image>(btnObj);
img.color = Color.clear;

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
public override void InitComponent()
{
m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkArea(component);

View File

@@ -13,7 +13,7 @@ namespace XCharts.Runtime
public override void InitComponent()
{
m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkLine(component);

View File

@@ -41,7 +41,7 @@ namespace XCharts.Runtime
{
radar.UpdateRadarCenter(chart);
var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
radar.gameObject = radarObject;
radar.gameObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT);

View File

@@ -22,7 +22,7 @@ namespace XCharts.Runtime
var pivot = title.location.runtimePivot;
var objName = ChartCached.GetComponentObjectName(title);
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
pivot, chart.chartSizeDelta);
pivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
title.gameObject = titleObject;
title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
anchorMin = title.location.runtimeAnchorMin;

View File

@@ -53,7 +53,7 @@ namespace XCharts.Runtime
{
var objName = ChartCached.GetComponentObjectName(tooltip);
tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
var tooltipObject = tooltip.gameObject;
tooltipObject.transform.localPosition = Vector3.zero;
tooltipObject.hideFlags = chart.chartHideFlags;

View File

@@ -44,7 +44,8 @@ namespace XCharts.Runtime
param.serieData.name,
param.color,
param.serieData,
chart);
chart,
param.serieIndex);
foreach (var item in content.Split('|'))
{
param.columns.Add(item);

View File

@@ -149,7 +149,7 @@ namespace XCharts.Runtime
else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f')
{
var isPercent = p == 'd' || p == 'D';
var isTotal = p == 'f' || p == 'f';
var isTotal = p == 'f' || p == 'F';
var bIndex = dataIndex;
var dimensionIndex = -1;
if (argsCount >= 2)
@@ -211,7 +211,7 @@ namespace XCharts.Runtime
}
public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total,
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null)
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null, int serieIndex = 0)
{
var mc = s_RegexForSerieLabel.Matches(content);
foreach (var m in mc)
@@ -270,6 +270,14 @@ namespace XCharts.Runtime
}
else if (p == 'f' || p == 'f')
{
if (pIndex != 1 && chart != null)
{
var serie = chart.GetSerie(serieIndex);
if (serie != null)
{
total = serie.GetDataTotal(pIndex, serieData);
}
}
content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter));
}
else if (p == 'g' || p == 'G')

View File

@@ -54,8 +54,8 @@ namespace XCharts.Runtime
p4 = ClampInGrid(grid, p4);
}
if (!clip ||
(clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
grid.Contains(p4))))
(clip && grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
grid.Contains(p4)))
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor);
}
@@ -83,12 +83,12 @@ namespace XCharts.Runtime
public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap,
bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos)
bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos, float symbolSize2 = 0)
{
if (!IsInChart(pos)) return;
if (!clip || (clip && (grid.Contains(pos))))
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
gap, cornerRadius, startPos);
gap, cornerRadius, startPos, symbolSize2);
}
public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
@@ -101,22 +101,22 @@ namespace XCharts.Runtime
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
float gap, float[] cornerRadius)
float gap, float[] cornerRadius, float symbolSize2 = 0)
{
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
gap, cornerRadius, Vector3.zero);
gap, cornerRadius, Vector3.zero, symbolSize2);
}
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
float gap, float[] cornerRadius, Vector3 startPos)
float gap, float[] cornerRadius, Vector3 startPos, float symbolSize2 = 0)
{
var backgroundColor = GetChartBackgroundColor();
if (ChartHelper.IsClearColor(emptyColor))
emptyColor = backgroundColor;
var smoothness = settings.cicleSmoothness;
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos);
cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos, symbolSize2);
}
public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)

View File

@@ -394,7 +394,7 @@ namespace XCharts.Runtime
{
var index = settings.reversePainter ? settings.maxPainter - 1 - i : i;
var painter = ChartHelper.AddPainterObject("painter_" + index, transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index);
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index, m_ChildNodeNames);
painter.index = m_PainterList.Count;
painter.type = Painter.Type.Serie;
painter.onPopulateMesh = OnDrawPainterSerie;
@@ -404,7 +404,7 @@ namespace XCharts.Runtime
m_PainterList.Add(painter);
}
m_PainterUpper = ChartHelper.AddPainterObject("painter_u", transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames);
m_PainterUpper.type = Painter.Type.Top;
m_PainterUpper.onPopulateMesh = OnDrawPainterUpper;
m_PainterUpper.SetActive(true, m_DebugInfo.showAllChartObject);
@@ -412,7 +412,7 @@ namespace XCharts.Runtime
m_PainterUpper.transform.SetSiblingIndex(settings.maxPainter + 1);
m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames);
m_PainterTop.type = Painter.Type.Top;
m_PainterTop.onPopulateMesh = OnDrawPainterTop;
m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject);

View File

@@ -158,8 +158,8 @@ namespace XCharts.Runtime
/// </summary>
public void RebuildChartObject()
{
ChartHelper.DestroyAllChildren(transform);
SetAllComponentDirty();
ChartHelper.DestoryGameObjectByMatch(transform, m_ChildNodeNames);
//SetAllComponentDirty();
}
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -14,6 +15,7 @@ namespace XCharts.Runtime
IDragHandler, IEndDragHandler, IScrollHandler
{
[SerializeField] protected bool m_EnableTextMeshPro = false;
[SerializeField] protected List<string> m_ChildNodeNames = new List<string>();
protected Painter m_Painter;
protected int m_SiblingIndex;
@@ -52,8 +54,11 @@ namespace XCharts.Runtime
public virtual HideFlags chartHideFlags { get { return HideFlags.None; } }
private ScrollRect m_ScrollRect;
private Vector2 m_PointerDownPos;
public Painter painter { get { return m_Painter; } }
public List<string> childrenNodeNames { get { return m_ChildNodeNames; } }
public bool isDragingClick { get; set; }
protected virtual void InitComponent()
{
@@ -158,7 +163,7 @@ namespace XCharts.Runtime
protected virtual void InitPainter()
{
m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1);
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1, m_ChildNodeNames);
m_Painter.type = Painter.Type.Base;
m_Painter.onPopulateMesh = OnDrawPainterBase;
m_Painter.transform.SetSiblingIndex(0);
@@ -284,11 +289,13 @@ namespace XCharts.Runtime
public virtual void OnPointerDown(PointerEventData eventData)
{
m_PointerDownPos = eventData.position;
if (m_OnPointerDown != null) m_OnPointerDown(eventData, this);
}
public virtual void OnPointerUp(PointerEventData eventData)
{
isDragingClick = Vector2.Distance(eventData.position, m_PointerDownPos) > 6;
if (m_OnPointerUp != null) m_OnPointerUp(eventData, this);
}

View File

@@ -187,13 +187,13 @@ namespace XCharts.Runtime
m_TMPText.alignment = TextAlignmentOptions.BottomRight;
break;
case TextAnchor.MiddleCenter:
m_TMPText.alignment = TextAlignmentOptions.Center;
m_TMPText.alignment = TextAlignmentOptions.Midline;
break;
case TextAnchor.MiddleLeft:
m_TMPText.alignment = TextAlignmentOptions.Left;
m_TMPText.alignment = TextAlignmentOptions.MidlineLeft;
break;
case TextAnchor.MiddleRight:
m_TMPText.alignment = TextAlignmentOptions.Right;
m_TMPText.alignment = TextAlignmentOptions.MidlineRight;
break;
case TextAnchor.UpperCenter:
m_TMPText.alignment = TextAlignmentOptions.Top;
@@ -205,8 +205,7 @@ namespace XCharts.Runtime
m_TMPText.alignment = TextAlignmentOptions.TopRight;
break;
default:
m_TMPText.alignment = TextAlignmentOptions.Center;
m_TextAlignment = TextAnchor.MiddleCenter;
m_TMPText.alignment = TextAlignmentOptions.Midline;
break;
}
#else

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
{
[SerializeField] private bool m_DebugModel = false;
[SerializeField] protected UIComponentTheme m_Theme = new UIComponentTheme();
[SerializeField] private Background m_Background = new Background() { show = true };
[SerializeField] protected Background m_Background = new Background() { show = true };
protected bool m_DataDirty;
private ThemeType m_CheckTheme = 0;

View File

@@ -9,7 +9,8 @@ namespace XCharts.Runtime
{
public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness, Vector3 startPos)
Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness,
Vector3 startPos, float symbolSize2 = 0f)
{
switch (type)
{
@@ -22,13 +23,14 @@ namespace XCharts.Runtime
}
else
{
if (tickness > 0)
if (tickness > 0 && !ChartHelper.IsClearColor(borderColor))
UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + tickness, borderColor, borderColor, color, smoothness);
else
UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
}
break;
case SymbolType.EmptyCircle:
if (tickness == 0) tickness = 4f;
if (gap > 0)
{
UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
@@ -40,23 +42,31 @@ namespace XCharts.Runtime
}
break;
case SymbolType.Rect:
if (gap > 0)
if (symbolSize2 > 0 && symbolSize2 != symbolSize)
{
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
UGL.DrawSquare(vh, pos, symbolSize, color, toColor);
UGL.DrawRectangle(vh, pos, symbolSize, symbolSize2, color, toColor);
}
else
{
if (tickness > 0)
if (gap > 0)
{
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius);
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
UGL.DrawSquare(vh, pos, symbolSize, color, toColor);
}
else
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
{
if (tickness > 0)
{
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius);
}
else
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
}
}
break;
case SymbolType.EmptyRect:
if (tickness == 0) tickness = 4f;
if (gap > 0)
{
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
@@ -75,6 +85,7 @@ namespace XCharts.Runtime
}
if (type == SymbolType.EmptyTriangle)
{
if (tickness == 0) tickness = 4f;
UGL.DrawEmptyTriangle(vh, pos, symbolSize * 1.4f, tickness * 2f, color, emptyColor);
}
else
@@ -92,6 +103,7 @@ namespace XCharts.Runtime
}
if (type == SymbolType.EmptyDiamond)
{
if (tickness == 0) tickness = 4f;
UGL.DrawEmptyDiamond(vh, pos, xRadius, yRadius, tickness, color, emptyColor);
}
else
@@ -124,6 +136,7 @@ namespace XCharts.Runtime
arrowOffset, arrowDent, color);
if (type == SymbolType.EmptyArrow)
{
if (tickness == 0) tickness = 4f;
arrowWidth = (symbolSize - tickness) * 2;
arrowHeight = arrowWidth * 1.5f;
arrowOffset = 0;

View File

@@ -156,6 +156,21 @@ namespace XCharts.Runtime
}
}
public static void DestoryGameObjectByMatch(Transform parent, List<string> children)
{
if (parent == null) return;
if (children == null || children.Count == 0) return;
var childCount = parent.childCount;
for (int i = childCount - 1; i >= 0; i--)
{
var go = parent.GetChild(i);
if (go != null && children.Contains(go.name))
{
GameObject.DestroyImmediate(go.gameObject, true);
}
}
}
public static void DestoryGameObject(GameObject go)
{
if (go != null) GameObject.DestroyImmediate(go, true);
@@ -233,7 +248,7 @@ namespace XCharts.Runtime
}
public static GameObject AddObject(string name, Transform parent, Vector2 anchorMin,
Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1)
Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1, List<string> cacheNames = null)
{
GameObject obj;
if (parent.Find(name))
@@ -267,6 +282,8 @@ namespace XCharts.Runtime
rect.anchorMax = anchorMax;
rect.pivot = pivot;
rect.anchoredPosition3D = Vector3.zero;
if (cacheNames != null && !cacheNames.Contains(name)) cacheNames.Add(name);
return obj;
}
@@ -297,7 +314,11 @@ namespace XCharts.Runtime
chartText.tmpText.fontStyle = textStyle.tmpFontStyle;
chartText.tmpText.richText = true;
chartText.tmpText.raycastTarget = false;
#if UNITY_2023_2_OR_NEWER
chartText.tmpText.textWrappingMode = textStyle.autoWrap ? TextWrappingModes.Normal : TextWrappingModes.NoWrap;
#else
chartText.tmpText.enableWordWrapping = textStyle.autoWrap;
#endif
#else
chartText.text = EnsureComponent<Text>(txtObj);
chartText.text.font = textStyle.font == null ? theme.font : textStyle.font;
@@ -319,7 +340,7 @@ namespace XCharts.Runtime
chartText.SetActive(textStyle.show);
RectTransform rect = EnsureComponent<RectTransform>(txtObj);
rect.localPosition = Vector3.zero;
rect.anchoredPosition3D = Vector3.zero;
rect.sizeDelta = sizeDelta;
rect.anchorMin = anchorMin;
rect.anchorMax = anchorMax;
@@ -328,9 +349,9 @@ namespace XCharts.Runtime
}
public static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex)
Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex, List<string> childNodeNames)
{
var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childNodeNames);
painterObj.hideFlags = hideFlags;
painterObj.transform.SetSiblingIndex(siblingIndex);
return ChartHelper.EnsureComponent<Painter>(painterObj);
@@ -492,7 +513,7 @@ namespace XCharts.Runtime
return label;
}
private static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax,
public static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax,
out Vector2 pivot)
{
switch (alignment)
@@ -770,6 +791,14 @@ namespace XCharts.Runtime
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
}
public static float GetMaxCeilRate(float value, float ceilRate)
{
if (ceilRate == 0) return value;
var mod = value % ceilRate;
int rate = (int)(value / ceilRate);
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
}
public static double GetMinCeilRate(double value, double ceilRate)
{
if (ceilRate == 0) return value;
@@ -778,6 +807,14 @@ namespace XCharts.Runtime
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
}
public static float GetMinCeilRate(float value, float ceilRate)
{
if (ceilRate == 0) return value;
var mod = value % ceilRate;
int rate = (int)(value / ceilRate);
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
}
public static double GetMinDivisibleValue(double min, double ceilRate)
{
if (min == 0) return 0;

View File

@@ -11,43 +11,66 @@ namespace XCharts.Runtime
/// </summary>
public static class UIHelper
{
internal static void DrawBackground(VertexHelper vh, UIComponent component)
public static void DrawBackground(VertexHelper vh, UIComponent component)
{
var background = component.background;
var rect = component.graphRect;
if (background.imageWidth > 0 || background.imageHeight > 0)
{
if (background.imageWidth > 0)
{
rect.width = background.imageWidth;
rect.x = component.graphX + (component.graphWidth - background.imageWidth) / 2;
}
if (background.imageHeight > 0)
{
rect.height = background.imageHeight;
rect.y = component.graphY + (component.graphHeight - background.imageHeight) / 2;
}
}
background.rect = rect;
if (!background.show)
return;
if (background.image != null)
return;
var backgroundColor = component.theme.GetBackgroundColor(background);
DrawBackground(vh, background, backgroundColor);
}
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
{
if (!background.show)
return;
if (background.image != null)
return;
var borderWidth = background.borderStyle.GetRuntimeBorderWidth();
var borderColor = background.borderStyle.GetRuntimeBorderColor();
var cornerRadius = background.borderStyle.GetRuntimeCornerRadius();
UGL.DrawRoundRectangleWithBorder(vh, component.graphRect, backgroundColor, backgroundColor, cornerRadius,
borderWidth, borderColor);
UGL.DrawRoundRectangleWithBorder(vh, background.rect, color, color, cornerRadius,
borderWidth, borderColor, 0, smoothness);
}
internal static void InitBackground(UIComponent table)
internal static void InitBackground(UIComponent component)
{
if (table.background.show == false ||
(table.background.image == null && ChartHelper.IsClearColor(table.background.imageColor)))
if (component.background.show == false ||
(component.background.image == null && ChartHelper.IsClearColor(component.background.imageColor)))
{
ChartHelper.DestoryGameObject(table.transform, "Background");
ChartHelper.DestoryGameObject(component.transform, "Background");
return;
}
var sizeDelta = table.background.imageWidth > 0 && table.background.imageHeight > 0 ?
new Vector2(table.background.imageWidth, table.background.imageHeight) :
table.graphSizeDelta;
var backgroundObj = ChartHelper.AddObject("Background", table.transform, table.graphMinAnchor,
table.graphMaxAnchor, table.graphPivot, sizeDelta);
backgroundObj.hideFlags = table.chartHideFlags;
var sizeDelta = component.background.imageWidth > 0 && component.background.imageHeight > 0 ?
new Vector2(component.background.imageWidth, component.background.imageHeight) :
component.graphSizeDelta;
var backgroundObj = ChartHelper.AddObject("Background", component.transform, component.graphMinAnchor,
component.graphMaxAnchor, component.graphPivot, sizeDelta);
backgroundObj.hideFlags = component.chartHideFlags;
var backgroundImage = ChartHelper.EnsureComponent<Image>(backgroundObj);
ChartHelper.UpdateRectTransform(backgroundObj, table.graphMinAnchor,
table.graphMaxAnchor, table.graphPivot, sizeDelta);
ChartHelper.SetBackground(backgroundImage, table.background);
ChartHelper.UpdateRectTransform(backgroundObj, component.graphMinAnchor,
component.graphMaxAnchor, component.graphPivot, sizeDelta);
ChartHelper.SetBackground(backgroundImage, component.background);
backgroundObj.transform.SetSiblingIndex(0);
backgroundObj.SetActive(table.background.show && table.background.image != null);
backgroundObj.SetActive(component.background.show && component.background.image != null);
}
}
}

View File

@@ -21,8 +21,8 @@ namespace XCharts.Runtime
[ExecuteInEditMode]
public static class XChartsMgr
{
public static readonly string version = "3.12.1";
public static readonly int versionDate = 20241201;
public static readonly string version = "3.13.0";
public static readonly int versionDate = 20250101;
public static string fullVersion { get { return version + "-" + versionDate; } }
internal static List<BaseChart> chartList = new List<BaseChart>();

View File

@@ -303,7 +303,7 @@ namespace XCharts.Runtime
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serie.context.colorIndex, state);
serieData.context.rect = new Rect(pos.x - symbolSize / 2, pos.y - symbolSize / 2, symbolSize, symbolSize);
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
color, color, emptyColor, borderColor, symbol.gap, cornerRadius);
color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
}
if (visualMap.hoverLink && highlight && emphasisStyle != null &&
@@ -461,7 +461,7 @@ namespace XCharts.Runtime
else
{
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
color, color, emptyColor, borderColor, symbol.gap, cornerRadius);
color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
}
if (visualMap.hoverLink && highlight && emphasisStyle != null &&

View File

@@ -275,7 +275,7 @@ namespace XCharts.Runtime
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
}
}
}

View File

@@ -345,7 +345,7 @@ namespace XCharts.Runtime
SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, chart.theme, colorIndex, serieState);
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, serieState);
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor,
symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
}
}
}
@@ -495,7 +495,7 @@ namespace XCharts.Runtime
symbolToColor = m_RadarCoord.outRangeColor;
}
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius, serie.symbol.size2);
}
}
if (!serie.animation.IsFinish())

View File

@@ -314,7 +314,7 @@ namespace XCharts.Runtime
}
var objName = s_SerieRootObjectName + "_" + serie.index;
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_SerieRoot.hideFlags = chart.chartHideFlags;
ChartHelper.SetActive(m_SerieRoot, true);
ChartHelper.HideAllObject(m_SerieRoot);
@@ -762,7 +762,7 @@ namespace XCharts.Runtime
{
var color = symbol.GetColor(defaultColor);
chart.DrawSymbol(vh, symbol.type, symbol.size, 1, pos,
color, color, ColorUtil.clearColor32, color, symbol.gap, null);
color, color, ColorUtil.clearColor32, color, symbol.gap, null, symbol.size2);
}
public override void OnPointerDown(PointerEventData eventData)

View File

@@ -7,6 +7,7 @@ namespace XCharts.Runtime
{
private static Dictionary<string, Color32> s_ColorCached = new Dictionary<string, Color32>();
public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0);
public static readonly Color32 white = new Color32(255, 255, 255, 255);
public static readonly Vector2 zeroVector2 = Vector2.zero;
/// <summary>

View File

@@ -3,9 +3,9 @@
"displayName": "XCharts",
"author": "monitor1394",
"license": "MIT",
"version": "3.12.1",
"date": "20241201",
"checkdate": "20241201",
"version": "3.13.0",
"date": "20250101",
"checkdate": "20250101",
"unity": "2018.3",
"description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.",
"keywords": [