[feature][axis] add showStartLine and showEndLine for AxisSplitLine

This commit is contained in:
monitor1394
2022-09-06 22:54:40 +08:00
parent 83744777c5
commit 16d055abc0
7 changed files with 41 additions and 6 deletions

View File

@@ -58,6 +58,7 @@
## master ## master
* (2022.09.06) 增加`AxisSplitLine``showStartLine``showEndLine`参数
* (2022.09.06) 增加`Heatmap`通过`symbol`设置不同的图案的支持 * (2022.09.06) 增加`Heatmap`通过`symbol`设置不同的图案的支持
* (2022.09.05) 增加`Heatmap``heatmapType`支持设置`Data``Count`两种不同映射方式的热力图 * (2022.09.05) 增加`Heatmap``heatmapType`支持设置`Data``Count`两种不同映射方式的热力图
* (2022.09.05) 优化`Tooltip`在热力图为数值轴时的指示 * (2022.09.05) 优化`Tooltip`在热力图为数值轴时的指示

View File

@@ -357,6 +357,8 @@ Split line of axis in grid area.
|`interval`|||Interval of Axis splitLine. |`interval`|||Interval of Axis splitLine.
|`distance`|||The distance between the split line and axis line. |`distance`|||The distance between the split line and axis line.
|`autoColor`|||auto color. |`autoColor`|||auto color.
|`showStartLine`|true|v3.3.0|Whether to show the first split line.
|`showEndLine`|true|v3.3.0|Whether to show the last split line.
## `AxisTheme` ## `AxisTheme`

View File

@@ -357,6 +357,8 @@ Inherits or Implemented: [BaseLine](#BaseLine)
|`interval`|||坐标轴分隔线的显示间隔。 |`interval`|||坐标轴分隔线的显示间隔。
|`distance`|||刻度线与轴线的距离。 |`distance`|||刻度线与轴线的距离。
|`autoColor`|||自动设置颜色。 |`autoColor`|||自动设置颜色。
|`showStartLine`|true|v3.3.0|是否显示第一条分割线。
|`showEndLine`|true|v3.3.0|是否显示最后一条分割线。
## `AxisTheme` ## `AxisTheme`

View File

@@ -44,6 +44,8 @@ namespace XCharts.Editor
PropertyField(prop, "m_Interval"); PropertyField(prop, "m_Interval");
PropertyField(prop, "m_Distance"); PropertyField(prop, "m_Distance");
PropertyField(prop, "m_AutoColor"); PropertyField(prop, "m_AutoColor");
PropertyField(prop, "m_ShowStartLine");
PropertyField(prop, "m_ShowEndLine");
} }
} }

View File

@@ -817,11 +817,11 @@ namespace XCharts
} }
if (axis.splitLine.show) if (axis.splitLine.show)
{ {
if (axis.splitLine.NeedShow(i)) if (axis.splitLine.NeedShow(i, size))
{ {
if (orient == Orient.Horizonal) 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, ChartDrawer.DrawLineStyle(vh,
lineType, lineType,
@@ -885,7 +885,7 @@ namespace XCharts
} }
else 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, ChartDrawer.DrawLineStyle(vh,
lineType, lineType,

View File

@@ -13,6 +13,8 @@ namespace XCharts.Runtime
[SerializeField] private int m_Interval; [SerializeField] private int m_Interval;
[SerializeField] private float m_Distance; [SerializeField] private float m_Distance;
[SerializeField] private bool m_AutoColor; [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> /// <summary>
/// The distance between the split line and axis line. /// The distance between the split line and axis line.
@@ -33,6 +35,24 @@ namespace XCharts.Runtime
get { return m_Interval; } get { return m_Interval; }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); } 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 bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
public override void ClearVerticesDirty() public override void ClearVerticesDirty()
@@ -56,6 +76,8 @@ namespace XCharts.Runtime
var axisSplitLine = new AxisSplitLine(); var axisSplitLine = new AxisSplitLine();
axisSplitLine.show = show; axisSplitLine.show = show;
axisSplitLine.interval = interval; axisSplitLine.interval = interval;
axisSplitLine.showStartLine = showStartLine;
axisSplitLine.showEndLine = showEndLine;
axisSplitLine.lineStyle = lineStyle.Clone(); axisSplitLine.lineStyle = lineStyle.Clone();
return axisSplitLine; return axisSplitLine;
} }
@@ -64,11 +86,17 @@ namespace XCharts.Runtime
{ {
base.Copy(splitLine); base.Copy(splitLine);
interval = splitLine.interval; 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;
} }
} }
} }

View File

@@ -147,7 +147,7 @@ namespace XCharts.Runtime
{ {
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, color); 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); ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor);
} }