mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 02:40:13 +00:00
优化Comment的位置,用Location代替Position
This commit is contained in:
@@ -64,6 +64,7 @@ slug: /changelog
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2022.11.27) 优化`Comment`的位置,用`Location代替Position`
|
||||||
* (2022.11.27) 优化`Tooltip`的`LineStyle`支持设置`Shadow`时的颜色
|
* (2022.11.27) 优化`Tooltip`的`LineStyle`支持设置`Shadow`时的颜色
|
||||||
* (2022.11.26) 优化`LabelLine`的`symbol`默认不显示
|
* (2022.11.26) 优化`LabelLine`的`symbol`默认不显示
|
||||||
* (2022.11.26) 修复`LineChart`在`XY`都为数值轴时添加无序数据显示异常的问题
|
* (2022.11.26) 修复`LineChart`在`XY`都为数值轴时添加无序数据显示异常的问题
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
PropertyField(prop, "m_Content");
|
PropertyField(prop, "m_Content");
|
||||||
PropertyField(prop, "m_Position");
|
PropertyField(prop, "m_Location");
|
||||||
//PropertyField(prop, "m_MarkRect");
|
//PropertyField(prop, "m_MarkRect");
|
||||||
//PropertyField(prop, "m_MarkStyle");
|
//PropertyField(prop, "m_MarkStyle");
|
||||||
PropertyField(prop, "m_LabelStyle");
|
PropertyField(prop, "m_LabelStyle");
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
[ComponentHandler(typeof(CommentHander), true)]
|
[ComponentHandler(typeof(CommentHander), true)]
|
||||||
public class Comment : MainComponent
|
public class Comment : MainComponent, IPropertyChanged
|
||||||
{
|
{
|
||||||
[SerializeField] private bool m_Show = true;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||||
@@ -65,5 +65,17 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
return m_MarkStyle;
|
return m_MarkStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback handling when parameters change.
|
||||||
|
/// |参数变更时的回调处理。
|
||||||
|
/// </summary>
|
||||||
|
public void OnChanged()
|
||||||
|
{
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
item.location.OnChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ namespace XCharts.Runtime
|
|||||||
public override void InitComponent()
|
public override void InitComponent()
|
||||||
{
|
{
|
||||||
var comment = component;
|
var comment = component;
|
||||||
|
comment.OnChanged();
|
||||||
comment.painter = null;
|
comment.painter = null;
|
||||||
comment.refreshComponent = delegate()
|
comment.refreshComponent = delegate()
|
||||||
{
|
{
|
||||||
@@ -30,10 +31,12 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var item = comment.items[i];
|
var item = comment.items[i];
|
||||||
var labelStyle = comment.GetLabelStyle(i);
|
var labelStyle = comment.GetLabelStyle(i);
|
||||||
|
var labelPos = chart.chartPosition + item.location.GetPosition(chart.chartWidth, chart.chartHeight);
|
||||||
var label = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common,
|
var label = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common,
|
||||||
GetContent(item), Color.clear, TextAnchor.MiddleCenter);
|
GetContent(item), Color.clear, TextAnchor.MiddleCenter);
|
||||||
label.SetActive(comment.show && item.show);
|
label.SetActive(comment.show && item.show);
|
||||||
label.SetPosition(item.position + labelStyle.offset);
|
label.SetPosition(labelPos);
|
||||||
|
label.text.SetLocalPosition(labelStyle.offset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
comment.refreshComponent();
|
comment.refreshComponent();
|
||||||
|
|||||||
@@ -12,10 +12,11 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
[SerializeField] private bool m_Show = true;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private string m_Content = "comment";
|
[SerializeField] private string m_Content = "comment";
|
||||||
[SerializeField] private Vector3 m_Position;
|
|
||||||
[SerializeField] private Rect m_MarkRect;
|
[SerializeField] private Rect m_MarkRect;
|
||||||
[SerializeField] private CommentMarkStyle m_MarkStyle = new CommentMarkStyle() { show = false };
|
[SerializeField] private CommentMarkStyle m_MarkStyle = new CommentMarkStyle() { show = false };
|
||||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false };
|
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false };
|
||||||
|
[SerializeField] [Since("v3.5.0")]private Location m_Location = new Location() { align = Location.Align.TopLeft, top = 0.125f };
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this to false to prevent this comment item from showing.
|
/// Set this to false to prevent this comment item from showing.
|
||||||
@@ -23,11 +24,6 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// position of comment.
|
|
||||||
/// |注解项的位置坐标。
|
|
||||||
/// </summary>
|
|
||||||
public Vector3 position { get { return m_Position; } set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetComponentDirty(); } }
|
|
||||||
/// <summary>
|
|
||||||
/// content of comment.
|
/// content of comment.
|
||||||
/// |注解的文本内容。支持模板参数,可以参考Tooltip的itemFormatter。
|
/// |注解的文本内容。支持模板参数,可以参考Tooltip的itemFormatter。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -51,5 +47,14 @@ namespace XCharts.Runtime
|
|||||||
get { return m_LabelStyle; }
|
get { return m_LabelStyle; }
|
||||||
set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The location of comment.
|
||||||
|
/// |Comment显示的位置。
|
||||||
|
/// </summary>
|
||||||
|
public Location location
|
||||||
|
{
|
||||||
|
get { return m_Location; }
|
||||||
|
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user