mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
[feature][axis] add showStartLine and showEndLine for AxisSplitLine
This commit is contained in:
@@ -817,11 +817,11 @@ namespace XCharts
|
||||
}
|
||||
if (axis.splitLine.show)
|
||||
{
|
||||
if (axis.splitLine.NeedShow(i))
|
||||
if (axis.splitLine.NeedShow(i, size))
|
||||
{
|
||||
if (orient == Orient.Horizonal)
|
||||
{
|
||||
if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.x))
|
||||
if (relativedAxis == null || !relativedAxis.axisLine.show || !MathUtil.Approximately(current, relativedAxis.context.x))
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh,
|
||||
lineType,
|
||||
@@ -885,7 +885,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.y))
|
||||
if (relativedAxis == null || !relativedAxis.axisLine.show || !MathUtil.Approximately(current, relativedAxis.context.y))
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh,
|
||||
lineType,
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private float m_Distance;
|
||||
[SerializeField] private bool m_AutoColor;
|
||||
[SerializeField][Since("v3.3.0")] private bool m_ShowStartLine = true;
|
||||
[SerializeField][Since("v3.3.0")] private bool m_ShowEndLine = true;
|
||||
|
||||
/// <summary>
|
||||
/// The distance between the split line and axis line.
|
||||
@@ -33,6 +35,24 @@ namespace XCharts.Runtime
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show the first split line.
|
||||
/// |是否显示第一条分割线。
|
||||
/// </summary>
|
||||
public bool showStartLine
|
||||
{
|
||||
get { return m_ShowStartLine; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowStartLine, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show the last split line.
|
||||
/// |是否显示最后一条分割线。
|
||||
/// </summary>
|
||||
public bool showEndLine
|
||||
{
|
||||
get { return m_ShowEndLine; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowEndLine, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
|
||||
public override void ClearVerticesDirty()
|
||||
@@ -56,6 +76,8 @@ namespace XCharts.Runtime
|
||||
var axisSplitLine = new AxisSplitLine();
|
||||
axisSplitLine.show = show;
|
||||
axisSplitLine.interval = interval;
|
||||
axisSplitLine.showStartLine = showStartLine;
|
||||
axisSplitLine.showEndLine = showEndLine;
|
||||
axisSplitLine.lineStyle = lineStyle.Clone();
|
||||
return axisSplitLine;
|
||||
}
|
||||
@@ -64,11 +86,17 @@ namespace XCharts.Runtime
|
||||
{
|
||||
base.Copy(splitLine);
|
||||
interval = splitLine.interval;
|
||||
showStartLine = splitLine.showStartLine;
|
||||
showEndLine = splitLine.showEndLine;
|
||||
}
|
||||
|
||||
internal bool NeedShow(int index)
|
||||
internal bool NeedShow(int index, int total)
|
||||
{
|
||||
return show && (interval == 0 || index % (interval + 1) == 0);
|
||||
if (!show) return false;
|
||||
if (interval != 0 && index % (interval + 1) != 0) return false;
|
||||
if (!showStartLine && index == 0) return false;
|
||||
if (!showEndLine && index == total - 1) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, color);
|
||||
}
|
||||
if (radar.splitLine.NeedShow(i))
|
||||
if (radar.splitLine.NeedShow(i, radar.splitNumber))
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user