修复饼图添加数据时Label异常的问题

This commit is contained in:
monitor1394
2019-11-09 16:34:16 +08:00
parent 70bcebe9ea
commit 6cfcf84b5d
3 changed files with 10 additions and 1 deletions

View File

@@ -461,6 +461,7 @@ namespace XCharts
/// 饼图的数据项之和
/// </summary>
public float runtimePieDataTotal { get; internal set; }
internal int runtimeLastCheckDataCount { get; set; }
internal List<Vector3> GetUpSmoothList(int dataIndex, int size = 100)
{

View File

@@ -289,7 +289,6 @@ namespace XCharts
{
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, chartAnchorMin,
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
//ChartHelper.DestroyAllChildren(labelObject.transform);
SerieLabelPool.ReleaseAll(labelObject.transform);
int count = 0;
for (int i = 0; i < m_Series.Count; i++)
@@ -484,6 +483,14 @@ namespace XCharts
protected void CheckRefreshLabel()
{
foreach (var serie in m_Series.list)
{
if (serie.label.show && serie.runtimeLastCheckDataCount != serie.dataCount)
{
m_ReinitLabel = true;
serie.runtimeLastCheckDataCount = serie.dataCount;
}
}
if (m_ReinitLabel)
{
m_ReinitLabel = false;

View File

@@ -387,6 +387,7 @@ namespace XCharts
protected void UpdateLabelPostion(Serie serie, SerieData serieData)
{
if (serieData.labelText == null) return;
var currAngle = serieData.runtimePieHalfAngle;
var currRad = currAngle * Mathf.Deg2Rad;
var offsetRadius = serieData.runtimePieOffsetRadius;