mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
增加Serie的minShowLabel可隐藏小于指定值的label
This commit is contained in:
@@ -70,6 +70,7 @@ slug: /changelog
|
||||
|
||||
## master
|
||||
|
||||
* (2023.12.10) 增加`Serie`的`minShowLabel`可隐藏小于指定值的`label`
|
||||
* (2023.12.09) 增加`LevelStyle`的`LineStyle`和`depth`支持
|
||||
* (2023.12.09) 增加`Serie`的`Link`可用于桑基图添加节点边关系
|
||||
* (2023.12.05) 增加`ResetChartStatus()`可主动重置图表状态
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace XCharts.Editor
|
||||
PropertyField("m_Large");
|
||||
PropertyField("m_LargeThreshold");
|
||||
PropertyField("m_PlaceHolder");
|
||||
PropertyField("m_MinShowLabel");
|
||||
PropertyField("m_MinShowLabelValue");
|
||||
});
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_Animation");
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace XCharts.Editor
|
||||
PropertyField("m_IgnoreValue");
|
||||
PropertyField("m_ClickOffset");
|
||||
PropertyField("m_RadiusGradient");
|
||||
PropertyField("m_MinShowLabel");
|
||||
PropertyField("m_MinShowLabelValue");
|
||||
});
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_Animation");
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace XCharts.Runtime
|
||||
serieData.context.currentAngle = serie.animation.CheckDetailBreak(serieData.context.toAngle)
|
||||
? serie.animation.GetCurrDetail() : serieData.context.toAngle;
|
||||
serieData.context.insideRadius = serie.context.insideRadius;
|
||||
serieData.context.canShowLabel = serieData.context.currentAngle >= serieData.context.halfAngle;
|
||||
serieData.context.canShowLabel = serieData.context.currentAngle >= serieData.context.halfAngle && !serie.IsMinShowLabelValue(value);
|
||||
UpdateSerieDataRadius(serieData, value);
|
||||
UpdatePieLabelPosition(serie, serieData);
|
||||
startDegree = serieData.context.toAngle;
|
||||
|
||||
@@ -281,6 +281,8 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.48f };
|
||||
[SerializeField] private float[] m_Radius = new float[2] { 0, 0.28f };
|
||||
[SerializeField][Since("v3.8.0")] private float m_MinRadius = 0f;
|
||||
[SerializeField][Since("v3.10.0")] private bool m_MinShowLabel = false;
|
||||
[SerializeField][Since("v3.10.0")] private double m_MinShowLabelValue = 0;
|
||||
|
||||
[SerializeField][Range(2, 10)] private int m_ShowDataDimension;
|
||||
[SerializeField] private bool m_ShowDataName;
|
||||
@@ -963,6 +965,24 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_PlaceHolder, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the label is not displayed when the enabled value is less than the specified value.
|
||||
/// ||是否开启值小于指定值`minShowLabelValue`时不显示标签。
|
||||
/// </summary>
|
||||
public bool minShowLabel
|
||||
{
|
||||
get { return m_MinShowLabel; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinShowLabel, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// When 'minShowLabel' is enabled, labels are not displayed if the value is less than this value.
|
||||
/// ||当开启`minShowLabel`时,值小于该值时不显示标签。
|
||||
/// </summary>
|
||||
public double minShowLabelValue
|
||||
{
|
||||
get { return m_MinShowLabelValue; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinShowLabelValue, value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
public List<SerieData> data { get { return m_Data; } }
|
||||
@@ -1896,6 +1916,24 @@ namespace XCharts.Runtime
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsMinShowLabelValue(int index, int dimension = 1)
|
||||
{
|
||||
var serieData = GetSerieData(index);
|
||||
if (serieData != null)
|
||||
return IsMinShowLabelValue(serieData, dimension);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsMinShowLabelValue(SerieData serieData, int dimension = 1)
|
||||
{
|
||||
return IsMinShowLabelValue(serieData.GetData(dimension));
|
||||
}
|
||||
|
||||
public bool IsMinShowLabelValue(double value)
|
||||
{
|
||||
return m_MinShowLabel && value <= m_MinShowLabelValue;
|
||||
}
|
||||
|
||||
public bool IsSerie<T>() where T : Serie
|
||||
{
|
||||
return this is T;
|
||||
|
||||
@@ -505,7 +505,7 @@ namespace XCharts.Runtime
|
||||
SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
||||
currLabel, color);
|
||||
var offset = GetSerieDataLabelOffset(serieData, currLabel);
|
||||
labelObject.SetActive(currLabel.show && !isIgnore);
|
||||
labelObject.SetActive(currLabel.show && !isIgnore && !serie.IsMinShowLabelValue(value));
|
||||
labelObject.SetText(content);
|
||||
labelObject.SetPosition(serieData.context.dataPoints[i] + offset);
|
||||
labelObject.UpdateIcon(currLabel.icon);
|
||||
@@ -526,7 +526,7 @@ namespace XCharts.Runtime
|
||||
ChartCached.NumberToStr(value, currLabel.numericFormatter) :
|
||||
SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
||||
currLabel, color);
|
||||
serieData.SetLabelActive(currLabel.show && !isIgnore);
|
||||
serieData.SetLabelActive(currLabel.show && !isIgnore && !serie.IsMinShowLabelValue(value));
|
||||
serieData.labelObject.UpdateIcon(currLabel.icon);
|
||||
serieData.labelObject.SetText(content);
|
||||
UpdateLabelPosition(serieData, currLabel);
|
||||
|
||||
Reference in New Issue
Block a user